📄 mpatrol.texi
字号:
\input texinfo@c mpatrol@c A library for controlling and tracing dynamic memory allocations.@c Copyright (C) 1997-2002 Graeme S. Roy <graeme.roy@analog.com>@c@c This library is free software; you can redistribute it and/or@c modify it under the terms of the GNU Library General Public@c License as published by the Free Software Foundation; either@c version 2 of the License, or (at your option) any later version.@c@c This library is distributed in the hope that it will be useful,@c but WITHOUT ANY WARRANTY; without even the implied warranty of@c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU@c Library General Public License for more details.@c@c You should have received a copy of the GNU Library General Public@c License along with this library; if not, write to the Free@c Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,@c MA 02111-1307, USA.@c $Id: mpatrol.texi,v 1.256 2002/01/08 22:07:02 graeme Exp $@c %**start of header@setfilename mpatrol.info@settitle mpatrol@setchapternewpage odd@afourpaper@finalout@c %**end of header@dircategory Programming tools@direntry* mpatrol: (mpatrol). The mpatrol library.@end direntry@c Remember to change these after each revision!@set EDITION 2.13@set VERSION 1.4.8@set UPDATED 8th January, 2002@ifinfoThis file documents mpatrol, a library for controlling and tracing dynamicmemory allocations.Copyright @copyright{} 1997-2002 Graeme S. Roy @email{graeme.roy@@analog.com}This is edition @value{EDITION} of the mpatrol manual for version@value{VERSION}, @value{UPDATED}.Permission is granted to make and distribute verbatim copies of this manualprovided the copyright notice and this permission notice are preserved on allcopies.@ignorePermission is granted to process this file through TeX and print the results,provided the printed document carries a copying permission notice identical tothis one except for the removal of this paragraph (this paragraph not beingrelevant to the printed manual).@end ignorePermission is granted to copy and distribute modified versions of this manualunder the conditions for verbatim copying, provided that the entire resultingderived work is distributed under the terms of a permission notice identical tothis one.Permission is granted to copy and distribute translations of this manual intoanother language, under the above conditions for modified versions, except thatthis permission notice may be stated in a translation approved by the FreeSoftware Foundation.All product names mentioned in the documentation and source code for thislibrary are the trademarks of their respective owners.@end ifinfo@titlepage@title mpatrol@subtitle A library for controlling and tracing dynamic memory allocations@subtitle Edition @value{EDITION} for mpatrol version @value{VERSION}@subtitle @value{UPDATED}@sp 5@image{images/mpatrol}@author Graeme S. Roy@page@vskip 0pt plus 1filllCopyright @copyright{} 1997-2002 Graeme S. Roy <@email{graeme.roy@@analog.com}>Permission is granted to make and distribute verbatim copies of this manualprovided the copyright notice and this permission notice are preserved on allcopies.Permission is granted to copy and distribute modified versions of this manualunder the conditions for verbatim copying, provided that the entire resultingderived work is distributed under the terms of a permission notice identical tothis one.Permission is granted to copy and distribute translations of this manual intoanother language, under the above conditions for modified versions, except thatthis permission notice may be stated in a translation approved by the FreeSoftware Foundation.All product names mentioned in the documentation and source code for thislibrary are the trademarks of their respective owners.@end titlepage@contents@node Top, Foreword, , (dir)@top mpatrol@ifinfo@image{images/mpatrol}@end ifinfo@ifhtml@image{images/mpatrol}@end ifhtmlThis document describes mpatrol, a library for controlling and tracing dynamicmemory allocations.This is edition @value{EDITION} of the mpatrol manual for version@value{VERSION}, @value{UPDATED}.@menu* Foreword:: Motivation and feedback.* Overview:: Overview of mpatrol.* Features:: Features of mpatrol.* Installation:: Building and installing.* Integration:: Debugging existing programs.* Memory allocations:: Background.* Operating system support:: Additional background.* Using mpatrol:: Using the library.* Tools:: Additional tools.* Utilities:: External programs.* Profiling:: Memory allocation profiling.* Tracing:: Memory allocation tracing.* Heap corruption:: Squashing those errors.* Memory leaks:: Detection and identification.* Improving performance:: Life beyond mpatrol.* How it works:: Implementation details.* Examples:: Examples of usage.* Tutorial:: Complete example.* Functions:: Library functions.* Environment:: Library run-time options.* Options:: Command line options.* Diagnostic messages:: Warnings and errors.* Library performance:: Comparitive timings.* File formats:: Output file layouts.* Supported systems:: Known platforms that mpatrol runs on.* Porting:: How to port mpatrol to a new system.* Notes:: Known bugs and future enhancements.* Frequently asked questions:: For answering specific problems.* Related software:: Similar programs.* References:: Additional information.* About the author:: Information about me.* Copying:: GNU Library General Public License.* Function index:: Library functions.* Index:: Main index.@end menu@node Foreword, Overview, Top, Top@unnumbered Foreword@cindex forewordI first started writing this library a few years ago when the company I work forsent me out to a customer who had reported a memory leak, which he expected wascoming from the code generated by our C++ compiler. A few years on and thelibrary has changed dramatically from its first beginnings, but I thought I'drelease it publicly in case anyone else found it useful.When writing the library, I placed more emphasis on the quantity and quality ofinformation about allocated memory rather than the speed and efficiency ofallocating the actual memory. This means that the library will use dramaticallymore memory than normal dynamic memory allocation libraries and can slow down toa crawl depending on which options you use. However, the end results are likelyto be accurate and reliable, and in most cases the library will run quitehappily at a sane speed.@cindex warrantyThe mpatrol library is by no means the only library of its kind. Solaris hasno less that 6 different malloc libraries, and there are plenty available asfreeware or as commercial products. Try to keep in mind that mpatrol comes withabsolutely no warranty and so if it doesn't work for you and you need a fastsolution, try some of the other libraries or products available. I have listedsome of the most popular at the end of this manual (@pxref{Related software}).@cindex manual layoutThis manual is arranged so that complete reference material on the mpatrollibrary can be found in the appendices, while introductory and backgroundmaterial can be found in the preceding chapters and sections. For readers whowish to delve right in and use the library, the Installation(@pxref{Installation}) and Examples (@pxref{Examples}) chapters should be enoughto get started in combination with the quick reference card. Otherwise, thismanual should be read from beginning to end in order to get the most out of thesoftware it describes. Note that all of the output shown from the examples wasproduced on 32-bit environments, although mpatrol can be built to support 64-bitenvironments as well.@cindex bug reports@cindex reporting bugsDue to their very nature, problems with dynamic memory allocations arenotoriously difficult to reproduce and debug, and this is likely to be the caseif you find a bug in the mpatrol library as it might be extremely hard toreproduce on another system. Details on how to report bugs are given elsewherein this document (@pxref{Notes}), but it would be very useful if you could tryto provide as much information as possible when reporting a problem, and thatincludes having a look in the library source code to see if it's obvious what iswrong. However, please try to read the frequently asked questions(@pxref{Frequently asked questions}) first in case your question or problem iscovered there since they are usually updated every time I receive a questionabout mpatrol.@cindex contacting the author@cindex author, contacting@cindex getting updates@cindex updates@cindex FreshMeat@cindex SourceForgeThe latest version of the mpatrol library and this manual can always be found at@uref{http://www.cbmamiga.demon.co.uk/mpatrol/}, and any correspondence relatingto mpatrol (bug reports, enhancement requests, compliments, etc.@:) should besent to @email{mpatrol@@cbmamiga.demon.co.uk}. I'd be very interested inhearing any success stories with using mpatrol to debug programs, since I getvery little feedback apart from the occasional bug report. The mpatrol libraryis also registered at FreshMeat (@uref{http://freshmeat.net/projects/mpatrol/})and SourceForge (@uref{http://sourceforge.net/projects/mpatrol/}) and severalother software sites so you can receive notification of updates there as well.I normally only check my e-mail about once or twice a week, so don't expect animmediate response. I can also be reached at @email{graeme.roy@@analog.com} butthat is my work e-mail address. There is also a discussion group at@uref{http://groups.yahoo.com/group/mpatrol/} where you can post mpatrol-relatedquestions but you must first subscribe to the group before you can send mail toit.@cindex acknowledgements@cindex contributorsFinally, I'd like to thank Stephan Springl (@email{springl@@bfw-online.de}) forhis help on reading debugging information from object files via the GNU BFDlibrary, and Adam Zell (@email{zell@@best.com}) for helping with patching thedynamic linker support functions for loading shared libraries. Both AlexanderBarton (@email{abarton@@innotrac.com}) and Dave Gibson(@email{david.gibson@@analog.com}) helped to make mpatrol thread-safe. RogerKeane (@email{rgr@@bcs-inc.com}) provided the perl code in the @command{mpsym}command and also the idea for the @code{MP_USE_ATEXIT} feature macro. SteveMcIntyre (@email{smcintyre@@allstor-sw.co.uk}) helped by diagnosing the@code{fork()} problem and provided example code on how to fix it. PeterZijlstra (@email{peter@@xlnt-software.com}) contributed code to enhance stacktraces for errors.Boris Makushkin (@email{oberon@@antibiotic.ru}) requested, helped with, andprovided initial testing for the FreeBSD port, and Ivan Finch(@email{i.finch@@rl.ac.uk}), Gerrit Bruchhaeuser(@email{gbruchhaeuser@@orga.com}) and Andreas Schallenberg(@email{andreas.schallenberg@@informatik.uni-oldenburg.de}) did the same for theTru64 and SuSE ports. Both Aleksandar Donev (@email{donev@@pa.msu.edu}) and VanSnyder (@email{vsnyder@@math.jpl.nasa.gov}) provided suggestions and code forusing mpatrol with FORTRAN. Michael Anthony (@email{m@@xyzfind.com}) wrote theprofdiff tool and Jerome Marant (@email{jerome@@debian.org}) did the DebianGNU/Linux port.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!@cindex release buildsOh, 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.Happy debugging!Graeme Roy, 11th October, 1999.Edinburgh, Scotland.@node Overview, Features, Foreword, Top@chapter Overview@cindex overview@cindex mpatrol@cindex mpatrol library@cindex library, mpatrol@cindex run-time errors@cindex errors, run-timeThe 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()} function or @code{operator
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -