⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpatrol.html

📁 debug source code under unix platform.
💻 HTML
📖 第 1 页 / 共 5 页
字号:
it.<p>Finally, I'd like to thank Stephan Springl (<a href="mailto:springl@bfw-online.de">springl@bfw-online.de</a>) forhis help on reading debugging information from object files via the GNU BFDlibrary, and Adam Zell (<a href="mailto:zell@best.com">zell@best.com</a>) for helping with patching thedynamic linker support functions for loading shared libraries.  Both AlexanderBarton (<a href="mailto:abarton@innotrac.com">abarton@innotrac.com</a>) and Dave Gibson(<a href="mailto:david.gibson@analog.com">david.gibson@analog.com</a>) helped to make mpatrol thread-safe.  RogerKeane (<a href="mailto:rgr@bcs-inc.com">rgr@bcs-inc.com</a>) provided the perl code in the <code>mpsym</code>command and also the idea for the <code>MP_USE_ATEXIT</code> feature macro.  SteveMcIntyre (<a href="mailto:smcintyre@allstor-sw.co.uk">smcintyre@allstor-sw.co.uk</a>) helped by diagnosing the<code>fork()</code> problem and provided example code on how to fix it.  PeterZijlstra (<a href="mailto:peter@xlnt-software.com">peter@xlnt-software.com</a>) contributed code to enhance stacktraces for errors.<p>Boris Makushkin (<a href="mailto:oberon@antibiotic.ru">oberon@antibiotic.ru</a>) requested, helped with, andprovided initial testing for the FreeBSD port, and Ivan Finch(<a href="mailto:i.finch@rl.ac.uk">i.finch@rl.ac.uk</a>), Gerrit Bruchhaeuser(<a href="mailto:gbruchhaeuser@orga.com">gbruchhaeuser@orga.com</a>) and Andreas Schallenberg(<a href="mailto:andreas.schallenberg@informatik.uni-oldenburg.de">andreas.schallenberg@informatik.uni-oldenburg.de</a>) did the same for theTru64 and SuSE ports.  Both Aleksandar Donev (<a href="mailto:donev@pa.msu.edu">donev@pa.msu.edu</a>) and VanSnyder (<a href="mailto:vsnyder@math.jpl.nasa.gov">vsnyder@math.jpl.nasa.gov</a>) provided suggestions and code forusing mpatrol with FORTRAN.  Michael Anthony (<a href="mailto:m@xyzfind.com">m@xyzfind.com</a>) wrote theprofdiff tool and Jerome Marant (<a href="mailto:jerome@debian.org">jerome@debian.org</a>) did the DebianGNU/Linux port.<p>In addition, after spending well over 2000 hours designing and programmingmpatrol, my sanity would not have been preserved in the state it is in todaywere it not for the music of The Chemical Brothers, The Manic Street Preachers,Orbital and The Prodigy.  You can now argue how sane I am depending on yourmusical tastes!<p>Oh, and always remember to do final release builds without the mpatrol libraryas the library is much slower than normal malloc implementations and uses muchmore memory.<p>Happy debugging!<p>Graeme Roy, 11th October, 1999.<p>Edinburgh, Scotland.<p><hr>Node:<a name="Overview">Overview</a>,Next:<a rel=next href="#Features">Features</a>,Previous:<a rel=previous href="#Foreword">Foreword</a>,Up:<a rel=up href="#Top">Top</a><br><h1>1 Overview</h1><p>The mpatrol library is yet another link library that attempts to diagnoserun-time errors that are caused by the wrong use of dynamically allocatedmemory.  If you don't know what the <code>malloc()</code> function or <code>operatornew[]</code> do then this library is probably not for you.  You have to have a certainamount of programming expertise and a knowledge of how to run a command linecompiler and linker before you should attempt to use this.<p>Along with providing a comprehensive and configurable log of all dynamic memoryoperations that occurred during the lifetime of a program, the mpatrol libraryperforms extensive checking to detect any misuse of dynamically allocatedmemory.  All of this functionality can be integrated into existing code throughthe inclusion of a single header file at compile-time.  On UNIX and Windowsplatforms (and AmigaOS when using <code>gcc</code>) this may not even be necessaryas 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.<p>All logging and tracing output from the mpatrol library is sent to a separatelog file in order to keep its diagnostics separate from any that the programbeing tested might generate.  A wide variety of library settings can also bechanged at run-time via an environment variable, thus removing the need torecompile or relink in order to change the library's behaviour.<p>A file containing a summary of the memory allocation profiling statistics for aparticular program can be produced by the mpatrol library.  This file can thenbe read by a profiling tool which will display a set of tables based upon theaccumulated data.  The profiling information includes summaries of all of thememory allocations listed by size and the function that allocated them and alist of memory leaks with the call stack of the allocating function.  It alsoincludes a graph of all memory allocations listed in tabular form, and anoptional graph specification file for later processing by the <code>dot</code>graph visualisation package.<p>A file containing a concise encoded trace of all memory allocations,reallocations and deallocations made by a program can also be produced by thempatrol library.  This file can then be read by a tracing tool which will decodethe trace and display the events in tabular or graphical form, and also displayany relevant statistics that could be calculated.<p>The mpatrol library has been designed with the intention of replacing calls toexisting C and C++ memory allocation functions as seamlessly as possible, butin many cases that may not be possible and slight code modifications may berequired.  However, a preprocessor macro containing the version of the mpatrollibrary is provided for the purposes of conditional compilation so that releasebuilds and debug builds can be easily automated.<p><hr>Node:<a name="Features">Features</a>,Next:<a rel=next href="#Installation">Installation</a>,Previous:<a rel=previous href="#Overview">Overview</a>,Up:<a rel=up href="#Top">Top</a><br><h1>2 Features</h1><p>An overall list of features contained in the mpatrol library is given below. This is not intended to be exhaustive since the best way to see what the librarydoes is to read the documentation and try it out.<ul><li>Written for 32-bit and 64-bit UNIX, AmigaOS, Windows and Netware platforms. Contains direct support for (and takes advantage of most of the features of)AIX, DG/UX, DRS/NX, DYNIX/ptx, FreeBSD, HP/UX, IRIX, Linux, LynxOS, NetBSD,OpenBSD, SINIX, Solaris, SunOS, Tru64 and UnixWare.  Also containstarget-specific code to take advantage of Alpha, Intel 80x86, Motorola 680x0and 88xx0, MIPS, HP PA/RISC, IBM RS/6000, PowerPC and SPARC processors.<li>Has the ability to read symbols from executable files and shared libraries inthe <code>a.out</code>, COFF, XCOFF, ELF32, ELF64 and Windows Portable Executable fileformats, and if the GNU BFD library is available then the mpatrol library canread symbols from all of the file formats that it has support for as well.  Canalso liase with AIX, BSD-based, HP/UX, IRIX, OSF, SVR4-based and Windows dynamiclinkers in order to find out information about shared libraries.<li>Can be built to allocate memory from a fixed-sized static array rather thanusing heap memory from the system.<li>Can be built as archive, shared and/or thread-safe libraries on systems thatsupport them, or even as one large object file.  A lint library can also bebuilt from the mpatrol library on UNIX platforms.<li>A release version of the mpatrol library is provided, which has the samefunctional interface, but does not contain any of mpatrol's debugging, tracingor profiling features.  It is intended to be used to quickly remove the mpatrollibrary.<li>Details of memory allocations and free memory are stored internally as a treestructure for speed and also to allow the best fit allocation algorithm to beused.  This also enables the library to perform intelligent resizing of memoryallocations and can be used to quickly determine if an address has beenallocated on the heap.<li>Contains 19 replacement C dynamic memory allocation functions:<p><table><tr align="left"><td><code>malloc()</code><td>ANSI<td>Allocates memory. <br></tr><tr align="left"><td><code>calloc()</code><td>ANSI<td>Allocates zero-filled memory. <br></tr><tr align="left"><td><code>memalign()</code><td>UNIX<td>Allocates memory with a specified alignment. <br></tr><tr align="left"><td><code>valloc()</code><td>UNIX<td>Allocates page-aligned memory. <br></tr><tr align="left"><td><code>pvalloc()</code><td>UNIX<td>Allocates a number of pages. <br></tr><tr align="left"><td><code>alloca()</code><td>old<td>Allocates temporary memory. <br></tr><tr align="left"><td><code>strdup()</code><td>UNIX<td>Duplicates a string. <br></tr><tr align="left"><td><code>strndup()</code><td>old<td>Duplicates a string with a maximum length. <br></tr><tr align="left"><td><code>strsave()</code><td>old<td>Duplicates a string. <br></tr><tr align="left"><td><code>strnsave()</code><td>old<td>Duplicates a string with a maximum length. <br></tr><tr align="left"><td><code>strdupa()</code><td>old<td>Duplicates a string. <br></tr><tr align="left"><td><code>strndupa()</code><td>old<td>Duplicates a string with a maximum length. <br></tr><tr align="left"><td><code>realloc()</code><td>ANSI<td>Resizes memory. <br></tr><tr align="left"><td><code>reallocf()</code><td>BSD<td>Resizes memory and frees on failure. <br></tr><tr align="left"><td><code>recalloc()</code><td>old<td>Resizes memory allocated by <code>calloc()</code>. <br></tr><tr align="left"><td><code>expand()</code><td>old<td>Resizes memory but does not relocate it. <br></tr><tr align="left"><td><code>free()</code><td>ANSI<td>Frees memory. <br></tr><tr align="left"><td><code>cfree()</code><td>old<td>Frees memory allocated by <code>calloc()</code>. <br></tr><tr align="left"><td><code>dealloca()</code><td>new<td>Explicitly frees temporary memory.<br></tr></table><li>Contains 5 replacement C dynamic memory extension functions:<p><table><tr align="left"><td><code>xmalloc()</code><td>Allocates memory without failure. <br></tr><tr align="left"><td><code>xcalloc()</code><td>Allocates zero-filled memory without failure. <br></tr><tr align="left"><td><code>xstrdup()</code><td>Duplicates a string without failure. <br></tr><tr align="left"><td><code>xrealloc()</code><td>Resizes memory without failure. <br></tr><tr align="left"><td><code>xfree()</code><td>Frees memory.<br></tr></table><li>Contains 6 replacement C dynamic memory alternative functions:<p><table><tr align="left"><td><code>MP_MALLOC()</code><td>Allocates memory without failure. <br></tr><tr align="left"><td><code>MP_CALLOC()</code><td>Allocates zero-filled memory without failure. <br></tr><tr align="left"><td><code>MP_STRDUP()</code><td>Duplicates a string without failure. <br></tr><tr align="left"><td><code>MP_REALLOC()</code><td>Resizes memory without failure. <br></tr><tr align="left"><td><code>MP_FREE()</code><td>Frees memory. <br></tr><tr align="left"><td><code>MP_FAILURE()</code><td>Sets the allocation failure handler.<br></tr></table><li>Contains 4 replacement C++ dynamic memory allocation operators (in both<em>throw</em> and <em>nothrow</em> forms):<p><table><tr align="left"><td><code>operator new</code><td>Allocates memory. <br></tr><tr align="left"><td><code>operator new[]</code><td>Allocates memory for an array. <br></tr><tr align="left"><td><code>operator delete</code><td>Frees memory. <br></tr><tr align="left"><td><code>operator delete[]</code><td>Frees memory allocated by <code>operator new[]</code>.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -