GDB备忘单

时间:2009-05-17 18:52:15

标签: xcode debugging gdb

有人可以为gbd推荐一个好的备忘单吗?我对windbg命令很有经验,我正在为lml(列表加载模块),〜* k(所有线程堆栈),ba(访问中断),dt(转储类型),dv(转储帧变量)寻找gdb等价物),sxe(设置SEH处理程序)等。 我知道不会有1比1的等价物,但我只需要大多数使用/有用的命令的精简摘要。

6 个答案:

答案 0 :(得分:42)

我个人使用这个:gdb's cheat sheet  或that link is not broken yet ..。 我在工作时打印过它。

答案 1 :(得分:8)

答案 2 :(得分:4)

  +========================+==============================+=============================+
  |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                            |
  +========================+==============================+=============================+

答案 3 :(得分:0)

这是我使用(和创建)的一个非常简单的跨平台调试备忘单。 http://mohit.io/blog/cross-platform-debugging-cheat-sheet/ 我希望你找到所需的windbg - &gt; gdb命令。

答案 4 :(得分:0)

  +===========+===========+=========+============+==============+========+====+======+=====+======+=======+
  |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 ddd   |emacs         |N       |N   |N     |ddd  |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|
  +===========+===========+=========+============+==============+========+====+======+=====+======+=======+  

答案 5 :(得分:0)

来自Google的两个链接,我很快发现了一些我在其他答案的链接中找不到的实用内容: