On 2/8/19 10:58 AM, Ahmad Nouralizadeh wrote:
By image, I mean the binary code of the program to be traced and all the shared libraries accessed by that program. As soon as they are loaded, they will be searched for calls to malloc,... and some code will be added before and after each call
It would be more robust to re-write the first several instructions of malloc itself, instead of trying to find all the calls. In particular, a tail-merged call that jumps to the "call malloc@PLT" instruction might not be recognized by the insertion of code "before and after each call to malloc". Also, malloc() can be called through a pointer: void *(*f)(size_t) = malloc; char *x = f(10); and the "before ... and after" recognizer probably will miss some of those. ld-linux (the PT_INTERP) might have its own malloc, separate from libc.so.6. In some (but not all) cases mmap(0,size,prot,MAP_PRIVATE|MAP_ANONYMOUS,-1,0) should be considered an allocation. Do all the measurement programs agree? _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users