- publishing free software manuals
Valgrind 3.3 - Advanced Debugging and Profiling for GNU/Linux applications
by J. Seward, N. Nethercote, J. Weidendorfer and the Valgrind Development Team
Paperback (6"x9"), 164 pages
ISBN 0954612051
RRP £12.95 ($19.95)

Get a printed copy>>>

4.2.4 Debugging

Figuring out what's going on given the dynamic nature of wrapping can be difficult. The ‘--trace-redir=yes’ flag makes this possible by showing the complete state of the redirection subsystem after every ‘mmap’/‘munmap’ event affecting code (text).

There are two central concepts:

The state of the wrapping-and-redirection subsystem comprises a set of specifications and a set of active bindings. The specifications are acquired/discarded by watching all ‘mmap’/‘munmap’ events on code (text) sections. The active binding set is (conceptually) recomputed from the specifications, and all known symbol names, following any change to the specification set.

‘--trace-redir=yes’ shows the contents of both sets following any such event.

‘-v’ prints a line of text each time an active specification is used for the first time.

Hence for maximum debugging effectiveness you will need to use both flags.

One final comment. The function-wrapping facility is closely tied to Valgrind's ability to replace (redirect) specified functions, for example to redirect calls to ‘malloc’ to its own implementation. Indeed, a replacement function can be regarded as a wrapper function which does not call the original. However, to make the implementation more robust, the two kinds of interception (wrapping vs replacement) are treated differently.

‘--trace-redir=yes’ shows specifications and bindings for both replacement and wrapper functions. To differentiate the two, replacement bindings are printed using ‘R->’ whereas wraps are printed using ‘W->’.

ISBN 0954612051Valgrind 3.3 - Advanced Debugging and Profiling for GNU/Linux applicationsSee the print edition