Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GDB Rocks!

GDB Rocks!

GDB Rocks!
Basic gdb case study, advanced gdb tricks, shared library debugging

Kent Chen

March 05, 2013
Tweet

More Decks by Kent Chen

Other Decks in Technology

Transcript

  1. C interpreter 1. $ gdb `which gdb` 2. (gdb) start

    3. Enjoy your world… • Example: (gdb)  p  1  +  2  +  abs(-­‐3) (gdb)  p  strcmp("VIVOTEK",  "AXIS") (gdb)  x/s  getenv(“HOME”) (gdb)  p  (char*)getenv("HOME") (gdb)  p  (char)*getenv("HOME") (gdb)  p  printf("%d\n",  12345678)
  2. Signal Handler Terminal hang / Reboot PC You have to

    close terminal (e.g., PuTTY, iTerm,...) Conventional solution GNU Screen / Tmux nohup GDB solution $ gdb [program] [pid] (gdb) handle SIGHUP nopass (gdb) continue (gdb)  handle  SIGHUP Signal                Stop            Print      Pass  to  program  Description SIGHUP                Yes              Yes          Yes                          Hangup (gdb)  handle  SIGHUP  nopass Signal                Stop            Print      Pass  to  program  Description SIGHUP                Yes              Yes          No                            Hangup Program  received  signal  SIGHUP,  Hangup. 0x0000003ac7a954e0  in  __nanosleep_nocancel  ()  from  /lib64/libc.so.6 (gdb) Continuing.
  3. Reference 快快樂樂學 GNU Debugger (gdb) Part I + II (Jserv)

    http://jserv.sayya.org/debugger/ http://pyclewn.sourceforge.net/ http://clewn.sourceforge.net/ http://reverse.put.as/ GDB的妙用 (vgod) [GDB Tricks] File Descriptor Hijacking / 劫持 FDs 之奇技淫巧