|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
RRP £12.95 ($19.95)
2 Quick Start Guide
This chapter provides a quick start guide for new users of Valgrind.
The Valgrind tool suite provides a number of debugging and profiling tools. The most popular is Memcheck, a memory checking tool which can detect many common memory errors such as:
- Touching memory you shouldn't (e.g. overrunning heap block boundaries, or reading/writing freed memory).
- Using values before they have been initialized.
- Incorrect freeing of memory, such as double-freeing heap blocks.
- Memory leaks.
Memcheck is only one of the tools in the Valgrind suite. Other tools you may find useful are:
- Cachegrind: a profiling tool which produces detailed data on cache (miss) and branch (misprediction) events. Statistics are gathered for the entire program, for each function, and for each line of code, if you need that level of detail.
- Callgrind: a profiling tool that shows cost relationships across function calls, optionally with cache simulation similar to Cachegrind. Information gathered by Callgrind can be viewed either with an included command line tool, or by using the KCachegrind GUI. KCachegrind is not part of the Valgrind suite--it is part of the KDE Desktop Environment.
- Massif: a space profiling tool. It allows you to explore in detail which parts of your program allocate memory.
- Helgrind: a debugging tool for threaded programs. Helgrind looks for various kinds of synchronisation errors in code that uses the POSIX PThreads API.
- In addition, there are a number of “experimental” tools in the codebase. They can be distinguished by the “exp-” prefix on their names. Experimental tools are not subject to the same quality control standards that apply to our production-grade tools (Memcheck, Cachegrind, Callgrind, Massif and Helgrind).
The rest of this chapter discusses only the Memcheck tool. For full documentation on the other tools, and for Memcheck, see the subsequent chapters of this book.
What follows is the minimum information you need to start detecting memory errors in your program with Memcheck. Note that this guide applies to Valgrind version 3.3.0 and later. Some of the information is not applicable for earlier versions.
|ISBN 0954612051||Valgrind 3.3 - Advanced Debugging and Profiling for GNU/Linux applications||See the print edition|