Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:31

0001 
0002 /*--------------------------------------------------------------------*/
0003 /*--- Malloc replacement.                 pub_tool_replacemalloc.h ---*/
0004 /*--------------------------------------------------------------------*/
0005 
0006 /*
0007    This file is part of Valgrind, a dynamic binary instrumentation
0008    framework.
0009 
0010    Copyright (C) 2000-2017 Julian Seward
0011       jseward@acm.org
0012 
0013    This program is free software; you can redistribute it and/or
0014    modify it under the terms of the GNU General Public License as
0015    published by the Free Software Foundation; either version 2 of the
0016    License, or (at your option) any later version.
0017 
0018    This program is distributed in the hope that it will be useful, but
0019    WITHOUT ANY WARRANTY; without even the implied warranty of
0020    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0021    General Public License for more details.
0022 
0023    You should have received a copy of the GNU General Public License
0024    along with this program; if not, see <http://www.gnu.org/licenses/>.
0025 
0026    The GNU General Public License is contained in the file COPYING.
0027 */
0028 
0029 #ifndef __PUB_TOOL_REPLACEMALLOC_H
0030 #define __PUB_TOOL_REPLACEMALLOC_H
0031 
0032 #include "pub_tool_basics.h"   // Addr
0033 
0034 /* If a tool replaces malloc() et al, the easiest way to do so is to
0035    link libreplacemalloc_toolpreload.o into its vgpreload_*.so file, and
0036    use the functions declared below.  You can do it from scratch,
0037    though, if you enjoy that sort of thing. */
0038 
0039 /* Can be called from VG_(tdict).malloc_malloc et al to do the actual
0040  * alloc/freeing. */
0041 extern void* VG_(cli_malloc) ( SizeT align, SizeT nbytes );
0042 extern void* VG_(cli_realloc)( void* ptr, SizeT nbytes );
0043 extern void  VG_(cli_free)   ( void* p );
0044 // Returns the usable size of a heap-block.  It's the asked-for size plus
0045 // possibly some more due to rounding up.
0046 extern SizeT VG_(cli_malloc_usable_size)( void* p );
0047 
0048 
0049 /* If a tool uses deferred freeing (e.g. memcheck to catch accesses to
0050    freed memory) it can maintain number and total size of queued blocks
0051    in these variable to provide more accurate statistics about client
0052    memory usage. Currently used by mallinfo(). */
0053 extern Long VG_(free_queue_volume);
0054 extern Long VG_(free_queue_length);
0055 
0056 /* Check if an address is within a range, allowing for redzones at edges */
0057 extern Bool VG_(addr_is_in_block)( Addr a, Addr start,
0058                                    SizeT size, SizeT rz_szB );
0059 
0060 /* ------------------------------------------------------------------ */
0061 /* Some options that can be used by a tool if malloc() et al are replaced.
0062    The tool should call the functions in the appropriate places to give
0063    control over these aspects of Valgrind's version of malloc(). */
0064 
0065 /* DEBUG: print malloc details?  default: NO */
0066 extern Bool VG_(clo_trace_malloc);
0067 /* Minimum alignment in functions that don't specify alignment explicitly.
0068    default: VG_MIN_MALLOC_SZB */
0069 extern UInt VG_(clo_alignment);
0070 
0071 extern Bool VG_(replacement_malloc_process_cmd_line_option) ( const HChar* arg );
0072 
0073 // If tool is replacing malloc for the client, the below returns
0074 // the effective client redzone as derived from the default
0075 // provided by the tool, VG_(clo_redzone_size) and the minimum
0076 // redzone required by m_mallocfree.c.
0077 // It is an error to call this before VG_(needs_malloc_replacement) has
0078 // been called.
0079 extern SizeT VG_(malloc_effective_client_redzone_size)(void);
0080 
0081 #endif   // __PUB_TOOL_REPLACEMALLOC_H
0082 
0083 /*--------------------------------------------------------------------*/
0084 /*--- end                                                          ---*/
0085 /*--------------------------------------------------------------------*/