GDB commands by function

  • Startup
gdb -help print startup help, show switches
gdb object normal debug
gdb object core core debug (must specify core file)
gdb object pid attach to running process
gdb use file command to load object
  • Help
(gdb) help list command classes
(gdb) help running list commands in one command class
(gdb) help run bottom-level help for a command "run"
(gdb) help info list info commands (running program state)
(gdb) help info line help for a particular info command
(gdb) help show list show commands (gdb state)
(gdb) help show commands specific help for a show command
  • Breakpoints
(gdb) break funcname set a breakpoint on a function
(gdb) break linenum set a breakpoint on a line number
(gdb) break filename:funcname set breakpoint at file and function
(gdb) break filename:linenum set breakpoint at file and line
(gdb) info breakpoints show breakpoints
(gdb) delete breakpointnum delete a breakpoint by number
(gdb) delete delete all breakpoints
(gdb) clear delete breakpoints at current line
(gdb) clear funcname delete breakpoints at function
(gdb) clear linenum delete breakpoints at line
(gdb) disable breakpointnum turn a breakpoint off, but don't remove it
(gdb) enable breakpointnum turn disabled breakpoint back on
(gdb) tbreak funcname\linenum set a temporary breakpoint
(gdb) commands break-no … end set gdb commands with breakpoint
(gdb) ignore break-no count ignore bpt N-1 times before activation
(gdb) condition break-no expression break only if condition is true
(gdb) condition 2 i == 20 example: break on breakpoint 2 if i equals 20
(gdb) watch expression set software watchpoint on variable
(gdb) info watchpoints show current watchpoints
  • Running the program
(gdb) run run the program with current arguments
(gdb) run args redirection run with args and redirection
(gdb) set args args… set arguments for run
(gdb) show args show current arguments to run
(gdb) cont continue the program
(gdb) step single step the program; step into functions
(gdb) step count single step count times
(gdb) next step but step over functions
(gdb) next count next count times
(gdb) CTRL-C actually SIGINT, stop execution of current program
(gdb) attach process-id attach to running program
(gdb) detach detach from running program
(gdb) finish finish current function's execution
(gdb) kill kill current executing program
  • Stack backtrace
(gdb) bt print stack backtrace
(gdb) frame show current execution position
(gdb) up move up stack trace (towards main)
(gdb) down move down stack trace (away from main)
(gdb) info locals print automatic variables in frame
(gdb) info args print function parameters
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值