Using mtrace for c++
c++
Solution
On many unix systems you can also use the addr2line utility to map an address back to a file name and line number. This utility requires that the code be compiled with the debug flag (-g for gcc). For a program named wombat you would use it like such:
addr2line -e wombat 0x400b159f
and it will print out something like
wombat_helper.c:1023
if you get ??:0 it can't find the function.
UPDATE: The memory addresses reported by mtrace are the locations where the malloc and free functions are called. For C++, this is almost always in the new and delete operators, and thus would be of very limited use, without other information, such as a stack trace to tell where in your program new or delete operator is called from.
Problem
When i use mtrace in my c++ programme,i get output like the following Memory not freed: ``` Address Size Caller 0x0804a3c8 0x4 at 0x400b159f ``` How do i know where in the code is 0x400b159f?