编译Debug版本
catkin_make -DCMAKE_BUILD_TYPE=Debug
gdb启动ros node
rosrun --prefix 'gdb -ex run --args' package node
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x0000000000460d30 in boost::detail::atomic_increment (pw=0x555ed0 <__libc_csu_init+8>) at /usr/include/boost/smart_ptr/detail/sp_counted_base_sync.hpp:43
43 __sync_fetch_and_add( pw, 1 );
此时看到 'Segmentation fault'崩溃了,使用'bt'命令列出崩溃call stack
(gdb) bt
#0 0x0000000000460d30 in boost::detail::atomic_increment (pw=0x555ed0 <__libc_csu_init+8>) at /usr/include/boost/smart_ptr/detail/sp_counted_base_sync.hpp:43
#1 0x0000000000460e40 in boost::detail::sp_counted_base::add_ref_copy (this=0x555ec8 <__libc_csu_init>) at /usr/include/boost/smart_ptr/detail/sp_counted_base_sync.hpp:116
#2 0x0000000000460ea4 in boost::detail::shared_count::shared_count (this=0x7fffffeb90, r=...) at /usr/include/boost/smart_ptr/detail/shared_count.hpp:454
#3 0x000000000046173c in boost::shared_ptr<autoware::Line>::shared_ptr (this=0x7fffffeb88, r=...) at /usr/include/boost/smart_ptr/shared_ptr.hpp:392
#4 0x00000000004618dc in boost::shared_ptr<autoware::Line>::operator= (this=0x7fffffec28, r=...) at /usr/include/boost/smart_ptr/shared_ptr.hpp:502
#5 0x0000000000460638 in autoware::WhiteLine::fromHADLane (pHADLane=0x6b1ab0) at /home/nvidia/catkin_ws/src/baidu_had/src/autoware.cpp:140
#6 0x000000000045c568 in autoware_vector_map (pDB=0x677c00, links=std::vector of length 1127, capacity 2048 = {...}, pg_path="/home/nvidia/catkin_ws/src/baidu_had")
at /home/nvidia/catkin_ws/src/baidu_had/src/db_console.cc:192
#7 0x000000000045ca78 in main (argc=1, argv=0x7ffffff1c0) at /home/nvidia/catkin_ws/src/baidu_had/src/db_console.cc:247
这里已经可以都看到frame 6调用shared_ptr引起崩溃,还有代码文件名和行数。接下来可以 frame 6 和 frame info来看详细的寄存器信息.
其它的调试命令如: info locals , info args 等可以打印frame的参数等