GDB cheat sheet

后端 未结 6 1234
别跟我提以往
别跟我提以往 2021-01-30 03:38

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),

相关标签:
6条回答
  • 2021-01-30 03:50
      +========================+==============================+=============================+
      |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                            |
      +========================+==============================+=============================+
    
    0 讨论(0)
  • 2021-01-30 03:52

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

    0 讨论(0)
  • 2021-01-30 03:58

    Here is a very simple cross platform debugging cheat sheet that I use (and created). http://mohit.io/blog/cross-platform-debugging-cheat-sheet/ I hope you find the required windbg -> gdb commands.

    0 讨论(0)
  • 2021-01-30 04:00
      +===========+===========+=========+============+==============+========+====+======+=====+======+=======+
      |Feature    |Description|vc       |dbx         |gdb           |windbg  |ntsd|edebug|perld|i386kd|wdeb386|
      +===========+===========+=========+============+==============+========+====+======+=====+======+=======+
      |Lang       |-          |c        |c           |c             |c       |c   |elisp |perl |c     |c      |
      |OS         |-          |win      |unix        |unix etc      |win     |win |all   |all  |win   |win    |
      |GUI        |-          |Y        |N           |N             |Y       |N   |emacs |N    |N     |N      |
      |Alt GUI    |-          |N        |emacs ffffd   |emacs         |N       |N   |N     |ffffd  |N     |N      |
      |Vendor GUI |-          |Y        |Sun/workshop|HP/wdbg       |Y       |N   |emacs |N    |N     |N      |
      |Cmdline    |-          |No No    |Y           |Y             |Y       |Y   |-     |Y    |Y     |Y      |
      |Alias      |-          |keymapper|alias/define|command       |N       |ini |Y     +=    |N     |N      |
      |Completion |<TAB>      |-        |Y           |YY            |N       |N   |YY    |-    |N     |N      |
      |Script     |script     |VbPerlOle|ksh         |Y             |dll     |dll |Y     |Y    |$<file|dll    |
      |Actions    |When .. do |         |when        |              |        |    |      |a<>{}|      |       |
      |History    |cmd history|N        |Y           |Y             |Y       |Y   |Y     |!    |Y     |Y      |
      |Init       |setup      |regedit  |.dbxrc      |.gdbinit      |regedit |ini |.emacs|-    |ENV   |-      |
      |Options    |config     |regedit  |dbxenv      |set           |        |    |      |O    |      |       |
      |Help       |?          |msdn     |help        |i   info      |? .hlp  |?   |info  |h pod|? msdn|? msnd |
      +===========+===========+=========+============+==============+========+====+======+=====+======+=======+
      |bp         |break      |F9       |stop at     |b             |bp      |bp  |-     |-    |bp    |bp     |
      |ba         |hardware   |A-F9     |stop access |hbreak/b *addr|br      |ba  |-     |N    |ba    |br     |
      |bl handlers|list stops |A-F9     |status      |i b           |-       |-   |l     |L    |bl    |-      |
      |bd         |delete     |F9       |delete N    |delete break N|-       |-   |u     |d D  |-     |-      |
      |bc clear   |del current|C-F9     |clear       |clear         |-       |-   |-     |-    |bc    |-      |
      |bp once    |break once |F9 F5 F9 |stop -temp  |tbreak        |-       |-   |-     |c .. |-     |-      |
      |be on      |enable     |C-F9     |-           |enable        |-       |-   |-     |-    |be    |-      |
      |bd off     |disable    |C-F9     | -disable   |disable       |-       |-   |-     |-    |bd    |-      |
      |bp if      |conditional|C-F9     |cond -if    |condition     |J       |-   |-     |-    |J     |-      |
      |bp --k==0  |count to bp|C-F9     |-count k    |ignore .. k   |J       |-   |-     |-    |J     |-      |
      |bp do act  |action on b|N        |when..{..}  |command ...   |J       |-   |-     |-    |J     |-      |
      +===========+===========+=========+============+==============+========+====+======+=====+======+=======+
      |unassemble |disassemble|C-F11/A-8|dis   $pc   |disassem addr |u       |-   |-     |-    |U     |-      |
      |bt         |backtrace  |A-7      |where       |bt            |kd kb kd|-   |-     |T    |~k ln |-      |
      |frame      |           |A-7      |frame       |up/down       |-       |-   |-     |-    |-     |-      |
      |Locals vars|-          |A-4      |dump        |-             |-       |-   |-     |V    |-     |-      |
      |regs       |registers  |A-5      |regs -F     |info regs     |-       |#R  |-     |-    |-     |-      |
      |Expr       |eval expr  |F8       |print       |print         |?expr   |-   |e/R   |x m p|?expr |-      |
      |Change var |           |F8       |p x=y       |p x=y         |-       |-   |-     +=    |E F   |-      |
      |trace      |single step|VC       |trace       |trace         |-       |-   |-     |t    |tr    |-      |
      |Examine Mem|-          |A-6      |x addr/fmt  |x/fmt addr    |dw db dc|-   |-     |-    |D     |-      |
      |Threads    |-          |A-6      |-           |-             |-       |~*KB|-     |-    |~     |-      |
      |symbols    |-          |-        |-           |i             |-       |X   |C-h   |-    |X     |-      |
      |watch      |-          |A-3      |display     |-             |-       |-   |-     |w    |-     |-      |
      |typeof     |           |         |whatis -t   |ptype         |-       |-   |-     |-    |-     |-      |
      +===========+===========+=========+============+==============+========+====+======+=====+======+=======+
      |Exe        |-          |Menu     |debug a.out |file a.out    |-       |-   |-     |-    |ini   |win.com|
      |args       |-          |Menu     |runargs     |set args      |Menu    |cmd |-     |cmd  |Kernel|Kernel |
      |src        |-          |vc pdb   |dir ~/src   |pathmap ~/src |-       |-   |-     |-    |-     |-      |
      |Edit       |-          |builtin  |list        |list          |-       |-   |-     |-    |-     |-      |
      |start      |-          |C-S-F5   |run [args]  |run           |G       |-   |-     |-    |G     |-      |
      |continue   |go         |F5       |cont        |continue      |-       |-   |c     |c    |-     |-      |
      |step into  |-          |F11      |step        |step          |T       |-   |d     |s    |T     |-      |
      |stepi      |instruction|-        |stepi       |stepi         |-       |-   |-     |-    |J     |-      |
      |step over  |-          |F10      |next        |next          |P       |-   |-     |n    |P     |-      |
      |step if    |-          |-        |-           |-             |-       |-   |-     |-    |J     |-      |
      +===========+===========+=========+============+==============+========+====+======+=====+======+=======+
      |finish     |till return|F12      |step up     |finish        |-       |-   |r     |r    |-     |-      |
      |until      |till cursor|F6       | -temp;cont |until         |-       |-   |bc    |-    |-     |-      |
      |jump       |-          |F2       |cont at     |jump          |-       |-   |-     |-    |-     |-      |
      |pop        |return now |\jump    |pop         |return        |-       |-   |-     |r    |-     |-      |
      |repeat     |redo       |-        |!!          |<CR>          |-       |-   |-     |<CR> |-     |-      |
      |quit       |-          |MENU     |quit        |q             |q       |q   |q C-] |-    |q     |q      |
      +===========+===========+=========+============+==============+========+====+======+=====+======+=======+
      |Feature    |Desc       |vc       |dbx         |gdb           |windbg  |ntsd|edebug|perld|i386kd|wdeb386|
      +===========+===========+=========+============+==============+========+====+======+=====+======+=======+  
    
    0 讨论(0)
  • 2021-01-30 04:06

    Two links from Google where I quickly found some actually useful stuff I couldn't find in the links from other answers:

    • http://www.sthu.org/code/codesnippets/files/gdb_cheatsheet.pdf
    • http://erik.cabetas.com/stuff/debug/gdb-essentials.pdf
    0 讨论(0)
  • 2021-01-30 04:07

    http://www.digilife.be/quickreferences/QRC/GDB%20Quick%20Reference.pdf

    0 讨论(0)
提交回复
热议问题