Skip to content

Instantly share code, notes, and snippets.

@YukiSakamoto
Created August 30, 2012 06:52
Show Gist options
  • Save YukiSakamoto/3523498 to your computer and use it in GitHub Desktop.
Save YukiSakamoto/3523498 to your computer and use it in GitHub Desktop.
gcc finstrument-functions test
#include <stdio.h>
/* When compiling, set 'finstrument-functions'!
*
* gcc -finstrument-functions hook.c
*
* フックされた時に呼ばれる関数の定義は、macの場合、profile_func_enter, profile_func_exitにしないと
* いけないみたい。Linuxの場合は頭に__cyg_をそれぞれ付ける(LINUXの場合はマングリングしないはずだから_は気にしない。)
*/
__attribute__ ((no_instrument_function))
void /*__cyg_*/profile_func_enter(void* func_address, void* call_site)
{
printf("Enter:\t%p\n", func_address);
}
__attribute__ ((no_instrument_function))
void /*__cyg_*/profile_func_exit(void* func_address, void* call_site)
{
printf("Exit: \t%p\n", func_address);
}
int func(void)
{
return 0;
}
int main(void)
{
func();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment