This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Valgrind - exact leak location.
- From: "Kaz Kylheku" <kaz at zeugmasystems dot com>
- To: "Srivatsan Ramanujam" <juggernautvatsan at yahoo dot com>, <gcc-help at gcc dot gnu dot org>
- Date: Thu, 26 Oct 2006 09:06:01 -0700
- Subject: RE: Valgrind - exact leak location.
> Hi People,
>
> I have been trying to run valgrind to detect leaks in
> my backend C++ algorithm.
But what valgrind has detected is an invalid read, not a leak.
> the rogue operation is being performed inside
> ABCParser::parseString() however this is a very big
> function and I am unable to painstakingly go thru it
> to find out the possible source of leak.
What leak? The routine is dereferencing an invalid pointer.
> Is there a way out? Can valgrind give me the exact
> line number in a file where the "invalid read"
> occured?
Let's look at it:
==9984== by 0x1B97AB4E: ABCParser::parseString() (stl_vector.h:501)
The invalid read did occur in stl_vector.h:501. But that is the middle
of an inlined function that was incorporated into the body of
parseString(). It doesn't have its own stack frame, which would give a
backtrace to the parent function.
Inlining is an optimization which, as you can see, can interfere with
debugging.
Have you thought of recompiling the code with inlining disabled?
> How can I make valgrind point out the exact location
> of the error in my code?
In what way is is the machine address 0x1B97AB4E not an exact location?
Compile with -g, and then use objdump -S to an assembly listing
annotated with the source code lines.