- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i just want to test how the function instrumentation works.
i have a simple single file as below to test but it does not work.
test.cpp
********************************************************************
#include
#include
#include
#include
#include
#include
using namespace std;
#define __NON_INSTRUMENT_FUNCTION__ __attribute__((__no_instrument_function__))
void
__NON_INSTRUMENT_FUNCTION__
__cyg_profile_func_enter(void *this_fn, void *call_site)
{
printf("entry: %p\\n", this_fn);
(void)call_site;
}
void
__NON_INSTRUMENT_FUNCTION__
__cyg_profile_func_exit(void *this_fn, void *call_site)
{
printf("exit: %p\\n", this_fn);
(void)call_site;
}
void asd2(void)
{
printf("asd2\\n");
}
int main()
{
bool i = 1;
asd2();
return 0;
}
********************************************************************
and i am compiling the file as below
> icc -g -finstrument-functions test.cpp -o main
but it doesn't work. it only prints "asd2" when i executed ./main
when i splitt the file into two pieces as below, function instrumentation works
> icc -g -finstrument-functions ftest.cpp trace.c -o main2 // compiling with this command
and it works.
how can it be happening ?
ftest.cpp
*************
#include
using namespace std;
void asd1(void)
{
printf("asd1\\n");
}
int main()
{
bool i = 1;
asd1();
return 0;
}
*************
and
trace.c
*************
#include
#include
#include
#include
#include
#define __NON_INSTRUMENT_FUNCTION__ __attribute__((__no_instrument_function__))
void
__NON_INSTRUMENT_FUNCTION__
__cyg_profile_func_enter(void *this_fn, void *call_site)
{
printf("entry: %p\\n", this_fn);
(void)call_site;
}
void
__NON_INSTRUMENT_FUNCTION__
__cyg_profile_func_exit(void *this_fn, void *call_site)
{
printf("exit : %p\\n", this_fn);
(void)call_site;
}
***********
i have a simple single file as below to test but it does not work.
test.cpp
********************************************************************
#include
#include
#include
#include
#include
#include
using namespace std;
#define __NON_INSTRUMENT_FUNCTION__ __attribute__((__no_instrument_function__))
void
__NON_INSTRUMENT_FUNCTION__
__cyg_profile_func_enter(void *this_fn, void *call_site)
{
printf("entry: %p\\n", this_fn);
(void)call_site;
}
void
__NON_INSTRUMENT_FUNCTION__
__cyg_profile_func_exit(void *this_fn, void *call_site)
{
printf("exit: %p\\n", this_fn);
(void)call_site;
}
void asd2(void)
{
printf("asd2\\n");
}
int main()
{
bool i = 1;
asd2();
return 0;
}
********************************************************************
and i am compiling the file as below
> icc -g -finstrument-functions test.cpp -o main
but it doesn't work. it only prints "asd2" when i executed ./main
when i splitt the file into two pieces as below, function instrumentation works
> icc -g -finstrument-functions ftest.cpp trace.c -o main2 // compiling with this command
and it works.
how can it be happening ?
ftest.cpp
*************
#include
using namespace std;
void asd1(void)
{
printf("asd1\\n");
}
int main()
{
bool i = 1;
asd1();
return 0;
}
*************
and
trace.c
*************
#include
#include
#include
#include
#include
#define __NON_INSTRUMENT_FUNCTION__ __attribute__((__no_instrument_function__))
void
__NON_INSTRUMENT_FUNCTION__
__cyg_profile_func_enter(void *this_fn, void *call_site)
{
printf("entry: %p\\n", this_fn);
(void)call_site;
}
void
__NON_INSTRUMENT_FUNCTION__
__cyg_profile_func_exit(void *this_fn, void *call_site)
{
printf("exit : %p\\n", this_fn);
(void)call_site;
}
***********
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm still looking into this a bit, but what I tried first that seemed to work was to declare the two instrumented functions as extern "C". So do:
[cpp]test.cpp ******************************************************************** #include#include #include #include #include #include using namespace std; extern "C" { #define __NON_INSTRUMENT_FUNCTION__ __attribute__((__no_instrument_function__)) void __NON_INSTRUMENT_FUNCTION__ __cyg_profile_func_enter(void *this_fn, void *call_site) { printf("entry: %pn", this_fn); (void)call_site; } void __NON_INSTRUMENT_FUNCTION__ __cyg_profile_func_exit(void *this_fn, void *call_site) { printf("exit: %pn", this_fn); (void)call_site; } } // end extern "C" void asd2(void) { printf("asd2n"); } int main() { bool i = 1; asd2(); return 0; } ******************************************************************** [/cpp]

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page