Should I worry about it? I changed in the makefile this line:
CFLAGS? = -O2
To:
CFLAGS? = -g -O0
That should do it (although when I build SDL 1.2 here, it uses -g
without me having to change anything?), but it looks like your test
was using those from the system instead of your custom-built ones?
==31870== by 0x406DBE2: SDL_VideoInit (in /usr/lib/libSDL-1.2.so.0.11.2)
==31870== by 0x4040987: SDL_InitSubSystem (in /usr/lib/libSDL-1.2.so.0.11.2)
==31870== by 0x40409E6: SDL_Init (in /usr/lib/libSDL-1.2.so.0.11.2)
You can set the LD_LIBRARY_PATH environment variable (on Linux,
right?) to point to your version of the library, something like this:
export LD_LIBRARY_PATH=$HOME/src/SDL/SDL-1.2/build/.libs
Adapt the path as needed, of course, wherever the libSDL-1.2.so.0.11.2
that you built is located. The output of Valgrind should report that
one instead of the one in /usr/lib, and hopefully will have source
file names and line numbers to guide you to the source of those leaks.
What else I need to do to compile a debug version? Or should I forget those
leaks and wait for next version of SDL? There is any way to supress those
leaks so I can see only leaks from my application (discarding SDL leaks)?
You can indeed write a suppression file that you then give to Valgrind
with the --suppressions option. See the documentation on how to create
that file:
http://valgrind.org/docs/manual/mc-manual.html#mc-manual.suppfiles
http://valgrind.org/docs/manual/faq.html#faq.writesupp
As I said before, I strongly suggest that you start using Valgrind
with the most reliable and important stuff, then make your way to
stricter options (that might be mistaken) progressively. Personally, I
don’t even start with --leak-check, the base errors that Valgrind
gives are very important, and rarely wrong (things like “conditional
depends on undefined”). Those won’t just make your program memory
usage balloon, but are actually bugs that can give you incorrect
results! Note that --track-origins=yes can help locate those, BTW.
When those are all fixed, I then make my way to memory leaks, first
just the unreachable that are likely to be true leaks, then once those
are all fixed (or otherwise accounted for with a suppression file),
enable --show-reachable.
If you have unit tests, I suggest running them under Valgrind, with
–error-exitcode=42 (or some other non-zero value), so that you don’t
introduce regressions!
Good luck!On Wed, May 20, 2009 at 6:27 AM, Bruno Adami <a_j_bruno at hotmail.com> wrote:
–
http://pphaneuf.livejournal.com/