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 malloc and exec MC_(malloc) instead of real malloc. It's very convenient. So can i get the address of the original malloc in MC_(malloc) and exec it? if not,can i use I_WRAP_SONAME_FNNAME_ZU function to hook malloc in my valgrind tool's code?

Yes if you want to wrap the function rather than replacing it
then use the _WRAP_ macros and then your wrapper can get the
original address and call it.

Tom

--
Tom Hughes (t...@compton.nu)
http://compton.nu/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to