Download Valgrind Documentation

Transcript
Writing a New Valgrind Tool
13.3.4. Profiling
To profile a tool, use Cachegrind on it.
Valgrind.
Read README_DEVELOPERS for details on running Valgrind under
Alternatively, you can use OProfile. In most cases, it is better than Cachegrind because it’s much faster, and gives
real times, as opposed to instruction and cache hit/miss counts.
13.3.5. Other Makefile Hackery
If you add any directories under valgrind/foobar/, you will need to add an appropriate Makefile.am to it,
and add a corresponding entry to the AC_OUTPUT list in valgrind/configure.in.
If you add any scripts to your tool (see Cachegrind for an example) you need to add them to the bin_SCRIPTS
variable in valgrind/foobar/Makefile.am.
13.3.6. Core/tool Interface Versions
In order to allow for the core/tool interface to evolve over time, Valgrind uses a basic interface versioning system. All
a tool has to do is use the VG_DETERMINE_INTERFACE_VERSION macro exactly once in its code. If not, a link
error will occur when the tool is built.
The interface version number is changed when binary incompatible changes are made to the interface. If the core
and tool has the same major version number X they should work together. If X doesn’t match, Valgrind will abort
execution with an explanation of the problem.
This approach was chosen so that if the interface changes in the future, old tools won’t work and the reason will be
clearly explained, instead of possibly crashing mysteriously. We have attempted to minimise the potential for binary
incompatible changes by means such as minimising the use of naked structs in the interface.
13.4. Final Words
The core/tool interface is not fixed. It’s pretty stable these days, but it does change. We deliberately do not provide
backward compatibility with old interfaces, because it is too difficult and too restrictive. The interface checking should
catch any incompatibilities. We view this as a good thing -- if we had to be backward compatible with earlier versions,
many improvements now in the system could not have been added.
Happy programming.
135