GDB是一个由GNU开源组织发布的、UNIX/LINUX操作系统下的、基于命令行的、功能强大的程序调试工具。我尝试用GBD调试的原因是程序出现非重复性的错误,报错后找不到原因。
1.报错
[kitti_filtering_node-4] process has died [pid 17594, exit code -11, cmd /home/lmk/file/OSCode/dev_lidarclass/L8C/catkin_ws/devel/lib/lidar_localization/kitti_filtering_node __name:=kitti_filtering_node __log:=/home/lmk/.ros/log/bbfdea4e-a753-11ed-8674-a4ae128129e9/kitti_filtering_node-4.log].
log file: /home/lmk/.ros/log/bbfdea4e-a753-11ed-8674-a4ae128129e9/kitti_filtering_node-4*.log
2.在launch文件中添加
launch-prefix = "gdb -ex run --args"
3.我添加后的效果
<node pkg="localization" type="filtering_node" name="filtering_node" output="screen" launch-prefix = "gdb -ex run --args"></node>
4.启动launch文件后,会出现和GBD配置相关的一些输出信息,可以直接按回车进行确认。
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
---Type <return> to continue, or q <return> to quit---process[base2imu-6]: started with pid [9878]
5.发现错误,应该内存没搞好。
Thread 1 "kitti_filtering" received signal SIGSEGV, Segmentation fault.
0x000055555559c259 in lidar_localization::KITTIFilteringFlow::ValidLidarData() ()
(gdb) valid imu: 1 valid gnss: 1valid velocitydr: 0 valid gnssgps: 0