mcheck/mtrace for c++

Carlo Wood carlo@alinoe.com
Wed Feb 6 15:36:00 GMT 2002


On Wed, Feb 06, 2002 at 07:57:09PM +0000, ahoward wrote:
> 
> 
> all-
> 
> By using #include <mcheck.h> and the mtrace() call one can obtain very
> usefull diagnostics about dynamic memory usage :
> 
> Memory not freed:
> -----------------
>    Address     Size     Caller
> 0x08049eb8   0xb0f2  at /home/ahoward/eg/c/leaky.cc:15
> 0x08060ee8      0x4  at /scratch/gcc-3.0/i686-pc-linux-gnu/libstdc++-v3/libsupc++/new_op.cc:48
> 
> 
> however, the second line shows this does not work with c++, since only the
> call to malloc from within new is shown.  i'm trying to implement
> something similar for c++ and have attempted to use the following code to
> register a new_handler, it comipiles fine and runs as well - but the
> handler does not get registered (output does not show up).  Any help is
> appreciated and apologies all round if this is not an appropriate list to
> mail this item to.

You might like to use libcwd, which is doing exactly this
and much more.  See http://libcw.sourceforge.net/debugging/

Soon I'll release the next version which is thread-safe.

-- 
Carlo Wood <carlo@alinoe.com>



More information about the Libstdc++ mailing list