|
From: <sv...@va...> - 2005-11-17 12:31:25
|
Author: tom Date: 2005-11-17 12:31:12 +0000 (Thu, 17 Nov 2005) New Revision: 5165 Log: Update README_DEVELOPERS to describe how to debug valgrind more easily. Based on patch from Yao Qi <qiy...@cn...>. Modified: trunk/README_DEVELOPERS Modified: trunk/README_DEVELOPERS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/README_DEVELOPERS 2005-11-17 12:14:42 UTC (rev 5164) +++ trunk/README_DEVELOPERS 2005-11-17 12:31:12 UTC (rev 5165) @@ -35,22 +35,37 @@ =20 Debugging Valgrind with GDB ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -To debug stage 1 just run it under GDB in the normal way. +To debug the valgrind launcher program (<prefix>/bin/valgrind) just +run it under gdb in the normal way. =20 -To debug Valgrind proper (stage 2) with GDB, start Valgrind like this: +Debugging the main body of the valgrind code (and/or the code for +a particular tool) requires a bit more trickery but can be achieved +without too much problem by following these steps: =20 - valgrind --tool=3Dnone --wait-for-gdb=3Dyes <prog> +(1) Set VALGRIND_LAUNCHER to <prefix>/bin/valgrind: =20 -Then start gdb like this in another terminal: + export VALGRIND_LAUNCHER=3D/usr/local/bin/valgrind =20 - gdb /usr/lib/valgrind/stage2 <pid> +(2) Run "gdb <prefix>/lib/valgrind/<platform>/<tool>": =20 -Where <pid> is the pid valgrind printed. Then set whatever breakpoints -you want and do this in gdb: + gdb /usr/local/lib/valgrind/ppc32-linux/lackey =20 - jump *$eip +(3) Do "handle SIGSEGV SIGILL nostop noprint" in GDB to prevent GDB from + stopping on a SIGSEGV or SIGILL: =20 + (gdb) handle SIGILL SIGSEGV nostop noprint =20 +(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 VG_(do_exec), you could do like this in GDB: + + (gdb) b vgPlain_do_exec + +(5) Run the tool with required options: + + (gdb) run pwd + + Self-hosting ~~~~~~~~~~~~ To run Valgrind under Valgrind: |