Created
August 30, 2012 06:52
-
-
Save YukiSakamoto/3523498 to your computer and use it in GitHub Desktop.
gcc finstrument-functions test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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