|
From: Edward M. <em...@li...> - 2008-06-23 23:38:52
|
I am trying to figure out where my c++ application is doing the wrong
thing which produces this call. I am trying to create a wrapper to give
me the back trace.
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "valgrind/valgrind.h"
void* I_WRAP_SONAME_FNNAME_ZU(NONE,malloc) ( size_t n )
{
void* r;
OrigFn fn;
VALGRIND_GET_ORIG_FN(fn);
if ( n < 0 )
{
VALGRIND_PRINTF_BACKTRACE("malloc: %d", n );
}
CALL_FN_W_W(r, fn, n);
return r;
}
I use automake/autoconf/gcc to generate the file libmalloc_silly_arg.so
with c naming conventions. I then run the command /bin/env
LD_PRELOAD=/full/path/libmalloc_silly_arg.so valgrind --tool=memcheck my_app
I would appreciate help in understanding what I am doing wrong.
Thanks,
Ed
|
|
From: Edward M. <em...@li...> - 2008-06-24 00:03:21
|
Julian Seward wrote:
> size_t is unsigned, so "n < 0" is always false?
>
I have replaced size_t with int and still get no output.
> J
>
> On Tuesday 24 June 2008 01:38, Edward Maros wrote:
>
>> I am trying to figure out where my c++ application is doing the wrong
>> thing which produces this call. I am trying to create a wrapper to give
>> me the back trace.
>>
>> #include <stdlib.h>
>> #include <stdio.h>
>> #include <assert.h>
>>
>> #include "valgrind/valgrind.h"
>>
>> void* I_WRAP_SONAME_FNNAME_ZU(NONE,malloc) ( size_t n )
>> {
>> void* r;
>> OrigFn fn;
>>
>> VALGRIND_GET_ORIG_FN(fn);
>> if ( n < 0 )
>> {
>> VALGRIND_PRINTF_BACKTRACE("malloc: %d", n );
>> }
>> CALL_FN_W_W(r, fn, n);
>> return r;
>> }
>>
>> I use automake/autoconf/gcc to generate the file libmalloc_silly_arg.so
>> with c naming conventions. I then run the command /bin/env
>> LD_PRELOAD=/full/path/libmalloc_silly_arg.so valgrind --tool=memcheck
>> my_app
>>
>>
>> I would appreciate help in understanding what I am doing wrong.
>>
>> Thanks,
>> Ed
>>
>> -------------------------------------------------------------------------
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services for
>> just about anything Open Source.
>> http://sourceforge.net/services/buy/index.php
>> _______________________________________________
>> Valgrind-users mailing list
>> Val...@li...
>> https://lists.sourceforge.net/lists/listinfo/valgrind-users
>>
|
|
From: Paul W. <pa...@bl...> - 2008-06-24 09:53:26
|
On Mon, Jun 23, 2008 at 04:38:41PM -0700, Edward Maros wrote: > I would appreciate help in understanding what I am doing wrong. Unless I'm missing something, you haven't actually said what's not behaving as expected when you use the wrapper...? (For what it's worth, valgrind seems slight overkill for this - I'd probably redefine malloc with a macro and if the argument is negative just do a NULL dereference to cause a backtrace. But each to their own.) -- Paul |