|
From: Stephen T. <st...@to...> - 2007-03-31 17:35:48
|
On Sat, 2007-03-31 at 07:44 +0100, Olly Betts wrote:
> > Ok. I understand more of what you mean now. What is the strategy you
> > advise using this macro?
>
> Divide and conquer!
>
> First find the line where valgrind first reports an uninitialised
> access, and right before that line call VALGRIND_CHECK_MEM_IS_DEFINED on
> each of the variables mentioned in the problem line to establish which
> is actually to blame (sometimes it's obvious, but as with most
> debugging, it's worth double checking what seems obvious).
Ok. I can do that. When I try to attach the debugger I get the following
message:
==9059== ---- Attach to debugger ? --- [Return/N/n/Y/y/C/c] ---- y
starting debugger
==9059== starting debugger with cmd: -nw /proc/9061/fd/1014 9061
/bin/sh: -nw: command not found
==9059==
==9059== Debugger has detached. Valgrind regains control. We continue.
I can only attach it by default if I do:
valgrind -v --tool=memcheck --db-attach=yes --db-command="gdb -nw %f %
p" ./reverse --file kernel32.dll
When I do that get that gdb is trying to attach itself but it hangs
during the attaching process:
==9069== starting debugger with cmd: gdb -nw /proc/9071/fd/1014 9071
GNU gdb Red Hat Linux (6.5-15.fc6rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you
are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host
libthread_db library "/lib/libthread_db.so.1".
Attaching to program: /proc/9071/fd/1014, process 9071
> Then add calls back along the execution path leading to that point. If
> you add a few widely spaced calls you should be able to narrow down the
> area pretty quickly.
>
> Cheers,
> Olly
Is this the correct us of VALGRIND_CHECK_MEM_IS_DEFINED? The macro wants
a int and I am sending it the pointer to a const Component_Graph and a
std::string.
void Reverse_Impl::print_Graph
( infrastructure::Component_Graph const& graph_ref,
std::string const name ) const
{
VALGRIND_CHECK_MEM_IS_DEFINED(&graph_ref,sizeof(graph_ref));
VALGRIND_CHECK_MEM_IS_DEFINED(&name,name.size());
....
}
Stephen
|