GDB cheat sheet

20,836

Solution 1

I use this one personally: gdb's cheat sheet or that link is not broken yet .. . I 've printed it at work.

Solution 2

  +========================+==============================+=============================+
  |GDB                     | DBX                          | WINDOWS  ntsd,wdeb386,windbg|
  +========================+==============================+=============================+
  |break line              | stop at line                 |                          F9 |
  |break func              | stop in func                 |bp func                 A-F9 |
  |break *addr             | stopi at addr                |br,ba                   A-F9 |
  |break ... if expr       | stop ... -if expr            |bp f "j cond 'r';'g'"   A-F9 |
  |cond n                  | stop ... -if expr            |                             |
  |tbreak                  | stop ... -temp               |bp f "bc"           F9 F5 F9 |
  |watch expr              | stop expr [slow]             |                             |
  |watch var               | stop modify &var [fast]      |                             |
  |                        | stop change var              |                        A-F9 |
  |catch x                 | intercept x                  |                             |
  |info break              | status                       |bl                      A-F9 |
  |info watch              | status                       |                             |
  |clear                   | clear                        |                             |
  |clear fun               | delete n                     |bc                           |
  |delete                  | delete all                   |bc *                    A-F9 |
  |disable                 | handler -disable all         |bd *                    C-F9 |
  |disable n               | handler -disable n           |                             |
  |enable                  | handler -enable all          |be                           |
  |enable n                | handler -enable n            |                             |
  |ignore n cnt            | handler -count n cnt         |bp n cnt                A-F9 |
  +========================+==============================+=============================+
  |set args                | runargs                      |                         A-F7|
  |run                     | run args                     |g                      C-S-F5|
  |continue                | cont                         |g (go)                   F5  |
  |stepi                   | stepi                        |t                            |
  |step                    | step                         |                         F11 |
  |next                    | next                         |p                        F10 |
  |jump line               | cont at line                 |p =addr / g =addr     R-Mouse|
  |finish                  | step up                      |bp retaddr+4             F12 |
  |return (now)            | pop                          |g =retaddr                   |
  |until line              | stop at line -temp;cont      |bp func;g                    |
  |C-j                     | !!                           |<CR> (repeat)                |
  +========================+==============================+=============================+
  |commands n              | when ... { cmds; }           |bp n "cmds"                  |
  |backtrace n             | where n                      |kb ks kv                     |
  |frame n                 | frame n                      |                             |
  |info reg reg            | print $reg                   |r                            |
  |signal num              | cont sig num                 |                             |
  |set var=expr            | assign var=expr              |e (enter bytes),f (fill)     |
  |x/fmt addr              | x addr/fmt                   |d[abcw] addr (display)    A-6|
  |disassem addr           | dis addr                     |u                   C-F11,A-8|
  |shell cmd               | sh cmd [if needed]           |                             |
  |info func regex         | funcs regexp                 |X (ntsd)                     |
  |ptype type              | whatis -t type               |                             |
  |define cmd              | function cmd                 |zs,zl,zd (default cmd)       |
  |handle sig              | stop sig sig                 |                             |
  |info signals            | status; catch                |di (display IDT)             |
  |attach pid              | debug - pid                  |                             |
  |attach pid              | debug a.out pid              |                             |
  |file file               | [unnecessary]                |                             |
  |exec file               | debug file                   |                             |
  |core file               | debug a.out corefile         |                             |
  |set editing on          | set -o emacs                 |                             |
  |set language x          | language x                   |                             |
  |set prompt x            | PS1=x                        |                             |
  |set history size x      | HISTSIZE=x                   |                             |
  |set print object on     | dbxenv output_dynamic_type on|                             |
  |show commands           | history                      |                             |
  |dir name                | pathmap name                 |                             |
  |show dir                | pathmap                      |lm                           |
  |info line <n            | listi n                      |                             |
  |info source             | file                         |ln                           |
  |info sources            | files; modules               |                             |
  |forw regex              | search regexp                |lse regexp                   |
  |rev regex               | bsearch regexp               |                             |
  |.gdbinit                | .dbxrc (was .dbxinit)        |                             |
  |q                       | quit                         |q                            |
  +========================+==============================+=============================+
Share:
20,836
Remus Rusanu
Author by

Remus Rusanu

Founder of DBHistory.com, a SQL Server monitoring and configuration management service. Former developer with the SQL Server team.

Updated on October 15, 2020

Comments

  • Remus Rusanu
    Remus Rusanu over 3 years

    Can anyone recommend a good cheat sheet for gbd? I'm experienced with windbg commands, I'm looking for gdb equivalents for lml (list loaded modules), ~*k (all threads stack), ba (break on access), dt (dump type), dv (dump frame variables), sxe (set up SEH handler) etc. I understand there won't be a 1 to 1 equivalent, but I just need a condensed summary of most used/usefull commands.