根据这个答案,它应该打印所有函数名称:
[root@ test]# cat hw.c
#include <stdio.h>
int func(void)
{
return 1;
}
int main(void)
{
func();
printf("%d",6);
return 6;
}
[root@ test]# gcc -Wall hw.c -o hw -finstrument-functions
[root@ test]# ./hw
6
[root@ test]# gcc --version
gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)
Copyright (C) 2006 Free Software Foundation, Inc.
Run Code Online (Sandbox Code Playgroud)
但为什么它不适合我呢?
我想跟踪函数调用的每个路径.例如:
int a()
{
b();
return 1;
}
void b()
{
}
int main()
{
int x=a();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
所以我的调用跟踪是main-> a-> b这样我想跟踪每个设置的调用路径.我想到了深度优先搜索.但我不确定这会怎样.任何人都可以建议我在perl中实现任何具体方法吗?我将拥有C程序文件,并将在其上运行perl脚本以获取调用跟踪.