Natsu-Akatsuki / ExtendedGdb

基于Python的GDB拓展命令

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GDB

本仓库记录基于Python的GDB拓展命令和常用操作

Dependency

System Python Version Pass
Ubuntu22.04 Built-in Python(3.10)
Ubuntu20.04 Built-in Python(3.7)
$ pip3 install -r requirements.txt

Install

$ git clone https://github.com/Natsu-Akatsuki/ExtendedGdb ~/.gdb

Usage

Pretty Printer

  • For Eigen data
# 导入脚本
$ echo "source ~/.gdb/eigen_gdb.py" >> ~/.gdbinit

img

# 导入脚本
$ echo "source ~/.gdb/mat_pretty_printer.py" >> ~/.gdbinit

Viewer

  • 基于Matplotlib查看图片(效果类同于J家三方插件OpenCV Image Viewer
# 导入脚本
$ echo "source ~/.gdb/img_gdb.py" >> ~/.gdbinit

# 可视化图片
(gdb) imshow <img>

image-20220803112325107

  • 基于Open3D查看点云
# 导入脚本
$ echo "source ~/.gdb/pointcloud_gdb.py" >> ~/.gdbinit

# 可视化点云
(gdb) pcl_viewer <pointcloud>
# 可视化和保存点云
(gdb) pcl_viewer <pointcloud> -s

image-20220803112041923

Q&A

IDE

  • 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

GDB

  • 能否支持打开多个可视化窗口来查看数据

不能。实测,只有关闭了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再取值

Reference

About

基于Python的GDB拓展命令


Languages

Language:Python 95.4%Language:C++ 3.3%Language:CMake 1.3%