|
From: Yao Qi <qiy...@cn...> - 2005-11-16 03:09:13
|
On Tue, Nov 15, 2005 at 11:07:29AM +0000, Tom Hughes wrote: > In message <200...@cn...> > Yao Qi <qiy...@cn...> wrote: > > > The part about debugging Valgrind in README_DEVELOPERS is out-of-date. > > I code a patch for this. > > I actually think we should drop all that - there are much easier ways > to debug valgrind now that everything is statically linked with the > tool: > > - Set VALGRIND_LAUNCHER to <prefix>/bin/valgrind > > - Run "gdb <prefix>/lib/valgrind/<platform>/<tool>" > > - Do "handle SIGSEGV nostop noprint" to stop gdb stopping on > a SEGV as valgrindd needs to be able to handle them to do > stack extension > > - Set any breakpoints you want and proceed as normal for gdb It is much simpler than the one I post, and it works well. This part could be replace 'Debugging Valgrind with GDB' in README_DEVELOPERS. I rewrite the part per your comments and list the new patch at the end of this mail. Any comments? Now, we could debug Valgrind in this way, and how about the option '--wait-for-gdb' and VG_(clo_wait_for_gdb)? Do you think it could be removed from coregrind/m_main.c? > > In principle debugging valgrind itself should work, the only problem > is getting control when it starts the tool to set breakpoints. Doing > a "catch exec" doesn't really work as that stops before the exec and > my gdb doesn't implement "catch start" or "catch thread_start". We can set breakpoint at load_client or vgPlain_do_exec, do you think it is OK? > > Tom > > -- > Tom Hughes (to...@co...) > http://www.compton.nu/ > > Here is the nwe patch, Index: README_DEVELOPERS =================================================================== --- README_DEVELOPERS (revision 5114) +++ README_DEVELOPERS (working copy) @@ -35,22 +35,33 @@ Debugging Valgrind with GDB ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -To debug stage 1 just run it under GDB in the normal way. +Now, it would be much easier to debug Valgrind now that everything is +statically linked with the tools, -To debug Valgrind proper (stage 2) with GDB, start Valgrind like this: +(1) Set VALGRIND_LAUNCHER to <prefix>/bin/valgrind - valgrind --tool=none --wait-for-gdb=yes <prog> + export VALGRIND_LAUNCHER=/usr/local/bin/valgrind + +(2) Run "gdb <prefix>/lib/valgrind/<platform>/<tool>" -Then start gdb like this in another terminal: + gdb /usr/local/lib/valgrind/ppc32-linux/lackey - gdb /usr/lib/valgrind/stage2 <pid> +(3) Do "handle SIGSEGV SIGILL nostop noprint" in GDB to prevent GDB from +stopping on a SIGSEGV or SIGILL. -Where <pid> is the pid valgrind printed. Then set whatever breakpoints -you want and do this in gdb: + (gdb) handle SIGILL SIGSEGV nostop noprint - jump *$eip +(4) Set any breakpoints you want and proceed as normal for gdb. The macro +VG_(FUNC) is expanded to vgPlain_FUNC, so If you want to set a breakpoint +on VG_(do_exec), you could do like this in GDB, + (gdb) b vgPlain_do_exec +(5) Run the tool with corresponding options. + + (gdb) run pwd + + Self-hosting ~~~~~~~~~~~~ To run Valgrind under Valgrind: -- Regards, Yao ------------ Yao Qi |