|
From: <sv...@va...> - 2005-11-29 09:59:37
|
Author: tom
Date: 2005-11-29 09:59:32 +0000 (Tue, 29 Nov 2005)
New Revision: 5246
Log:
Update the tool writing documentation.
Based on patch from Yao Qi <qiy...@cn...>.
Modified:
trunk/docs/xml/writing-tools.xml
Modified: trunk/docs/xml/writing-tools.xml
=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/docs/xml/writing-tools.xml 2005-11-28 17:32:49 UTC (rev 5245)
+++ trunk/docs/xml/writing-tools.xml 2005-11-29 09:59:32 UTC (rev 5246)
@@ -601,40 +601,43 @@
<sect3 id=3D"writing-tools.debugfns">
<title>Debugging C functions</title>
=20
-<para>If you want to debug C functions used by your tool, you can
-attach GDB to Valgrind with some effort:</para>
+<para>If you want to debug C functions used by your tool, you can=20
+achieve this by following these steps:</para>
<orderedlist>
<listitem>
- <para>Enable the following code in
- <filename>coregrind/vg_main.c</filename> by changing
- <computeroutput>if (0)</computeroutput>=20
- into <computeroutput>if (1)</computeroutput>:
-<programlisting><![CDATA[
- /* Hook to delay things long enough so we can get the pid and
- attach GDB in another shell. */
- if (0) {=20
- Int p, q;
- for ( p =3D 0; p < 50000; p++ )
- for ( q =3D 0; q < 50000; q++ ) ;
- }]]></programlisting>
- and rebuild Valgrind.</para>
+ <para>Set VALGRIND_LAUNCHER to <![CDATA[ <prefix>/bin/valgrind]]>:
+ </para>
+ <programlisting><![CDATA[
+ export VALGRIND_LAUNCHER=3D/usr/local/bin/valgrind]]>
+ </programlisting>
</listitem>
=20
<listitem>
- <para>Then run:</para>
+ <para>Then run <screen>gdb <![CDATA[ <prefix>/lib/valgrind/<platform>/=
<tool>"]]></screen>:
+ </para>
<programlisting><![CDATA[
- valgrind <prog>]]></programlisting>
- <para>Valgrind starts the program, printing its process id, and
- then delays for a few seconds (you may have to change the loop
- bounds to get a suitable delay).</para>
+ gdb /usr/local/lib/valgrind/ppc32-linux/lackey]]></programlisting>
</listitem>
=20
<listitem>
- <para>In a second shell run:</para>
+ <para>Do <screen>handle SIGSEGV SIGILL nostop noprint</screen> in
+ GDB to prevent GDB from stopping on a SIGSEGV or SIGILL:</para>
<programlisting><![CDATA[
- gdb <prog pid>]]></programlisting>
+ (gdb) handle SIGILL SIGSEGV nostop noprint]]></programlisting>
</listitem>
=20
+ <listitem>
+ <para>Set any breakpoints you want and proceed as normal for gdb:</par=
a>
+ <programlisting><![CDATA[(gdb) b vgPlain_do_exec]]></programlisting>
+ <para>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</pa=
ra>
+ </listitem>
+
+ <listitem>
+ <para>Run the tool with required options:</para>
+ <programlisting><![CDATA[(gdb) run pwd]]></programlisting>
+ </listitem>
+
</orderedlist>
=20
<para>GDB may be able to give you useful information. Note that
@@ -1026,16 +1029,13 @@
<orderedlist>
<listitem>
<para>Make a directory
- <computeroutput>foobar/tests/</computeroutput>.</para>
+ <computeroutput>foobar/tests/</computeroutput>. Make sure the name
+ of the directory is <computeroutput>tests/</computeroutput> as the
+ build system assumes that any tests for the tool will be in a
+ directory by that name.</para>
</listitem>
=20
<listitem>
- <para>Edit <computeroutput>foobar/Makefile.am</computeroutput>,
- adding <computeroutput>tests</computeroutput> to the
- <computeroutput>SUBDIRS</computeroutput> variable.</para>
- </listitem>
-
- <listitem>
<para>Edit <computeroutput>configure.in</computeroutput>,
adding <computeroutput>foobar/tests/Makefile</computeroutput>
to the <computeroutput>AC_OUTPUT</computeroutput> list.</para>
|