blob: 0d38c92332e4b868f90b24cf6c80a275cdd44010 [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001
2/*--------------------------------------------------------------------*/
3/*--- A header file for all parts of Valgrind. ---*/
4/*--- Include no other! ---*/
5/*--- vg_include.h ---*/
6/*--------------------------------------------------------------------*/
7
8/*
9 This file is part of Valgrind, an x86 protected-mode emulator
10 designed for debugging and profiling binaries on x86-Unixes.
11
12 Copyright (C) 2000-2002 Julian Seward
13 jseward@acm.org
sewardjde4a1d02002-03-22 01:27:54 +000014
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 LICENSE.
31*/
32
33#ifndef __VG_INCLUDE_H
34#define __VG_INCLUDE_H
35
36
37#include <stdarg.h> /* ANSI varargs stuff */
38#include <setjmp.h> /* for jmp_buf */
39
40
41/* ---------------------------------------------------------------------
sewardj2d94c112002-06-03 01:25:54 +000042 Where to send bug reports to.
43 ------------------------------------------------------------------ */
44
45#define VG_EMAIL_ADDR "jseward@acm.org"
46
47
48/* ---------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +000049 Build options and table sizes. You should be able to change these
50 options or sizes, recompile, and still have a working system.
51 ------------------------------------------------------------------ */
52
53#include "vg_constants.h"
54
55
56/* Set to 1 to enable time profiling. Since this uses SIGPROF, we
57 don't want this permanently enabled -- only for profiling
58 builds. */
59#if 0
60# define VG_PROFILE
61#endif
62
63
64/* Total number of integer registers available for allocation. That's
65 all of them except %esp, %edi and %ebp. %edi is a general spare
66 temporary. %ebp permanently points at VG_(baseBlock). Note that
67 it's important that this tie in with what rankToRealRegNo() says.
68 DO NOT CHANGE THIS VALUE FROM 5. ! */
69#define VG_MAX_REALREGS 5
70
71/* Total number of spill slots available for allocation, if a TempReg
72 doesn't make it into a RealReg. Just bomb the entire system if
73 this value is too small; we don't expect it will ever get
74 particularly high. */
75#define VG_MAX_SPILLSLOTS 24
76
77
78/* Constants for the slow translation lookup cache. */
79#define VG_TRANSTAB_SLOW_BITS 11
80#define VG_TRANSTAB_SLOW_SIZE (1 << VG_TRANSTAB_SLOW_BITS)
81#define VG_TRANSTAB_SLOW_MASK ((VG_TRANSTAB_SLOW_SIZE) - 1)
82
83/* Size of a buffer used for creating messages. */
84#define M_VG_MSGBUF 10000
85
86/* Size of a smallish table used to read /proc/self/map entries. */
sewardjebc82332002-04-24 14:44:23 +000087#define M_PROCMAP_BUF 50000
sewardjde4a1d02002-03-22 01:27:54 +000088
89/* Max length of pathname to a .so/executable file. */
90#define M_VG_LIBNAMESTR 100
91
92/* Max length of a text fragment used to construct error messages. */
93#define M_VG_ERRTXT 512
94
95/* Max length of the string copied from env var VG_ARGS at startup. */
96#define M_VG_CMDLINE_STRLEN 1000
97
98/* Max number of options for Valgrind which we can handle. */
99#define M_VG_CMDLINE_OPTS 100
100
101/* After this many different unsuppressed errors have been observed,
102 be more conservative about collecting new ones. */
103#define M_VG_COLLECT_ERRORS_SLOWLY_AFTER 50
104
105/* After this many different unsuppressed errors have been observed,
106 stop collecting errors at all, and tell the user their program is
107 evidently a steaming pile of camel dung. */
sewardj1bebcbf2002-04-24 21:24:18 +0000108#define M_VG_COLLECT_NO_ERRORS_AFTER_SHOWN 300
sewardjf2537be2002-04-24 21:03:47 +0000109
110/* After this many total errors have been observed, stop collecting
111 errors at all. Counterpart to M_VG_COLLECT_NO_ERRORS_AFTER_SHOWN. */
sewardj1bebcbf2002-04-24 21:24:18 +0000112#define M_VG_COLLECT_NO_ERRORS_AFTER_FOUND 30000
sewardjde4a1d02002-03-22 01:27:54 +0000113
114/* These many bytes below %ESP are considered addressible if we're
115 doing the --workaround-gcc296-bugs hack. */
sewardjb581a132002-05-08 00:32:50 +0000116#define VG_GCC296_BUG_STACK_SLOP 1024
sewardjde4a1d02002-03-22 01:27:54 +0000117
118/* The maximum number of calls we're prepared to save in a
119 backtrace. */
120#define VG_DEEPEST_BACKTRACE 50
121
122/* Number of lists in which we keep track of malloc'd but not free'd
123 blocks. Should be prime. */
124#define VG_N_MALLOCLISTS 997
125
126/* Number of lists in which we keep track of ExeContexts. Should be
127 prime. */
128#define VG_N_EC_LISTS /*997*/ 4999
129
sewardj2e93c502002-04-12 11:12:52 +0000130/* Defines the thread-scheduling timeslice, in terms of the number of
131 basic blocks we attempt to run each thread for. Smaller values
132 give finer interleaving but much increased scheduling overheads. */
sewardj4505b9e2002-05-28 11:27:31 +0000133#define VG_SCHEDULING_QUANTUM 50000
sewardj2e93c502002-04-12 11:12:52 +0000134
135/* The maximum number of pthreads that we support. This is
136 deliberately not very high since our implementation of some of the
sewardj5f07b662002-04-23 16:52:51 +0000137 scheduler algorithms is surely O(N) in the number of threads, since
138 that's simple, at least. And (in practice) we hope that most
sewardj2e93c502002-04-12 11:12:52 +0000139 programs do not need many threads. */
sewardj8208ae82002-06-17 14:25:00 +0000140#define VG_N_THREADS 50
sewardj5f07b662002-04-23 16:52:51 +0000141
142/* Maximum number of pthread keys available. Again, we start low until
143 the need for a higher number presents itself. */
sewardj8208ae82002-06-17 14:25:00 +0000144#define VG_N_THREAD_KEYS 50
sewardj2e93c502002-04-12 11:12:52 +0000145
146/* Number of file descriptors that can simultaneously be waited on for
147 I/O to complete. Perhaps this should be the same as VG_N_THREADS
148 (surely a thread can't wait on more than one fd at once?. Who
149 knows.) */
150#define VG_N_WAITING_FDS 10
151
sewardjbf290b92002-05-01 02:28:01 +0000152/* Stack size for a thread. We try and check that they do not go
153 beyond it. */
sewardjf0b06452002-06-04 08:38:04 +0000154#define VG_PTHREAD_STACK_SIZE (1 << 20)
sewardjbf290b92002-05-01 02:28:01 +0000155
sewardj20917d82002-05-28 01:36:45 +0000156/* Number of entries in the semaphore-remapping table. */
157#define VG_N_SEMAPHORES 50
158
159/* Number of entries in the rwlock-remapping table. */
160#define VG_N_RWLOCKS 50
161
sewardj8ad94e12002-05-29 00:10:20 +0000162/* Number of entries in each thread's cleanup stack. */
163#define VG_N_CLEANUPSTACK 8
164
sewardj2cb00342002-06-28 01:46:26 +0000165/* Number of entries in each thread's fork-handler stack. */
166#define VG_N_FORKHANDLERSTACK 2
167
sewardjde4a1d02002-03-22 01:27:54 +0000168
169/* ---------------------------------------------------------------------
170 Basic types
171 ------------------------------------------------------------------ */
172
173typedef unsigned char UChar;
174typedef unsigned short UShort;
175typedef unsigned int UInt;
176typedef unsigned long long int ULong;
177
178typedef signed char Char;
179typedef signed short Short;
180typedef signed int Int;
181typedef signed long long int Long;
182
183typedef unsigned int Addr;
184
185typedef unsigned char Bool;
186#define False ((Bool)0)
187#define True ((Bool)1)
188
189#define mycat_wrk(aaa,bbb) aaa##bbb
190#define mycat(aaa,bbb) mycat_wrk(aaa,bbb)
191
192/* Just pray that gcc's constant folding works properly ... */
193#define BITS(bit7,bit6,bit5,bit4,bit3,bit2,bit1,bit0) \
194 ( ((bit7) << 7) | ((bit6) << 6) | ((bit5) << 5) | ((bit4) << 4) \
195 | ((bit3) << 3) | ((bit2) << 2) | ((bit1) << 1) | (bit0))
196
njn7cf0bd32002-06-08 13:36:03 +0000197/* For cache simulation */
198typedef struct {
199 int size; /* bytes */
200 int assoc;
201 int line_size; /* bytes */
202} cache_t;
203
204#define UNDEFINED_CACHE ((cache_t) { -1, -1, -1 })
sewardjde4a1d02002-03-22 01:27:54 +0000205
206/* ---------------------------------------------------------------------
207 Now the basic types are set up, we can haul in the kernel-interface
208 definitions.
209 ------------------------------------------------------------------ */
210
211#include "./vg_kerneliface.h"
212
213
214/* ---------------------------------------------------------------------
215 Command-line-settable options
216 ------------------------------------------------------------------ */
217
218#define VG_CLO_SMC_NONE 0
219#define VG_CLO_SMC_SOME 1
220#define VG_CLO_SMC_ALL 2
221
222#define VG_CLO_MAX_SFILES 10
223
sewardj72f98ff2002-06-13 17:23:38 +0000224/* Should we stop collecting errors if too many appear? default: YES */
sewardj2e432902002-06-13 20:44:00 +0000225extern Bool VG_(clo_error_limit);
sewardj97ced732002-03-25 00:07:36 +0000226/* Shall we V-check addrs (they are always A checked too): default: YES */
sewardj72f98ff2002-06-13 17:23:38 +0000227extern Bool VG_(clo_check_addrVs);
sewardjde4a1d02002-03-22 01:27:54 +0000228/* Enquire about whether to attach to GDB at errors? default: NO */
229extern Bool VG_(clo_GDB_attach);
230/* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */
231extern Int VG_(sanity_level);
232/* Verbosity level: 0 = silent, 1 (default), > 1 = more verbose. */
233extern Int VG_(clo_verbosity);
234/* Automatically attempt to demangle C++ names? default: YES */
235extern Bool VG_(clo_demangle);
236/* Do leak check at exit? default: NO */
237extern Bool VG_(clo_leak_check);
238/* In leak check, show reachable-but-not-freed blocks? default: NO */
239extern Bool VG_(clo_show_reachable);
240/* How closely should we compare ExeContexts in leak records? default: 2 */
241extern Int VG_(clo_leak_resolution);
242/* Round malloc sizes upwards to integral number of words? default:
243 NO */
244extern Bool VG_(clo_sloppy_malloc);
sewardj246d4662002-06-14 10:17:05 +0000245/* Minimum alignment in functions that don't specify alignment explicitly.
246 default: 0, i.e. use default of the machine (== 4) */
247extern Int VG_(clo_alignment);
sewardjde4a1d02002-03-22 01:27:54 +0000248/* Allow loads from partially-valid addresses? default: YES */
249extern Bool VG_(clo_partial_loads_ok);
250/* Simulate child processes? default: NO */
251extern Bool VG_(clo_trace_children);
252/* The file id on which we send all messages. default: 2 (stderr). */
253extern Int VG_(clo_logfile_fd);
254/* Max volume of the freed blocks queue. */
255extern Int VG_(clo_freelist_vol);
256/* Assume accesses immediately below %esp are due to gcc-2.96 bugs.
257 default: NO */
258extern Bool VG_(clo_workaround_gcc296_bugs);
259
260/* The number of suppression files specified. */
261extern Int VG_(clo_n_suppressions);
262/* The names of the suppression files. */
263extern Char* VG_(clo_suppressions)[VG_CLO_MAX_SFILES];
264
265/* Single stepping? default: NO */
266extern Bool VG_(clo_single_step);
267/* Code improvement? default: YES */
268extern Bool VG_(clo_optimise);
269/* Memory-check instrumentation? default: YES */
270extern Bool VG_(clo_instrument);
271/* DEBUG: clean up instrumented code? default: YES */
272extern Bool VG_(clo_cleanup);
njn4f9c9342002-04-29 16:03:24 +0000273/* Cache simulation instrumentation? default: NO */
274extern Bool VG_(clo_cachesim);
njn7cf0bd32002-06-08 13:36:03 +0000275/* I1 cache configuration. default: undefined */
276extern cache_t VG_(clo_I1_cache);
277/* D1 cache configuration. default: undefined */
278extern cache_t VG_(clo_D1_cache);
279/* L2 cache configuration. default: undefined */
280extern cache_t VG_(clo_L2_cache);
sewardjde4a1d02002-03-22 01:27:54 +0000281/* SMC write checks? default: SOME (1,2,4 byte movs to mem) */
282extern Int VG_(clo_smc_check);
283/* DEBUG: print system calls? default: NO */
284extern Bool VG_(clo_trace_syscalls);
285/* DEBUG: print signal details? default: NO */
286extern Bool VG_(clo_trace_signals);
287/* DEBUG: print symtab details? default: NO */
288extern Bool VG_(clo_trace_symtab);
289/* DEBUG: print malloc details? default: NO */
290extern Bool VG_(clo_trace_malloc);
sewardj8937c812002-04-12 20:12:20 +0000291/* DEBUG: print thread scheduling events? default: NO */
292extern Bool VG_(clo_trace_sched);
sewardj45b4b372002-04-16 22:50:32 +0000293/* DEBUG: print pthread (mutex etc) events? default: 0 (none), 1
294 (some), 2 (all) */
295extern Int VG_(clo_trace_pthread_level);
sewardjde4a1d02002-03-22 01:27:54 +0000296/* Stop after this many basic blocks. default: Infinity. */
297extern ULong VG_(clo_stop_after);
298/* Display gory details for the k'th most popular error. default:
299 Infinity. */
300extern Int VG_(clo_dump_error);
301/* Number of parents of a backtrace. Default: 8. */
302extern Int VG_(clo_backtrace_size);
sewardj3984b852002-05-12 03:00:17 +0000303/* Engage miscellaneous wierd hacks needed for some progs. */
sewardj8d365b52002-05-12 10:52:16 +0000304extern Char* VG_(clo_weird_hacks);
sewardjde4a1d02002-03-22 01:27:54 +0000305
306
307/* ---------------------------------------------------------------------
308 Debugging and profiling stuff
309 ------------------------------------------------------------------ */
310
311/* No, really. I _am_ that strange. */
312#define OINK(nnn) VG_(message)(Vg_DebugMsg, "OINK %d",nnn)
313
314/* Tools for building messages from multiple parts. */
315typedef
316 enum { Vg_UserMsg, Vg_DebugMsg, Vg_DebugExtraMsg }
317 VgMsgKind;
318
319extern void VG_(start_msg) ( VgMsgKind kind );
320extern void VG_(add_to_msg) ( Char* format, ... );
321extern void VG_(end_msg) ( void );
322
323/* Send a simple, single-part message. */
324extern void VG_(message) ( VgMsgKind kind, Char* format, ... );
325
326/* Create a logfile into which messages can be dumped. */
327extern void VG_(startup_logging) ( void );
328extern void VG_(shutdown_logging) ( void );
329
330
331/* Profiling stuff */
332#ifdef VG_PROFILE
333
334#define VGP_M_STACK 10
335
sewardj671ff542002-05-07 09:25:30 +0000336#define VGP_M_CCS 26 /* == the # of elems in VGP_LIST */
sewardjde4a1d02002-03-22 01:27:54 +0000337#define VGP_LIST \
sewardj671ff542002-05-07 09:25:30 +0000338 VGP_PAIR(VgpUnc=0, "unclassified"), \
339 VGP_PAIR(VgpRun, "running"), \
340 VGP_PAIR(VgpSched, "scheduler"), \
sewardjde4a1d02002-03-22 01:27:54 +0000341 VGP_PAIR(VgpMalloc, "low-lev malloc/free"), \
342 VGP_PAIR(VgpCliMalloc, "client malloc/free"), \
343 VGP_PAIR(VgpTranslate, "translate-main"), \
344 VGP_PAIR(VgpToUCode, "to-ucode"), \
345 VGP_PAIR(VgpFromUcode, "from-ucode"), \
346 VGP_PAIR(VgpImprove, "improve"), \
347 VGP_PAIR(VgpInstrument, "instrument"), \
348 VGP_PAIR(VgpCleanup, "cleanup"), \
349 VGP_PAIR(VgpRegAlloc, "reg-alloc"), \
350 VGP_PAIR(VgpDoLRU, "do-lru"), \
351 VGP_PAIR(VgpSlowFindT, "slow-search-transtab"), \
352 VGP_PAIR(VgpInitAudit, "init-mem-audit"), \
353 VGP_PAIR(VgpExeContext, "exe-context"), \
354 VGP_PAIR(VgpReadSyms, "read-syms"), \
355 VGP_PAIR(VgpAddToT, "add-to-transtab"), \
356 VGP_PAIR(VgpSARP, "set-addr-range-perms"), \
357 VGP_PAIR(VgpSyscall, "syscall wrapper"), \
njn4f9c9342002-04-29 16:03:24 +0000358 VGP_PAIR(VgpCacheInstrument, "cache instrument"), \
359 VGP_PAIR(VgpCacheGetBBCC,"cache get BBCC"), \
360 VGP_PAIR(VgpCacheSimulate, "cache simulate"), \
361 VGP_PAIR(VgpCacheDump, "cache stats dump"), \
sewardjde4a1d02002-03-22 01:27:54 +0000362 VGP_PAIR(VgpSpare1, "spare 1"), \
363 VGP_PAIR(VgpSpare2, "spare 2")
364
365#define VGP_PAIR(enumname,str) enumname
366typedef enum { VGP_LIST } VgpCC;
367#undef VGP_PAIR
368
369extern void VGP_(init_profiling) ( void );
370extern void VGP_(done_profiling) ( void );
371extern void VGP_(pushcc) ( VgpCC );
372extern void VGP_(popcc) ( void );
373
374#define VGP_PUSHCC(cc) VGP_(pushcc)(cc)
375#define VGP_POPCC VGP_(popcc)()
376
377#else
378
379#define VGP_PUSHCC(cc) /* */
380#define VGP_POPCC /* */
381
382#endif /* VG_PROFILE */
383
384
385/* ---------------------------------------------------------------------
386 Exports of vg_malloc2.c
387 ------------------------------------------------------------------ */
388
389/* Allocation arenas.
390 SYMTAB is for Valgrind's symbol table storage.
391 CLIENT is for the client's mallocs/frees.
392 DEMANGLE is for the C++ demangler.
393 EXECTXT is for storing ExeContexts.
394 ERRCTXT is for storing ErrContexts.
395 PRIVATE is for Valgrind general stuff.
396 TRANSIENT is for very short-term use. It should be empty
397 in between uses.
398 When adding a new arena, remember also to add it
399 to ensure_mm_init().
400*/
401typedef Int ArenaId;
402
403#define VG_N_ARENAS 7
404
405#define VG_AR_PRIVATE 0 /* :: ArenaId */
406#define VG_AR_SYMTAB 1 /* :: ArenaId */
407#define VG_AR_CLIENT 2 /* :: ArenaId */
408#define VG_AR_DEMANGLE 3 /* :: ArenaId */
409#define VG_AR_EXECTXT 4 /* :: ArenaId */
410#define VG_AR_ERRCTXT 5 /* :: ArenaId */
411#define VG_AR_TRANSIENT 6 /* :: ArenaId */
412
413extern void* VG_(malloc) ( ArenaId arena, Int nbytes );
414extern void VG_(free) ( ArenaId arena, void* ptr );
415extern void* VG_(calloc) ( ArenaId arena, Int nmemb, Int nbytes );
416extern void* VG_(realloc) ( ArenaId arena, void* ptr, Int size );
417extern void* VG_(malloc_aligned) ( ArenaId aid, Int req_alignB,
418 Int req_pszB );
419
420extern void VG_(mallocSanityCheckArena) ( ArenaId arena );
421extern void VG_(mallocSanityCheckAll) ( void );
422
423extern void VG_(show_all_arena_stats) ( void );
424extern Bool VG_(is_empty_arena) ( ArenaId aid );
425
426
427/* The red-zone size for the client. This can be arbitrary, but
428 unfortunately must be set at compile time. */
429#define VG_AR_CLIENT_REDZONE_SZW 4
430
431#define VG_AR_CLIENT_REDZONE_SZB \
432 (VG_AR_CLIENT_REDZONE_SZW * VKI_BYTES_PER_WORD)
433
434
435/* ---------------------------------------------------------------------
sewardj2e93c502002-04-12 11:12:52 +0000436 Exports of vg_clientfuns.c
437 ------------------------------------------------------------------ */
438
439/* This doesn't export code or data that valgrind.so needs to link
440 against. However, the scheduler does need to know the following
441 request codes. A few, publically-visible, request codes are also
442 defined in valgrind.h. */
443
444#define VG_USERREQ__MALLOC 0x2001
445#define VG_USERREQ__BUILTIN_NEW 0x2002
446#define VG_USERREQ__BUILTIN_VEC_NEW 0x2003
447
448#define VG_USERREQ__FREE 0x2004
449#define VG_USERREQ__BUILTIN_DELETE 0x2005
450#define VG_USERREQ__BUILTIN_VEC_DELETE 0x2006
451
452#define VG_USERREQ__CALLOC 0x2007
453#define VG_USERREQ__REALLOC 0x2008
454#define VG_USERREQ__MEMALIGN 0x2009
455
456
sewardj20917d82002-05-28 01:36:45 +0000457/* (Fn, Arg): Create a new thread and run Fn applied to Arg in it. Fn
458 MUST NOT return -- ever. Eventually it will do either __QUIT or
459 __WAIT_JOINER. */
460#define VG_USERREQ__APPLY_IN_NEW_THREAD 0x3001
461
462/* ( no-args ): calling thread disappears from the system forever.
463 Reclaim resources. */
464#define VG_USERREQ__QUIT 0x3002
465
466/* ( void* ): calling thread waits for joiner and returns the void* to
467 it. */
468#define VG_USERREQ__WAIT_JOINER 0x3003
469
470/* ( ThreadId, void** ): wait to join a thread. */
471#define VG_USERREQ__PTHREAD_JOIN 0x3004
472
473/* Set cancellation state and type for this thread. */
474#define VG_USERREQ__SET_CANCELSTATE 0x3005
475#define VG_USERREQ__SET_CANCELTYPE 0x3006
476
477/* ( no-args ): Test if we are at a cancellation point. */
478#define VG_USERREQ__TESTCANCEL 0x3007
479
480/* ( ThreadId, &thread_exit_wrapper is the only allowable arg ): call
481 with this arg to indicate that a cancel is now pending for the
482 specified thread. */
483#define VG_USERREQ__SET_CANCELPEND 0x3008
484
485/* Set/get detach state for this thread. */
486#define VG_USERREQ__SET_OR_GET_DETACH 0x3009
487
488#define VG_USERREQ__PTHREAD_GET_THREADID 0x300B
489#define VG_USERREQ__PTHREAD_MUTEX_LOCK 0x300C
490#define VG_USERREQ__PTHREAD_MUTEX_TRYLOCK 0x300D
491#define VG_USERREQ__PTHREAD_MUTEX_UNLOCK 0x300E
492#define VG_USERREQ__PTHREAD_COND_WAIT 0x300F
493#define VG_USERREQ__PTHREAD_COND_TIMEDWAIT 0x3010
494#define VG_USERREQ__PTHREAD_COND_SIGNAL 0x3011
495#define VG_USERREQ__PTHREAD_COND_BROADCAST 0x3012
496#define VG_USERREQ__PTHREAD_KEY_CREATE 0x3013
497#define VG_USERREQ__PTHREAD_KEY_DELETE 0x3014
498#define VG_USERREQ__PTHREAD_SETSPECIFIC 0x3015
499#define VG_USERREQ__PTHREAD_GETSPECIFIC 0x3016
500#define VG_USERREQ__READ_MILLISECOND_TIMER 0x3017
501#define VG_USERREQ__PTHREAD_SIGMASK 0x3018
502#define VG_USERREQ__SIGWAIT 0x3019
503#define VG_USERREQ__PTHREAD_KILL 0x301A
504#define VG_USERREQ__PTHREAD_YIELD 0x301B
sewardj2e93c502002-04-12 11:12:52 +0000505
sewardj8ad94e12002-05-29 00:10:20 +0000506#define VG_USERREQ__CLEANUP_PUSH 0x3020
507#define VG_USERREQ__CLEANUP_POP 0x3021
sewardj870497a2002-05-29 01:06:47 +0000508#define VG_USERREQ__GET_KEY_D_AND_S 0x3022
sewardj8ad94e12002-05-29 00:10:20 +0000509
sewardjef037c72002-05-30 00:40:03 +0000510#define VG_USERREQ__NUKE_OTHER_THREADS 0x3023
sewardjefbfcdf2002-06-19 17:35:45 +0000511
512/* Ask how many signal handler returns have happened to this
513 thread. */
sewardj9a2224b2002-06-19 10:17:40 +0000514#define VG_USERREQ__GET_N_SIGS_RETURNED 0x3024
sewardjef037c72002-05-30 00:40:03 +0000515
sewardj2cb00342002-06-28 01:46:26 +0000516/* Get/set entries for a thread's pthread_atfork stack. */
517#define VG_USERREQ__SET_FHSTACK_USED 0x3025
518#define VG_USERREQ__GET_FHSTACK_USED 0x3026
519#define VG_USERREQ__SET_FHSTACK_ENTRY 0x3027
520#define VG_USERREQ__GET_FHSTACK_ENTRY 0x3028
sewardjefbfcdf2002-06-19 17:35:45 +0000521
sewardj1fe7b002002-07-16 01:43:15 +0000522/* Denote the finish of VG_(__libc_freeres_wrapper). */
523#define VG_USERREQ__LIBC_FREERES_DONE 0x3029
524
sewardj45b4b372002-04-16 22:50:32 +0000525/* Cosmetic ... */
526#define VG_USERREQ__GET_PTHREAD_TRACE_LEVEL 0x3101
sewardj4dced352002-06-04 22:54:20 +0000527/* Log a pthread error from client-space. Cosmetic. */
528#define VG_USERREQ__PTHREAD_ERROR 0x3102
sewardj45b4b372002-04-16 22:50:32 +0000529
sewardj54cacf02002-04-12 23:24:59 +0000530/*
531In vg_constants.h:
532#define VG_USERREQ__SIGNAL_RETURNS 0x4001
sewardj54cacf02002-04-12 23:24:59 +0000533*/
534
sewardj1fe7b002002-07-16 01:43:15 +0000535/* The scheduler does need to know the address of it so it can be
536 called at program exit. */
537extern void VG_(__libc_freeres_wrapper)( void );
538
sewardj54cacf02002-04-12 23:24:59 +0000539
sewardj2e93c502002-04-12 11:12:52 +0000540/* ---------------------------------------------------------------------
541 Constants pertaining to the simulated CPU state, VG_(baseBlock),
542 which need to go here to avoid ugly circularities.
543 ------------------------------------------------------------------ */
544
545/* How big is the saved FPU state? */
546#define VG_SIZE_OF_FPUSTATE 108
547/* ... and in words ... */
548#define VG_SIZE_OF_FPUSTATE_W ((VG_SIZE_OF_FPUSTATE+3)/4)
549
550
551/* ---------------------------------------------------------------------
552 Exports of vg_scheduler.c
553 ------------------------------------------------------------------ */
554
555/* ThreadIds are simply indices into the vg_threads[] array. */
556typedef
557 UInt
558 ThreadId;
559
sewardj6072c362002-04-19 14:40:57 +0000560/* Special magic value for an invalid ThreadId. It corresponds to
561 LinuxThreads using zero as the initial value for
562 pthread_mutex_t.__m_owner and pthread_cond_t.__c_waiting. */
563#define VG_INVALID_THREADID ((ThreadId)(0))
sewardj2e93c502002-04-12 11:12:52 +0000564
565typedef
566 enum {
567 VgTs_Empty, /* this slot is not in use */
568 VgTs_Runnable, /* waiting to be scheduled */
569 VgTs_WaitJoiner, /* waiting for someone to do join on me */
570 VgTs_WaitJoinee, /* waiting for the thread I did join on */
571 VgTs_WaitFD, /* waiting for I/O completion on a fd */
572 VgTs_WaitMX, /* waiting on a mutex */
sewardj3b5d8862002-04-20 13:53:23 +0000573 VgTs_WaitCV, /* waiting on a condition variable */
sewardjb48e5002002-05-13 00:16:03 +0000574 VgTs_WaitSIG, /* waiting due to sigwait() */
sewardj2e93c502002-04-12 11:12:52 +0000575 VgTs_Sleeping /* sleeping for a while */
576 }
577 ThreadStatus;
sewardj8ad94e12002-05-29 00:10:20 +0000578
579/* An entry in a threads's cleanup stack. */
580typedef
581 struct {
582 void (*fn)(void*);
583 void* arg;
584 }
585 CleanupEntry;
sewardj2cb00342002-06-28 01:46:26 +0000586
587/* An entry in a thread's fork-handler stack. */
588typedef
589 struct {
590 void (*prepare)(void);
591 void (*parent)(void);
592 void (*child)(void);
593 }
594 ForkHandlerEntry;
595
596
sewardj2e93c502002-04-12 11:12:52 +0000597typedef
598 struct {
sewardj6072c362002-04-19 14:40:57 +0000599 /* ThreadId == 0 (and hence vg_threads[0]) is NEVER USED.
600 The thread identity is simply the index in vg_threads[].
601 ThreadId == 1 is the root thread and has the special property
sewardj1e8cdc92002-04-18 11:37:52 +0000602 that we don't try and allocate or deallocate its stack. For
603 convenience of generating error message, we also put the
604 ThreadId in this tid field, but be aware that it should
sewardj604ec3c2002-04-18 22:38:41 +0000605 ALWAYS == the index in vg_threads[]. */
sewardj1e8cdc92002-04-18 11:37:52 +0000606 ThreadId tid;
sewardj2e93c502002-04-12 11:12:52 +0000607
sewardj5f07b662002-04-23 16:52:51 +0000608 /* Current scheduling status.
609
610 Complications: whenever this is set to VgTs_WaitMX, you
611 should also set .m_edx to whatever the required return value
612 is for pthread_mutex_lock / pthread_cond_timedwait for when
613 the mutex finally gets unblocked. */
sewardj2e93c502002-04-12 11:12:52 +0000614 ThreadStatus status;
615
sewardj3b5d8862002-04-20 13:53:23 +0000616 /* When .status == WaitMX, points to the mutex I am waiting for.
617 When .status == WaitCV, points to the mutex associated with
618 the condition variable indicated by the .associated_cv field.
619 In all other cases, should be NULL. */
620 void* /* pthread_mutex_t* */ associated_mx;
621
622 /* When .status == WaitCV, points to the condition variable I am
623 waiting for. In all other cases, should be NULL. */
624 void* /* pthread_cond_t* */ associated_cv;
sewardj2e93c502002-04-12 11:12:52 +0000625
sewardj5f07b662002-04-23 16:52:51 +0000626 /* If VgTs_Sleeping, this is when we should wake up, measured in
627 milliseconds as supplied by VG_(read_millisecond_counter).
628
629 If VgTs_WaitCV, this indicates the time at which
630 pthread_cond_timedwait should wake up. If == 0xFFFFFFFF,
631 this means infinitely far in the future, viz,
632 pthread_cond_wait. */
633 UInt awaken_at;
sewardj2e93c502002-04-12 11:12:52 +0000634
sewardj20917d82002-05-28 01:36:45 +0000635 /* If VgTs_WaitJoiner, return value, as generated by joinees. */
636 void* joinee_retval;
637
638 /* If VgTs_WaitJoinee, place to copy the return value to, and
639 the identity of the thread we're waiting for. */
640 void** joiner_thread_return;
641 ThreadId joiner_jee_tid;
642
sewardj8ad94e12002-05-29 00:10:20 +0000643 /* Whether or not detached. */
644 Bool detached;
645
sewardj20917d82002-05-28 01:36:45 +0000646 /* Cancelability state and type. */
647 Bool cancel_st; /* False==PTH_CANCEL_DISABLE; True==.._ENABLE */
648 Bool cancel_ty; /* False==PTH_CANC_ASYNCH; True==..._DEFERRED */
649
650 /* Pointer to fn to call to do cancellation. Indicates whether
651 or not cancellation is pending. If NULL, not pending. Else
652 should be &thread_exit_wrapper(), indicating that
653 cancallation is pending. */
654 void (*cancel_pend)(void*);
655
sewardj8ad94e12002-05-29 00:10:20 +0000656 /* The cleanup stack. */
657 Int custack_used;
658 CleanupEntry custack[VG_N_CLEANUPSTACK];
sewardj2e93c502002-04-12 11:12:52 +0000659
sewardj5f07b662002-04-23 16:52:51 +0000660 /* thread-specific data */
661 void* specifics[VG_N_THREAD_KEYS];
662
sewardjb48e5002002-05-13 00:16:03 +0000663 /* This thread's blocked-signals mask. Semantics is that for a
664 signal to be delivered to this thread, the signal must not be
665 blocked by either the process-wide signal mask nor by this
666 one. So, if this thread is prepared to handle any signal that
667 the process as a whole is prepared to handle, this mask should
668 be made empty -- and that it is its default, starting
669 state. */
670 vki_ksigset_t sig_mask;
671
672 /* When not VgTs_WaitSIG, has no meaning. When VgTs_WaitSIG,
673 is the set of signals for which we are sigwait()ing. */
674 vki_ksigset_t sigs_waited_for;
675
sewardj9a2224b2002-06-19 10:17:40 +0000676 /* Counts the number of times a signal handler for this thread
677 has returned. This makes it easy to implement pause(), by
678 polling this value, of course interspersed with nanosleeps,
679 and waiting till it changes. */
680 UInt n_signals_returned;
681
sewardj2e93c502002-04-12 11:12:52 +0000682 /* Stacks. When a thread slot is freed, we don't deallocate its
683 stack; we just leave it lying around for the next use of the
684 slot. If the next use of the slot requires a larger stack,
685 only then is the old one deallocated and a new one
686 allocated.
687
688 For the main thread (threadid == 0), this mechanism doesn't
689 apply. We don't know the size of the stack since we didn't
690 allocate it, and furthermore we never reallocate it. */
691
692 /* The allocated size of this thread's stack (permanently zero
693 if this is ThreadId == 0, since we didn't allocate its stack) */
694 UInt stack_size;
695
696 /* Address of the lowest word in this thread's stack. NULL means
697 not allocated yet.
698 */
699 Addr stack_base;
700
sewardj1e8cdc92002-04-18 11:37:52 +0000701 /* Address of the highest legitimate word in this stack. This is
702 used for error messages only -- not critical for execution
703 correctness. Is is set for all stacks, specifically including
704 ThreadId == 0 (the main thread). */
705 Addr stack_highest_word;
706
sewardj2e93c502002-04-12 11:12:52 +0000707 /* Saved machine context. */
708 UInt m_eax;
709 UInt m_ebx;
710 UInt m_ecx;
711 UInt m_edx;
712 UInt m_esi;
713 UInt m_edi;
714 UInt m_ebp;
715 UInt m_esp;
716 UInt m_eflags;
717 UInt m_eip;
718 UInt m_fpu[VG_SIZE_OF_FPUSTATE_W];
719
720 UInt sh_eax;
721 UInt sh_ebx;
722 UInt sh_ecx;
723 UInt sh_edx;
724 UInt sh_esi;
725 UInt sh_edi;
726 UInt sh_ebp;
727 UInt sh_esp;
728 UInt sh_eflags;
729 }
730 ThreadState;
731
732
sewardj018f7622002-05-15 21:13:39 +0000733/* The thread table. */
734extern ThreadState VG_(threads)[VG_N_THREADS];
735
736/* Check that tid is in range and denotes a non-Empty thread. */
sewardjb48e5002002-05-13 00:16:03 +0000737extern Bool VG_(is_valid_tid) ( ThreadId tid );
738
sewardj018f7622002-05-15 21:13:39 +0000739/* Check that tid is in range. */
740extern Bool VG_(is_valid_or_empty_tid) ( ThreadId tid );
741
sewardj2e93c502002-04-12 11:12:52 +0000742/* Copy the specified thread's state into VG_(baseBlock) in
743 preparation for running it. */
744extern void VG_(load_thread_state)( ThreadId );
745
746/* Save the specified thread's state back in VG_(baseBlock), and fill
747 VG_(baseBlock) with junk, for sanity-check reasons. */
748extern void VG_(save_thread_state)( ThreadId );
749
sewardj1e8cdc92002-04-18 11:37:52 +0000750/* And for the currently running one, if valid. */
751extern ThreadState* VG_(get_current_thread_state) ( void );
sewardj2e93c502002-04-12 11:12:52 +0000752
sewardj1e8cdc92002-04-18 11:37:52 +0000753/* Similarly ... */
754extern ThreadId VG_(get_current_tid) ( void );
755
756/* Which thread is this address in the stack of, if any? Used for
757 error message generation. */
758extern ThreadId VG_(identify_stack_addr)( Addr a );
759
sewardjccef2e62002-05-29 19:26:32 +0000760/* Nuke all threads except tid. */
761extern void VG_(nuke_all_threads_except) ( ThreadId me );
762
sewardj2e93c502002-04-12 11:12:52 +0000763
764/* Return codes from the scheduler. */
765typedef
sewardj7e87e382002-05-03 19:09:05 +0000766 enum {
767 VgSrc_Deadlock, /* no runnable threads and no prospect of any
768 even if we wait for a long time */
769 VgSrc_ExitSyscall, /* client called exit(). This is the normal
770 route out. */
771 VgSrc_BbsDone /* In a debugging run, the specified number of
772 bbs has been completed. */
773 }
sewardj2e93c502002-04-12 11:12:52 +0000774 VgSchedReturnCode;
775
sewardj7e87e382002-05-03 19:09:05 +0000776
sewardj2e93c502002-04-12 11:12:52 +0000777/* The scheduler. */
778extern VgSchedReturnCode VG_(scheduler) ( void );
779
780extern void VG_(scheduler_init) ( void );
781
sewardj15a43e12002-04-17 19:35:12 +0000782extern void VG_(pp_sched_status) ( void );
sewardj2e93c502002-04-12 11:12:52 +0000783
784/* vg_oursignalhandler() might longjmp(). Here's the jmp_buf. */
785extern jmp_buf VG_(scheduler_jmpbuf);
sewardj872051c2002-07-13 12:12:56 +0000786/* This says whether scheduler_jmpbuf is actually valid. Needed so
787 that our signal handler doesn't longjmp when the buffer isn't
788 actually valid. */
789extern Bool VG_(scheduler_jmpbuf_valid);
sewardj2e93c502002-04-12 11:12:52 +0000790/* ... and if so, here's the signal which caused it to do so. */
791extern Int VG_(longjmpd_on_signal);
792
793
sewardja1679dd2002-05-10 22:31:40 +0000794/* Possible places where the main stack might be based. We check that
795 the initial stack, which we can't move, is allocated here.
796 VG_(scheduler_init) checks this. Andrea Archelangi's 2.4 kernels
797 have been rumoured to start stacks at 0x80000000, so that too is
daywalkera2562202002-07-15 19:39:51 +0000798 considered. It seems systems with longer uptimes tend to to use
799 stacks which start at 0x40000000 sometimes.
sewardj2e93c502002-04-12 11:12:52 +0000800*/
sewardja1679dd2002-05-10 22:31:40 +0000801#define VG_STARTUP_STACK_BASE_1 (Addr)0xC0000000
802#define VG_STARTUP_STACK_BASE_2 (Addr)0x80000000
daywalkera2562202002-07-15 19:39:51 +0000803#define VG_STARTUP_STACK_BASE_3 (Addr)0x40000000
sewardja1679dd2002-05-10 22:31:40 +0000804#define VG_STARTUP_STACK_SMALLERTHAN 0x100000 /* 1024k */
805
806#define VG_STACK_MATCHES_BASE(zzstack, zzbase) \
807 ( \
808 ((zzstack) & ((zzbase) - VG_STARTUP_STACK_SMALLERTHAN)) \
809 == \
810 ((zzbase) - VG_STARTUP_STACK_SMALLERTHAN) \
811 )
sewardj2e93c502002-04-12 11:12:52 +0000812
813
814/* The red-zone size which we put at the bottom (highest address) of
815 thread stacks, for paranoia reasons. This can be arbitrary, and
816 doesn't really need to be set at compile time. */
817#define VG_AR_CLIENT_STACKBASE_REDZONE_SZW 4
818
819#define VG_AR_CLIENT_STACKBASE_REDZONE_SZB \
820 (VG_AR_CLIENT_STACKBASE_REDZONE_SZW * VKI_BYTES_PER_WORD)
821
822
sewardj018f7622002-05-15 21:13:39 +0000823/* Write a value to the client's %EDX (request return value register)
824 and set the shadow to indicate it is defined. */
825#define SET_EDX(zztid, zzval) \
826 do { VG_(threads)[zztid].m_edx = (zzval); \
827 VG_(threads)[zztid].sh_edx = VGM_WORD_VALID; \
828 } while (0)
829
830#define SET_EAX(zztid, zzval) \
831 do { VG_(threads)[zztid].m_eax = (zzval); \
832 VG_(threads)[zztid].sh_eax = VGM_WORD_VALID; \
833 } while (0)
834
sewardj2e93c502002-04-12 11:12:52 +0000835
836/* ---------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +0000837 Exports of vg_signals.c
838 ------------------------------------------------------------------ */
839
sewardjde4a1d02002-03-22 01:27:54 +0000840extern void VG_(sigstartup_actions) ( void );
841
sewardjb48e5002002-05-13 00:16:03 +0000842extern Bool VG_(deliver_signals) ( void );
sewardjde4a1d02002-03-22 01:27:54 +0000843extern void VG_(unblock_host_signal) ( Int sigNo );
sewardj018f7622002-05-15 21:13:39 +0000844extern void VG_(handle_SCSS_change) ( Bool force_update );
845
sewardjde4a1d02002-03-22 01:27:54 +0000846
847/* Fake system calls for signal handling. */
sewardj2342c972002-05-22 23:34:20 +0000848extern void VG_(do__NR_sigaltstack) ( ThreadId tid );
sewardj2e93c502002-04-12 11:12:52 +0000849extern void VG_(do__NR_sigaction) ( ThreadId tid );
sewardj018f7622002-05-15 21:13:39 +0000850extern void VG_(do__NR_sigprocmask) ( ThreadId tid,
851 Int how,
852 vki_ksigset_t* set,
853 vki_ksigset_t* oldset );
854extern void VG_(do_pthread_sigmask_SCSS_upd) ( ThreadId tid,
855 Int how,
856 vki_ksigset_t* set,
857 vki_ksigset_t* oldset );
858extern void VG_(send_signal_to_thread) ( ThreadId thread,
859 Int signo );
sewardjde4a1d02002-03-22 01:27:54 +0000860
sewardjefbfcdf2002-06-19 17:35:45 +0000861extern void VG_(do_sigpending) ( ThreadId tid, vki_ksigset_t* set );
862
863
sewardj2e93c502002-04-12 11:12:52 +0000864/* Modify the current thread's state once we have detected it is
865 returning from a signal handler. */
sewardj77e466c2002-04-14 02:29:29 +0000866extern Bool VG_(signal_returns) ( ThreadId );
sewardjde4a1d02002-03-22 01:27:54 +0000867
sewardj2e93c502002-04-12 11:12:52 +0000868/* Handy utilities to block/restore all host signals. */
869extern void VG_(block_all_host_signals)
870 ( /* OUT */ vki_ksigset_t* saved_mask );
sewardj018f7622002-05-15 21:13:39 +0000871extern void VG_(restore_all_host_signals)
sewardj2e93c502002-04-12 11:12:52 +0000872 ( /* IN */ vki_ksigset_t* saved_mask );
sewardjde4a1d02002-03-22 01:27:54 +0000873
874/* ---------------------------------------------------------------------
875 Exports of vg_mylibc.c
876 ------------------------------------------------------------------ */
877
878
sewardjfbe18b92002-05-10 00:46:59 +0000879#if !defined(NULL)
880# define NULL ((void*)0)
881#endif
sewardjde4a1d02002-03-22 01:27:54 +0000882
883extern void VG_(exit)( Int status )
884 __attribute__ ((__noreturn__));
885
886extern void VG_(printf) ( const char *format, ... );
887/* too noisy ... __attribute__ ((format (printf, 1, 2))) ; */
888
889extern void VG_(sprintf) ( Char* buf, Char *format, ... );
890
891extern void VG_(vprintf) ( void(*send)(Char),
892 const Char *format, va_list vargs );
893
894extern Bool VG_(isspace) ( Char c );
njn7cf0bd32002-06-08 13:36:03 +0000895extern Bool VG_(isdigit) ( Char c );
sewardjde4a1d02002-03-22 01:27:54 +0000896
897extern Int VG_(strlen) ( const Char* str );
898
899extern Long VG_(atoll) ( Char* str );
sewardja70ca3f2002-05-30 01:22:20 +0000900extern Long VG_(atoll36) ( Char* str );
sewardjde4a1d02002-03-22 01:27:54 +0000901
902extern Char* VG_(strcat) ( Char* dest, const Char* src );
903extern Char* VG_(strncat) ( Char* dest, const Char* src, Int n );
904extern Char* VG_(strpbrk) ( const Char* s, const Char* accept );
905
906extern Char* VG_(strcpy) ( Char* dest, const Char* src );
907
908extern Int VG_(strcmp) ( const Char* s1, const Char* s2 );
909extern Int VG_(strcmp_ws) ( const Char* s1, const Char* s2 );
910
911extern Int VG_(strncmp) ( const Char* s1, const Char* s2, Int nmax );
912extern Int VG_(strncmp_ws) ( const Char* s1, const Char* s2, Int nmax );
913
914extern Char* VG_(strstr) ( const Char* haystack, Char* needle );
915extern Char* VG_(strchr) ( const Char* s, Char c );
916extern Char* VG_(strdup) ( ArenaId aid, const Char* s);
917
918extern Char* VG_(getenv) ( Char* name );
919extern Int VG_(getpid) ( void );
sewardj5f07b662002-04-23 16:52:51 +0000920
921extern void VG_(start_rdtsc_calibration) ( void );
922extern void VG_(end_rdtsc_calibration) ( void );
923extern UInt VG_(read_millisecond_timer) ( void );
sewardjde4a1d02002-03-22 01:27:54 +0000924
925
926extern Char VG_(toupper) ( Char c );
927
928extern void VG_(strncpy_safely) ( Char* dest, const Char* src, Int ndest );
929
930extern void VG_(strncpy) ( Char* dest, const Char* src, Int ndest );
931
932extern Bool VG_(stringMatch) ( Char* pat, Char* str );
933
934
sewardj3e1eb1f2002-05-18 13:14:17 +0000935#define VG__STRING(__str) #__str
sewardjde4a1d02002-03-22 01:27:54 +0000936
937/* Asserts are permanently enabled. Hurrah! */
938#define vg_assert(expr) \
939 ((void) ((expr) ? 0 : \
sewardj3e1eb1f2002-05-18 13:14:17 +0000940 (VG_(assert_fail) (VG__STRING(expr), \
sewardjde4a1d02002-03-22 01:27:54 +0000941 __FILE__, __LINE__, \
942 __PRETTY_FUNCTION__), 0)))
943
944extern void VG_(assert_fail) ( Char* expr, Char* file,
945 Int line, Char* fn )
946 __attribute__ ((__noreturn__));
947
njn4f9c9342002-04-29 16:03:24 +0000948/* Reading and writing files. */
sewardjde4a1d02002-03-22 01:27:54 +0000949extern Int VG_(open_read) ( Char* pathname );
njn4f9c9342002-04-29 16:03:24 +0000950extern Int VG_(open_write) ( Char* pathname );
951extern Int VG_(create_and_write) ( Char* pathname );
sewardjde4a1d02002-03-22 01:27:54 +0000952extern void VG_(close) ( Int fd );
953extern Int VG_(read) ( Int fd, void* buf, Int count);
954extern Int VG_(write) ( Int fd, void* buf, Int count);
sewardjb3586202002-05-09 17:38:13 +0000955extern Int VG_(stat) ( Char* file_name, struct vki_stat* buf );
sewardjde4a1d02002-03-22 01:27:54 +0000956
sewardj2e93c502002-04-12 11:12:52 +0000957extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg );
958
959extern Int VG_(select)( Int n,
960 vki_fd_set* readfds,
961 vki_fd_set* writefds,
962 vki_fd_set* exceptfds,
963 struct vki_timeval * timeout );
964extern Int VG_(nanosleep)( const struct vki_timespec *req,
965 struct vki_timespec *rem );
966
967
sewardjde4a1d02002-03-22 01:27:54 +0000968/* mmap-ery ... */
969extern void* VG_(mmap)( void* start, UInt length,
970 UInt prot, UInt flags, UInt fd, UInt offset );
971
sewardj2e93c502002-04-12 11:12:52 +0000972extern Int VG_(munmap)( void* start, Int length );
sewardjde4a1d02002-03-22 01:27:54 +0000973
sewardjb3586202002-05-09 17:38:13 +0000974extern void* VG_(brk) ( void* end_data_segment );
975
sewardjde4a1d02002-03-22 01:27:54 +0000976
977/* Print a (panic) message, and abort. */
978extern void VG_(panic) ( Char* str )
979 __attribute__ ((__noreturn__));
980
981/* Get memory by anonymous mmap. */
sewardje9047952002-06-05 20:28:33 +0000982extern void* VG_(get_memory_from_mmap) ( Int nBytes, Char* who );
sewardje6a25242002-04-21 22:03:07 +0000983
984/* Crude stand-in for the glibc system() call. */
985extern Int VG_(system) ( Char* cmd );
986
sewardjde4a1d02002-03-22 01:27:54 +0000987
988/* Signal stuff. Note that these use the vk_ (kernel) structure
989 definitions, which are different in places from those that glibc
990 defines. Since we're operating right at the kernel interface,
991 glibc's view of the world is entirely irrelevant. */
sewardj018f7622002-05-15 21:13:39 +0000992
993/* --- Signal set ops --- */
sewardjb48e5002002-05-13 00:16:03 +0000994extern Int VG_(ksigfillset)( vki_ksigset_t* set );
995extern Int VG_(ksigemptyset)( vki_ksigset_t* set );
sewardjde4a1d02002-03-22 01:27:54 +0000996
sewardj018f7622002-05-15 21:13:39 +0000997extern Bool VG_(kisfullsigset)( vki_ksigset_t* set );
998extern Bool VG_(kisemptysigset)( vki_ksigset_t* set );
999
1000extern Int VG_(ksigaddset)( vki_ksigset_t* set, Int signum );
1001extern Int VG_(ksigdelset)( vki_ksigset_t* set, Int signum );
1002extern Int VG_(ksigismember) ( vki_ksigset_t* set, Int signum );
1003
sewardjb48e5002002-05-13 00:16:03 +00001004extern void VG_(ksigaddset_from_set)( vki_ksigset_t* dst,
1005 vki_ksigset_t* src );
1006extern void VG_(ksigdelset_from_set)( vki_ksigset_t* dst,
1007 vki_ksigset_t* src );
1008
sewardj018f7622002-05-15 21:13:39 +00001009/* --- Mess with the kernel's sig state --- */
1010extern Int VG_(ksigprocmask)( Int how, const vki_ksigset_t* set,
1011 vki_ksigset_t* oldset );
1012extern Int VG_(ksigaction) ( Int signum,
1013 const vki_ksigaction* act,
1014 vki_ksigaction* oldact );
sewardjde4a1d02002-03-22 01:27:54 +00001015
1016extern Int VG_(ksignal)(Int signum, void (*sighandler)(Int));
1017
1018extern Int VG_(ksigaltstack)( const vki_kstack_t* ss, vki_kstack_t* oss );
1019
sewardj018f7622002-05-15 21:13:39 +00001020extern Int VG_(kill)( Int pid, Int signo );
sewardjefbfcdf2002-06-19 17:35:45 +00001021extern Int VG_(sigpending) ( vki_ksigset_t* set );
sewardjde4a1d02002-03-22 01:27:54 +00001022
1023
1024/* ---------------------------------------------------------------------
1025 Definitions for the JITter (vg_translate.c, vg_to_ucode.c,
1026 vg_from_ucode.c).
1027 ------------------------------------------------------------------ */
1028
1029/* Tags which describe what operands are. */
1030typedef
1031 enum { TempReg=0, ArchReg=1, RealReg=2,
1032 SpillNo=3, Literal=4, Lit16=5,
1033 NoValue=6 }
1034 Tag;
1035
1036
1037/* Microinstruction opcodes. */
1038typedef
1039 enum {
1040 NOP,
1041 GET,
1042 PUT,
1043 LOAD,
1044 STORE,
1045 MOV,
1046 CMOV, /* Used for cmpxchg and cmov */
1047 WIDEN,
1048 JMP,
1049
1050 /* Read/write the %EFLAGS register into a TempReg. */
1051 GETF, PUTF,
1052
1053 ADD, ADC, AND, OR, XOR, SUB, SBB,
1054 SHL, SHR, SAR, ROL, ROR, RCL, RCR,
1055 NOT, NEG, INC, DEC, BSWAP,
1056 CC2VAL,
1057
1058 /* Not strictly needed, but useful for making better
1059 translations of address calculations. */
1060 LEA1, /* reg2 := const + reg1 */
1061 LEA2, /* reg3 := const + reg1 + reg2 * 1,2,4 or 8 */
1062
1063 /* not for translating x86 calls -- only to call helpers */
1064 CALLM_S, CALLM_E, /* Mark start and end of push/pop sequences
1065 for CALLM. */
1066 PUSH, POP, CLEAR, /* Add/remove/zap args for helpers. */
1067 CALLM, /* call to a machine-code helper */
1068
1069 /* Hack for translating string (REP-) insns. Jump to literal if
1070 TempReg/RealReg is zero. */
1071 JIFZ,
1072
1073 /* FPU ops which read/write mem or don't touch mem at all. */
1074 FPU_R,
1075 FPU_W,
1076 FPU,
1077
1078 /* Advance the simulated %eip by some small (< 128) number. */
1079 INCEIP,
1080
1081 /* uinstrs which are not needed for mere translation of x86 code,
1082 only for instrumentation of it. */
1083 LOADV,
1084 STOREV,
1085 GETV,
1086 PUTV,
1087 TESTV,
1088 SETV,
1089 /* Get/set the v-bit (and it is only one bit) for the simulated
1090 %eflags register. */
1091 GETVF,
1092 PUTVF,
1093
1094 /* Do a unary or binary tag op. Only for post-instrumented
1095 code. For TAG1, first and only arg is a TempReg, and is both
1096 arg and result reg. For TAG2, first arg is src, second is
1097 dst, in the normal way; both are TempRegs. In both cases,
1098 3rd arg is a RiCHelper with a Lit16 tag. This indicates
1099 which tag op to do. */
1100 TAG1,
1101 TAG2
1102 }
1103 Opcode;
1104
1105
1106/* Condition codes, observing the Intel encoding. CondAlways is an
1107 extra. */
1108typedef
1109 enum {
1110 CondO = 0, /* overflow */
1111 CondNO = 1, /* no overflow */
1112 CondB = 2, /* below */
1113 CondNB = 3, /* not below */
1114 CondZ = 4, /* zero */
1115 CondNZ = 5, /* not zero */
1116 CondBE = 6, /* below or equal */
1117 CondNBE = 7, /* not below or equal */
1118 CondS = 8, /* negative */
1119 ConsNS = 9, /* not negative */
1120 CondP = 10, /* parity even */
1121 CondNP = 11, /* not parity even */
1122 CondL = 12, /* jump less */
1123 CondNL = 13, /* not less */
1124 CondLE = 14, /* less or equal */
1125 CondNLE = 15, /* not less or equal */
1126 CondAlways = 16 /* Jump always */
1127 }
1128 Condcode;
1129
1130
sewardj2e93c502002-04-12 11:12:52 +00001131/* Descriptions of additional properties of *unconditional* jumps. */
1132typedef
1133 enum {
1134 JmpBoring=0, /* boring unconditional jump */
1135 JmpCall=1, /* jump due to an x86 call insn */
1136 JmpRet=2, /* jump due to an x86 ret insn */
1137 JmpSyscall=3, /* do a system call, then jump */
1138 JmpClientReq=4 /* do a client request, then jump */
1139 }
1140 JmpKind;
1141
1142
sewardjde4a1d02002-03-22 01:27:54 +00001143/* Flags. User-level code can only read/write O(verflow), S(ign),
1144 Z(ero), A(ux-carry), C(arry), P(arity), and may also write
1145 D(irection). That's a total of 7 flags. A FlagSet is a bitset,
1146 thusly:
1147 76543210
1148 DOSZACP
1149 and bit 7 must always be zero since it is unused.
1150*/
1151typedef UChar FlagSet;
1152
1153#define FlagD (1<<6)
1154#define FlagO (1<<5)
1155#define FlagS (1<<4)
1156#define FlagZ (1<<3)
1157#define FlagA (1<<2)
1158#define FlagC (1<<1)
1159#define FlagP (1<<0)
1160
1161#define FlagsOSZACP (FlagO | FlagS | FlagZ | FlagA | FlagC | FlagP)
1162#define FlagsOSZAP (FlagO | FlagS | FlagZ | FlagA | FlagP)
1163#define FlagsOSZCP (FlagO | FlagS | FlagZ | FlagC | FlagP)
1164#define FlagsOSACP (FlagO | FlagS | FlagA | FlagC | FlagP)
1165#define FlagsSZACP ( FlagS | FlagZ | FlagA | FlagC | FlagP)
1166#define FlagsSZAP ( FlagS | FlagZ | FlagA | FlagP)
sewardj4a7456e2002-03-24 13:52:19 +00001167#define FlagsZCP ( FlagZ | FlagC | FlagP)
sewardjde4a1d02002-03-22 01:27:54 +00001168#define FlagsOC (FlagO | FlagC )
sewardj4d0ab1f2002-03-24 10:00:09 +00001169#define FlagsAC ( FlagA | FlagC )
sewardjde4a1d02002-03-22 01:27:54 +00001170
1171#define FlagsALL (FlagsOSZACP | FlagD)
1172#define FlagsEmpty (FlagSet)0
1173
1174#define VG_IS_FLAG_SUBSET(set1,set2) \
1175 (( ((FlagSet)set1) & ((FlagSet)set2) ) == ((FlagSet)set1) )
1176
1177#define VG_UNION_FLAG_SETS(set1,set2) \
1178 ( ((FlagSet)set1) | ((FlagSet)set2) )
1179
1180
1181
1182/* A Micro (u)-instruction. */
1183typedef
1184 struct {
1185 /* word 1 */
1186 UInt lit32; /* 32-bit literal */
1187
1188 /* word 2 */
1189 UShort val1; /* first operand */
1190 UShort val2; /* second operand */
1191
1192 /* word 3 */
1193 UShort val3; /* third operand */
1194 UChar opcode; /* opcode */
1195 UChar size; /* data transfer size */
1196
1197 /* word 4 */
1198 FlagSet flags_r; /* :: FlagSet */
1199 FlagSet flags_w; /* :: FlagSet */
1200 UChar tag1:4; /* first operand tag */
1201 UChar tag2:4; /* second operand tag */
1202 UChar tag3:4; /* third operand tag */
1203 UChar extra4b:4; /* Spare field, used by WIDEN for src
1204 -size, and by LEA2 for scale
njn4f9c9342002-04-29 16:03:24 +00001205 (1,2,4 or 8), and by unconditional JMPs for
1206 orig x86 instr size if --cachesim=yes */
1207
sewardjde4a1d02002-03-22 01:27:54 +00001208
1209 /* word 5 */
1210 UChar cond; /* condition, for jumps */
1211 Bool smc_check:1; /* do a smc test, if writes memory. */
1212 Bool signed_widen:1; /* signed or unsigned WIDEN ? */
sewardj2e93c502002-04-12 11:12:52 +00001213 JmpKind jmpkind:3; /* additional properties of unconditional JMP */
sewardjde4a1d02002-03-22 01:27:54 +00001214 }
1215 UInstr;
1216
1217
1218/* Expandable arrays of uinstrs. */
1219typedef
1220 struct {
1221 Int used;
1222 Int size;
1223 UInstr* instrs;
1224 Int nextTemp;
1225 }
1226 UCodeBlock;
1227
1228/* Refer to `the last instruction stuffed in', including as an
1229 lvalue. */
1230#define LAST_UINSTR(cb) (cb)->instrs[(cb)->used-1]
1231
1232/* An invalid temporary number :-) */
1233#define INVALID_TEMPREG 999999999
1234
1235
1236/* ---------------------------------------------------------------------
1237 Exports of vg_demangle.c
1238 ------------------------------------------------------------------ */
1239
1240extern void VG_(demangle) ( Char* orig, Char* result, Int result_size );
1241
1242
1243/* ---------------------------------------------------------------------
1244 Exports of vg_from_ucode.c
1245 ------------------------------------------------------------------ */
1246
1247extern UChar* VG_(emit_code) ( UCodeBlock* cb, Int* nbytes );
1248
1249
1250/* ---------------------------------------------------------------------
1251 Exports of vg_to_ucode.c
1252 ------------------------------------------------------------------ */
1253
1254extern Int VG_(disBB) ( UCodeBlock* cb, Addr eip0 );
1255extern Char* VG_(nameOfIntReg) ( Int size, Int reg );
1256extern Char VG_(nameOfIntSize) ( Int size );
1257extern UInt VG_(extend_s_8to32) ( UInt x );
1258extern Int VG_(getNewTemp) ( UCodeBlock* cb );
1259extern Int VG_(getNewShadow) ( UCodeBlock* cb );
1260
1261#define SHADOW(tempreg) ((tempreg)+1)
1262
1263
1264/* ---------------------------------------------------------------------
1265 Exports of vg_translate.c
1266 ------------------------------------------------------------------ */
1267
sewardj1e8cdc92002-04-18 11:37:52 +00001268extern void VG_(translate) ( ThreadState* tst,
1269 Addr orig_addr,
sewardjde4a1d02002-03-22 01:27:54 +00001270 UInt* orig_size,
1271 Addr* trans_addr,
1272 UInt* trans_size );
1273
1274extern void VG_(emptyUInstr) ( UInstr* u );
1275extern void VG_(newUInstr0) ( UCodeBlock* cb, Opcode opcode, Int sz );
1276extern void VG_(newUInstr1) ( UCodeBlock* cb, Opcode opcode, Int sz,
1277 Tag tag1, UInt val1 );
1278extern void VG_(newUInstr2) ( UCodeBlock* cb, Opcode opcode, Int sz,
1279 Tag tag1, UInt val1,
1280 Tag tag2, UInt val2 );
1281extern void VG_(newUInstr3) ( UCodeBlock* cb, Opcode opcode, Int sz,
1282 Tag tag1, UInt val1,
1283 Tag tag2, UInt val2,
1284 Tag tag3, UInt val3 );
1285extern void VG_(setFlagRW) ( UInstr* u,
1286 FlagSet fr, FlagSet fw );
1287
1288extern void VG_(setLiteralField) ( UCodeBlock* cb, UInt lit32 );
1289extern Bool VG_(anyFlagUse) ( UInstr* u );
1290
1291
1292
1293extern void VG_(ppUInstr) ( Int instrNo, UInstr* u );
1294extern void VG_(ppUCodeBlock) ( UCodeBlock* cb, Char* title );
1295
njn4f9c9342002-04-29 16:03:24 +00001296extern UCodeBlock* VG_(allocCodeBlock) ( void );
1297extern void VG_(freeCodeBlock) ( UCodeBlock* cb );
1298extern void VG_(copyUInstr) ( UCodeBlock* cb, UInstr* instr );
1299
sewardjde4a1d02002-03-22 01:27:54 +00001300extern Char* VG_(nameCondcode) ( Condcode cond );
1301extern Bool VG_(saneUInstr) ( Bool beforeRA, UInstr* u );
1302extern Bool VG_(saneUCodeBlock) ( UCodeBlock* cb );
1303extern Char* VG_(nameUOpcode) ( Bool upper, Opcode opc );
1304extern Int VG_(rankToRealRegNo) ( Int rank );
1305
1306extern void* VG_(jitmalloc) ( Int nbytes );
1307extern void VG_(jitfree) ( void* ptr );
1308
1309
1310/* ---------------------------------------------------------------------
1311 Exports of vg_execontext.c.
1312 ------------------------------------------------------------------ */
1313
1314/* Records the PC and a bit of the call chain. The first 4 %eip
1315 values are used in comparisons do remove duplicate errors, and for
1316 comparing against suppression specifications. The rest are purely
1317 informational (but often important). */
1318
1319typedef
1320 struct _ExeContextRec {
1321 struct _ExeContextRec * next;
1322 /* The size of this array is VG_(clo_backtrace_size); at least
1323 2, at most VG_DEEPEST_BACKTRACE. [0] is the current %eip,
1324 [1] is its caller, [2] is the caller of [1], etc. */
1325 Addr eips[0];
1326 }
1327 ExeContext;
1328
1329
1330/* Initialise the ExeContext storage mechanism. */
1331extern void VG_(init_ExeContext_storage) ( void );
1332
1333/* Print stats (informational only). */
1334extern void VG_(show_ExeContext_stats) ( void );
1335
1336
1337/* Take a snapshot of the client's stack. Search our collection of
1338 ExeContexts to see if we already have it, and if not, allocate a
1339 new one. Either way, return a pointer to the context. */
sewardj8c824512002-04-14 04:16:48 +00001340extern ExeContext* VG_(get_ExeContext) ( Bool skip_top_frame,
1341 Addr eip, Addr ebp );
sewardjde4a1d02002-03-22 01:27:54 +00001342
1343/* Print an ExeContext. */
1344extern void VG_(pp_ExeContext) ( ExeContext* );
1345
1346/* Compare two ExeContexts, just comparing the top two callers. */
1347extern Bool VG_(eq_ExeContext_top2) ( ExeContext* e1, ExeContext* e2 );
1348
1349/* Compare two ExeContexts, just comparing the top four callers. */
1350extern Bool VG_(eq_ExeContext_top4) ( ExeContext* e1, ExeContext* e2 );
1351
1352/* Compare two ExeContexts, comparing all callers. */
1353extern Bool VG_(eq_ExeContext_all) ( ExeContext* e1, ExeContext* e2 );
1354
1355
1356
1357/* ---------------------------------------------------------------------
1358 Exports of vg_errcontext.c.
1359 ------------------------------------------------------------------ */
1360
1361extern void VG_(load_suppressions) ( void );
1362extern void VG_(show_all_errors) ( void );
1363extern void VG_(record_value_error) ( Int size );
sewardjaabd5ad2002-04-19 15:43:37 +00001364extern void VG_(record_free_error) ( ThreadState* tst, Addr a );
1365extern void VG_(record_freemismatch_error) ( ThreadState* tst, Addr a );
sewardjde4a1d02002-03-22 01:27:54 +00001366extern void VG_(record_address_error) ( Addr a, Int size,
1367 Bool isWrite );
sewardj1e8cdc92002-04-18 11:37:52 +00001368
1369extern void VG_(record_jump_error) ( ThreadState* tst, Addr a );
sewardj8c824512002-04-14 04:16:48 +00001370
1371extern void VG_(record_param_err) ( ThreadState* tst,
1372 Addr a,
sewardjde4a1d02002-03-22 01:27:54 +00001373 Bool isWriteLack,
1374 Char* msg );
sewardj8c824512002-04-14 04:16:48 +00001375extern void VG_(record_user_err) ( ThreadState* tst,
1376 Addr a, Bool isWriteLack );
sewardj4dced352002-06-04 22:54:20 +00001377extern void VG_(record_pthread_err) ( ThreadId tid, Char* msg );
1378
sewardjde4a1d02002-03-22 01:27:54 +00001379
1380
1381/* The classification of a faulting address. */
1382typedef
sewardjb581a132002-05-08 00:32:50 +00001383 enum { Undescribed, /* as-yet unclassified */
1384 Stack,
1385 Unknown, /* classification yielded nothing useful */
1386 Freed, Mallocd,
1387 UserG, UserS }
sewardjde4a1d02002-03-22 01:27:54 +00001388 AddrKind;
1389
1390/* Records info about a faulting address. */
1391typedef
1392 struct {
1393 /* ALL */
1394 AddrKind akind;
1395 /* Freed, Mallocd */
1396 Int blksize;
1397 /* Freed, Mallocd */
1398 Int rwoffset;
1399 /* Freed, Mallocd */
1400 ExeContext* lastchange;
sewardj1e8cdc92002-04-18 11:37:52 +00001401 /* Stack */
1402 ThreadId stack_tid;
sewardjb581a132002-05-08 00:32:50 +00001403 /* True if is just-below %esp -- could be a gcc bug. */
1404 Bool maybe_gcc;
sewardjde4a1d02002-03-22 01:27:54 +00001405 }
1406 AddrInfo;
1407
1408
1409/* ---------------------------------------------------------------------
1410 Exports of vg_clientperms.c
1411 ------------------------------------------------------------------ */
1412
1413extern Bool VG_(client_perm_maybe_describe)( Addr a, AddrInfo* ai );
1414
sewardj8c824512002-04-14 04:16:48 +00001415extern UInt VG_(handle_client_request) ( ThreadState* tst, UInt* arg_block );
sewardjde4a1d02002-03-22 01:27:54 +00001416
1417extern void VG_(delete_client_stack_blocks_following_ESP_change) ( void );
1418
1419extern void VG_(show_client_block_stats) ( void );
1420
1421
1422/* ---------------------------------------------------------------------
1423 Exports of vg_procselfmaps.c
1424 ------------------------------------------------------------------ */
1425
1426extern
1427void VG_(read_procselfmaps) (
1428 void (*record_mapping)( Addr, UInt, Char, Char, Char, UInt, UChar* )
1429);
1430
1431
1432/* ---------------------------------------------------------------------
1433 Exports of vg_symtab2.c
1434 ------------------------------------------------------------------ */
1435
1436/* We assume the executable is loaded here ... can't really find
1437 out. There is a hacky sanity check in vg_init_memory_audit()
1438 which should trip up most stupidities.
1439*/
1440#define VG_ASSUMED_EXE_BASE (Addr)0x8048000
1441
1442extern void VG_(read_symbols) ( void );
1443extern void VG_(mini_stack_dump) ( ExeContext* ec );
1444extern void VG_(what_obj_and_fun_is_this)
1445 ( Addr a,
1446 Char* obj_buf, Int n_obj_buf,
1447 Char* fun_buf, Int n_fun_buf );
njn4f9c9342002-04-29 16:03:24 +00001448extern Bool VG_(what_line_is_this) ( Addr a,
1449 UChar* filename, Int n_filename,
1450 UInt* lineno );
1451extern Bool VG_(what_fn_is_this) ( Bool no_demangle, Addr a,
1452 Char* fn_name, Int n_fn_name);
sewardjde4a1d02002-03-22 01:27:54 +00001453
sewardj18d75132002-05-16 11:06:21 +00001454extern Bool VG_(symtab_notify_munmap) ( Addr start, UInt length );
sewardjde4a1d02002-03-22 01:27:54 +00001455
1456
1457/* ---------------------------------------------------------------------
1458 Exports of vg_clientmalloc.c
1459 ------------------------------------------------------------------ */
1460
sewardjde4a1d02002-03-22 01:27:54 +00001461typedef
1462 enum {
1463 Vg_AllocMalloc = 0,
sewardj2e93c502002-04-12 11:12:52 +00001464 Vg_AllocNew = 1,
sewardjde4a1d02002-03-22 01:27:54 +00001465 Vg_AllocNewVec = 2
1466 }
1467 VgAllocKind;
1468
1469/* Description of a malloc'd chunk. */
1470typedef
1471 struct _ShadowChunk {
1472 struct _ShadowChunk* next;
1473 ExeContext* where; /* where malloc'd/free'd */
1474 UInt size : 30; /* size requested. */
1475 VgAllocKind allockind : 2; /* which wrapper did the allocation */
1476 Addr data; /* ptr to actual block. */
1477 }
1478 ShadowChunk;
1479
1480extern void VG_(clientmalloc_done) ( void );
1481extern void VG_(describe_addr) ( Addr a, AddrInfo* ai );
1482extern ShadowChunk** VG_(get_malloc_shadows) ( /*OUT*/ UInt* n_shadows );
1483
sewardj2e93c502002-04-12 11:12:52 +00001484/* These are called from the scheduler, when it intercepts a user
1485 request. */
sewardj8c824512002-04-14 04:16:48 +00001486extern void* VG_(client_malloc) ( ThreadState* tst,
1487 UInt size, VgAllocKind kind );
1488extern void* VG_(client_memalign) ( ThreadState* tst,
1489 UInt align, UInt size );
1490extern void VG_(client_free) ( ThreadState* tst,
1491 void* ptrV, VgAllocKind kind );
1492extern void* VG_(client_calloc) ( ThreadState* tst,
1493 UInt nmemb, UInt size1 );
1494extern void* VG_(client_realloc) ( ThreadState* tst,
1495 void* ptrV, UInt size_new );
sewardjde4a1d02002-03-22 01:27:54 +00001496
1497
1498/* ---------------------------------------------------------------------
1499 Exports of vg_main.c
1500 ------------------------------------------------------------------ */
1501
sewardjde4a1d02002-03-22 01:27:54 +00001502/* A structure used as an intermediary when passing the simulated
1503 CPU's state to some assembly fragments, particularly system calls.
1504 Stuff is copied from baseBlock to here, the assembly magic runs,
1505 and then the inverse copy is done. */
1506
1507extern UInt VG_(m_state_static) [8 /* int regs, in Intel order */
1508 + 1 /* %eflags */
1509 + 1 /* %eip */
1510 + VG_SIZE_OF_FPUSTATE_W /* FPU state */
1511 ];
1512
1513/* Handy fns for doing the copy back and forth. */
1514extern void VG_(copy_baseBlock_to_m_state_static) ( void );
1515extern void VG_(copy_m_state_static_to_baseBlock) ( void );
1516
sewardjde4a1d02002-03-22 01:27:54 +00001517/* Called when some unhandleable client behaviour is detected.
1518 Prints a msg and aborts. */
1519extern void VG_(unimplemented) ( Char* msg );
sewardjcfc39b22002-05-08 01:58:18 +00001520extern void VG_(nvidia_moan) ( void );
sewardjde4a1d02002-03-22 01:27:54 +00001521
1522/* The stack on which Valgrind runs. We can't use the same stack as the
1523 simulatee -- that's an important design decision. */
1524extern UInt VG_(stack)[10000];
1525
1526/* Similarly, we have to ask for signals to be delivered on an
1527 alternative stack, since it is possible, although unlikely, that
1528 we'll have to run client code from inside the Valgrind-installed
1529 signal handler. If this happens it will be done by
1530 vg_deliver_signal_immediately(). */
1531extern UInt VG_(sigstack)[10000];
1532
sewardjde4a1d02002-03-22 01:27:54 +00001533/* Holds client's %esp at the point we gained control. From this the
1534 client's argc, argv and envp are deduced. */
1535extern Addr VG_(esp_at_startup);
1536extern Int VG_(client_argc);
1537extern Char** VG_(client_argv);
1538extern Char** VG_(client_envp);
1539
1540/* Remove valgrind.so from a LD_PRELOAD=... string so child processes
sewardj3e1eb1f2002-05-18 13:14:17 +00001541 don't get traced into. Also mess up $libdir/valgrind so that our
1542 libpthread.so disappears from view. */
1543void VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH) ( Char* ld_preload_str,
1544 Char* ld_library_path_str );
sewardjde4a1d02002-03-22 01:27:54 +00001545
1546/* Something of a function looking for a home ... start up GDB. This
1547 is called from VG_(swizzle_esp_then_start_GDB) and so runs on the
1548 *client's* stack. This is necessary to give GDB the illusion that
1549 the client program really was running on the real cpu. */
1550extern void VG_(start_GDB_whilst_on_client_stack) ( void );
1551
1552/* Spew out vast amounts of junk during JITting? */
1553extern Bool VG_(disassemble);
1554
1555/* 64-bit counter for the number of basic blocks done. */
1556extern ULong VG_(bbs_done);
1557/* 64-bit counter for the number of bbs to go before a debug exit. */
1558extern ULong VG_(bbs_to_go);
1559
1560/* Counts downwards in vg_run_innerloop. */
1561extern UInt VG_(dispatch_ctr);
1562
sewardjde4a1d02002-03-22 01:27:54 +00001563/* Is the client running on the simulated CPU or the real one? */
1564extern Bool VG_(running_on_simd_CPU); /* Initially False */
1565
1566/* The current LRU epoch. */
1567extern UInt VG_(current_epoch);
1568
sewardj7e87e382002-05-03 19:09:05 +00001569/* This is the ThreadId of the last thread the scheduler ran. */
1570extern ThreadId VG_(last_run_tid);
1571
sewardjde4a1d02002-03-22 01:27:54 +00001572
1573/* --- Counters, for informational purposes only. --- */
1574
1575/* Number of lookups which miss the fast tt helper. */
1576extern UInt VG_(tt_fast_misses);
1577
1578/* Counts for LRU informational messages. */
1579
1580/* Number and total o/t size of new translations this epoch. */
1581extern UInt VG_(this_epoch_in_count);
1582extern UInt VG_(this_epoch_in_osize);
1583extern UInt VG_(this_epoch_in_tsize);
1584/* Number and total o/t size of discarded translations this epoch. */
1585extern UInt VG_(this_epoch_out_count);
1586extern UInt VG_(this_epoch_out_osize);
1587extern UInt VG_(this_epoch_out_tsize);
1588/* Number and total o/t size of translations overall. */
1589extern UInt VG_(overall_in_count);
1590extern UInt VG_(overall_in_osize);
1591extern UInt VG_(overall_in_tsize);
1592/* Number and total o/t size of discards overall. */
1593extern UInt VG_(overall_out_count);
1594extern UInt VG_(overall_out_osize);
1595extern UInt VG_(overall_out_tsize);
1596
1597/* The number of LRU-clearings of TT/TC. */
1598extern UInt VG_(number_of_lrus);
1599
1600/* Counts pertaining to the register allocator. */
1601
1602/* total number of uinstrs input to reg-alloc */
1603extern UInt VG_(uinstrs_prealloc);
1604
1605/* total number of uinstrs added due to spill code */
1606extern UInt VG_(uinstrs_spill);
1607
1608/* number of bbs requiring spill code */
1609extern UInt VG_(translations_needing_spill);
1610
1611/* total of register ranks over all translations */
1612extern UInt VG_(total_reg_rank);
1613
sewardjde4a1d02002-03-22 01:27:54 +00001614/* Counts pertaining to internal sanity checking. */
1615extern UInt VG_(sanity_fast_count);
1616extern UInt VG_(sanity_slow_count);
1617
sewardj2e93c502002-04-12 11:12:52 +00001618/* Counts pertaining to the scheduler. */
1619extern UInt VG_(num_scheduling_events_MINOR);
1620extern UInt VG_(num_scheduling_events_MAJOR);
1621
sewardjde4a1d02002-03-22 01:27:54 +00001622
1623/* ---------------------------------------------------------------------
1624 Exports of vg_memory.c
1625 ------------------------------------------------------------------ */
1626
1627extern void VGM_(init_memory_audit) ( void );
1628extern Addr VGM_(curr_dataseg_end);
1629extern void VG_(show_reg_tags) ( void );
1630extern void VG_(detect_memory_leaks) ( void );
1631extern void VG_(done_prof_mem) ( void );
1632
1633/* Set permissions for an address range. Not speed-critical. */
1634extern void VGM_(make_noaccess) ( Addr a, UInt len );
1635extern void VGM_(make_writable) ( Addr a, UInt len );
1636extern void VGM_(make_readable) ( Addr a, UInt len );
1637/* Use with care! (read: use for shmat only) */
1638extern void VGM_(make_readwritable) ( Addr a, UInt len );
1639extern void VGM_(copy_address_range_perms) ( Addr src, Addr dst,
1640 UInt len );
1641
1642/* Check permissions for an address range. Not speed-critical. */
1643extern Bool VGM_(check_writable) ( Addr a, UInt len, Addr* bad_addr );
1644extern Bool VGM_(check_readable) ( Addr a, UInt len, Addr* bad_addr );
1645extern Bool VGM_(check_readable_asciiz) ( Addr a, Addr* bad_addr );
1646
sewardj0c3b53f2002-05-01 01:58:35 +00001647/* Sanity checks which may be done at any time. The scheduler decides
1648 when. */
1649extern void VG_(do_sanity_checks) ( Bool force_expensive );
sewardjde4a1d02002-03-22 01:27:54 +00001650/* Very cheap ... */
1651extern Bool VG_(first_and_last_secondaries_look_plausible) ( void );
1652
1653/* These functions are called from generated code. */
1654extern void VG_(helperc_STOREV4) ( UInt, Addr );
1655extern void VG_(helperc_STOREV2) ( UInt, Addr );
1656extern void VG_(helperc_STOREV1) ( UInt, Addr );
1657
1658extern UInt VG_(helperc_LOADV1) ( Addr );
1659extern UInt VG_(helperc_LOADV2) ( Addr );
1660extern UInt VG_(helperc_LOADV4) ( Addr );
1661
1662extern void VGM_(handle_esp_assignment) ( Addr new_espA );
1663extern void VGM_(fpu_write_check) ( Addr addr, Int size );
1664extern void VGM_(fpu_read_check) ( Addr addr, Int size );
1665
1666/* Safely (avoiding SIGSEGV / SIGBUS) scan the entire valid address
1667 space and pass the addresses and values of all addressible,
1668 defined, aligned words to notify_word. This is the basis for the
1669 leak detector. Returns the number of calls made to notify_word. */
1670UInt VG_(scan_all_valid_memory) ( void (*notify_word)( Addr, UInt ) );
1671
1672/* Is this address within some small distance below %ESP? Used only
1673 for the --workaround-gcc296-bugs kludge. */
sewardj8c824512002-04-14 04:16:48 +00001674extern Bool VG_(is_just_below_ESP)( Addr esp, Addr aa );
sewardjde4a1d02002-03-22 01:27:54 +00001675
1676/* Nasty kludgery to deal with applications which switch stacks,
1677 like netscape. */
sewardjde4a1d02002-03-22 01:27:54 +00001678#define VG_PLAUSIBLE_STACK_SIZE 8000000
1679
sewardjc3bd5f52002-05-01 03:24:23 +00001680/* Needed by the pthreads implementation. */
1681#define VGM_WORD_VALID 0
1682#define VGM_WORD_INVALID 0xFFFFFFFF
1683
sewardjde4a1d02002-03-22 01:27:54 +00001684
1685/* ---------------------------------------------------------------------
1686 Exports of vg_syscall_mem.c
1687 ------------------------------------------------------------------ */
1688
sewardj2e93c502002-04-12 11:12:52 +00001689extern void VG_(perform_assumed_nonblocking_syscall) ( ThreadId tid );
sewardjde4a1d02002-03-22 01:27:54 +00001690
sewardj2e93c502002-04-12 11:12:52 +00001691extern void VG_(check_known_blocking_syscall) ( ThreadId tid,
1692 Int syscallno,
1693 Int* /*IN*/ res );
sewardjde4a1d02002-03-22 01:27:54 +00001694
1695extern Bool VG_(is_kerror) ( Int res );
1696
sewardj018f7622002-05-15 21:13:39 +00001697#define KERNEL_DO_SYSCALL(thread_id, result_lvalue) \
1698 VG_(load_thread_state)(thread_id); \
1699 VG_(copy_baseBlock_to_m_state_static)(); \
1700 VG_(do_syscall)(); \
1701 VG_(copy_m_state_static_to_baseBlock)(); \
1702 VG_(save_thread_state)(thread_id); \
1703 VG_(threads)[thread_id].sh_eax = VGM_WORD_VALID; \
1704 result_lvalue = VG_(threads)[thread_id].m_eax;
sewardjde4a1d02002-03-22 01:27:54 +00001705
1706
1707/* ---------------------------------------------------------------------
1708 Exports of vg_transtab.c
1709 ------------------------------------------------------------------ */
1710
1711/* An entry in the translation table (TT). */
1712typedef
1713 struct {
1714 /* +0 */ Addr orig_addr;
1715 /* +4 */ Addr trans_addr;
1716 /* +8 */ UInt mru_epoch;
1717 /* +12 */ UShort orig_size;
1718 /* +14 */ UShort trans_size;
1719 }
1720 TTEntry;
1721
1722/* The number of basic blocks in an epoch (one age-step). */
1723#define VG_BBS_PER_EPOCH 20000
1724
1725extern void VG_(get_tt_tc_used) ( UInt* tt_used, UInt* tc_used );
1726extern void VG_(maybe_do_lru_pass) ( void );
1727extern void VG_(flush_transtab) ( void );
1728extern Addr VG_(copy_to_transcache) ( Addr trans_addr, Int trans_size );
1729extern void VG_(add_to_trans_tab) ( TTEntry* tte );
sewardj18d75132002-05-16 11:06:21 +00001730extern void VG_(invalidate_translations) ( Addr start, UInt range );
sewardjde4a1d02002-03-22 01:27:54 +00001731
sewardj18d75132002-05-16 11:06:21 +00001732extern void VG_(init_tt_tc) ( void );
sewardjde4a1d02002-03-22 01:27:54 +00001733
1734extern void VG_(sanity_check_tc_tt) ( void );
1735extern Addr VG_(search_transtab) ( Addr original_addr );
1736
1737extern void VG_(invalidate_tt_fast)( void );
1738
1739
1740/* ---------------------------------------------------------------------
1741 Exports of vg_vtagops.c
1742 ------------------------------------------------------------------ */
1743
1744/* Lists the names of value-tag operations used in instrumented
1745 code. These are the third argument to TAG1 and TAG2 uinsns. */
1746
1747typedef
1748 enum {
1749 /* Unary. */
1750 VgT_PCast40, VgT_PCast20, VgT_PCast10,
1751 VgT_PCast01, VgT_PCast02, VgT_PCast04,
1752
1753 VgT_PCast14, VgT_PCast12, VgT_PCast11,
1754
1755 VgT_Left4, VgT_Left2, VgT_Left1,
1756
1757 VgT_SWiden14, VgT_SWiden24, VgT_SWiden12,
1758 VgT_ZWiden14, VgT_ZWiden24, VgT_ZWiden12,
1759
1760 /* Binary; 1st is rd; 2nd is rd+wr */
1761 VgT_UifU4, VgT_UifU2, VgT_UifU1, VgT_UifU0,
1762 VgT_DifD4, VgT_DifD2, VgT_DifD1,
1763
1764 VgT_ImproveAND4_TQ, VgT_ImproveAND2_TQ, VgT_ImproveAND1_TQ,
1765 VgT_ImproveOR4_TQ, VgT_ImproveOR2_TQ, VgT_ImproveOR1_TQ,
1766 VgT_DebugFn
1767 }
1768 VgTagOp;
1769
1770extern Char* VG_(nameOfTagOp) ( VgTagOp );
1771extern UInt VG_(DebugFn) ( UInt a1, UInt a2 );
1772
1773
1774/* ---------------------------------------------------------------------
1775 Exports of vg_syscall.S
1776 ------------------------------------------------------------------ */
1777
1778extern void VG_(do_syscall) ( void );
1779
1780
1781/* ---------------------------------------------------------------------
1782 Exports of vg_startup.S
1783 ------------------------------------------------------------------ */
1784
sewardjde4a1d02002-03-22 01:27:54 +00001785extern void VG_(switch_to_real_CPU) ( void );
1786
sewardj35805422002-04-21 13:05:34 +00001787extern void VG_(swizzle_esp_then_start_GDB) ( Addr m_eip_at_error,
1788 Addr m_esp_at_error,
1789 Addr m_ebp_at_error );
sewardjde4a1d02002-03-22 01:27:54 +00001790
1791
1792/* ---------------------------------------------------------------------
1793 Exports of vg_dispatch.S
1794 ------------------------------------------------------------------ */
1795
sewardj2e93c502002-04-12 11:12:52 +00001796/* Run a thread for a (very short) while, until some event happens
1797 which means we need to defer to the scheduler. */
1798extern UInt VG_(run_innerloop) ( void );
sewardjde4a1d02002-03-22 01:27:54 +00001799
1800
1801/* ---------------------------------------------------------------------
1802 Exports of vg_helpers.S
1803 ------------------------------------------------------------------ */
1804
sewardjde4a1d02002-03-22 01:27:54 +00001805/* Mul, div, etc, -- we don't codegen these directly. */
1806extern void VG_(helper_idiv_64_32);
1807extern void VG_(helper_div_64_32);
1808extern void VG_(helper_idiv_32_16);
1809extern void VG_(helper_div_32_16);
1810extern void VG_(helper_idiv_16_8);
1811extern void VG_(helper_div_16_8);
1812
1813extern void VG_(helper_imul_32_64);
1814extern void VG_(helper_mul_32_64);
1815extern void VG_(helper_imul_16_32);
1816extern void VG_(helper_mul_16_32);
1817extern void VG_(helper_imul_8_16);
1818extern void VG_(helper_mul_8_16);
1819
1820extern void VG_(helper_CLD);
1821extern void VG_(helper_STD);
1822extern void VG_(helper_get_dirflag);
1823
sewardj7d78e782002-06-02 00:04:00 +00001824extern void VG_(helper_CLC);
1825extern void VG_(helper_STC);
1826
sewardjde4a1d02002-03-22 01:27:54 +00001827extern void VG_(helper_shldl);
1828extern void VG_(helper_shldw);
1829extern void VG_(helper_shrdl);
1830extern void VG_(helper_shrdw);
1831
1832extern void VG_(helper_RDTSC);
1833extern void VG_(helper_CPUID);
1834
sewardjde4a1d02002-03-22 01:27:54 +00001835extern void VG_(helper_bsf);
1836extern void VG_(helper_bsr);
1837
1838extern void VG_(helper_fstsw_AX);
1839extern void VG_(helper_SAHF);
sewardj4d0ab1f2002-03-24 10:00:09 +00001840extern void VG_(helper_DAS);
sewardjfe8a1662002-03-24 11:54:07 +00001841extern void VG_(helper_DAA);
sewardjde4a1d02002-03-22 01:27:54 +00001842
1843extern void VG_(helper_value_check4_fail);
1844extern void VG_(helper_value_check2_fail);
1845extern void VG_(helper_value_check1_fail);
1846extern void VG_(helper_value_check0_fail);
1847
sewardj20917d82002-05-28 01:36:45 +00001848/* NOT A FUNCTION; this is a bogus RETURN ADDRESS. */
sewardj54cacf02002-04-12 23:24:59 +00001849extern void VG_(signalreturn_bogusRA)( void );
sewardj20917d82002-05-28 01:36:45 +00001850
sewardj54cacf02002-04-12 23:24:59 +00001851
njn4f9c9342002-04-29 16:03:24 +00001852/* ---------------------------------------------------------------------
1853 Exports of vg_cachesim.c
1854 ------------------------------------------------------------------ */
1855
sewardj07133bf2002-06-13 10:25:56 +00001856extern Int VG_(log2) ( Int x );
njn7cf0bd32002-06-08 13:36:03 +00001857
sewardj07133bf2002-06-13 10:25:56 +00001858extern UCodeBlock* VG_(cachesim_instrument) ( UCodeBlock* cb_in,
1859 Addr orig_addr );
njn4f9c9342002-04-29 16:03:24 +00001860
1861typedef struct _iCC iCC;
1862typedef struct _idCC idCC;
1863
njn7cf0bd32002-06-08 13:36:03 +00001864extern void VG_(init_cachesim) ( void );
1865extern void VG_(do_cachesim_results)( Int client_argc, Char** client_argv );
njn4f9c9342002-04-29 16:03:24 +00001866
1867extern void VG_(cachesim_log_non_mem_instr)( iCC* cc );
1868extern void VG_(cachesim_log_mem_instr) ( idCC* cc, Addr data_addr );
sewardjde4a1d02002-03-22 01:27:54 +00001869
sewardj18d75132002-05-16 11:06:21 +00001870extern void VG_(cachesim_notify_discard) ( TTEntry* tte );
1871
1872
sewardjde4a1d02002-03-22 01:27:54 +00001873/* ---------------------------------------------------------------------
1874 The state of the simulated CPU.
1875 ------------------------------------------------------------------ */
1876
1877/* This is the Intel register encoding. */
1878#define R_EAX 0
1879#define R_ECX 1
1880#define R_EDX 2
1881#define R_EBX 3
1882#define R_ESP 4
1883#define R_EBP 5
1884#define R_ESI 6
1885#define R_EDI 7
1886
1887#define R_AL (0+R_EAX)
1888#define R_CL (0+R_ECX)
1889#define R_DL (0+R_EDX)
1890#define R_BL (0+R_EBX)
1891#define R_AH (4+R_EAX)
1892#define R_CH (4+R_ECX)
1893#define R_DH (4+R_EDX)
1894#define R_BH (4+R_EBX)
1895
1896
1897/* ---------------------------------------------------------------------
1898 Offsets into baseBlock for everything which needs to referred to
1899 from generated code. The order of these decls does not imply
1900 what the order of the actual offsets is. The latter is important
1901 and is set up in vg_main.c.
1902 ------------------------------------------------------------------ */
1903
1904/* An array of words. In generated code, %ebp always points to the
1905 start of this array. Useful stuff, like the simulated CPU state,
1906 and the addresses of helper functions, can then be found by
1907 indexing off %ebp. The following declares variables which, at
1908 startup time, are given values denoting offsets into baseBlock.
1909 These offsets are in *words* from the start of baseBlock. */
1910
1911#define VG_BASEBLOCK_WORDS 200
1912
1913extern UInt VG_(baseBlock)[VG_BASEBLOCK_WORDS];
1914
1915
1916/* -----------------------------------------------------
1917 Read-write parts of baseBlock.
1918 -------------------------------------------------- */
1919
1920/* State of the simulated CPU. */
1921extern Int VGOFF_(m_eax);
1922extern Int VGOFF_(m_ecx);
1923extern Int VGOFF_(m_edx);
1924extern Int VGOFF_(m_ebx);
1925extern Int VGOFF_(m_esp);
1926extern Int VGOFF_(m_ebp);
1927extern Int VGOFF_(m_esi);
1928extern Int VGOFF_(m_edi);
1929extern Int VGOFF_(m_eflags);
1930extern Int VGOFF_(m_fpustate);
1931extern Int VGOFF_(m_eip);
1932
1933/* Reg-alloc spill area (VG_MAX_SPILLSLOTS words long). */
1934extern Int VGOFF_(spillslots);
1935
1936/* Records the valid bits for the 8 integer regs & flags reg. */
1937extern Int VGOFF_(sh_eax);
1938extern Int VGOFF_(sh_ecx);
1939extern Int VGOFF_(sh_edx);
1940extern Int VGOFF_(sh_ebx);
1941extern Int VGOFF_(sh_esp);
1942extern Int VGOFF_(sh_ebp);
1943extern Int VGOFF_(sh_esi);
1944extern Int VGOFF_(sh_edi);
1945extern Int VGOFF_(sh_eflags);
1946
1947
1948/* -----------------------------------------------------
1949 Read-only parts of baseBlock.
1950 -------------------------------------------------- */
1951
1952/* Offsets of addresses of helper functions. A "helper" function is
1953 one which is called from generated code. */
1954
1955extern Int VGOFF_(helper_idiv_64_32);
1956extern Int VGOFF_(helper_div_64_32);
1957extern Int VGOFF_(helper_idiv_32_16);
1958extern Int VGOFF_(helper_div_32_16);
1959extern Int VGOFF_(helper_idiv_16_8);
1960extern Int VGOFF_(helper_div_16_8);
1961
1962extern Int VGOFF_(helper_imul_32_64);
1963extern Int VGOFF_(helper_mul_32_64);
1964extern Int VGOFF_(helper_imul_16_32);
1965extern Int VGOFF_(helper_mul_16_32);
1966extern Int VGOFF_(helper_imul_8_16);
1967extern Int VGOFF_(helper_mul_8_16);
1968
1969extern Int VGOFF_(helper_CLD);
1970extern Int VGOFF_(helper_STD);
1971extern Int VGOFF_(helper_get_dirflag);
1972
sewardj7d78e782002-06-02 00:04:00 +00001973extern Int VGOFF_(helper_CLC);
1974extern Int VGOFF_(helper_STC);
1975
sewardjde4a1d02002-03-22 01:27:54 +00001976extern Int VGOFF_(helper_shldl);
1977extern Int VGOFF_(helper_shldw);
1978extern Int VGOFF_(helper_shrdl);
1979extern Int VGOFF_(helper_shrdw);
1980
1981extern Int VGOFF_(helper_RDTSC);
1982extern Int VGOFF_(helper_CPUID);
1983
sewardjde4a1d02002-03-22 01:27:54 +00001984extern Int VGOFF_(helper_bsf);
1985extern Int VGOFF_(helper_bsr);
1986
1987extern Int VGOFF_(helper_fstsw_AX);
1988extern Int VGOFF_(helper_SAHF);
sewardj4d0ab1f2002-03-24 10:00:09 +00001989extern Int VGOFF_(helper_DAS);
sewardjfe8a1662002-03-24 11:54:07 +00001990extern Int VGOFF_(helper_DAA);
sewardjde4a1d02002-03-22 01:27:54 +00001991
1992extern Int VGOFF_(helper_value_check4_fail);
1993extern Int VGOFF_(helper_value_check2_fail);
1994extern Int VGOFF_(helper_value_check1_fail);
1995extern Int VGOFF_(helper_value_check0_fail);
1996
sewardjde4a1d02002-03-22 01:27:54 +00001997extern Int VGOFF_(helperc_STOREV4); /* :: UInt -> Addr -> void */
1998extern Int VGOFF_(helperc_STOREV2); /* :: UInt -> Addr -> void */
1999extern Int VGOFF_(helperc_STOREV1); /* :: UInt -> Addr -> void */
2000
2001extern Int VGOFF_(helperc_LOADV4); /* :: Addr -> UInt -> void */
2002extern Int VGOFF_(helperc_LOADV2); /* :: Addr -> UInt -> void */
2003extern Int VGOFF_(helperc_LOADV1); /* :: Addr -> UInt -> void */
2004
2005extern Int VGOFF_(handle_esp_assignment); /* :: Addr -> void */
2006extern Int VGOFF_(fpu_write_check); /* :: Addr -> Int -> void */
2007extern Int VGOFF_(fpu_read_check); /* :: Addr -> Int -> void */
2008
njn4f9c9342002-04-29 16:03:24 +00002009extern Int VGOFF_(cachesim_log_non_mem_instr);
2010extern Int VGOFF_(cachesim_log_mem_instr);
sewardjde4a1d02002-03-22 01:27:54 +00002011
2012#endif /* ndef __VG_INCLUDE_H */
2013
sewardj3b2736a2002-03-24 12:18:35 +00002014
2015/* ---------------------------------------------------------------------
2016 Finally - autoconf-generated settings
2017 ------------------------------------------------------------------ */
2018
2019#include "config.h"
2020
sewardjde4a1d02002-03-22 01:27:54 +00002021/*--------------------------------------------------------------------*/
2022/*--- end vg_include.h ---*/
2023/*--------------------------------------------------------------------*/