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

📄 refcard.tex

📁 debug source code under unix platform.
💻 TEX
📖 第 1 页 / 共 3 页
字号:
% mpatrol% A library for controlling and tracing dynamic memory allocations.% Copyright (C) 1997-2002 Graeme S. Roy <graeme.roy@analog.com>%% This library is free software; you can redistribute it and/or% modify it under the terms of the GNU Library General Public% License as published by the Free Software Foundation; either% version 2 of the License, or (at your option) any later version.%% This library is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU% Library General Public License for more details.%% You should have received a copy of the GNU Library General Public% License along with this library; if not, write to the Free% Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,% MA 02111-1307, USA.% LaTeX reference card for mpatrol% $Id: refcard.tex,v 1.33 2002/01/08 20:45:08 graeme Exp $\documentclass[a4paper,landscape,final]{article}\usepackage{multicol}% Adapt the page dimensions to the paper size.\setlength{\textwidth}{\paperwidth}\addtolength{\textwidth}{-1in}\setlength{\textheight}{\paperheight}\addtolength{\textheight}{-1in}\setlength{\headheight}{0in}\setlength{\headsep}{0in}\setlength{\footskip}{0in}\setlength{\parindent}{0in}\setlength{\columnsep}{.5in}\setlength{\oddsidemargin}{-.5in}\setlength{\evensidemargin}{-.5in}\setlength{\topmargin}{-.5in}% Define new commands for formatting the headings and options.\newcommand{\heading}[1]{\textbf{\normalsize #1}}\newcommand{\command}[1]{\textbf{#1}}\newcommand{\function}[1]{\texttt{#1()}}\newcommand{\variable}[1]{\texttt{#1}}\newcommand{\error}[1]{\texttt{#1}}\newcommand{\flag}[1]{\textbf{---#1}}\newcommand{\flagpar}[2]{\flag{#1} \texttt{<}\textit{#2}\texttt{>}}\newcommand{\option}[1]{\texttt{#1}}\newcommand{\optionarg}[2]{\option{#1}\texttt{=<#2>}}\newcommand{\optionpar}[2]{\option{#1}\texttt{=<}\textit{#2}\texttt{>}}\begin{document}\pagestyle{empty}\footnotesize\begin{multicols}{3}{\textbf{\Large mpatrol reference card}}\vskip 12ptThe mpatrol library can read certain options at run-time from an environmentvariable called \texttt{MPATROL\_OPTIONS}.  This variable must contain one ormore valid option keywords from the list below and must be no longer than 1024characters in length.  If \texttt{MPATROL\_OPTIONS} is unset or empty then thedefault settings will be used.The \texttt{LOGDIR}, \texttt{PROFDIR} and \texttt{TRACEDIR} environmentvariables are also read in order to determine where the log file, profilingoutput file and tracing output file should go.  Note that if they are set thenthe default filenames for the log file, profiling output file and tracing outputfile will also be changed.\vskip 12pt\heading{Library behaviour}\vskip 6pt\begin{description}\item[\option{HELP}]Displays a quick-reference option summary.\item[\optionpar{PROGFILE}{string}]Specifies an alternative filename with which to locate the executable filecontaining the program's symbols.\item[\optionpar{CHECK}{unsigned range}]Specifies a range of allocation indices at which to check the integrity of freememory and overflow buffers.\item[\option{EDIT}]Specifies that a text editor should be invoked to edit any relevant source filesthat are associated with any warnings or errors when they occur.\item[\option{LIST}]Specifies that a context listing should be shown for any relevant source filesthat are associated with any warnings or errors when they occur.\item[\optionpar{DEFALIGN}{unsigned integer}]Specifies the default alignment for general-purpose memory allocations, whichmust be a power of two.\item[\option{NOPROTECT}]Specifies that the mpatrol library's internal data structures should not be maderead-only after every memory allocation, reallocation or deallocation.\item[\option{SAFESIGNALS}]Instructs the library to save and replace certain signal handlers during theexecution of library code and to restore them afterwards.\item[\option{CHECKFORK}]Checks at every call to see if the process has been forked in case new log,profiling and tracing output files need to be started.\item[\option{USEMMAP}]Specifies that the library should use \function{mmap} instead of \function{sbrk}to allocate user memory on UNIX platforms.\end{description}\vskip 12pt\heading{Logging and tracing}\vskip 6pt\begin{description}\item[\optionpar{LOGFILE}{string}]Specifies an alternative file in which to place all diagnostics from the mpatrollibrary.\item[\option{LOGALLOCS}]Specifies that all memory allocations are to be logged and sent to the log file.\item[\option{LOGREALLOCS}]Specifies that all memory reallocations are to be logged and sent to the logfile.\item[\option{LOGFREES}]Specifies that all memory deallocations are to be logged and sent to the logfile.\item[\option{LOGMEMORY}]Specifies that all memory operations are to be logged and sent to the log file.\item[\option{LOGALL}]Equivalent to the \option{LOGALLOCS}, \option{LOGREALLOCS}, \option{LOGFREES}and \option{LOGMEMORY} options specified together.\item[\option{TRACE}]Specifies that all memory allocations are to be traced and sent to the tracingoutput file.\item[\optionpar{TRACEFILE}{string}]Specifies an alternative file in which to place all memory allocation tracinginformation from the mpatrol library.\item[\option{LEAKTABLE}]Specifies that the leak table should be automatically used and a leak tablesummary should be displayed at the end of program execution.\item[\option{SHOWFREE}]Specifies that a summary of all of the free memory blocks should be displayed atthe end of program execution.\item[\option{SHOWFREED}]Specifies that a summary of all of the freed memory allocations should bedisplayed at the end of program execution.\item[\option{SHOWUNFREED}]Specifies that a summary of all of the unfreed memory allocations should bedisplayed at the end of program execution.\item[\option{SHOWMAP}]Specifies that a memory map of the entire heap should be displayed at the end ofprogram execution.\item[\option{SHOWSYMBOLS}]Specifies that a summary of all of the function symbols read from the program'sexecutable file should be displayed at the end of program execution.\item[\option{SHOWALL}]Equivalent to the \option{SHOWFREE}, \option{SHOWFREED}, \option{SHOWUNFREED},\option{SHOWMAP} and \option{SHOWSYMBOLS} options specified together.\item[\option{USEDEBUG}]Specifies that any debugging information in the executable file should be usedto obtain additional source-level information.\end{description}\vskip 12pt\heading{General errors}\vskip 6pt\begin{description}\item[\option{CHECKALLOCS}]Checks that no attempt is made to allocate a block of memory of size zero.\item[\option{CHECKREALLOCS}]Checks that no attempt is made to reallocate a \texttt{NULL} pointer or resizean existing block of memory to size zero.\item[\option{CHECKFREES}]Checks that no attempt is made to deallocate a \texttt{NULL} pointer.\item[\option{CHECKMEMORY}]Checks that no attempt is made to perform a zero-length memory operation on a\texttt{NULL} pointer.\item[\option{CHECKALL}]Equivalent to the \option{CHECKALLOCS}, \option{CHECKREALLOCS},\option{CHECKFREES} and \option{CHECKMEMORY} options specified together.\item[\optionpar{ALLOCBYTE}{unsigned integer}]Specifies an 8-bit byte pattern with which to prefill newly-allocated memory.\item[\optionpar{FREEBYTE}{unsigned integer}]Specifies an 8-bit byte pattern with which to prefill newly-freed memory.\item[\optionpar{NOFREE}{unsigned integer}]Specifies that a number of recently-freed memory allocations should be preventedfrom being returned to the free memory pool.\item[\option{PRESERVE}]Specifies that any reallocated or freed memory allocations should preserve theiroriginal contents.\end{description}\vskip 12pt\heading{Overwrites and underwrites}\vskip 6pt\begin{description}\item[\optionpar{OFLOWSIZE}{unsigned integer}]Specifies the size in bytes to use for all overflow buffers, which must be apower of two.\item[\optionpar{OFLOWBYTE}{unsigned integer}]Specifies an 8-bit byte pattern with which to fill the overflow buffers of allmemory allocations.\item[\option{OFLOWWATCH}]Specifies that watch point areas should be used for overflow buffers rather thanfilling with the overflow byte.\item[\optionarg{PAGEALLOC}{LOWER|UPPER}]Specifies that each individual memory allocation should occupy at least one pageof virtual memory and should be placed at the lowest or highest point withinthese pages.\item[\option{ALLOWOFLOW}]Specifies that a warning rather than an error should be produced if any memoryoperation function overflows the boundaries of a memory allocation, and thatthe operation should still be performed.\end{description}\vskip 12pt\heading{Using with a debugger}\vskip 6pt\begin{description}\item[\optionpar{ALLOCSTOP}{unsigned integer}]Specifies an allocation index at which to stop the program when it is beingallocated.\item[\optionpar{REALLOCSTOP}{unsigned integer}]Specifies an allocation index at which to stop the program when a memoryallocation is being reallocated.\item[\optionpar{FREESTOP}{unsigned integer}]Specifies an allocation index at which to stop the program when it is beingfreed.\end{description}\vskip 12pt\heading{Testing}\vskip 6pt\begin{description}\item[\optionpar{LIMIT}{unsigned integer}]Specifies the limit in bytes at which all memory allocations should fail if thetotal allocated memory should increase beyond this.\item[\optionpar{FAILFREQ}{unsigned integer}]Specifies the frequency at which all memory allocations will randomly fail.\item[\optionpar{FAILSEED}{unsigned integer}]Specifies the random number seed which will be used when determining whichmemory allocations will randomly fail.\item[\optionpar{UNFREEDABORT}{unsigned integer}]Specifies the minimum number of unfreed allocations at which to abort theprogram just before program termination.\end{description}\vskip 12pt\heading{Profiling}\vskip 6pt\begin{description}\item[\option{PROF}]Specifies that all memory allocations are to be profiled and sent to theprofiling output file.\item[\optionpar{PROFFILE}{string}]Specifies an alternative file in which to place all memory allocation profilinginformation from the mpatrol library.\item[\optionpar{AUTOSAVE}{unsigned integer}]Specifies the frequency at which to periodically write the profiling data to theprofiling output file.\item[\optionpar{SMALLBOUND}{unsigned integer}]Specifies the limit in bytes up to which memory allocations should be classifiedas small allocations for profiling purposes.\item[\optionpar{MEDIUMBOUND}{unsigned integer}]Specifies the limit in bytes up to which memory allocations should be classifiedas medium allocations for profiling purposes.\item[\optionpar{LARGEBOUND}{unsigned integer}]Specifies the limit in bytes up to which memory allocations should be classifiedas large allocations for profiling purposes.\end{description}\vskip 12ptAll of the function definitions in \texttt{mpatrol.h} can be disabled bydefining the \texttt{NDEBUG} preprocessor macro, which is the same macro usedto control the behaviour of the \function{assert} function.  If \texttt{NDEBUG}is defined then no macro redefinition of functions will take place and allspecial mpatrol library functions will evaluate to empty statements.  The\texttt{mpalloc.h} header file will also be included in this case.  It isintended that the \texttt{NDEBUG} preprocessor macro be defined in releasebuilds.The \function{MP\_MALLOC} family of functions that are defined in\texttt{mpalloc.h} are also defined in \texttt{mpatrol.h} when \texttt{NDEBUG}is not defined.  The mpatrol versions of these functions contain more debugginginformation than the mpalloc versions do, but they do not call the allocationfailure handler when no more memory is available (they cause the \error{OUTMEM}error message to be given instead).There may be problems during preprocessing when the preprocessor macros definingthe replacement C$++$ operators in \texttt{mpatrol.h} are used.  If this is thecase then either the \texttt{MP\_NOCPLUSPLUS} preprocessor macro can be definedto disable all C$++$ support, or the \texttt{MP\_NONEWDELETE} preprocessor macrocan be defined to prevent the debugging versions of \texttt{operator new} and\texttt{operator delete} from being used by default.  The preprocessor macros\texttt{MP\_NEW}, \texttt{MP\_NEW\_NOTHROW} and \texttt{MP\_DELETE} will then

⌨️ 快捷键说明

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