Graphics.ValgrindDoug - lordmundi/wikidoctest GitHub Wiki

Valgrind Doug

UNFINISHED DOCUMENT - UNDER CONSTRUCTION

Disclaimer

Initially, I was going to show how I got this working with Doug, but going to write in general, and show what I did for Doug later.

Intro

Valgrind is a tool to catch memory problems with an executable.

Get Valgrind

I had to download the latest for it to work with Doug. Here is the download site

Hack For Local Valgrind (not installing to /usr/local)

If you get this error on startup
  valgrind: failed to start tool 'memcheck' for platform 'x86-linux': No such file or directory

 In perf/tinycc.c

 after
    tcc_add_library_path(s, "/usr/local/lib");
    tcc_add_library_path(s, "/usr/lib");
    tcc_add_library_path(s, "/lib");

 add
    tcc_add_library_path(s, "[myprefix]/lib");

Give It A First Shot

% valgrind &mdash;tool=memcheck <myexec>

Suppressing Ugly System Errors You Don't Want To See

If you see something like:
 ==9567== Invalid read of size 4
 ==9567==    at 0&times;4014C37: (within /lib/ld-2.6.1.so)
 ==9567==    by 0&times;4A28061: (within /lib/tls/i686/cmov/libc-2.6.1.so)
 ==9567==    by 0&times;400D015: (within /lib/ld-2.6.1.so)
 ==9567==    by 0&times;4A28224: __libc_dlopen_mode (in /lib/tls/i686/cmov/libc-2.6.1.so)
 ==9567==  Address 0&times;4EF2B04 is 28 bytes inside a block of size 31 alloc'd
 ==9567==    at 0&times;4022765: malloc (vg_replace_malloc.c:149)
 ==9567==    by 0&times;4007FA1: (within /lib/ld-2.6.1.so)
 ==9567==    by 0&times;4A28061: (within /lib/tls/i686/cmov/libc-2.6.1.so)
 ==9567==    by 0&times;400D015: (within /lib/ld-2.6.1.so)
 ==9567==    by 0&times;4A28224: __libc_dlopen_mode (in /lib/tls/i686/cmov/libc-2.6.1.so)
 ==9567==    by 0&times;4A02756: __nss_lookup_function (in /lib/tls/i686/cmov/libc-2.6.1.so)

 Do this:
 % valgrind &mdash;tool=memcheck &mdash;error-limit=no  \    
&mdash;gen-suppressions=yes  \    
&mdash;suppressions=${HOME}/bin/valgrind-suppressions <myexec>

 &rarr; STOPPED HERE &larr;
⚠️ **GitHub.com Fallback** ⚠️