blob: 850c63c98f42d1e10f6be83203c03799fc8268d0 [file] [log] [blame]
njn5c004e42002-11-18 11:04:50 +00001
2/*--------------------------------------------------------------------*/
njn43c799e2003-04-08 00:08:52 +00003/*--- Declarations shared between MemCheck and AddrCheck. ---*/
4/*--- mac_shared.h ---*/
njn5c004e42002-11-18 11:04:50 +00005/*--------------------------------------------------------------------*/
6
7/*
nethercote137bc552003-11-14 17:47:54 +00008 This file is part of MemCheck, a heavyweight Valgrind tool for
9 detecting memory errors, and AddrCheck, a lightweight Valgrind tool
njn5c004e42002-11-18 11:04:50 +000010 for detecting memory errors.
11
nethercotebb1c9912004-01-04 16:43:23 +000012 Copyright (C) 2000-2004 Julian Seward
njn5c004e42002-11-18 11:04:50 +000013 jseward@acm.org
14
15 This program is free software; you can redistribute it and/or
16 modify it under the terms of the GNU General Public License as
17 published by the Free Software Foundation; either version 2 of the
18 License, or (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 02111-1307, USA.
29
30 The GNU General Public License is contained in the file COPYING.
31*/
32
njn43c799e2003-04-08 00:08:52 +000033/* Note: This header contains the declarations shared between
34 Addrcheck and Memcheck, and is #included by both. */
35
36#ifndef __MAC_SHARED_H
37#define __MAC_SHARED_H
njn5c004e42002-11-18 11:04:50 +000038
nethercote46063202004-09-02 08:51:43 +000039#include "tool.h"
njn43c799e2003-04-08 00:08:52 +000040
41#define MAC_(str) VGAPPEND(vgMAC_,str)
njn5c004e42002-11-18 11:04:50 +000042
njn9b007f62003-04-07 14:40:25 +000043/*------------------------------------------------------------*/
44/*--- Errors and suppressions ---*/
45/*------------------------------------------------------------*/
46
njn5c004e42002-11-18 11:04:50 +000047/* The classification of a faulting address. */
48typedef
njn43c799e2003-04-08 00:08:52 +000049 enum {
nethercote8b76fe52004-11-08 19:20:09 +000050 Undescribed, // as-yet unclassified
njn43c799e2003-04-08 00:08:52 +000051 Stack,
nethercote8b76fe52004-11-08 19:20:09 +000052 Unknown, // classification yielded nothing useful
njn43c799e2003-04-08 00:08:52 +000053 Freed, Mallocd,
nethercote8b76fe52004-11-08 19:20:09 +000054 UserG, // in a user-defined block
55 Mempool, // in a mempool
56 Register, // in a register; for Param errors only
njn5c004e42002-11-18 11:04:50 +000057 }
58 AddrKind;
59
60/* Records info about a faulting address. */
61typedef
nethercote05675c82004-08-04 10:37:49 +000062 struct { // Used by:
63 AddrKind akind; // ALL
nethercote928a5f72004-11-03 18:10:37 +000064 SizeT blksize; // Freed, Mallocd
nethercote8b76fe52004-11-08 19:20:09 +000065 OffT rwoffset; // Freed, Mallocd
nethercote05675c82004-08-04 10:37:49 +000066 ExeContext* lastchange; // Freed, Mallocd
67 ThreadId stack_tid; // Stack
68 Bool maybe_gcc; // True if just below %esp -- could be a gcc bug.
njn5c004e42002-11-18 11:04:50 +000069 }
70 AddrInfo;
71
72typedef
73 enum {
nethercote05675c82004-08-04 10:37:49 +000074 ParamSupp, // Bad syscall params
75 CoreMemSupp, // Memory errors in core (pthread ops, signal handling)
76
77 // Use of invalid values of given size (MemCheck only)
njnc0616662003-06-12 09:58:41 +000078 Value0Supp, Value1Supp, Value2Supp, Value4Supp, Value8Supp, Value16Supp,
nethercote05675c82004-08-04 10:37:49 +000079
80 // Invalid read/write attempt at given size
njnc0616662003-06-12 09:58:41 +000081 Addr1Supp, Addr2Supp, Addr4Supp, Addr8Supp, Addr16Supp,
nethercote05675c82004-08-04 10:37:49 +000082
83 FreeSupp, // Invalid or mismatching free
84 OverlapSupp, // Overlapping blocks in memcpy(), strcpy(), etc
85 LeakSupp, // Something to be suppressed in a leak check.
86 MempoolSupp, // Memory pool suppression.
njn5c004e42002-11-18 11:04:50 +000087 }
njn43c799e2003-04-08 00:08:52 +000088 MAC_SuppKind;
njn5c004e42002-11-18 11:04:50 +000089
90/* What kind of error it is. */
91typedef
92 enum { ValueErr, /* Memcheck only */
93 CoreMemErr,
94 AddrErr,
95 ParamErr, UserErr, /* behaves like an anonymous ParamErr */
njn43c799e2003-04-08 00:08:52 +000096 FreeErr, FreeMismatchErr,
njn7201b2a2003-08-19 12:16:05 +000097 OverlapErr,
rjwalshbc0bb832004-06-19 18:12:36 +000098 LeakErr,
99 IllegalMempoolErr,
njn5c004e42002-11-18 11:04:50 +0000100 }
njn43c799e2003-04-08 00:08:52 +0000101 MAC_ErrorKind;
njn5c004e42002-11-18 11:04:50 +0000102
103/* What kind of memory access is involved in the error? */
104typedef
105 enum { ReadAxs, WriteAxs, ExecAxs }
106 AxsKind;
107
108/* Extra context for memory errors */
109typedef
nethercote05675c82004-08-04 10:37:49 +0000110 struct { // Used by:
111 AxsKind axskind; // AddrErr
112 Int size; // AddrErr, ValueErr
113 AddrInfo addrinfo; // {Addr,Free,FreeMismatch,Param,User}Err
nethercote8b76fe52004-11-08 19:20:09 +0000114 Bool isUnaddr; // {CoreMem,Param,User}Err
njn5c004e42002-11-18 11:04:50 +0000115 }
njn43c799e2003-04-08 00:08:52 +0000116 MAC_Error;
njn5c004e42002-11-18 11:04:50 +0000117
njnb6cae9f2003-09-04 20:50:47 +0000118/* Extra info for overlap errors */
119typedef
120 struct {
121 Addr src;
122 Addr dst;
123 Int len; // -1 if unused
124 }
125 OverlapExtra;
126
njn3e884182003-04-15 13:03:23 +0000127/* For malloc()/new/new[] vs. free()/delete/delete[] mismatch checking. */
128typedef
129 enum {
130 MAC_AllocMalloc = 0,
131 MAC_AllocNew = 1,
njn10785452003-05-20 16:38:24 +0000132 MAC_AllocNewVec = 2,
133 MAC_AllocCustom = 3
njn3e884182003-04-15 13:03:23 +0000134 }
135 MAC_AllocKind;
136
137/* Nb: first two fields must match core's VgHashNode. */
138typedef
139 struct _MAC_Chunk {
140 struct _MAC_Chunk* next;
nethercote05675c82004-08-04 10:37:49 +0000141 Addr data; // ptr to actual block
142 UInt size : 30; // size requested
143 MAC_AllocKind allockind : 2; // which wrapper did the allocation
144 ExeContext* where; // where it was allocated
njn3e884182003-04-15 13:03:23 +0000145 }
146 MAC_Chunk;
147
rjwalshbc0bb832004-06-19 18:12:36 +0000148/* Memory pool. Nb: first two fields must match core's VgHashNode. */
149typedef
150 struct _MAC_Mempool {
151 struct _MAC_Mempool* next;
nethercote05675c82004-08-04 10:37:49 +0000152 Addr pool; // pool identifier
153 UInt rzB; // pool red-zone size
154 Bool is_zeroed; // allocations from this pool are zeroed
155 VgHashTable chunks; // chunks associated with this pool
rjwalshbc0bb832004-06-19 18:12:36 +0000156 }
157 MAC_Mempool;
158
159
njn9b007f62003-04-07 14:40:25 +0000160/*------------------------------------------------------------*/
nethercote7cc9c232004-01-21 15:08:04 +0000161/*--- Profiling of tools and memory events ---*/
njn9b007f62003-04-07 14:40:25 +0000162/*------------------------------------------------------------*/
163
164typedef
165 enum {
166 VgpCheckMem = VgpFini+1,
167 VgpSetMem,
168 VgpESPAdj
169 }
nethercote7cc9c232004-01-21 15:08:04 +0000170 VgpToolCC;
njn9b007f62003-04-07 14:40:25 +0000171
172/* Define to collect detailed performance info. */
njn43c799e2003-04-08 00:08:52 +0000173/* #define MAC_PROFILE_MEMORY */
njn5c004e42002-11-18 11:04:50 +0000174
njn43c799e2003-04-08 00:08:52 +0000175#ifdef MAC_PROFILE_MEMORY
njn9b007f62003-04-07 14:40:25 +0000176# define N_PROF_EVENTS 150
njn5c004e42002-11-18 11:04:50 +0000177
njn43c799e2003-04-08 00:08:52 +0000178extern UInt MAC_(event_ctr)[N_PROF_EVENTS];
njn9b007f62003-04-07 14:40:25 +0000179
njn43c799e2003-04-08 00:08:52 +0000180# define PROF_EVENT(ev) \
njnca82cc02004-11-22 17:18:48 +0000181 do { tl_assert((ev) >= 0 && (ev) < N_PROF_EVENTS); \
njn43c799e2003-04-08 00:08:52 +0000182 MAC_(event_ctr)[ev]++; \
njn5c004e42002-11-18 11:04:50 +0000183 } while (False);
184
185#else
186
njn9b007f62003-04-07 14:40:25 +0000187# define PROF_EVENT(ev) /* */
njn5c004e42002-11-18 11:04:50 +0000188
njn43c799e2003-04-08 00:08:52 +0000189#endif /* MAC_PROFILE_MEMORY */
njn5c004e42002-11-18 11:04:50 +0000190
njn9b007f62003-04-07 14:40:25 +0000191/*------------------------------------------------------------*/
192/*--- V and A bits ---*/
193/*------------------------------------------------------------*/
194
njn5c004e42002-11-18 11:04:50 +0000195#define IS_DISTINGUISHED_SM(smap) \
196 ((smap) == &distinguished_secondary_map)
197
njn43c799e2003-04-08 00:08:52 +0000198#define ENSURE_MAPPABLE(addr,caller) \
199 do { \
njn5c004e42002-11-18 11:04:50 +0000200 if (IS_DISTINGUISHED_SM(primary_map[(addr) >> 16])) { \
201 primary_map[(addr) >> 16] = alloc_secondary_map(caller); \
njn43c799e2003-04-08 00:08:52 +0000202 /* VG_(printf)("new 2map because of %p\n", addr); */ \
203 } \
njn5c004e42002-11-18 11:04:50 +0000204 } while(0)
205
206#define BITARR_SET(aaa_p,iii_p) \
207 do { \
208 UInt iii = (UInt)iii_p; \
209 UChar* aaa = (UChar*)aaa_p; \
210 aaa[iii >> 3] |= (1 << (iii & 7)); \
211 } while (0)
212
213#define BITARR_CLEAR(aaa_p,iii_p) \
214 do { \
215 UInt iii = (UInt)iii_p; \
216 UChar* aaa = (UChar*)aaa_p; \
217 aaa[iii >> 3] &= ~(1 << (iii & 7)); \
218 } while (0)
219
220#define BITARR_TEST(aaa_p,iii_p) \
221 (0 != (((UChar*)aaa_p)[ ((UInt)iii_p) >> 3 ] \
222 & (1 << (((UInt)iii_p) & 7)))) \
223
224
225#define VGM_BIT_VALID 0
226#define VGM_BIT_INVALID 1
227
228#define VGM_NIBBLE_VALID 0
229#define VGM_NIBBLE_INVALID 0xF
230
231#define VGM_BYTE_VALID 0
232#define VGM_BYTE_INVALID 0xFF
233
234#define VGM_WORD_VALID 0
235#define VGM_WORD_INVALID 0xFFFFFFFF
236
237#define VGM_EFLAGS_VALID 0xFFFFFFFE
238#define VGM_EFLAGS_INVALID 0xFFFFFFFF /* not used */
239
240/*------------------------------------------------------------*/
241/*--- Command line options + defaults ---*/
242/*------------------------------------------------------------*/
243
njn43c799e2003-04-08 00:08:52 +0000244/* Memcheck defines a couple more. */
njn5c004e42002-11-18 11:04:50 +0000245
246/* Allow loads from partially-valid addresses? default: YES */
njn43c799e2003-04-08 00:08:52 +0000247extern Bool MAC_(clo_partial_loads_ok);
njn5c004e42002-11-18 11:04:50 +0000248
249/* Max volume of the freed blocks queue. */
njn43c799e2003-04-08 00:08:52 +0000250extern Int MAC_(clo_freelist_vol);
njn5c004e42002-11-18 11:04:50 +0000251
252/* Do leak check at exit? default: NO */
njn43c799e2003-04-08 00:08:52 +0000253extern Bool MAC_(clo_leak_check);
njn5c004e42002-11-18 11:04:50 +0000254
255/* How closely should we compare ExeContexts in leak records? default: 2 */
njn43c799e2003-04-08 00:08:52 +0000256extern VgRes MAC_(clo_leak_resolution);
njn5c004e42002-11-18 11:04:50 +0000257
258/* In leak check, show reachable-but-not-freed blocks? default: NO */
njn43c799e2003-04-08 00:08:52 +0000259extern Bool MAC_(clo_show_reachable);
njn5c004e42002-11-18 11:04:50 +0000260
261/* Assume accesses immediately below %esp are due to gcc-2.96 bugs.
262 * default: NO*/
njn43c799e2003-04-08 00:08:52 +0000263extern Bool MAC_(clo_workaround_gcc296_bugs);
njn5c004e42002-11-18 11:04:50 +0000264
njn3e884182003-04-15 13:03:23 +0000265extern Bool MAC_(process_common_cmd_line_option) ( Char* arg );
266extern void MAC_(print_common_usage) ( void );
267extern void MAC_(print_common_debug_usage) ( void );
268
269
270/*------------------------------------------------------------*/
271/*--- Variables ---*/
272/*------------------------------------------------------------*/
273
274/* For tracking malloc'd blocks */
275extern VgHashTable MAC_(malloc_list);
276
rjwalshbc0bb832004-06-19 18:12:36 +0000277/* For tracking memory pools. */
278extern VgHashTable MAC_(mempool_list);
279
nethercote7cc9c232004-01-21 15:08:04 +0000280/* Function pointers for the two tools to track interesting events. */
nethercote451eae92004-11-02 13:06:32 +0000281extern void (*MAC_(new_mem_heap)) ( Addr a, SizeT len, Bool is_inited );
282extern void (*MAC_(ban_mem_heap)) ( Addr a, SizeT len );
283extern void (*MAC_(die_mem_heap)) ( Addr a, SizeT len );
284extern void (*MAC_(copy_mem_heap))( Addr from, Addr to, SizeT len );
njn3e884182003-04-15 13:03:23 +0000285
sewardjecf8e102003-07-12 12:11:39 +0000286/* Function pointers for internal sanity checking. */
nethercote451eae92004-11-02 13:06:32 +0000287extern Bool (*MAC_(check_noaccess))( Addr a, SizeT len, Addr* bad_addr );
sewardjecf8e102003-07-12 12:11:39 +0000288
njn3e884182003-04-15 13:03:23 +0000289/* Used in describe_addr() */
290extern Bool (*MAC_(describe_addr_supp)) ( Addr a, AddrInfo* ai );
njn5c004e42002-11-18 11:04:50 +0000291
njn47363ab2003-04-21 13:24:40 +0000292/* For VALGRIND_COUNT_LEAKS client request */
njne8b5c052003-07-22 22:03:58 +0000293extern Int MAC_(bytes_leaked);
294extern Int MAC_(bytes_dubious);
295extern Int MAC_(bytes_reachable);
296extern Int MAC_(bytes_suppressed);
sewardj99aac972002-12-26 01:53:45 +0000297
njn5c004e42002-11-18 11:04:50 +0000298/*------------------------------------------------------------*/
299/*--- Functions ---*/
300/*------------------------------------------------------------*/
301
njn43c799e2003-04-08 00:08:52 +0000302extern void MAC_(pp_AddrInfo) ( Addr a, AddrInfo* ai );
njn5c004e42002-11-18 11:04:50 +0000303
njn43c799e2003-04-08 00:08:52 +0000304extern void MAC_(clear_MAC_Error) ( MAC_Error* err_extra );
njn5c004e42002-11-18 11:04:50 +0000305
njn43c799e2003-04-08 00:08:52 +0000306extern Bool MAC_(shared_recognised_suppression) ( Char* name, Supp* su );
njn5c004e42002-11-18 11:04:50 +0000307
nethercote7ac7f7b2004-11-02 12:36:02 +0000308extern void* MAC_(new_block) ( Addr p, SizeT size, SizeT align, UInt rzB,
nethercote57e36b32004-07-10 14:56:28 +0000309 Bool is_zeroed, MAC_AllocKind kind,
310 VgHashTable table);
njn72718642003-07-24 08:45:32 +0000311extern void MAC_(handle_free) ( Addr p, UInt rzB, MAC_AllocKind kind );
njn10785452003-05-20 16:38:24 +0000312
rjwalshbc0bb832004-06-19 18:12:36 +0000313extern void MAC_(create_mempool)(Addr pool, UInt rzB, Bool is_zeroed);
314extern void MAC_(destroy_mempool)(Addr pool);
nethercote7ac7f7b2004-11-02 12:36:02 +0000315extern void MAC_(mempool_alloc)(Addr pool, Addr addr, SizeT size);
rjwalshbc0bb832004-06-19 18:12:36 +0000316extern void MAC_(mempool_free)(Addr pool, Addr addr);
317
njn72718642003-07-24 08:45:32 +0000318extern void MAC_(record_address_error) ( ThreadId tid, Addr a,
sewardjaf48a602003-07-06 00:54:47 +0000319 Int size, Bool isWrite );
nethercote8b76fe52004-11-08 19:20:09 +0000320extern void MAC_(record_core_mem_error) ( ThreadId tid, Bool isUnaddr,
njn43c799e2003-04-08 00:08:52 +0000321 Char* s );
nethercote8b76fe52004-11-08 19:20:09 +0000322extern void MAC_(record_param_error) ( ThreadId tid, Addr a, Bool isReg,
323 Bool isUnaddr, Char* msg );
njn72718642003-07-24 08:45:32 +0000324extern void MAC_(record_jump_error) ( ThreadId tid, Addr a );
325extern void MAC_(record_free_error) ( ThreadId tid, Addr a );
326extern void MAC_(record_freemismatch_error)( ThreadId tid, Addr a );
njnb6cae9f2003-09-04 20:50:47 +0000327extern void MAC_(record_overlap_error) ( Char* function, OverlapExtra* oe );
rjwalshbc0bb832004-06-19 18:12:36 +0000328extern void MAC_(record_illegal_mempool_error) ( ThreadId tid, Addr pool );
njn5c004e42002-11-18 11:04:50 +0000329
njn43c799e2003-04-08 00:08:52 +0000330extern void MAC_(pp_shared_SkinError) ( Error* err);
331
thughes4ad52d02004-06-27 17:37:21 +0000332extern MAC_Chunk* MAC_(first_matching_freed_MAC_Chunk)( Bool (*p)(MAC_Chunk*, void*), void* d );
njn43c799e2003-04-08 00:08:52 +0000333
njn3e884182003-04-15 13:03:23 +0000334extern void MAC_(common_pre_clo_init) ( void );
335extern void MAC_(common_fini) ( void (*leak_check)(void) );
336
njn72718642003-07-24 08:45:32 +0000337extern Bool MAC_(handle_common_client_requests) ( ThreadId tid,
nethercoted1b64b22004-11-04 18:22:28 +0000338 UWord* arg_block, UWord* ret );
njn47363ab2003-04-21 13:24:40 +0000339
njn3e884182003-04-15 13:03:23 +0000340extern void MAC_(print_malloc_stats) ( void );
njn43c799e2003-04-08 00:08:52 +0000341
342/* For leak checking */
343extern void MAC_(pp_LeakError)(void* vl, UInt n_this_record,
344 UInt n_total_records);
345
346extern void MAC_(do_detect_memory_leaks) (
347 Bool is_valid_64k_chunk ( UInt ),
348 Bool is_valid_address ( Addr )
349 );
350
nethercoteeec46302004-08-23 15:06:23 +0000351extern REGPARM(1) void MAC_(new_mem_stack_4) ( Addr old_ESP );
352extern REGPARM(1) void MAC_(die_mem_stack_4) ( Addr old_ESP );
353extern REGPARM(1) void MAC_(new_mem_stack_8) ( Addr old_ESP );
354extern REGPARM(1) void MAC_(die_mem_stack_8) ( Addr old_ESP );
355extern REGPARM(1) void MAC_(new_mem_stack_12) ( Addr old_ESP );
356extern REGPARM(1) void MAC_(die_mem_stack_12) ( Addr old_ESP );
357extern REGPARM(1) void MAC_(new_mem_stack_16) ( Addr old_ESP );
358extern REGPARM(1) void MAC_(die_mem_stack_16) ( Addr old_ESP );
359extern REGPARM(1) void MAC_(new_mem_stack_32) ( Addr old_ESP );
360extern REGPARM(1) void MAC_(die_mem_stack_32) ( Addr old_ESP );
nethercote451eae92004-11-02 13:06:32 +0000361extern void MAC_(die_mem_stack) ( Addr a, SizeT len);
362extern void MAC_(new_mem_stack) ( Addr a, SizeT len);
njn9b007f62003-04-07 14:40:25 +0000363
364
365/*------------------------------------------------------------*/
366/*--- Stack pointer adjustment ---*/
367/*------------------------------------------------------------*/
368
369/* Some noble preprocessor abuse, to enable Memcheck and Addrcheck to
njn3e884182003-04-15 13:03:23 +0000370 share this code, but call different functions.
njn9b007f62003-04-07 14:40:25 +0000371
372 Note that this code is executed very frequently and must be highly
373 optimised, which is why I resort to the preprocessor to achieve the
374 factoring, rather than eg. using function pointers.
375*/
376
377#define ESP_UPDATE_HANDLERS(ALIGNED4_NEW, ALIGNED4_DIE, \
378 ALIGNED8_NEW, ALIGNED8_DIE, \
379 UNALIGNED_NEW, UNALIGNED_DIE) \
380 \
nethercoteeec46302004-08-23 15:06:23 +0000381void REGPARM(1) MAC_(new_mem_stack_4)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000382{ \
383 PROF_EVENT(110); \
384 if (IS_ALIGNED4_ADDR(new_ESP)) { \
385 ALIGNED4_NEW ( new_ESP ); \
386 } else { \
387 UNALIGNED_NEW ( new_ESP, 4 ); \
388 } \
389} \
390 \
nethercoteeec46302004-08-23 15:06:23 +0000391void REGPARM(1) MAC_(die_mem_stack_4)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000392{ \
393 PROF_EVENT(120); \
394 if (IS_ALIGNED4_ADDR(new_ESP)) { \
395 ALIGNED4_DIE ( new_ESP-4 ); \
396 } else { \
397 UNALIGNED_DIE ( new_ESP-4, 4 ); \
398 } \
399} \
400 \
nethercoteeec46302004-08-23 15:06:23 +0000401void REGPARM(1) MAC_(new_mem_stack_8)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000402{ \
403 PROF_EVENT(111); \
404 if (IS_ALIGNED8_ADDR(new_ESP)) { \
405 ALIGNED8_NEW ( new_ESP ); \
406 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
407 ALIGNED4_NEW ( new_ESP ); \
408 ALIGNED4_NEW ( new_ESP+4 ); \
409 } else { \
410 UNALIGNED_NEW ( new_ESP, 8 ); \
411 } \
412} \
413 \
nethercoteeec46302004-08-23 15:06:23 +0000414void REGPARM(1) MAC_(die_mem_stack_8)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000415{ \
416 PROF_EVENT(121); \
417 if (IS_ALIGNED8_ADDR(new_ESP)) { \
418 ALIGNED8_DIE ( new_ESP-8 ); \
419 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
420 ALIGNED4_DIE ( new_ESP-8 ); \
421 ALIGNED4_DIE ( new_ESP-4 ); \
422 } else { \
423 UNALIGNED_DIE ( new_ESP-8, 8 ); \
424 } \
425} \
426 \
nethercoteeec46302004-08-23 15:06:23 +0000427void REGPARM(1) MAC_(new_mem_stack_12)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000428{ \
429 PROF_EVENT(112); \
430 if (IS_ALIGNED8_ADDR(new_ESP)) { \
431 ALIGNED8_NEW ( new_ESP ); \
432 ALIGNED4_NEW ( new_ESP+8 ); \
433 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
434 ALIGNED4_NEW ( new_ESP ); \
435 ALIGNED8_NEW ( new_ESP+4 ); \
436 } else { \
437 UNALIGNED_NEW ( new_ESP, 12 ); \
438 } \
439} \
440 \
nethercoteeec46302004-08-23 15:06:23 +0000441void REGPARM(1) MAC_(die_mem_stack_12)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000442{ \
443 PROF_EVENT(122); \
444 /* Note the -12 in the test */ \
445 if (IS_ALIGNED8_ADDR(new_ESP-12)) { \
446 ALIGNED8_DIE ( new_ESP-12 ); \
447 ALIGNED4_DIE ( new_ESP-4 ); \
448 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
449 ALIGNED4_DIE ( new_ESP-12 ); \
450 ALIGNED8_DIE ( new_ESP-8 ); \
451 } else { \
452 UNALIGNED_DIE ( new_ESP-12, 12 ); \
453 } \
454} \
455 \
nethercoteeec46302004-08-23 15:06:23 +0000456void REGPARM(1) MAC_(new_mem_stack_16)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000457{ \
458 PROF_EVENT(113); \
459 if (IS_ALIGNED8_ADDR(new_ESP)) { \
460 ALIGNED8_NEW ( new_ESP ); \
461 ALIGNED8_NEW ( new_ESP+8 ); \
462 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
463 ALIGNED4_NEW ( new_ESP ); \
464 ALIGNED8_NEW ( new_ESP+4 ); \
465 ALIGNED4_NEW ( new_ESP+12 ); \
466 } else { \
467 UNALIGNED_NEW ( new_ESP, 16 ); \
468 } \
469} \
470 \
nethercoteeec46302004-08-23 15:06:23 +0000471void REGPARM(1) MAC_(die_mem_stack_16)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000472{ \
473 PROF_EVENT(123); \
474 if (IS_ALIGNED8_ADDR(new_ESP)) { \
475 ALIGNED8_DIE ( new_ESP-16 ); \
476 ALIGNED8_DIE ( new_ESP-8 ); \
477 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
478 ALIGNED4_DIE ( new_ESP-16 ); \
479 ALIGNED8_DIE ( new_ESP-12 ); \
480 ALIGNED4_DIE ( new_ESP-4 ); \
481 } else { \
482 UNALIGNED_DIE ( new_ESP-16, 16 ); \
483 } \
484} \
485 \
nethercoteeec46302004-08-23 15:06:23 +0000486void REGPARM(1) MAC_(new_mem_stack_32)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000487{ \
488 PROF_EVENT(114); \
489 if (IS_ALIGNED8_ADDR(new_ESP)) { \
490 ALIGNED8_NEW ( new_ESP ); \
491 ALIGNED8_NEW ( new_ESP+8 ); \
492 ALIGNED8_NEW ( new_ESP+16 ); \
493 ALIGNED8_NEW ( new_ESP+24 ); \
494 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
495 ALIGNED4_NEW ( new_ESP ); \
496 ALIGNED8_NEW ( new_ESP+4 ); \
497 ALIGNED8_NEW ( new_ESP+12 ); \
498 ALIGNED8_NEW ( new_ESP+20 ); \
499 ALIGNED4_NEW ( new_ESP+28 ); \
500 } else { \
501 UNALIGNED_NEW ( new_ESP, 32 ); \
502 } \
503} \
504 \
nethercoteeec46302004-08-23 15:06:23 +0000505void REGPARM(1) MAC_(die_mem_stack_32)(Addr new_ESP) \
njn9b007f62003-04-07 14:40:25 +0000506{ \
507 PROF_EVENT(124); \
508 if (IS_ALIGNED8_ADDR(new_ESP)) { \
509 ALIGNED8_DIE ( new_ESP-32 ); \
510 ALIGNED8_DIE ( new_ESP-24 ); \
511 ALIGNED8_DIE ( new_ESP-16 ); \
512 ALIGNED8_DIE ( new_ESP- 8 ); \
513 } else if (IS_ALIGNED4_ADDR(new_ESP)) { \
514 ALIGNED4_DIE ( new_ESP-32 ); \
515 ALIGNED8_DIE ( new_ESP-28 ); \
516 ALIGNED8_DIE ( new_ESP-20 ); \
517 ALIGNED8_DIE ( new_ESP-12 ); \
518 ALIGNED4_DIE ( new_ESP-4 ); \
519 } else { \
520 UNALIGNED_DIE ( new_ESP-32, 32 ); \
521 } \
522} \
523 \
nethercote451eae92004-11-02 13:06:32 +0000524void MAC_(new_mem_stack) ( Addr a, SizeT len ) \
njn9b007f62003-04-07 14:40:25 +0000525{ \
526 PROF_EVENT(115); \
527 UNALIGNED_NEW ( a, len ); \
528} \
529 \
nethercote451eae92004-11-02 13:06:32 +0000530void MAC_(die_mem_stack) ( Addr a, SizeT len ) \
njn9b007f62003-04-07 14:40:25 +0000531{ \
532 PROF_EVENT(125); \
533 UNALIGNED_DIE ( a, len ); \
534}
535
njn43c799e2003-04-08 00:08:52 +0000536#endif /* __MAC_SHARED_H */
njn5c004e42002-11-18 11:04:50 +0000537
538/*--------------------------------------------------------------------*/
njn43c799e2003-04-08 00:08:52 +0000539/*--- end mac_shared.h ---*/
njn5c004e42002-11-18 11:04:50 +0000540/*--------------------------------------------------------------------*/