GDB用法以及在ROS中使用

程序的调试过程主要有:单步执行,跳入函数,跳出函数,设置断点,设置观察点,查看变量。
本文将主要介绍linux下的强大调试工具是怎么完成这些工作的。

之所以要调试程序,是因为程序的运行结果和预期结果不一致,或者程序出现运行时错误。
调试的基本思想是:
分析现象 -> 假设错误原因 -> 产生新的现象去验证假设

调试器(如GDB)的目的是允许你在程序运行时进入到某个程序内部去看看该程序在做什么,或者在该程序崩溃时它在做什么。

GDB主要可以做4大类事(加上一些其他的辅助工作),以帮助用户在程序运行过程中发现bug。
* 启动您的程序,并列出可能会影响它运行的一些信息
* 使您的程序在特定条件下停止下来
* 当程序停下来的时候,检查发生了什么
* 对程序做出相应的调整,这样您就能尝试纠正一个错误并继续发现其它错误
 

 

The launch-prefix attribute of the <node> tag that, among other things, makes it easy to debug a ROS node process. Here are some example launch-prefixes you might find useful:

  • launch-prefix="xterm -e gdb --args" : run your node in a gdb in a separate xterm window, manually type run to start it

  • launch-prefix="gdb -ex run --args" : run your node in gdb in the same xterm as your launch without having to type run to start it

  • launch-prefix="stterm -g 200x60 -e gdb -ex run --args" : run your node in gdb in a new stterm window without having to type run to start it

  • launch-prefix="valgrind" : run your node in valgrind

  • launch-prefix="xterm -e" : run your node in a separate xterm window

  • launch-prefix="nice" : nice your process to lower its CPU usage

  • launch-prefix="screen -d -m gdb --args" : useful if the node is being run on another machine; you can then ssh to that machine and do screen -D -R to see the gdb session

  • launch-prefix="xterm -e python -m pdb" : run your python node a separate xterm window in pdb for debugging; manually type run to start it

  • launch-prefix="yappi -b -f pstat -o <filename>": run your rospy node in a multi-thread profiler such as yappi.

  • launch-prefix="/path/to/run_tmux": run your node in a new tmux window; you'll need to create /path/to/run_tmux with the contents:

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值