sewardj | 55f9d1a | 2005-04-25 11:11:44 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
njn | 43b9a8a | 2005-05-10 04:37:01 +0000 | [diff] [blame] | 3 | /*--- The address space manager. pub_core_aspacemgr.h ---*/ |
sewardj | 55f9d1a | 2005-04-25 11:11:44 +0000 | [diff] [blame] | 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
sewardj | 0f157dd | 2013-10-18 14:27:36 +0000 | [diff] [blame] | 10 | Copyright (C) 2000-2013 Julian Seward |
sewardj | 55f9d1a | 2005-04-25 11:11:44 +0000 | [diff] [blame] | 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_CORE_ASPACEMGR_H |
| 32 | #define __PUB_CORE_ASPACEMGR_H |
| 33 | |
| 34 | //-------------------------------------------------------------------- |
| 35 | // PURPOSE: This module deals with management of the entire process |
| 36 | // address space. Almost everything depends upon it, including dynamic |
| 37 | // memory management. Hence this module is almost completely |
| 38 | // standalone; the only module it uses is m_debuglog. DO NOT CHANGE |
| 39 | // THIS. |
| 40 | //-------------------------------------------------------------------- |
| 41 | |
njn | 4802b38 | 2005-06-11 04:58:29 +0000 | [diff] [blame] | 42 | #include "pub_tool_aspacemgr.h" |
sewardj | 55f9d1a | 2005-04-25 11:11:44 +0000 | [diff] [blame] | 43 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 44 | //-------------------------------------------------------------- |
| 45 | // Definition of address-space segments |
| 46 | |
| 47 | /* types SegKind, ShrinkMode and NSegment are described in |
| 48 | the tool-visible header file, not here. */ |
| 49 | |
| 50 | |
| 51 | //-------------------------------------------------------------- |
| 52 | // Initialisation |
| 53 | |
| 54 | /* Initialise the address space manager, setting up the initial |
| 55 | segment list, and reading /proc/self/maps into it. This must |
| 56 | be called before any other function. |
| 57 | |
| 58 | Takes a pointer to the SP at the time V gained control. This is |
| 59 | taken to be the highest usable address (more or less). Based on |
| 60 | that (and general consultation of tea leaves, etc) return a |
philippe | 38a74d2 | 2014-08-29 22:53:19 +0000 | [diff] [blame] | 61 | suggested end address (highest addressable byte) for the client's stack. */ |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 62 | extern Addr VG_(am_startup) ( Addr sp_at_startup ); |
| 63 | |
| 64 | |
| 65 | //-------------------------------------------------------------- |
| 66 | // Querying current status |
| 67 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 68 | |
| 69 | /* Find the next segment along from 'here', if it is a file/anon/resvn |
| 70 | segment. */ |
florian | 3e79863 | 2012-11-24 19:41:54 +0000 | [diff] [blame] | 71 | extern NSegment const* VG_(am_next_nsegment) ( const NSegment* here, |
| 72 | Bool fwds ); |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 73 | |
florian | 67d4603 | 2015-01-23 19:55:31 +0000 | [diff] [blame] | 74 | /* Is the area [start .. start+len-1] validly accessible by |
| 75 | valgrind with at least the permissions 'prot' ? To find out |
| 76 | simply if said area merely belongs to valgrind, pass |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 77 | VKI_PROT_NONE as 'prot'. Will return False if any part of the |
florian | 67d4603 | 2015-01-23 19:55:31 +0000 | [diff] [blame] | 78 | area does not belong to valgrind or does not have at least |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 79 | the stated permissions. */ |
philippe | adfff76 | 2014-04-20 22:10:24 +0000 | [diff] [blame] | 80 | extern Bool VG_(am_is_valid_for_valgrind) |
| 81 | ( Addr start, SizeT len, UInt prot ); |
| 82 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 83 | /* Variant of VG_(am_is_valid_for_client) which allows free areas to |
| 84 | be consider part of the client's addressable space. It also |
| 85 | considers reservations to be allowable, since from the client's |
| 86 | point of view they don't exist. */ |
| 87 | extern Bool VG_(am_is_valid_for_client_or_free_or_resvn) |
| 88 | ( Addr start, SizeT len, UInt prot ); |
| 89 | |
| 90 | /* Trivial fn: return the total amount of space in anonymous mappings, |
| 91 | both for V and the client. Is used for printing stats in |
| 92 | out-of-memory messages. */ |
| 93 | extern ULong VG_(am_get_anonsize_total)( void ); |
| 94 | |
| 95 | /* Show the segment array on the debug log, at given loglevel. */ |
florian | dbb3584 | 2012-10-27 18:39:11 +0000 | [diff] [blame] | 96 | extern void VG_(am_show_nsegments) ( Int logLevel, const HChar* who ); |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 97 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 98 | /* VG_(am_get_segment_starts) is also part of this section, but its |
| 99 | prototype is tool-visible, hence not in this header file. */ |
| 100 | |
| 101 | /* Sanity check: check that Valgrind and the kernel agree on the |
| 102 | address space layout. Prints offending segments and call point if |
| 103 | a discrepancy is detected, but does not abort the system. Returned |
| 104 | Bool is False if a discrepancy was found. */ |
| 105 | |
| 106 | extern Bool VG_(am_do_sync_check) ( const HChar* fn, |
| 107 | const HChar* file, Int line ); |
| 108 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 109 | //-------------------------------------------------------------- |
| 110 | // Functions pertaining to the central query-notify mechanism |
| 111 | // used to handle mmap/munmap/mprotect resulting from client |
| 112 | // syscalls. |
| 113 | |
| 114 | /* Describes a request for VG_(am_get_advisory). */ |
| 115 | typedef |
| 116 | struct { |
| 117 | enum { MFixed, MHint, MAny } rkind; |
| 118 | Addr start; |
| 119 | Addr len; |
| 120 | } |
| 121 | MapRequest; |
| 122 | |
| 123 | /* Query aspacem to ask where a mapping should go. On success, the |
| 124 | advised placement is returned, and *ok is set to True. On failure, |
| 125 | zero is returned and *ok is set to False. Note that *ok must be |
| 126 | consulted by the caller to establish success or failure; that |
| 127 | cannot be established reliably from the returned value. If *ok is |
| 128 | set to False, it means aspacem has vetoed the mapping, and so the |
| 129 | caller should not proceed with it. */ |
| 130 | extern Addr VG_(am_get_advisory) |
florian | 3297124 | 2014-10-23 17:47:15 +0000 | [diff] [blame] | 131 | ( const MapRequest* req, Bool forClient, /*OUT*/Bool* ok ); |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 132 | |
| 133 | /* Convenience wrapper for VG_(am_get_advisory) for client floating or |
| 134 | fixed requests. If start is zero, a floating request is issued; if |
| 135 | nonzero, a fixed request at that address is issued. Same comments |
| 136 | about return values apply. */ |
| 137 | extern Addr VG_(am_get_advisory_client_simple) |
| 138 | ( Addr start, SizeT len, /*OUT*/Bool* ok ); |
| 139 | |
philippe | 15e301e | 2011-12-22 13:25:58 +0000 | [diff] [blame] | 140 | /* Returns True if [start, start + len - 1] is covered by a single |
| 141 | free segment, otherwise returns False. |
| 142 | This allows to check the following case: |
| 143 | VG_(am_get_advisory_client_simple) (first arg == 0, meaning |
| 144 | this-or-nothing) is too lenient, and may allow us to trash |
| 145 | the next segment along. So make very sure that the proposed |
| 146 | new area really is free. This is perhaps overly |
| 147 | conservative, but it fixes #129866. */ |
| 148 | extern Bool VG_(am_covered_by_single_free_segment) |
| 149 | ( Addr start, SizeT len); |
| 150 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 151 | /* Notifies aspacem that the client completed an mmap successfully. |
| 152 | The segment array is updated accordingly. If the returned Bool is |
| 153 | True, the caller should immediately discard translations from the |
| 154 | specified address range. */ |
| 155 | extern Bool VG_(am_notify_client_mmap) |
sewardj | 274461d | 2005-10-02 17:01:41 +0000 | [diff] [blame] | 156 | ( Addr a, SizeT len, UInt prot, UInt flags, Int fd, Off64T offset ); |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 157 | |
tom | 1340c35 | 2005-10-04 15:59:54 +0000 | [diff] [blame] | 158 | /* Notifies aspacem that the client completed a shmat successfully. |
| 159 | The segment array is updated accordingly. If the returned Bool is |
| 160 | True, the caller should immediately discard translations from the |
| 161 | specified address range. */ |
| 162 | extern Bool VG_(am_notify_client_shmat)( Addr a, SizeT len, UInt prot ); |
| 163 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 164 | /* Notifies aspacem that an mprotect was completed successfully. The |
| 165 | segment array is updated accordingly. Note, as with |
| 166 | VG_(am_notify_munmap), it is not the job of this function to reject |
| 167 | stupid mprotects, for example the client doing mprotect of |
| 168 | non-client areas. Such requests should be intercepted earlier, by |
| 169 | the syscall wrapper for mprotect. This function merely records |
| 170 | whatever it is told. If the returned Bool is True, the caller |
| 171 | should immediately discard translations from the specified address |
| 172 | range. */ |
| 173 | extern Bool VG_(am_notify_mprotect)( Addr start, SizeT len, UInt prot ); |
| 174 | |
| 175 | /* Notifies aspacem that an munmap completed successfully. The |
| 176 | segment array is updated accordingly. As with |
| 177 | VG_(am_notify_munmap), we merely record the given info, and don't |
| 178 | check it for sensibleness. If the returned Bool is True, the |
| 179 | caller should immediately discard translations from the specified |
| 180 | address range. */ |
| 181 | extern Bool VG_(am_notify_munmap)( Addr start, SizeT len ); |
| 182 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 183 | /* Hand a raw mmap to the kernel, without aspacem updating the segment |
| 184 | array. THIS FUNCTION IS DANGEROUS -- it will cause aspacem's view |
| 185 | of the address space to diverge from that of the kernel. DO NOT |
| 186 | USE IT UNLESS YOU UNDERSTAND the request-notify model used by |
| 187 | aspacem. In short, DO NOT USE THIS FUNCTION. */ |
| 188 | extern SysRes VG_(am_do_mmap_NO_NOTIFY) |
njn | 9506f0d | 2009-05-20 03:20:05 +0000 | [diff] [blame] | 189 | ( Addr start, SizeT length, UInt prot, UInt flags, Int fd, Off64T offset); |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 190 | |
| 191 | |
| 192 | //-------------------------------------------------------------- |
| 193 | // Dealing with mappings which do not arise directly from the |
| 194 | // simulation of the client. These are typically used for |
| 195 | // loading the client and building its stack/data segment, before |
| 196 | // execution begins. Also for V's own administrative use. |
| 197 | |
| 198 | /* --- --- --- map, unmap, protect --- --- --- */ |
| 199 | |
| 200 | /* Map a file at a fixed address for the client, and update the |
| 201 | segment array accordingly. */ |
| 202 | extern SysRes VG_(am_mmap_file_fixed_client) |
sewardj | 274461d | 2005-10-02 17:01:41 +0000 | [diff] [blame] | 203 | ( Addr start, SizeT length, UInt prot, Int fd, Off64T offset ); |
njn | f76d27a | 2009-05-28 01:53:07 +0000 | [diff] [blame] | 204 | extern SysRes VG_(am_mmap_named_file_fixed_client) |
| 205 | ( Addr start, SizeT length, UInt prot, Int fd, Off64T offset, const HChar *name ); |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 206 | |
| 207 | /* Map anonymously at a fixed address for the client, and update |
| 208 | the segment array accordingly. */ |
| 209 | extern SysRes VG_(am_mmap_anon_fixed_client) |
| 210 | ( Addr start, SizeT length, UInt prot ); |
| 211 | |
sewardj | fa2a246 | 2006-10-17 01:30:07 +0000 | [diff] [blame] | 212 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 213 | /* Map anonymously at an unconstrained address for the client, and |
| 214 | update the segment array accordingly. */ |
| 215 | extern SysRes VG_(am_mmap_anon_float_client) ( SizeT length, Int prot ); |
| 216 | |
| 217 | /* Map anonymously at an unconstrained address for V, and update the |
| 218 | segment array accordingly. This is fundamentally how V allocates |
| 219 | itself more address space when needed. */ |
| 220 | extern SysRes VG_(am_mmap_anon_float_valgrind)( SizeT cszB ); |
| 221 | |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 222 | /* Map privately a file at an unconstrained address for V, and update the |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 223 | segment array accordingly. This is used by V for transiently |
| 224 | mapping in object files to read their debug info. */ |
| 225 | extern SysRes VG_(am_mmap_file_float_valgrind) |
sewardj | 274461d | 2005-10-02 17:01:41 +0000 | [diff] [blame] | 226 | ( SizeT length, UInt prot, Int fd, Off64T offset ); |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 227 | |
sewardj | 3b29048 | 2011-05-06 21:02:55 +0000 | [diff] [blame] | 228 | /* Map shared a file at an unconstrained address for V, and update the |
| 229 | segment array accordingly. This is used by V for communicating |
| 230 | with vgdb. */ |
| 231 | extern SysRes VG_(am_shared_mmap_file_float_valgrind) |
| 232 | ( SizeT length, UInt prot, Int fd, Off64T offset ); |
| 233 | |
florian | 2fa66ce | 2015-03-07 23:01:14 +0000 | [diff] [blame^] | 234 | /* Convenience wrapper around VG_(am_mmap_anon_float_client) which also |
| 235 | marks the segment as containing the client heap. */ |
| 236 | extern SysRes VG_(am_mmap_client_heap) ( SizeT length, Int prot ); |
| 237 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 238 | /* Unmap the given address range and update the segment array |
| 239 | accordingly. This fails if the range isn't valid for the client. |
| 240 | If *need_discard is True after a successful return, the caller |
| 241 | should immediately discard translations from the specified address |
| 242 | range. */ |
| 243 | extern SysRes VG_(am_munmap_client)( /*OUT*/Bool* need_discard, |
| 244 | Addr start, SizeT length ); |
| 245 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 246 | /* Let (start,len) denote an area within a single Valgrind-owned |
| 247 | segment (anon or file). Change the ownership of [start, start+len) |
| 248 | to the client instead. Fails if (start,len) does not denote a |
| 249 | suitable segment. */ |
| 250 | extern Bool VG_(am_change_ownership_v_to_c)( Addr start, SizeT len ); |
| 251 | |
florian | 2fa66ce | 2015-03-07 23:01:14 +0000 | [diff] [blame^] | 252 | /* Set the 'hasT' bit on the segment containing ADDR indicating that |
| 253 | translations have or may have been taken from this segment. ADDR is |
| 254 | expected to belong to a client segment. */ |
| 255 | extern void VG_(am_set_segment_hasT)( Addr addr ); |
sewardj | fa2a246 | 2006-10-17 01:30:07 +0000 | [diff] [blame] | 256 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 257 | /* --- --- --- reservations --- --- --- */ |
| 258 | |
| 259 | /* Create a reservation from START .. START+LENGTH-1, with the given |
| 260 | ShrinkMode. When checking whether the reservation can be created, |
| 261 | also ensure that at least abs(EXTRA) extra free bytes will remain |
| 262 | above (> 0) or below (< 0) the reservation. |
| 263 | |
| 264 | The reservation will only be created if it, plus the extra-zone, |
| 265 | falls entirely within a single free segment. The returned Bool |
| 266 | indicates whether the creation succeeded. */ |
| 267 | extern Bool VG_(am_create_reservation) |
| 268 | ( Addr start, SizeT length, ShrinkMode smode, SSizeT extra ); |
| 269 | |
florian | 888b815 | 2015-02-26 16:07:12 +0000 | [diff] [blame] | 270 | /* ADDR is the start address of an anonymous client mapping. This fn extends |
| 271 | the mapping by DELTA bytes, taking the space from a reservation section |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 272 | which must be adjacent. If DELTA is positive, the segment is |
| 273 | extended forwards in the address space, and the reservation must be |
| 274 | the next one along. If DELTA is negative, the segment is extended |
| 275 | backwards in the address space and the reservation must be the |
sewardj | 6684d2a | 2005-09-28 01:46:31 +0000 | [diff] [blame] | 276 | previous one. DELTA must be page aligned. abs(DELTA) must not |
| 277 | exceed the size of the reservation segment minus one page, that is, |
| 278 | the reservation segment after the operation must be at least one |
florian | 888b815 | 2015-02-26 16:07:12 +0000 | [diff] [blame] | 279 | page long. The function returns a pointer to the resized segment. */ |
| 280 | extern const NSegment *VG_(am_extend_into_adjacent_reservation_client) |
florian | 15fa8a2 | 2015-03-03 14:56:17 +0000 | [diff] [blame] | 281 | ( Addr addr, SSizeT delta, /*OUT*/Bool *overflow ); |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 282 | |
| 283 | /* --- --- --- resizing/move a mapping --- --- --- */ |
| 284 | |
florian | dd7318b | 2015-02-25 10:06:06 +0000 | [diff] [blame] | 285 | /* This function grows a client mapping in place into an adjacent free segment. |
| 286 | ADDR is the client mapping's start address and DELTA, which must be page |
| 287 | aligned, is the growth amount. The function returns a pointer to the |
| 288 | resized segment. The function is used in support of mremap. */ |
| 289 | extern const NSegment *VG_(am_extend_map_client)( Addr addr, SizeT delta ); |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 290 | |
| 291 | /* Remap the old address range to the new address range. Fails if any |
| 292 | parameter is not page aligned, if the either size is zero, if any |
| 293 | wraparound is implied, if the old address range does not fall |
| 294 | entirely within a single segment, if the new address range overlaps |
| 295 | with the old one, or if the old address range is not a valid client |
| 296 | mapping. If *need_discard is True after a successful return, the |
| 297 | caller should immediately discard translations from both specified |
| 298 | address ranges. */ |
| 299 | extern Bool VG_(am_relocate_nooverlap_client)( /*OUT*/Bool* need_discard, |
| 300 | Addr old_addr, SizeT old_len, |
| 301 | Addr new_addr, SizeT new_len ); |
| 302 | |
| 303 | //-------------------------------------------------------------- |
| 304 | // Valgrind (non-client) thread stacks. V itself runs on such |
| 305 | // stacks. The address space manager provides and suitably |
| 306 | // protects such stacks. |
| 307 | |
carll | cae0cc2 | 2014-08-07 23:17:29 +0000 | [diff] [blame] | 308 | #if defined(VGP_ppc32_linux) \ |
| 309 | || defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux) \ |
sewardj | f0c1250 | 2014-01-12 12:54:00 +0000 | [diff] [blame] | 310 | || defined(VGP_mips32_linux) || defined(VGP_mips64_linux) \ |
| 311 | || defined(VGP_arm64_linux) |
sewardj | e66f2e0 | 2006-12-30 17:45:08 +0000 | [diff] [blame] | 312 | # define VG_STACK_GUARD_SZB 65536 // 1 or 16 pages |
sewardj | 9e0a6b8 | 2010-07-21 09:49:27 +0000 | [diff] [blame] | 313 | # define VG_STACK_ACTIVE_SZB (4096 * 256) // 1Mb |
sewardj | e66f2e0 | 2006-12-30 17:45:08 +0000 | [diff] [blame] | 314 | #else |
| 315 | # define VG_STACK_GUARD_SZB 8192 // 2 pages |
sewardj | 9e0a6b8 | 2010-07-21 09:49:27 +0000 | [diff] [blame] | 316 | # define VG_STACK_ACTIVE_SZB (4096 * 256) // 1Mb |
sewardj | e66f2e0 | 2006-12-30 17:45:08 +0000 | [diff] [blame] | 317 | #endif |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 318 | |
| 319 | typedef |
| 320 | struct { |
| 321 | HChar bytes[VG_STACK_GUARD_SZB |
| 322 | + VG_STACK_ACTIVE_SZB |
| 323 | + VG_STACK_GUARD_SZB]; |
| 324 | } |
| 325 | VgStack; |
| 326 | |
| 327 | |
philippe | 17e76ec | 2014-04-20 19:50:13 +0000 | [diff] [blame] | 328 | /* Allocate and initialise a VgStack (anonymous valgrind space). |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 329 | Protect the stack active area and the guard areas appropriately. |
| 330 | Returns NULL on failure, else the address of the bottom of the |
| 331 | stack. On success, also sets *initial_sp to what the stack pointer |
| 332 | should be set to. */ |
| 333 | |
| 334 | extern VgStack* VG_(am_alloc_VgStack)( /*OUT*/Addr* initial_sp ); |
| 335 | |
sewardj | 46dbd3f | 2010-09-08 08:30:31 +0000 | [diff] [blame] | 336 | /* Figure out how many bytes of the stack's active area have not been |
| 337 | used. Used for estimating if we are close to overflowing it. If |
| 338 | the free area is larger than 'limit', just return 'limit'. */ |
florian | 3297124 | 2014-10-23 17:47:15 +0000 | [diff] [blame] | 339 | extern SizeT VG_(am_get_VgStack_unused_szB)( const VgStack* stack, |
| 340 | SizeT limit ); |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 341 | |
njn | f76d27a | 2009-05-28 01:53:07 +0000 | [diff] [blame] | 342 | // DDD: this is ugly |
| 343 | #if defined(VGO_darwin) |
| 344 | typedef |
| 345 | struct { |
| 346 | Bool is_added; // Added or removed seg? |
| 347 | Addr start; |
| 348 | SizeT end; |
| 349 | UInt prot; // Not used for removed segs. |
| 350 | Off64T offset; // Not used for removed segs. |
| 351 | } |
| 352 | ChangedSeg; |
| 353 | |
njn | fd1b461 | 2009-06-24 08:32:42 +0000 | [diff] [blame] | 354 | extern Bool VG_(get_changed_segments)( |
njn | f76d27a | 2009-05-28 01:53:07 +0000 | [diff] [blame] | 355 | const HChar* when, const HChar* where, /*OUT*/ChangedSeg* css, |
| 356 | Int css_size, /*OUT*/Int* css_used); |
| 357 | #endif |
njn | e3f0635 | 2005-06-01 03:48:33 +0000 | [diff] [blame] | 358 | |
sewardj | 55f9d1a | 2005-04-25 11:11:44 +0000 | [diff] [blame] | 359 | #endif // __PUB_CORE_ASPACEMGR_H |
| 360 | |
| 361 | /*--------------------------------------------------------------------*/ |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame] | 362 | /*--- end ---*/ |
sewardj | 55f9d1a | 2005-04-25 11:11:44 +0000 | [diff] [blame] | 363 | /*--------------------------------------------------------------------*/ |