gdb에서 특정 기능사용시 해당함수 디버깅 찍히게 할수 있나요?

Lch@Naver의 이미지

비주얼 스튜디오에서는 지원하는거 같던데 gdb에선 잘 못찾겠습니다 ㅠ 예를들어 어떤 프로그램에서 a라는 함수에 브레이크 포인트를 찍고 a함수가 호출되는 어떤 동작을 실행하면 a함수 부분 디버깅이 되게끔이요. 즉 첫줄부터 스텝 스텝 스텝 이렇게가 아니라 프로그램 실행후 어떤 기능 호출할때 디버깅 시작하게끔 가능한가요?

익명 사용자의 이미지

그게 브레이크 포인트의 원래 기능 아닌가요?

       Here are some of the most frequently needed GDB commands:
 
       break [file:]functiop
           Set a breakpoint at function (in file).
 
       run [arglist]
           Start your program (with arglist, if specified).
 
       bt  Backtrace: display the program stack.
 
       print expr
           Display the value of an expression.
 
       c   Continue running your program (after stopping, e.g. at a breakpoint).
 
       next
           Execute next program line (after stopping); step over any function calls in the line.
 
       edit [file:]function
           look at the program line where it is presently stopped.
 
       list [file:]function
           type the text of the program in the vicinity of where it is presently stopped.
 
       step
           Execute next program line (after stopping); step into any function calls in the line.
 
       help [name]
           Show information about GDB command name, or general information about using GDB.
 
       quit
           Exit from GDB
Stephen Kyoungwon Kim@Google의 이미지

foo 함수에 breakpoint를 잡을 때, break foo 라고 할 필요 없이 보통은 br foo 라고만 해도 됩니다.

gdb가 br을 보면 br로 시작하는 명령어가 없는지 확인하는데, 하나밖에 없으면 그 명령어로 해석합니다. 여러 개가 있으면 우선 순위에 따라 해석할 수도 있고, 혹은 그냥 포기하고 그런 명령어 없다고 할 수도 있습니다.

그리고 gdb는 그대로 실행하면 터미널에서 보기 불편한 형태로 나와요. 그런데 그 위에 UI를 얹기 쉬운 구조이기 때문에 보통 gdb에 user interface를 얹어서 씁니다. DDD가 가장 단순히 설치 사용 가능한 GUI 디버거고, 많은 리눅스 개발자는 EMACS + gud로 gdb를 씁니다. Eclipse CDT도 리눅스에서는 내부적으로는 gdb를 썼던 것 같은데 확실하지 않습니다.

좋은 gdb front-end (UI)를 찾아보세요.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.