GDB 高级应用
有没有人知道,怎么才能使用gdb 在进入一个函数时,吐出一条log。
要自动吐出。
例:
fun_1()
{
fun_2();
fun_3();
fun_2();
}
fun_2()
{
fun_3();
}
在程序运行时,自动吐出
call fun_1
call fun_2
call fun_3
call fun_3
call fun_2
[解决办法]
好像要用calls
[解决办法]
break fun_1
commands
printf "call fun_1\n"
continue
end
没试过
[解决办法]
只知道怎么跟踪系统调用
strace
[解决办法]
关注ing。。。。。。
[解决办法]
在每个函数入口处输出这样的log就可以了。。。
[解决办法]
GDB不是万能的
[解决办法]
[解决办法]
gdb的backtrace命令可以查看函数调用的关系
[解决办法]
建议使用
#ifdef _DEBUG_
ptinf("进入函数");
#endif
在编译调试版本时,
在Makefile中添加编译选项中添加 -D_DEBUG_
[解决办法]
写一个脚本将所有的printf改为
#ifdef _DEBUG_
printf("进入函数");
#endif
不就行了吗