[Gc] Re: Valgrind patch

Ludovic Courtès ludo at gnu.org
Mon Mar 8 13:06:26 PST 2010


Hi,

No Itisnt <theseaisinhere at gmail.com>
writes:

> It does this by using pthread
> attributes to get the stack base when the environment variable
> 'GC_VALGRIND' is set. A more elegant method would be to check
> /proc/self/maps for valgrind,

Actually Valgrind has an API for this:

  http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq

It boils down to:

  #include <valgrind/valgrind.h>

    if (RUNNING_ON_VALGRIND)
      ...

The presence of <valgrind/valgrind.h> can be checked for at
configuration time.  The manual reads this:

  The code added to your binary has negligible performance impact: on
  x86, amd64, ppc32 and ppc64, the overhead is 6 simple integer
  instructions and is probably undetectable except in tight loops.
  However, if you really wish to compile out the client requests, you
  can compile with -DNVALGRIND (analogous to -DNDEBUG's effect on
  assert).

Thanks,
Ludo’.



More information about the Gc mailing list