#include <stdio.h>
#import <execinfo.h>
void __cyg_profile_func_enter (void *, void *) __attribute__((no_instrument_function));
void __cyg_profile_func_exit (void *, void *) __attribute__((no_instrument_function));
int depth = -1;
void __cyg_profile_func_enter (void *func, void *caller)
{
int n;
depth++;
for (n = 0; n < depth; n++)
printf (" ");
printf ("-> %p\n", func);
void *bt[2];
int bt_size;
char **bt_syms;
bt_size = backtrace(bt, 2);
bt_syms = backtrace_symbols(bt, bt_size);
if(bt_size>=2){
printf("a%s\n",bt_syms[1]);
}
if(bt_syms) free((void*)bt_syms);
}
void __cyg_profile_func_exit (void *func, void *caller)
{
int n;
for (n = 0; n < depth; n++)
printf (" ");
printf ("<- %p\n", func);
depth--;
}
void bar(void)
{
}
void foo (void)
{
int x;
for (x = 0; x < 4; x++)
bar ();
}
int main (int argc, char *argv[])
{
foo ();
bar ();
return 0;
}
#import <execinfo.h>
void __cyg_profile_func_enter (void *, void *) __attribute__((no_instrument_function));
void __cyg_profile_func_exit (void *, void *) __attribute__((no_instrument_function));
int depth = -1;
void __cyg_profile_func_enter (void *func, void *caller)
{
int n;
depth++;
for (n = 0; n < depth; n++)
printf (" ");
printf ("-> %p\n", func);
void *bt[2];
int bt_size;
char **bt_syms;
bt_size = backtrace(bt, 2);
bt_syms = backtrace_symbols(bt, bt_size);
if(bt_size>=2){
printf("a%s\n",bt_syms[1]);
}
if(bt_syms) free((void*)bt_syms);
}
void __cyg_profile_func_exit (void *func, void *caller)
{
int n;
for (n = 0; n < depth; n++)
printf (" ");
printf ("<- %p\n", func);
depth--;
}
void bar(void)
{
}
void foo (void)
{
int x;
for (x = 0; x < 4; x++)
bar ();
}
int main (int argc, char *argv[])
{
foo ();
bar ();
return 0;
}