C++ gcc和g+之间的uu cyg u profile u函数输入有什么区别+;?
我对C++ gcc和g+之间的uu cyg u profile u函数输入有什么区别+;?,c++,gcc,g++,C++,Gcc,G++,我对\uuuuuuu属性 下面是C的一个简单示例: #include <stdio.h> int depth_ = -1; #ifdef __GNUC__ void __cyg_profile_func_enter(void *, void *) __attribute__((no_instrument_function)); void _cyg_profile_func_enter(void *, void *) __attribute__((no_instrume
\uuuuuuu属性
和\uuuuu cyg\u profile\u函数\u enter
知之甚少。当然,它们都是GNUC特性
我学习C++编译NGNX模块。我总是尝试把C代码样本转换成C++。p>
下面是C的一个简单示例:
#include <stdio.h>
int depth_ = -1;
#ifdef __GNUC__
void __cyg_profile_func_enter(void *, void *) __attribute__((no_instrument_function));
void _cyg_profile_func_enter(void *, void *) __attribute__((no_instrument_function));
#define sustainable(fn, caller) \
do {\
printf("%d, %s: fn = %p, caller = %p\n", depth_, __FUNCTION__, fn, caller); \
} while(0)
void __cyg_profile_func_enter(void *fn, void *caller){
printf("Enter:\n");
depth_++;
sustainable(fn, caller);
}
void __cyg_profile_func_exit(void *fn, void *caller){
printf("Exit:\n");
depth_--;
sustainable(fn, caller);
}
#endif
void sustain(){
depth_ = 100;
}
int main(){
depth_ = 10;
sustain();
//Suture suture;
//suture.sultry();
return 0;
}
然后我用
sh$ g++ -std=c++11 -finstrument-functions ....
它循环显示Enter:2、\uu cyg\u profile\u func\u Enter:fn=0x400925、caller=0x40099b
和Exit:1、\uuuu cyg\u profile\u func\u Exit:fn=0x400925、caller=0x40099b
真奇怪。为什么
depth=100
与gcc一起工作,而与g++不一起工作?您希望fn
作为的地址是什么函数?我在main()
中没有看到应该在depth\uu
赋值之后进行的函数调用
如果您看到的是重复调用,那么它们一定是由于库函数引起的,这些函数很可能在depth\uu100代码>分配。\u cyg\u profile\u函数\u enter()将在任何用户定义函数之前自动运行。它类似于所有用户定义函数的构造函数。当我调用sustain()时;它将自动调用uu cyg_profile_函数_enter()。
sh$ g++ -std=c++11 -finstrument-functions ....