相关疑难解决方法(0)

C函数分析(地址似乎是offseted)

我正在尝试使用-finstrument-functions选项来分析函数调用.基本上,我所做的是将以下内容写入任何已编译的源代码:

static int __stepper=0;
void __cyg_profile_func_enter(void *this_fn, void *call_site)
                              __attribute__((no_instrument_function));
void __cyg_profile_func_enter(void *this_fn, void *call_site) {
  int i=0;
  for( ; i<__stepper; i++ ) printf(" ");
  printf("E: %p %p\n", this_fn, call_site);
  __stepper ++;
} /* __cyg_profile_func_enter */

void __cyg_profile_func_exit(void *this_fn, void *call_site)
                             __attribute__((no_instrument_function));
void __cyg_profile_func_exit(void *this_fn, void *call_site) {
  int i=0;
  __stepper --;
  for( ; i<__stepper; i++ ) printf(" ");
  printf("L:  %p %p\n", this_fn, call_site);
} /* __cyg_profile_func_enter */
Run Code Online (Sandbox Code Playgroud)

并得到以下结果:

 E: 0xb7597ea0 0xb75987a8
  E: 0xb7597de0 0xb7597ef5
  L:  0xb7597de0 0xb7597ef5
 L:  0xb7597ea0 …
Run Code Online (Sandbox Code Playgroud)

c profiling function

7
推荐指数
1
解决办法
1644
查看次数

标签 统计

c ×1

function ×1

profiling ×1