参考链接:
https://www.cnblogs.com/zhaohongtian/p/6801310.html
-finstrument-functions:
一、多个文件同时编译:
[mjj@hadoop-senior test]$ gcc -g -finstrument-functions test.c main.c instrument.c -o main
可直接生成带有hook(进入与退出函数的桩点)的可执行文件main
instrument.c 相当于复写void __cyg_profile_func_enter( void *, void * ),void __cyg_profile_func_exit( void *, void * ) 这两个函数,使运行地址输出到指定为文件中。所以在没有-finstrument-functions选项的情况下,instrument.c的内容不会被调用;
-g保留源代码的符号信息,如果没有-g,对记录下的地址进行addr2line操作不能解析出该地址对应的函数名和所在的文件函数;
[mjj@hadoop-senior test]$ gcc -g -c -finstrument-functions test.c main.c instrument.c
[mjj@hadoop-senior test]$ gcc test.o main.o instrument.o -o main
分开编译多次测试发现只有将-g和-finstrument-functions选项全部加在汇编过程才能发挥作用&