GDB commands by function

来源:互联网 发布:杰信软件科技有限公司 编辑:程序博客网 时间:2024/06/10 12:00
  • Startup
gdb -helpprint startup help, show switchesgdb objectnormal debuggdb object corecore debug (must specify core file)gdb object pidattach to running processgdbuse file command to load object
  • Help
(gdb) helplist command classes(gdb) help runninglist commands in one command class(gdb) help runbottom-level help for a command "run"(gdb) help infolist info commands (running program state)(gdb) help info linehelp for a particular info command(gdb) help showlist show commands (gdb state)(gdb) help show commandsspecific help for a show command
  • Breakpoints
(gdb) break funcnameset a breakpoint on a function(gdb) break linenumset a breakpoint on a line number(gdb) break filename:funcnameset breakpoint at file and function(gdb) break filename:linenumset breakpoint at file and line(gdb) info breakpointsshow breakpoints(gdb) delete breakpointnumdelete a breakpoint by number(gdb) deletedelete all breakpoints(gdb) cleardelete breakpoints at current line(gdb) clear funcnamedelete breakpoints at function(gdb) clear linenumdelete breakpoints at line(gdb) disable breakpointnumturn a breakpoint off, but don't remove it(gdb) enable breakpointnumturn disabled breakpoint back on(gdb) tbreak funcname\linenumset a temporary breakpoint(gdb) commands break-no … endset gdb commands with breakpoint(gdb) ignore break-no countignore bpt N-1 times before activation(gdb) condition break-no expressionbreak only if condition is true(gdb) condition 2 i == 20example: break on breakpoint 2 if i equals 20(gdb) watch expressionset software watchpoint on variable(gdb) info watchpointsshow current watchpoints
  • Running the program
(gdb) runrun the program with current arguments(gdb) run args redirectionrun with args and redirection(gdb) set args args…set arguments for run(gdb) show argsshow current arguments to run(gdb) contcontinue the program(gdb) stepsingle step the program; step into functions(gdb) step countsingle step count times(gdb) nextstep but step over functions(gdb) next countnext count times(gdb) CTRL-Cactually SIGINT, stop execution of current program(gdb) attach process-idattach to running program(gdb) detachdetach from running program(gdb) finishfinish current function's execution(gdb) killkill current executing program
  • Stack backtrace
(gdb) btprint stack backtrace(gdb) frameshow current execution position(gdb) upmove up stack trace (towards main)(gdb) downmove down stack trace (away from main)(gdb) info localsprint automatic variables in frame(gdb) info argsprint function parameters
0 0
原创粉丝点击