1 2 /*--------------------------------------------------------------------*/ 3 /*--- Module-local header file for m_aspacemgr. ---*/ 4 /*--- priv_aspacemgr.h ---*/ 5 /*--------------------------------------------------------------------*/ 6 7 /* 8 This file is part of Valgrind, a dynamic binary instrumentation 9 framework. 10 11 Copyright (C) 2006-2013 OpenWorks LLP 12 info@open-works.co.uk 13 14 This program is free software; you can redistribute it and/or 15 modify it under the terms of the GNU General Public License as 16 published by the Free Software Foundation; either version 2 of the 17 License, or (at your option) any later version. 18 19 This program is distributed in the hope that it will be useful, but 20 WITHOUT ANY WARRANTY; without even the implied warranty of 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 General Public License for more details. 23 24 You should have received a copy of the GNU General Public License 25 along with this program; if not, write to the Free Software 26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 27 02111-1307, USA. 28 29 The GNU General Public License is contained in the file COPYING. 30 */ 31 32 #ifndef __PRIV_ASPACEMGR_H 33 #define __PRIV_ASPACEMGR_H 34 35 /* One of the important design goals of the address space manager is 36 to minimise dependence on other modules. Hence the following 37 minimal set of imports. */ 38 39 #include "pub_core_basics.h" // types 40 #include "pub_core_vkiscnums.h" // system call numbers 41 #include "pub_core_vki.h" // VKI_PAGE_SIZE, VKI_MREMAP_MAYMOVE, 42 // VKI_MREMAP_FIXED, vki_stat64 43 44 #include "pub_core_debuglog.h" // VG_(debugLog) 45 46 #include "pub_core_libcbase.h" // VG_(strlen), VG_(strcmp), VG_(strncpy) 47 // VG_IS_PAGE_ALIGNED 48 // VG_PGROUNDDN, VG_PGROUNDUP 49 50 #include "pub_core_syscall.h" // VG_(do_syscallN) 51 // VG_(mk_SysRes_Error) 52 // VG_(mk_SysRes_Success) 53 54 #include "pub_core_options.h" // VG_(clo_sanity_level) 55 56 #include "pub_core_aspacemgr.h" // self 57 58 59 /* --------------- Implemented in aspacemgr-common.c ---------------*/ 60 61 /* Simple assert-like, file I/O and syscall facilities, which avoid 62 dependence on m_libcassert, and hence on the entire module graph. 63 This is important since most of the system itself depends on 64 aspacem, so we have to do this to avoid a circular dependency. */ 65 66 __attribute__ ((noreturn)) 67 extern void ML_(am_exit) ( Int status ); 68 extern void ML_(am_barf) ( const HChar* what ); 69 extern void ML_(am_barf_toolow) ( const HChar* what ); 70 71 __attribute__ ((noreturn)) 72 extern void ML_(am_assert_fail) ( const HChar* expr, 73 const HChar* file, 74 Int line, 75 const HChar* fn ); 76 77 #define aspacem_assert(expr) \ 78 ((void) ((expr) ? 0 : \ 79 (ML_(am_assert_fail)(#expr, \ 80 __FILE__, __LINE__, \ 81 __PRETTY_FUNCTION__)))) 82 83 /* Dude, what's my process ID ? */ 84 extern Int ML_(am_getpid)( void ); 85 86 /* A simple, self-contained sprintf implementation. */ 87 extern UInt ML_(am_sprintf) ( HChar* buf, const HChar *format, ... ); 88 89 /* mmap et al wrappers */ 90 /* wrapper for munmap */ 91 extern SysRes ML_(am_do_munmap_NO_NOTIFY)(Addr start, SizeT length); 92 93 /* wrapper for the ghastly 'mremap' syscall */ 94 extern SysRes ML_(am_do_extend_mapping_NO_NOTIFY)( 95 Addr old_addr, 96 SizeT old_len, 97 SizeT new_len 98 ); 99 /* ditto */ 100 extern SysRes ML_(am_do_relocate_nooverlap_mapping_NO_NOTIFY)( 101 Addr old_addr, Addr old_len, 102 Addr new_addr, Addr new_len 103 ); 104 105 /* There is also VG_(do_mmap_NO_NOTIFY), but that's not declared 106 here (obviously). */ 107 108 extern SysRes ML_(am_open) ( const HChar* pathname, Int flags, Int mode ); 109 extern void ML_(am_close) ( Int fd ); 110 extern Int ML_(am_read) ( Int fd, void* buf, Int count); 111 extern Int ML_(am_readlink) ( HChar* path, HChar* buf, UInt bufsiz ); 112 extern Int ML_(am_fcntl) ( Int fd, Int cmd, Addr arg ); 113 114 /* Get the dev, inode and mode info for a file descriptor, if 115 possible. Returns True on success. */ 116 extern 117 Bool ML_(am_get_fd_d_i_m)( Int fd, 118 /*OUT*/ULong* dev, 119 /*OUT*/ULong* ino, /*OUT*/UInt* mode ); 120 121 extern 122 Bool ML_(am_resolve_filename) ( Int fd, /*OUT*/HChar* buf, Int nbuf ); 123 124 /* ------ Implemented separately in aspacemgr-linux.c ------ */ 125 126 /* Do a sanity check (/proc/self/maps sync check) */ 127 extern void ML_(am_do_sanity_check)( void ); 128 129 130 #endif // __PRIV_ASPACEMGR_H 131 132 /*--------------------------------------------------------------------*/ 133 /*--- end ---*/ 134 /*--------------------------------------------------------------------*/ 135