1.GDB。linux下的超级神器,就不细说了,bomblab, bufferlab全靠它debug出来的,功能极其强大。
2.valgrind,一款用于内存调试,内存泄漏检测以及性能分析的软件开发工具。支持x86, x86-64, Armv7以及PowerPC上的Linux.
3.宏:
__FILE__ (文件名:%s)
__LINE__ (行数: %d)
__func__ (函数名:%s)
例如:
#include
int hello()
{
printf("Hello from function %s\n",__func__);
return 1;
}
int main()
{
hello();
printf("This is line %d\n", __LINE__);
printf("Belongs to function %s\n", __func__);
printf("In filename: %s\n", __FILE__);
}
运行结果为:
Hello from function hello
This is line 11
Belongs to function main
In filename: /Users/wilbur/Desktop/15213/testing32/test.cpp