web-dev-qa-db-ja.com

GDBチートシート

誰かがgbdに適したチートシートをお勧めできますか?私はwindbgコマンドの経験があり、lml(ロードされたモジュールのリスト)、〜* k(すべてのスレッドスタック)、ba(アクセス時のブレーク)、dt(ダンプタイプ)、dv(ダンプフレーム変数)に相当するgdbを探しています)、sxe(SEHハンドラーのセットアップ)など。1対1に相当するものはないことは理解していますが、最もよく使用される/便利なコマンドの要約が必要です。

31
Remus Rusanu

私はこれを個人的に使用します: gdbのチートシート または そのリンクはまだ壊れていません.. 。私は仕事でそれを印刷しました。

42
yves Baumes
8
anon
  +========================+==============================+=============================+
  |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                            |
  +========================+==============================+=============================+
4
mosh
  +===========+===========+=========+============+==============+========+====+======+=====+======+=======+
  |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|
  +===========+===========+=========+============+==============+========+====+======+=====+======+=======+  
0
mosh

これは、私が使用(および作成)した非常に単純なクロスプラットフォームデバッグのチートシートです。 http://mohit.io/blog/cross-platform-debugging-cheat-sheet/ 必要なwindbg-> gdbコマンドが見つかることを願っています。

0
mohit

他の回答からのリンクでは見つけることができなかった実際に役立つものをすぐに見つけたGoogleからの2つのリンク:

0
akavel