c - Wrapping malloc and calling backtrace -


i have written malloc wrapper called using ld_preload mecanism. my_malloc calls backtrace backtrace_symbols. managed fact these functions call malloc counter , condition. nevertheless when launch myprog simple main, there no trace of malloc called in main ! traces of malloc calls in extern libraries.

void show_backtrace(){     void *array[10];     size_t size;     char **strings;     int i;     size = backtrace (array, 10);     strings = backtrace_symbols ((void *const *)array, size);     (i = 0; < size; i++)     {            printf ("%s | start @ %p \n", strings[i], array[i]);     }        free (strings); }    void *malloc(size_t size){     void *address = null;     if (real_malloc == null){         real_malloc = dlsym(rtld_next, "malloc");         //correspondance_init();     }             address = real_malloc(size);     if(no_backtrace_malloc <= 0){          no_backtrace_malloc = 10; // todo: more generic way manage         show_backtrace();         edit: no_backtrace_malloc = 1;     }   no_backtrace_malloc --;   return address; }     main(){    int * = malloc(sizeof(int) * 10);    int i;    (i=0;i<10;i++)      a[i] = i;   } 

my question is: why not working ? ie why there not trace of malloc called inside main. thank you,

i have answer ! forgot counter 0 after call show_backtrace() !! edited inside question.


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -