资源
工具和方法
1、gdb运行后给可执行程序设置参数
在GDB中间加入程序启动参数
比如我们需要调试一个可执行文件./a.out help
这时
$gdb ./a.out
进入到gdb的命令行模式下,然后:
(gdb) set args help
就能加上可执行文件需要的参数,如果要看argc[1]到argc[N]的参数,只需要
(gdb) show args
基本
使用
gdb ./exe_file core.xxxx
run
bt
1、示例
BESTPOS:
GPS Week: 1984 GPS milliseconds: 110177000
Latitude: 34.3999
Longitude: 117.471
Height: 49.7878
Solution status: 0
position type: 50
number of svs tracked: 19
number of svs used: 16
BESTPOS:
GPS Week: 1984 GPS milliseconds: 110178000
Latitude: 34.3999
Longitude: 117.471
Height: 49.7842
Solution status: 0
position type: 50
number of svs tracked: 19
number of svs used: 16
Program received signal SIGSEGV, Segmentation fault.
__memcpy_avx_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S:245
245 ../sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S: No such file or directory.
(gdb) bt
#0 __memcpy_avx_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S:245
#1 0x00007ffff7baa430 in novatel::Novatel::ParseBinary (this=0x7fffffffa210, message=0x7fffffffb598 "\252D\022\034\256", length=124, message_id=novatel::PSRDOPB_LOG_TYPE) at /home/yuhs/novatel_ws/src/novatel/src/novatel.cpp:1490
#2 0x00007ffff7ba9608 in novatel::Novatel::BufferIncomingData (this=0x7fffffffa210, message=0x7fffffecd070 "\022\034\060", length=1232659) at /home/yuhs/novatel_ws/src/novatel/src/novatel.cpp:1373
#3 0x00007ffff7ba8eef in novatel::Novatel::ReadFromFile (this=0x7fffffffa210, buffer=0x7fffffecd070 "\022\034\060", length=1232659) at /home/yuhs/novatel_ws/src/novatel/src/novatel.cpp:1233
#4 0x0000000000409588 in main (argc=2, argv=0x7fffffffd8b8) at /home/yuhs/novatel_ws/src/novatel/examples/novatel_read_from_file.cpp:121
工程化
1、工程化之-cmake工程需要-g 如何做
加入以下内容即可
SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
网友评论