njn | 717cde5 | 2005-05-10 02:47:21 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Malloc replacement. pub_tool_replacemalloc.h ---*/ |
| 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
| 10 | Copyright (C) 2000-2005 Julian Seward |
| 11 | jseward@acm.org |
| 12 | |
| 13 | This program is free software; you can redistribute it and/or |
| 14 | modify it under the terms of the GNU General Public License as |
| 15 | published by the Free Software Foundation; either version 2 of the |
| 16 | License, or (at your option) any later version. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, but |
| 19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; if not, write to the Free Software |
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 26 | 02111-1307, USA. |
| 27 | |
| 28 | The GNU General Public License is contained in the file COPYING. |
| 29 | */ |
| 30 | |
| 31 | #ifndef __PUB_TOOL_REPLACEMALLOC_H |
| 32 | #define __PUB_TOOL_REPLACEMALLOC_H |
| 33 | |
| 34 | /* If a tool replaces malloc() et al, the easiest way to do so is to |
| 35 | link libreplacemalloc_toolpreload.o into its vgpreload_*.so file, and |
| 36 | use the functions declared below. You can do it from scratch, |
| 37 | though, if you enjoy that sort of thing. */ |
| 38 | |
| 39 | /* Can be called from VG_(tdict).malloc_malloc et al to do the actual |
| 40 | * alloc/freeing. */ |
| 41 | extern void* VG_(cli_malloc) ( SizeT align, SizeT nbytes ); |
| 42 | extern void VG_(cli_free) ( void* p ); |
| 43 | |
| 44 | /* Check if an address is within a range, allowing for redzones at edges */ |
| 45 | extern Bool VG_(addr_is_in_block)( Addr a, Addr start, |
| 46 | SizeT size, SizeT rz_szB ); |
| 47 | |
| 48 | /* ------------------------------------------------------------------ */ |
| 49 | /* Some options that can be used by a tool if malloc() et al are replaced. |
| 50 | The tool should call the functions in the appropriate places to give |
| 51 | control over these aspects of Valgrind's version of malloc(). */ |
| 52 | |
| 53 | /* DEBUG: print malloc details? default: NO */ |
| 54 | extern Bool VG_(clo_trace_malloc); |
| 55 | /* Minimum alignment in functions that don't specify alignment explicitly. |
| 56 | default: VG_MIN_MALLOC_SZB */ |
| 57 | extern UInt VG_(clo_alignment); |
| 58 | |
| 59 | extern Bool VG_(replacement_malloc_process_cmd_line_option) ( Char* arg ); |
| 60 | extern void VG_(replacement_malloc_print_usage) ( void ); |
| 61 | extern void VG_(replacement_malloc_print_debug_usage) ( void ); |
| 62 | |
| 63 | #endif // __PUB_TOOL_REPLACEMALLOC_H |
| 64 | |
| 65 | /*--------------------------------------------------------------------*/ |
| 66 | /*--- end ---*/ |
| 67 | /*--------------------------------------------------------------------*/ |