GNU Debugger
Debugger!
Debugger ?
bug
?
!
bug
      ?
debug
↑ ↑ ↓ ↓ ← → ← → BA
printf
RUNTIME
TRACING
DYNAMIC
ANALYSIS
•
•
•
•
•
Good
 and
Evil
Good
 and
Evil
White
 and
Black
White    -box



 and
Black   -box
Debug
Event
Breakpoints
soft
Breakpoint
hardware
Breakpoint
memory
Breakpoint
Memory violation
Memory violation
         (segmentation faults)
Exceptions
GDB
?
$ gcc test.c -o test.o
$ ./test.o
$ gcc -g test.c -o test.o
$ gdb test.o
file
run
start                         main break
Ctrl+c
list [line/function]
print [var]
next [times]
step [times]
until [line]
continue
finish                  function
jump [line]
info [command]                (ex:info break)
Breakpoint
help breakpoints        breakpoints
break [line]                  breakpoint
break [function]
info break                        breakpoints
delete [n]                   breakpoint (       )
clear [line]                 breakpoint (       )
enable [n]                   breakpoint (       )
enable once [n]           breakpoint      break
disable [n]                  breakpoint (       )
ignore [n] [cont]            breakpoint (       ) (cont   )
condition [n] [cond]       cond            break
break [line] [cond]
                          break 10 if n > 5
commands [n]              break ,
watchpoint

watch [var]        var       break
rwatch [var]       var       break
awatch [var]       var
info watch       break   watch point
display
                        step next


display [var]           display
undisplay [n]              n    display
enable display             n    display
[n]
disable display            n    display
[n] display
info                 display table
function calls

backtrace      function stack
up
down
frame [n]           frame
return [var]                    return
• (gdb) help all
• (gdb) help
• Reference
gdbtui   ccdebug      Xcode

 cgdb     Glewn     GDBtk/Insight

Xxgdb     Emacs        WDB

 GVD       DDD         Dev-c

Nemiver    KDb          ........
gdbtui   ccdebug      Xcode

 cgdb     Glewn     GDBtk/Insight

Xxgdb     Emacs        WDB

 GVD       DDD         Dev-c

Nemiver    KDb          ........
gdbtui   ccdebug      Xcode

 cgdb     Glewn     GDBtk/Insight

Xxgdb     Emacs        WDB

 GVD       DDD         Dev-c

Nemiver    KDb          ........
GDB
Reference
•   GNU
      http://www.gnu.org/software/gdb/


•                    GNU Debugger (gdb) Part I
      http://jserv.sayya.org/debugger/HappyGDB-PartI-2008-07-12.pdf


•                 debugger GNU GDB
      http://cse.tw/981class/file/upe3.pdf


•   Gray Hat Python
•   http://www.cmlab.csie.ntu.edu.tw/~daniel/linux/gdb.html

•   http://www.study-area.org/cyril/opentools/opentools/
    x1253.html
Q&A

淺入淺出 GDB