本仓库记录基于Python的GDB拓展命令和常用操作
System | Python Version | Pass |
---|---|---|
Ubuntu22.04 | Built-in Python(3.10) | √ |
Ubuntu20.04 | Built-in Python(3.7) | √ |
$ pip3 install -r requirements.txt
$ git clone https://github.com/Natsu-Akatsuki/ExtendedGdb ~/.gdb
- For Eigen data
# 导入脚本
$ echo "source ~/.gdb/eigen_gdb.py" >> ~/.gdbinit
# 导入脚本
$ echo "source ~/.gdb/mat_pretty_printer.py" >> ~/.gdbinit
- 基于Matplotlib查看图片(效果类同于J家三方插件
OpenCV Image Viewer
)
# 导入脚本
$ echo "source ~/.gdb/img_gdb.py" >> ~/.gdbinit
# 可视化图片
(gdb) imshow <img>
- 基于Open3D查看点云
# 导入脚本
$ echo "source ~/.gdb/pointcloud_gdb.py" >> ~/.gdbinit
# 可视化点云
(gdb) pcl_viewer <pointcloud>
# 可视化和保存点云
(gdb) pcl_viewer <pointcloud> -s
- CLion GDB 调用pcl_viewer后显示 "Evaluation hung: call func(e) This may be caused by something like a deadlock or an infinite loop.To prevent this from happening when variables are calculated, please toggle 'Enable value renderers' off."
(ctrl + shift + a) and typing "registry" and then enter. And then adjusting the "cidr.debugger.timeout.eveluate" setting to a larger,默认是30000ms(30s),可调大(ref:detail)
- 能否支持打开多个可视化窗口来查看数据
不能。实测,只有关闭了GUI才能进行其他操作,即开新的GUI和执行GDB指令(用多线程也不能解决这个问题)。原因参考gdb文档:“gdb install handlers for SIGCHLD and SIGINT. Python code must not override these, or even change the options using sigaction. If your program changes the handling of these signals, gdb will most likely stop working correctly. Note that it is unfortunately common for GUI toolkits to install a SIGCHLD handler.”
- 使用gdb.parse_and_eval("pointcloud.get().points.data()")时,显示 gdb.error: Cannot evaluate function -- may be inlined
需要对该函数显式地进行实例化(@ref)
// 在对应的函数中添加 pointcloud.get()->points.data();
- Couldn't get registers: No such process
实测时发现这种方法取值 gdb.parse_and_eval("pointcloud.get().points.data()") 不太稳定,因此还是一步步来,先得到gdb.Value再取值