Re: [Valgrind-users] About how to hook malloc to do sth and execute the original malloc

2018-07-12 Thread Tom Hughes
Yes because printf will invoke malloc which will call your wrapper which will call printf etc etc until the stack is exhausted. You can't use anything in your wrapper that might use malloc. Tom On 12/07/18 13:07, shuai xi wrote: thank you for your answer. But when i use  _WRAP_ macros like

Re: [Valgrind-users] About how to hook malloc to do sth and execute the original malloc

2018-07-12 Thread shuai xi
thank you for your answer. But when i use _WRAP_ macros like following code, it gives me an error. *code:* long I_WRAP_SONAME_FNNAME_ZU(libcZdsoZd6,malloc) ( long n ) { char * r; OrigFn fn; printf("1\n"); VALGRIND_GET_ORIG_FN(fn); CALL_FN_W_W(r, fn, n); //printf("in

Re: [Valgrind-users] About how to hook malloc to do sth and execute the original malloc

2018-07-12 Thread Tom Hughes
On 12/07/18 10:26, shuai xi wrote: I know that 'Memcheck's implementation of malloc has "nothing to do" with glibc's implementation' after readind some code of valgrind, but i want to use the glibc's malloc to avoid changing heap layout. Memcheck sets the VG_(needs_malloc_replacement) to hook

[Valgrind-users] About how to hook malloc to do sth and execute the original malloc

2018-07-12 Thread shuai xi
hello developer, i want to write a tool for valgrind to analysis an program automatically. I know that 'Memcheck's implementation of malloc has "nothing to do" with glibc's implementation' after readind some code of valgrind, but i want to use the glibc's malloc to avoid changing heap layout.