mpatrol

mpatrol

Overview

The mpatrol library is a powerful debugging tool that attempts to diagnose run-time errors that are caused by the wrong use of dynamically allocated memory. It acts as a malloc() debugger for debugging dynamic memory allocations, although it can also trace and profile calls to malloc() and free() too. If you don't know what the malloc() function or operator new[] do then this library is probably not for you. You have to have a certain amount of programming expertise and a knowledge of how to run a command line compiler and linker before you should attempt to use this.

Along with providing a comprehensive and configurable log of all dynamic memory operations that occurred during the lifetime of a program, the mpatrol library performs extensive checking to detect any misuse of dynamically allocated memory. All of this functionality can be integrated into existing code through the inclusion of a single header file at compile-time. On UNIX and Windows platforms (and AmigaOS when using GCC) this may not even be necessary as the mpatrol library can be linked with existing object files at link-time or, on some platforms, even dynamically linked with existing programs at run-time.

All logging and tracing output from the mpatrol library is sent to a separate log file in order to keep its diagnostics separate from any that the program being tested might generate. A wide variety of library settings can also be changed at run-time via an environment variable, thus removing the need to recompile or relink in order to change the library's behaviour.

A file containing a summary of the memory allocation profiling statistics for a particular program can be produced by the mpatrol library. This file can then be read by a profiling tool which will display a set of tables based upon the accumulated data. The profiling information includes summaries of all of the memory allocations listed by size and the function that allocated them and a list of memory leaks with the call stack of the allocating function. It also includes a graph of all memory allocations listed in tabular form, and an optional graph specification file for later processing by the dot graph visualisation package.

A file containing a concise encoded trace of all memory allocations and deallocations made by a program can also be produced by the mpatrol library. This file can then be read by a tracing tool which will decode the trace and display the events in tabular or graphical form, and also display any relevant statistics that could be calculated.

The mpatrol library has been designed with the intention of replacing calls to existing C and C++ memory allocation functions as seamlessly as possible, but in many cases that may not be possible and slight code modifications may be required. However, a preprocessor macro containing the version of the mpatrol library is provided for the purposes of conditional compilation so that release builds and debug builds can be easily automated.

Documentation

The latest main distribution archive always contains an up to date edition of the mpatrol manual as unformatted TeXinfo documentation as well as in ASCII text, GNU Info, AmigaGuide and HTML formats, and the quick reference card as unformatted LaTeX documentation. It also contains the latest mpatrol manual and quick reference card in DVI, Postscript and PDF formats, as well as the latest UNIX manual pages for mpatrol in HTML, DVI, Postscript and PDF formats. Alternatively, you can browse the following online documentation or download the PDF versions of the mpatrol manual and quick reference card.

Online Documentation

Availability

The mpatrol library is freely distributable software and is covered by the GNU Library General Public License. Only the source code and preformatted documentation for the library is available for download from this site; prebuilt binaries for specific platforms may be found at various other FTP sites.

A table summarising the platforms that the mpatrol library has been built on (and the major features that are supported on each platform) is shown below. Note that it should be fairly easy to build mpatrol on a UNIX system that is not listed below, but some work may be required to enable many of the advanced features that mpatrol might have support for on such a system. See the appendix on supported systems in the mpatrol manual for more details on what is supported on specific platforms.

Platform Processor Minimum Integration Memory Access Handler Stack Traversal Symbol Reading Thread Safe
AIX 4.1 RS/6000 Link-time Yes Yes Yes No
DG/UX 4.11, 4.20 Pentium Pro, MC88100 Run-time Yes Yes Yes Yes
DRS/NX 6.2 SPARC V7 Link-time Yes Yes Yes No
DYNIX/ptx 4.5 Pentium Pro Run-time Yes Yes Yes Yes
FreeBSD 4.2 Pentium II Run-time Yes Yes Yes Yes
HP/UX 10.20 PA/RISC 9000 Link-time Yes Yes Yes No
IRIX 5.3 R4000 Run-time Yes Yes Yes No
Red Hat Linux 5.1, 6.0, 6.1, 6.2, 7.0, 7.1 Pentium III, MC68040 Run-time Yes Yes Yes Yes
SuSE Linux 7.1 Pentium II Run-time Yes Yes Yes Yes
LynxOS 3.0.0 Pentium Pro, PowerPC Link-time Yes Yes Limited Yes
SINIX 5.43 R4000 Link-time Yes Yes Yes No
Solaris 2.5, 2.6, 7, 8 Pentium Pro, SPARC V8/V9 Run-time Yes Yes Yes Yes
Tru64 5.0 Alpha Run-time Yes Yes Yes No
UnixWare 7.1.1 Pentium II Link-time Yes Yes Yes No
AmigaOS 3.1 MC68040 Link-time No Limited Limited Yes
Windows NT 4.0 Pentium III Link-time Yes Yes Yes Yes

Releases

The latest version of mpatrol can be downloaded from here, as well as older releases. However, due to space considerations, only selected older releases will be made available for download. All downloadable files are in gzipped tar archive format.

Version 1.4.8 (4310K, 8th January, 2002)
Version 1.4.7 (4268K, 5th September, 2001)
Version 1.4.6 (4261K, 28th August, 2001)

Patches

Several people have contributed code to mpatrol and some of that code has not yet made it into the mpatrol distribution. They are available here as patches that can be applied to the latest mpatrol distribution, but they are normally only useful for specific situations and are untested.

Patch 1 (10K, 8th January, 2002)
Internally reimplements the printf() family of functions for the mpatrol library so that writing to the log file does not cause recursive memory allocations.
Patch 2 (4K, 8th January, 2002)
Implements the dlopen() and dlclose() functions for SVR4-based ELF systems so that symbols can be read from shared libraries even after the mpatrol library has been initialised.
Patch 3 (6K, 8th January, 2002)
Operates on output from the mprof command in order to display differences between profiling output files.
Patch 4 (2K, 8th January, 2002)
Internally uses the ELF or GNU C++ encoded name demangler to decode function names read from object file symbol tables when the mpatrol library is built with support for the ELF or GNU BFD libraries.
Patch 5 (9K, 8th January, 2002)
A FORTRAN program that can be used to trim down the number of entries generated by the SHOWUNFREED option in the mpatrol log file and can also produce a summary as well.

This software is registered at

FreshMeat IceWalkers SourceForge


Subscribe to the mpatrol library discussion group
Browse the contents of the mpatrol archive A group hosted by Yahoo

Google Web Search

Google News Search

o Go back to my home page Web access statistics by Nedstat Web access statistics
Counter

Copyright © 1997-2005 Graeme S. Roy
Last updated on Monday 10th October, 2005.