Writing a New Valgrind Tool
5. Copy
none/nl_main.c
into
foobar/
, renaming it as
fb_main.c
. Edit it by changing the
details
lines
in
nl_pre_clo_init
to something appropriate for the tool. These fields are used in the startup message, except
for
bug_reports_to
which is used if a tool assertion fails.
Also, replace the string
"nl_"
throughout with
"fb_"
again.
6. Edit
Makefile.am
, adding the new directory
foobar
to the
TOOLS
or
EXP_TOOLS
variables.
7. Edit
configure.in
, adding
foobar/Makefile
and
foobar/tests/Makefile
to the
AC_OUTPUT
list.
8. Run:
autogen.sh
./configure --prefix=‘pwd‘/inst
make
make install
It should automake, configure and compile without errors, putting copies of the tool in
foobar/
and
inst/lib/valgrind/
.
9. You can test it with a command like:
inst/bin/valgrind --tool=foobar date
(almost any program should work;
date
is just an example). The output should be something like this:
==738== foobar-0.0.1, a foobarring tool.
==738== Copyright (C) 2002-2009, and GNU GPL’d, by J. Programmer.
==738== Using Valgrind-3.5.0.SVN and LibVEX; rerun with -h for copyright info
==738== Command: date
==738==
Tue Nov 27 12:40:49 EST 2007
==738==
The tool does nothing except run the program uninstrumented.
These steps don’t have to be followed exactly -- you can choose different names for your source files, and use a
different
--prefix
for
./configure
.
Now that we’ve setup, built and tested the simplest possible tool, onto the interesting stuff...
2.2.4. Writing the code
A tool must define at least these four functions:
pre_clo_init()
post_clo_init()
instrument()
fini()
The names can be different to the above, but these are the usual names. The first one is registered using the macro
VG_DETERMINE_INTERFACE_VERSION
. The last three are registered using the
VG_(basic_tool_funcs)
function.
3
Содержание BBV
Страница 176: ...Valgrind FAQ Release 3 8 0 10 August 2012 Copyright 2000 2012 Valgrind Developers Email valgrind valgrind org ...
Страница 177: ...Valgrind FAQ Table of Contents Valgrind Frequently Asked Questions 1 ii ...
Страница 302: ...README mips based on newer GCC versions if possible 95 ...
Страница 303: ...GNU Licenses ...
Страница 304: ...GNU Licenses Table of Contents 1 The GNU General Public License 1 2 The GNU Free Documentation License 8 ii ...