gprof 实验
关键在于编译的时候禁用PIE就可以了
gcc -pg -O0 -fno-pie -static test.c -o test
/*test.c*/
#include<stdio.h>
#include <stdlib.h>
void TestFunc();
static void StaticFunc();
void TestFunc()
{
int i = 0;
printf("In TestFunc\n");
for (i=0; i<20; i++)
StaticFunc();
}
static void StaticFunc()
{
int i = 0;
printf("In StaticFunc\n");
for (i=0; i<1000000000; i++);
}
int main(void)
{
printf("In main\n");
TestFunc();
return 0;
}
在terminal中编译运行
gcc -pg -O0 -fno-pie -static test.c -o test
./test
gprof test > data.txt
运行结果


一些输出选项后面补。。。