blob: ee7adfae1158404be78fa2168593dc006b98a043 [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/* ---------------------------------------------------------------------
42 Build options and table sizes. You should be able to change these
43 options or sizes, recompile, and still have a working system.
44 ------------------------------------------------------------------ */
45
46#include "vg_constants.h"
47
48
49/* Set to 1 to enable time profiling. Since this uses SIGPROF, we
50 don't want this permanently enabled -- only for profiling
51 builds. */
52#if 0
53# define VG_PROFILE
54#endif
55
56
57/* Total number of integer registers available for allocation. That's
58 all of them except %esp, %edi and %ebp. %edi is a general spare
59 temporary. %ebp permanently points at VG_(baseBlock). Note that
60 it's important that this tie in with what rankToRealRegNo() says.
61 DO NOT CHANGE THIS VALUE FROM 5. ! */
62#define VG_MAX_REALREGS 5
63
64/* Total number of spill slots available for allocation, if a TempReg
65 doesn't make it into a RealReg. Just bomb the entire system if
66 this value is too small; we don't expect it will ever get
67 particularly high. */
68#define VG_MAX_SPILLSLOTS 24
69
70
71/* Constants for the slow translation lookup cache. */
72#define VG_TRANSTAB_SLOW_BITS 11
73#define VG_TRANSTAB_SLOW_SIZE (1 << VG_TRANSTAB_SLOW_BITS)
74#define VG_TRANSTAB_SLOW_MASK ((VG_TRANSTAB_SLOW_SIZE) - 1)
75
76/* Size of a buffer used for creating messages. */
77#define M_VG_MSGBUF 10000
78
79/* Size of a smallish table used to read /proc/self/map entries. */
80#define M_PROCMAP_BUF 20000
81
82/* Max length of pathname to a .so/executable file. */
83#define M_VG_LIBNAMESTR 100
84
85/* Max length of a text fragment used to construct error messages. */
86#define M_VG_ERRTXT 512
87
88/* Max length of the string copied from env var VG_ARGS at startup. */
89#define M_VG_CMDLINE_STRLEN 1000
90
91/* Max number of options for Valgrind which we can handle. */
92#define M_VG_CMDLINE_OPTS 100
93
94/* After this many different unsuppressed errors have been observed,
95 be more conservative about collecting new ones. */
96#define M_VG_COLLECT_ERRORS_SLOWLY_AFTER 50
97
98/* After this many different unsuppressed errors have been observed,
99 stop collecting errors at all, and tell the user their program is
100 evidently a steaming pile of camel dung. */
101#define M_VG_COLLECT_NO_ERRORS_AFTER 500
102
103/* These many bytes below %ESP are considered addressible if we're
104 doing the --workaround-gcc296-bugs hack. */
105#define VG_GCC296_BUG_STACK_SLOP 256
106
107/* The maximum number of calls we're prepared to save in a
108 backtrace. */
109#define VG_DEEPEST_BACKTRACE 50
110
111/* Number of lists in which we keep track of malloc'd but not free'd
112 blocks. Should be prime. */
113#define VG_N_MALLOCLISTS 997
114
115/* Number of lists in which we keep track of ExeContexts. Should be
116 prime. */
117#define VG_N_EC_LISTS /*997*/ 4999
118
sewardj2e93c502002-04-12 11:12:52 +0000119/* Defines the thread-scheduling timeslice, in terms of the number of
120 basic blocks we attempt to run each thread for. Smaller values
121 give finer interleaving but much increased scheduling overheads. */
122#define VG_SCHEDULING_QUANTUM 10000
123
124/* The maximum number of pthreads that we support. This is
125 deliberately not very high since our implementation of some of the
126 scheduler algorithms is surely O(N^2) in the number of threads,
127 since that's simple, at least. And (in practice) we hope that most
128 programs do not need many threads. */
sewardj3b5d8862002-04-20 13:53:23 +0000129#define VG_N_THREADS 20
sewardj2e93c502002-04-12 11:12:52 +0000130
131/* Number of file descriptors that can simultaneously be waited on for
132 I/O to complete. Perhaps this should be the same as VG_N_THREADS
133 (surely a thread can't wait on more than one fd at once?. Who
134 knows.) */
135#define VG_N_WAITING_FDS 10
136
sewardjde4a1d02002-03-22 01:27:54 +0000137
138/* ---------------------------------------------------------------------
139 Basic types
140 ------------------------------------------------------------------ */
141
142typedef unsigned char UChar;
143typedef unsigned short UShort;
144typedef unsigned int UInt;
145typedef unsigned long long int ULong;
146
147typedef signed char Char;
148typedef signed short Short;
149typedef signed int Int;
150typedef signed long long int Long;
151
152typedef unsigned int Addr;
153
154typedef unsigned char Bool;
155#define False ((Bool)0)
156#define True ((Bool)1)
157
158#define mycat_wrk(aaa,bbb) aaa##bbb
159#define mycat(aaa,bbb) mycat_wrk(aaa,bbb)
160
161/* Just pray that gcc's constant folding works properly ... */
162#define BITS(bit7,bit6,bit5,bit4,bit3,bit2,bit1,bit0) \
163 ( ((bit7) << 7) | ((bit6) << 6) | ((bit5) << 5) | ((bit4) << 4) \
164 | ((bit3) << 3) | ((bit2) << 2) | ((bit1) << 1) | (bit0))
165
166
167/* ---------------------------------------------------------------------
168 Now the basic types are set up, we can haul in the kernel-interface
169 definitions.
170 ------------------------------------------------------------------ */
171
172#include "./vg_kerneliface.h"
173
174
175/* ---------------------------------------------------------------------
176 Command-line-settable options
177 ------------------------------------------------------------------ */
178
179#define VG_CLO_SMC_NONE 0
180#define VG_CLO_SMC_SOME 1
181#define VG_CLO_SMC_ALL 2
182
183#define VG_CLO_MAX_SFILES 10
184
sewardj97ced732002-03-25 00:07:36 +0000185/* Shall we V-check addrs (they are always A checked too): default: YES */
186extern Bool VG_(clo_check_addrVs);
sewardjde4a1d02002-03-22 01:27:54 +0000187/* Enquire about whether to attach to GDB at errors? default: NO */
188extern Bool VG_(clo_GDB_attach);
189/* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */
190extern Int VG_(sanity_level);
191/* Verbosity level: 0 = silent, 1 (default), > 1 = more verbose. */
192extern Int VG_(clo_verbosity);
193/* Automatically attempt to demangle C++ names? default: YES */
194extern Bool VG_(clo_demangle);
195/* Do leak check at exit? default: NO */
196extern Bool VG_(clo_leak_check);
197/* In leak check, show reachable-but-not-freed blocks? default: NO */
198extern Bool VG_(clo_show_reachable);
199/* How closely should we compare ExeContexts in leak records? default: 2 */
200extern Int VG_(clo_leak_resolution);
201/* Round malloc sizes upwards to integral number of words? default:
202 NO */
203extern Bool VG_(clo_sloppy_malloc);
204/* Allow loads from partially-valid addresses? default: YES */
205extern Bool VG_(clo_partial_loads_ok);
206/* Simulate child processes? default: NO */
207extern Bool VG_(clo_trace_children);
208/* The file id on which we send all messages. default: 2 (stderr). */
209extern Int VG_(clo_logfile_fd);
210/* Max volume of the freed blocks queue. */
211extern Int VG_(clo_freelist_vol);
212/* Assume accesses immediately below %esp are due to gcc-2.96 bugs.
213 default: NO */
214extern Bool VG_(clo_workaround_gcc296_bugs);
215
216/* The number of suppression files specified. */
217extern Int VG_(clo_n_suppressions);
218/* The names of the suppression files. */
219extern Char* VG_(clo_suppressions)[VG_CLO_MAX_SFILES];
220
221/* Single stepping? default: NO */
222extern Bool VG_(clo_single_step);
223/* Code improvement? default: YES */
224extern Bool VG_(clo_optimise);
225/* Memory-check instrumentation? default: YES */
226extern Bool VG_(clo_instrument);
227/* DEBUG: clean up instrumented code? default: YES */
228extern Bool VG_(clo_cleanup);
sewardjde4a1d02002-03-22 01:27:54 +0000229/* SMC write checks? default: SOME (1,2,4 byte movs to mem) */
230extern Int VG_(clo_smc_check);
231/* DEBUG: print system calls? default: NO */
232extern Bool VG_(clo_trace_syscalls);
233/* DEBUG: print signal details? default: NO */
234extern Bool VG_(clo_trace_signals);
235/* DEBUG: print symtab details? default: NO */
236extern Bool VG_(clo_trace_symtab);
237/* DEBUG: print malloc details? default: NO */
238extern Bool VG_(clo_trace_malloc);
sewardj8937c812002-04-12 20:12:20 +0000239/* DEBUG: print thread scheduling events? default: NO */
240extern Bool VG_(clo_trace_sched);
sewardj45b4b372002-04-16 22:50:32 +0000241/* DEBUG: print pthread (mutex etc) events? default: 0 (none), 1
242 (some), 2 (all) */
243extern Int VG_(clo_trace_pthread_level);
sewardjde4a1d02002-03-22 01:27:54 +0000244/* Stop after this many basic blocks. default: Infinity. */
245extern ULong VG_(clo_stop_after);
246/* Display gory details for the k'th most popular error. default:
247 Infinity. */
248extern Int VG_(clo_dump_error);
249/* Number of parents of a backtrace. Default: 8. */
250extern Int VG_(clo_backtrace_size);
251
252
253/* ---------------------------------------------------------------------
254 Debugging and profiling stuff
255 ------------------------------------------------------------------ */
256
257/* No, really. I _am_ that strange. */
258#define OINK(nnn) VG_(message)(Vg_DebugMsg, "OINK %d",nnn)
259
260/* Tools for building messages from multiple parts. */
261typedef
262 enum { Vg_UserMsg, Vg_DebugMsg, Vg_DebugExtraMsg }
263 VgMsgKind;
264
265extern void VG_(start_msg) ( VgMsgKind kind );
266extern void VG_(add_to_msg) ( Char* format, ... );
267extern void VG_(end_msg) ( void );
268
269/* Send a simple, single-part message. */
270extern void VG_(message) ( VgMsgKind kind, Char* format, ... );
271
272/* Create a logfile into which messages can be dumped. */
273extern void VG_(startup_logging) ( void );
274extern void VG_(shutdown_logging) ( void );
275
276
277/* Profiling stuff */
278#ifdef VG_PROFILE
279
280#define VGP_M_STACK 10
281
282#define VGP_M_CCS 20 /* == the # of elems in VGP_LIST */
283#define VGP_LIST \
284 VGP_PAIR(VgpRun=0, "running"), \
285 VGP_PAIR(VgpMalloc, "low-lev malloc/free"), \
286 VGP_PAIR(VgpCliMalloc, "client malloc/free"), \
287 VGP_PAIR(VgpTranslate, "translate-main"), \
288 VGP_PAIR(VgpToUCode, "to-ucode"), \
289 VGP_PAIR(VgpFromUcode, "from-ucode"), \
290 VGP_PAIR(VgpImprove, "improve"), \
291 VGP_PAIR(VgpInstrument, "instrument"), \
292 VGP_PAIR(VgpCleanup, "cleanup"), \
293 VGP_PAIR(VgpRegAlloc, "reg-alloc"), \
294 VGP_PAIR(VgpDoLRU, "do-lru"), \
295 VGP_PAIR(VgpSlowFindT, "slow-search-transtab"), \
296 VGP_PAIR(VgpInitAudit, "init-mem-audit"), \
297 VGP_PAIR(VgpExeContext, "exe-context"), \
298 VGP_PAIR(VgpReadSyms, "read-syms"), \
299 VGP_PAIR(VgpAddToT, "add-to-transtab"), \
300 VGP_PAIR(VgpSARP, "set-addr-range-perms"), \
301 VGP_PAIR(VgpSyscall, "syscall wrapper"), \
302 VGP_PAIR(VgpSpare1, "spare 1"), \
303 VGP_PAIR(VgpSpare2, "spare 2")
304
305#define VGP_PAIR(enumname,str) enumname
306typedef enum { VGP_LIST } VgpCC;
307#undef VGP_PAIR
308
309extern void VGP_(init_profiling) ( void );
310extern void VGP_(done_profiling) ( void );
311extern void VGP_(pushcc) ( VgpCC );
312extern void VGP_(popcc) ( void );
313
314#define VGP_PUSHCC(cc) VGP_(pushcc)(cc)
315#define VGP_POPCC VGP_(popcc)()
316
317#else
318
319#define VGP_PUSHCC(cc) /* */
320#define VGP_POPCC /* */
321
322#endif /* VG_PROFILE */
323
324
325/* ---------------------------------------------------------------------
326 Exports of vg_malloc2.c
327 ------------------------------------------------------------------ */
328
329/* Allocation arenas.
330 SYMTAB is for Valgrind's symbol table storage.
331 CLIENT is for the client's mallocs/frees.
332 DEMANGLE is for the C++ demangler.
333 EXECTXT is for storing ExeContexts.
334 ERRCTXT is for storing ErrContexts.
335 PRIVATE is for Valgrind general stuff.
336 TRANSIENT is for very short-term use. It should be empty
337 in between uses.
338 When adding a new arena, remember also to add it
339 to ensure_mm_init().
340*/
341typedef Int ArenaId;
342
343#define VG_N_ARENAS 7
344
345#define VG_AR_PRIVATE 0 /* :: ArenaId */
346#define VG_AR_SYMTAB 1 /* :: ArenaId */
347#define VG_AR_CLIENT 2 /* :: ArenaId */
348#define VG_AR_DEMANGLE 3 /* :: ArenaId */
349#define VG_AR_EXECTXT 4 /* :: ArenaId */
350#define VG_AR_ERRCTXT 5 /* :: ArenaId */
351#define VG_AR_TRANSIENT 6 /* :: ArenaId */
352
353extern void* VG_(malloc) ( ArenaId arena, Int nbytes );
354extern void VG_(free) ( ArenaId arena, void* ptr );
355extern void* VG_(calloc) ( ArenaId arena, Int nmemb, Int nbytes );
356extern void* VG_(realloc) ( ArenaId arena, void* ptr, Int size );
357extern void* VG_(malloc_aligned) ( ArenaId aid, Int req_alignB,
358 Int req_pszB );
359
360extern void VG_(mallocSanityCheckArena) ( ArenaId arena );
361extern void VG_(mallocSanityCheckAll) ( void );
362
363extern void VG_(show_all_arena_stats) ( void );
364extern Bool VG_(is_empty_arena) ( ArenaId aid );
365
366
367/* The red-zone size for the client. This can be arbitrary, but
368 unfortunately must be set at compile time. */
369#define VG_AR_CLIENT_REDZONE_SZW 4
370
371#define VG_AR_CLIENT_REDZONE_SZB \
372 (VG_AR_CLIENT_REDZONE_SZW * VKI_BYTES_PER_WORD)
373
374
375/* ---------------------------------------------------------------------
sewardj2e93c502002-04-12 11:12:52 +0000376 Exports of vg_clientfuns.c
377 ------------------------------------------------------------------ */
378
379/* This doesn't export code or data that valgrind.so needs to link
380 against. However, the scheduler does need to know the following
381 request codes. A few, publically-visible, request codes are also
382 defined in valgrind.h. */
383
384#define VG_USERREQ__MALLOC 0x2001
385#define VG_USERREQ__BUILTIN_NEW 0x2002
386#define VG_USERREQ__BUILTIN_VEC_NEW 0x2003
387
388#define VG_USERREQ__FREE 0x2004
389#define VG_USERREQ__BUILTIN_DELETE 0x2005
390#define VG_USERREQ__BUILTIN_VEC_DELETE 0x2006
391
392#define VG_USERREQ__CALLOC 0x2007
393#define VG_USERREQ__REALLOC 0x2008
394#define VG_USERREQ__MEMALIGN 0x2009
395
396
397#define VG_USERREQ__PTHREAD_CREATE 0x3001
sewardjbc5b99f2002-04-13 00:08:51 +0000398#define VG_USERREQ__PTHREAD_JOIN 0x3002
399#define VG_USERREQ__PTHREAD_GET_THREADID 0x3003
sewardj3b5d8862002-04-20 13:53:23 +0000400#define VG_USERREQ__PTHREAD_MUTEX_LOCK 0x3004
sewardj30671ff2002-04-21 00:13:57 +0000401#define VG_USERREQ__PTHREAD_MUTEX_TRYLOCK 0x3005
402#define VG_USERREQ__PTHREAD_MUTEX_UNLOCK 0x3006
403#define VG_USERREQ__PTHREAD_CANCEL 0x3007
404#define VG_USERREQ__PTHREAD_EXIT 0x3008
405#define VG_USERREQ__PTHREAD_COND_WAIT 0x3009
406#define VG_USERREQ__PTHREAD_COND_SIGNAL 0x300A
407#define VG_USERREQ__PTHREAD_COND_BROADCAST 0x300B
sewardj2e93c502002-04-12 11:12:52 +0000408
sewardj45b4b372002-04-16 22:50:32 +0000409/* Cosmetic ... */
410#define VG_USERREQ__GET_PTHREAD_TRACE_LEVEL 0x3101
411
sewardj54cacf02002-04-12 23:24:59 +0000412/*
413In vg_constants.h:
414#define VG_USERREQ__SIGNAL_RETURNS 0x4001
sewardjbc5b99f2002-04-13 00:08:51 +0000415#define VG_USERREQ__PTHREAD_RETURNS 0x4002
416#define VG_USERREQ__SHUTDOWN_VALGRIND 0x4003
sewardj54cacf02002-04-12 23:24:59 +0000417*/
418
419
sewardj2e93c502002-04-12 11:12:52 +0000420/* ---------------------------------------------------------------------
421 Constants pertaining to the simulated CPU state, VG_(baseBlock),
422 which need to go here to avoid ugly circularities.
423 ------------------------------------------------------------------ */
424
425/* How big is the saved FPU state? */
426#define VG_SIZE_OF_FPUSTATE 108
427/* ... and in words ... */
428#define VG_SIZE_OF_FPUSTATE_W ((VG_SIZE_OF_FPUSTATE+3)/4)
429
430
431/* ---------------------------------------------------------------------
432 Exports of vg_scheduler.c
433 ------------------------------------------------------------------ */
434
435/* ThreadIds are simply indices into the vg_threads[] array. */
436typedef
437 UInt
438 ThreadId;
439
sewardj6072c362002-04-19 14:40:57 +0000440/* Special magic value for an invalid ThreadId. It corresponds to
441 LinuxThreads using zero as the initial value for
442 pthread_mutex_t.__m_owner and pthread_cond_t.__c_waiting. */
443#define VG_INVALID_THREADID ((ThreadId)(0))
sewardj2e93c502002-04-12 11:12:52 +0000444
445typedef
446 enum {
447 VgTs_Empty, /* this slot is not in use */
448 VgTs_Runnable, /* waiting to be scheduled */
449 VgTs_WaitJoiner, /* waiting for someone to do join on me */
450 VgTs_WaitJoinee, /* waiting for the thread I did join on */
451 VgTs_WaitFD, /* waiting for I/O completion on a fd */
452 VgTs_WaitMX, /* waiting on a mutex */
sewardj3b5d8862002-04-20 13:53:23 +0000453 VgTs_WaitCV, /* waiting on a condition variable */
sewardj2e93c502002-04-12 11:12:52 +0000454 VgTs_Sleeping /* sleeping for a while */
455 }
456 ThreadStatus;
457
458typedef
459 struct {
sewardj6072c362002-04-19 14:40:57 +0000460 /* ThreadId == 0 (and hence vg_threads[0]) is NEVER USED.
461 The thread identity is simply the index in vg_threads[].
462 ThreadId == 1 is the root thread and has the special property
sewardj1e8cdc92002-04-18 11:37:52 +0000463 that we don't try and allocate or deallocate its stack. For
464 convenience of generating error message, we also put the
465 ThreadId in this tid field, but be aware that it should
sewardj604ec3c2002-04-18 22:38:41 +0000466 ALWAYS == the index in vg_threads[]. */
sewardj1e8cdc92002-04-18 11:37:52 +0000467 ThreadId tid;
sewardj2e93c502002-04-12 11:12:52 +0000468
469 /* Current scheduling status. */
470 ThreadStatus status;
471
472 /* Identity of joiner (thread who called join on me), or
473 VG_INVALID_THREADID if no one asked to join yet. */
474 ThreadId joiner;
475
sewardj3b5d8862002-04-20 13:53:23 +0000476 /* When .status == WaitMX, points to the mutex I am waiting for.
477 When .status == WaitCV, points to the mutex associated with
478 the condition variable indicated by the .associated_cv field.
479 In all other cases, should be NULL. */
480 void* /* pthread_mutex_t* */ associated_mx;
481
482 /* When .status == WaitCV, points to the condition variable I am
483 waiting for. In all other cases, should be NULL. */
484 void* /* pthread_cond_t* */ associated_cv;
sewardj2e93c502002-04-12 11:12:52 +0000485
486 /* If VgTs_Sleeping, this is when we should wake up. */
487 ULong awaken_at;
488
489 /* return value */
490 void* retval;
491
492 /* Stacks. When a thread slot is freed, we don't deallocate its
493 stack; we just leave it lying around for the next use of the
494 slot. If the next use of the slot requires a larger stack,
495 only then is the old one deallocated and a new one
496 allocated.
497
498 For the main thread (threadid == 0), this mechanism doesn't
499 apply. We don't know the size of the stack since we didn't
500 allocate it, and furthermore we never reallocate it. */
501
502 /* The allocated size of this thread's stack (permanently zero
503 if this is ThreadId == 0, since we didn't allocate its stack) */
504 UInt stack_size;
505
506 /* Address of the lowest word in this thread's stack. NULL means
507 not allocated yet.
508 */
509 Addr stack_base;
510
sewardj1e8cdc92002-04-18 11:37:52 +0000511 /* Address of the highest legitimate word in this stack. This is
512 used for error messages only -- not critical for execution
513 correctness. Is is set for all stacks, specifically including
514 ThreadId == 0 (the main thread). */
515 Addr stack_highest_word;
516
sewardj2e93c502002-04-12 11:12:52 +0000517 /* Saved machine context. */
518 UInt m_eax;
519 UInt m_ebx;
520 UInt m_ecx;
521 UInt m_edx;
522 UInt m_esi;
523 UInt m_edi;
524 UInt m_ebp;
525 UInt m_esp;
526 UInt m_eflags;
527 UInt m_eip;
528 UInt m_fpu[VG_SIZE_OF_FPUSTATE_W];
529
530 UInt sh_eax;
531 UInt sh_ebx;
532 UInt sh_ecx;
533 UInt sh_edx;
534 UInt sh_esi;
535 UInt sh_edi;
536 UInt sh_ebp;
537 UInt sh_esp;
538 UInt sh_eflags;
539 }
540 ThreadState;
541
542
543/* Copy the specified thread's state into VG_(baseBlock) in
544 preparation for running it. */
545extern void VG_(load_thread_state)( ThreadId );
546
547/* Save the specified thread's state back in VG_(baseBlock), and fill
548 VG_(baseBlock) with junk, for sanity-check reasons. */
549extern void VG_(save_thread_state)( ThreadId );
550
551/* Get the thread state block for the specified thread. */
552extern ThreadState* VG_(get_thread_state)( ThreadId );
553
sewardj1e8cdc92002-04-18 11:37:52 +0000554/* And for the currently running one, if valid. */
555extern ThreadState* VG_(get_current_thread_state) ( void );
sewardj2e93c502002-04-12 11:12:52 +0000556
sewardj1e8cdc92002-04-18 11:37:52 +0000557/* Similarly ... */
558extern ThreadId VG_(get_current_tid) ( void );
559
560/* Which thread is this address in the stack of, if any? Used for
561 error message generation. */
562extern ThreadId VG_(identify_stack_addr)( Addr a );
563
sewardj2e93c502002-04-12 11:12:52 +0000564
565/* Return codes from the scheduler. */
566typedef
567 enum { VgSrc_Deadlock, VgSrc_Shutdown, VgSrc_BbsDone }
568 VgSchedReturnCode;
569
570/* The scheduler. */
571extern VgSchedReturnCode VG_(scheduler) ( void );
572
573extern void VG_(scheduler_init) ( void );
574
sewardj15a43e12002-04-17 19:35:12 +0000575extern void VG_(pp_sched_status) ( void );
sewardj2e93c502002-04-12 11:12:52 +0000576
577/* vg_oursignalhandler() might longjmp(). Here's the jmp_buf. */
578extern jmp_buf VG_(scheduler_jmpbuf);
579/* ... and if so, here's the signal which caused it to do so. */
580extern Int VG_(longjmpd_on_signal);
581
582
583/* We check that the initial stack, which we can't move, is allocated
584 here. VG_(scheduler_init) checks this.
585*/
586#define VG_STARTUP_STACK_MASK (Addr)0xBFFF8000
587
588
589/* The red-zone size which we put at the bottom (highest address) of
590 thread stacks, for paranoia reasons. This can be arbitrary, and
591 doesn't really need to be set at compile time. */
592#define VG_AR_CLIENT_STACKBASE_REDZONE_SZW 4
593
594#define VG_AR_CLIENT_STACKBASE_REDZONE_SZB \
595 (VG_AR_CLIENT_STACKBASE_REDZONE_SZW * VKI_BYTES_PER_WORD)
596
597
598
599/* ---------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +0000600 Exports of vg_signals.c
601 ------------------------------------------------------------------ */
602
sewardjde4a1d02002-03-22 01:27:54 +0000603extern void VG_(sigstartup_actions) ( void );
604
sewardj2e93c502002-04-12 11:12:52 +0000605extern void VG_(deliver_signals) ( ThreadId );
sewardjde4a1d02002-03-22 01:27:54 +0000606extern void VG_(unblock_host_signal) ( Int sigNo );
607
608
609/* Fake system calls for signal handling. */
sewardj2e93c502002-04-12 11:12:52 +0000610extern void VG_(do__NR_sigaction) ( ThreadId tid );
sewardjde4a1d02002-03-22 01:27:54 +0000611extern void VG_(do__NR_sigprocmask) ( Int how, vki_ksigset_t* set );
612
sewardj2e93c502002-04-12 11:12:52 +0000613/* Modify the current thread's state once we have detected it is
614 returning from a signal handler. */
sewardj77e466c2002-04-14 02:29:29 +0000615extern Bool VG_(signal_returns) ( ThreadId );
sewardjde4a1d02002-03-22 01:27:54 +0000616
sewardj2e93c502002-04-12 11:12:52 +0000617/* Handy utilities to block/restore all host signals. */
618extern void VG_(block_all_host_signals)
619 ( /* OUT */ vki_ksigset_t* saved_mask );
620extern void VG_(restore_host_signals)
621 ( /* IN */ vki_ksigset_t* saved_mask );
sewardjde4a1d02002-03-22 01:27:54 +0000622
623/* ---------------------------------------------------------------------
624 Exports of vg_mylibc.c
625 ------------------------------------------------------------------ */
626
627
628#define NULL ((void*)0)
629
630extern void VG_(exit)( Int status )
631 __attribute__ ((__noreturn__));
632
633extern void VG_(printf) ( const char *format, ... );
634/* too noisy ... __attribute__ ((format (printf, 1, 2))) ; */
635
636extern void VG_(sprintf) ( Char* buf, Char *format, ... );
637
638extern void VG_(vprintf) ( void(*send)(Char),
639 const Char *format, va_list vargs );
640
641extern Bool VG_(isspace) ( Char c );
642
643extern Int VG_(strlen) ( const Char* str );
644
645extern Long VG_(atoll) ( Char* str );
646
647extern Char* VG_(strcat) ( Char* dest, const Char* src );
648extern Char* VG_(strncat) ( Char* dest, const Char* src, Int n );
649extern Char* VG_(strpbrk) ( const Char* s, const Char* accept );
650
651extern Char* VG_(strcpy) ( Char* dest, const Char* src );
652
653extern Int VG_(strcmp) ( const Char* s1, const Char* s2 );
654extern Int VG_(strcmp_ws) ( const Char* s1, const Char* s2 );
655
656extern Int VG_(strncmp) ( const Char* s1, const Char* s2, Int nmax );
657extern Int VG_(strncmp_ws) ( const Char* s1, const Char* s2, Int nmax );
658
659extern Char* VG_(strstr) ( const Char* haystack, Char* needle );
660extern Char* VG_(strchr) ( const Char* s, Char c );
661extern Char* VG_(strdup) ( ArenaId aid, const Char* s);
662
663extern Char* VG_(getenv) ( Char* name );
664extern Int VG_(getpid) ( void );
sewardj2e93c502002-04-12 11:12:52 +0000665extern ULong VG_(read_microsecond_timer)( void );
sewardjde4a1d02002-03-22 01:27:54 +0000666
667
668extern Char VG_(toupper) ( Char c );
669
670extern void VG_(strncpy_safely) ( Char* dest, const Char* src, Int ndest );
671
672extern void VG_(strncpy) ( Char* dest, const Char* src, Int ndest );
673
674extern Bool VG_(stringMatch) ( Char* pat, Char* str );
675
676
677#define __STRING(x) #x
678
679/* Asserts are permanently enabled. Hurrah! */
680#define vg_assert(expr) \
681 ((void) ((expr) ? 0 : \
682 (VG_(assert_fail) (__STRING(expr), \
683 __FILE__, __LINE__, \
684 __PRETTY_FUNCTION__), 0)))
685
686extern void VG_(assert_fail) ( Char* expr, Char* file,
687 Int line, Char* fn )
688 __attribute__ ((__noreturn__));
689
sewardjde4a1d02002-03-22 01:27:54 +0000690/* Reading files. */
691extern Int VG_(open_read) ( Char* pathname );
692extern void VG_(close) ( Int fd );
693extern Int VG_(read) ( Int fd, void* buf, Int count);
694extern Int VG_(write) ( Int fd, void* buf, Int count);
695
sewardj2e93c502002-04-12 11:12:52 +0000696extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg );
697
698extern Int VG_(select)( Int n,
699 vki_fd_set* readfds,
700 vki_fd_set* writefds,
701 vki_fd_set* exceptfds,
702 struct vki_timeval * timeout );
703extern Int VG_(nanosleep)( const struct vki_timespec *req,
704 struct vki_timespec *rem );
705
706
sewardjde4a1d02002-03-22 01:27:54 +0000707/* mmap-ery ... */
708extern void* VG_(mmap)( void* start, UInt length,
709 UInt prot, UInt flags, UInt fd, UInt offset );
710
sewardj2e93c502002-04-12 11:12:52 +0000711extern Int VG_(munmap)( void* start, Int length );
sewardjde4a1d02002-03-22 01:27:54 +0000712
713
714/* Print a (panic) message, and abort. */
715extern void VG_(panic) ( Char* str )
716 __attribute__ ((__noreturn__));
717
718/* Get memory by anonymous mmap. */
719void* VG_(get_memory_from_mmap) ( Int nBytes );
720
721/* Signal stuff. Note that these use the vk_ (kernel) structure
722 definitions, which are different in places from those that glibc
723 defines. Since we're operating right at the kernel interface,
724 glibc's view of the world is entirely irrelevant. */
725extern Int VG_(ksigfillset)( vki_ksigset_t* set );
726extern Int VG_(ksigemptyset)( vki_ksigset_t* set );
727extern Int VG_(ksigaddset)( vki_ksigset_t* set, Int signum );
728
729extern Int VG_(ksigprocmask)( Int how, const vki_ksigset_t* set,
730 vki_ksigset_t* oldset );
731extern Int VG_(ksigaction) ( Int signum,
732 const vki_ksigaction* act,
733 vki_ksigaction* oldact );
734extern Int VG_(ksigismember) ( vki_ksigset_t* set, Int signum );
735
736extern Int VG_(ksignal)(Int signum, void (*sighandler)(Int));
737
738extern Int VG_(ksigaltstack)( const vki_kstack_t* ss, vki_kstack_t* oss );
739
740
741
742/* ---------------------------------------------------------------------
743 Definitions for the JITter (vg_translate.c, vg_to_ucode.c,
744 vg_from_ucode.c).
745 ------------------------------------------------------------------ */
746
747/* Tags which describe what operands are. */
748typedef
749 enum { TempReg=0, ArchReg=1, RealReg=2,
750 SpillNo=3, Literal=4, Lit16=5,
751 NoValue=6 }
752 Tag;
753
754
755/* Microinstruction opcodes. */
756typedef
757 enum {
758 NOP,
759 GET,
760 PUT,
761 LOAD,
762 STORE,
763 MOV,
764 CMOV, /* Used for cmpxchg and cmov */
765 WIDEN,
766 JMP,
767
768 /* Read/write the %EFLAGS register into a TempReg. */
769 GETF, PUTF,
770
771 ADD, ADC, AND, OR, XOR, SUB, SBB,
772 SHL, SHR, SAR, ROL, ROR, RCL, RCR,
773 NOT, NEG, INC, DEC, BSWAP,
774 CC2VAL,
775
776 /* Not strictly needed, but useful for making better
777 translations of address calculations. */
778 LEA1, /* reg2 := const + reg1 */
779 LEA2, /* reg3 := const + reg1 + reg2 * 1,2,4 or 8 */
780
781 /* not for translating x86 calls -- only to call helpers */
782 CALLM_S, CALLM_E, /* Mark start and end of push/pop sequences
783 for CALLM. */
784 PUSH, POP, CLEAR, /* Add/remove/zap args for helpers. */
785 CALLM, /* call to a machine-code helper */
786
787 /* Hack for translating string (REP-) insns. Jump to literal if
788 TempReg/RealReg is zero. */
789 JIFZ,
790
791 /* FPU ops which read/write mem or don't touch mem at all. */
792 FPU_R,
793 FPU_W,
794 FPU,
795
796 /* Advance the simulated %eip by some small (< 128) number. */
797 INCEIP,
798
799 /* uinstrs which are not needed for mere translation of x86 code,
800 only for instrumentation of it. */
801 LOADV,
802 STOREV,
803 GETV,
804 PUTV,
805 TESTV,
806 SETV,
807 /* Get/set the v-bit (and it is only one bit) for the simulated
808 %eflags register. */
809 GETVF,
810 PUTVF,
811
812 /* Do a unary or binary tag op. Only for post-instrumented
813 code. For TAG1, first and only arg is a TempReg, and is both
814 arg and result reg. For TAG2, first arg is src, second is
815 dst, in the normal way; both are TempRegs. In both cases,
816 3rd arg is a RiCHelper with a Lit16 tag. This indicates
817 which tag op to do. */
818 TAG1,
819 TAG2
820 }
821 Opcode;
822
823
824/* Condition codes, observing the Intel encoding. CondAlways is an
825 extra. */
826typedef
827 enum {
828 CondO = 0, /* overflow */
829 CondNO = 1, /* no overflow */
830 CondB = 2, /* below */
831 CondNB = 3, /* not below */
832 CondZ = 4, /* zero */
833 CondNZ = 5, /* not zero */
834 CondBE = 6, /* below or equal */
835 CondNBE = 7, /* not below or equal */
836 CondS = 8, /* negative */
837 ConsNS = 9, /* not negative */
838 CondP = 10, /* parity even */
839 CondNP = 11, /* not parity even */
840 CondL = 12, /* jump less */
841 CondNL = 13, /* not less */
842 CondLE = 14, /* less or equal */
843 CondNLE = 15, /* not less or equal */
844 CondAlways = 16 /* Jump always */
845 }
846 Condcode;
847
848
sewardj2e93c502002-04-12 11:12:52 +0000849/* Descriptions of additional properties of *unconditional* jumps. */
850typedef
851 enum {
852 JmpBoring=0, /* boring unconditional jump */
853 JmpCall=1, /* jump due to an x86 call insn */
854 JmpRet=2, /* jump due to an x86 ret insn */
855 JmpSyscall=3, /* do a system call, then jump */
856 JmpClientReq=4 /* do a client request, then jump */
857 }
858 JmpKind;
859
860
sewardjde4a1d02002-03-22 01:27:54 +0000861/* Flags. User-level code can only read/write O(verflow), S(ign),
862 Z(ero), A(ux-carry), C(arry), P(arity), and may also write
863 D(irection). That's a total of 7 flags. A FlagSet is a bitset,
864 thusly:
865 76543210
866 DOSZACP
867 and bit 7 must always be zero since it is unused.
868*/
869typedef UChar FlagSet;
870
871#define FlagD (1<<6)
872#define FlagO (1<<5)
873#define FlagS (1<<4)
874#define FlagZ (1<<3)
875#define FlagA (1<<2)
876#define FlagC (1<<1)
877#define FlagP (1<<0)
878
879#define FlagsOSZACP (FlagO | FlagS | FlagZ | FlagA | FlagC | FlagP)
880#define FlagsOSZAP (FlagO | FlagS | FlagZ | FlagA | FlagP)
881#define FlagsOSZCP (FlagO | FlagS | FlagZ | FlagC | FlagP)
882#define FlagsOSACP (FlagO | FlagS | FlagA | FlagC | FlagP)
883#define FlagsSZACP ( FlagS | FlagZ | FlagA | FlagC | FlagP)
884#define FlagsSZAP ( FlagS | FlagZ | FlagA | FlagP)
sewardj4a7456e2002-03-24 13:52:19 +0000885#define FlagsZCP ( FlagZ | FlagC | FlagP)
sewardjde4a1d02002-03-22 01:27:54 +0000886#define FlagsOC (FlagO | FlagC )
sewardj4d0ab1f2002-03-24 10:00:09 +0000887#define FlagsAC ( FlagA | FlagC )
sewardjde4a1d02002-03-22 01:27:54 +0000888
889#define FlagsALL (FlagsOSZACP | FlagD)
890#define FlagsEmpty (FlagSet)0
891
892#define VG_IS_FLAG_SUBSET(set1,set2) \
893 (( ((FlagSet)set1) & ((FlagSet)set2) ) == ((FlagSet)set1) )
894
895#define VG_UNION_FLAG_SETS(set1,set2) \
896 ( ((FlagSet)set1) | ((FlagSet)set2) )
897
898
899
900/* A Micro (u)-instruction. */
901typedef
902 struct {
903 /* word 1 */
904 UInt lit32; /* 32-bit literal */
905
906 /* word 2 */
907 UShort val1; /* first operand */
908 UShort val2; /* second operand */
909
910 /* word 3 */
911 UShort val3; /* third operand */
912 UChar opcode; /* opcode */
913 UChar size; /* data transfer size */
914
915 /* word 4 */
916 FlagSet flags_r; /* :: FlagSet */
917 FlagSet flags_w; /* :: FlagSet */
918 UChar tag1:4; /* first operand tag */
919 UChar tag2:4; /* second operand tag */
920 UChar tag3:4; /* third operand tag */
921 UChar extra4b:4; /* Spare field, used by WIDEN for src
922 -size, and by LEA2 for scale
923 (1,2,4 or 8) */
924
925 /* word 5 */
926 UChar cond; /* condition, for jumps */
927 Bool smc_check:1; /* do a smc test, if writes memory. */
928 Bool signed_widen:1; /* signed or unsigned WIDEN ? */
sewardj2e93c502002-04-12 11:12:52 +0000929 JmpKind jmpkind:3; /* additional properties of unconditional JMP */
sewardjde4a1d02002-03-22 01:27:54 +0000930 }
931 UInstr;
932
933
934/* Expandable arrays of uinstrs. */
935typedef
936 struct {
937 Int used;
938 Int size;
939 UInstr* instrs;
940 Int nextTemp;
941 }
942 UCodeBlock;
943
944/* Refer to `the last instruction stuffed in', including as an
945 lvalue. */
946#define LAST_UINSTR(cb) (cb)->instrs[(cb)->used-1]
947
948/* An invalid temporary number :-) */
949#define INVALID_TEMPREG 999999999
950
951
952/* ---------------------------------------------------------------------
953 Exports of vg_demangle.c
954 ------------------------------------------------------------------ */
955
956extern void VG_(demangle) ( Char* orig, Char* result, Int result_size );
957
958
959/* ---------------------------------------------------------------------
960 Exports of vg_from_ucode.c
961 ------------------------------------------------------------------ */
962
963extern UChar* VG_(emit_code) ( UCodeBlock* cb, Int* nbytes );
964
965
966/* ---------------------------------------------------------------------
967 Exports of vg_to_ucode.c
968 ------------------------------------------------------------------ */
969
970extern Int VG_(disBB) ( UCodeBlock* cb, Addr eip0 );
971extern Char* VG_(nameOfIntReg) ( Int size, Int reg );
972extern Char VG_(nameOfIntSize) ( Int size );
973extern UInt VG_(extend_s_8to32) ( UInt x );
974extern Int VG_(getNewTemp) ( UCodeBlock* cb );
975extern Int VG_(getNewShadow) ( UCodeBlock* cb );
976
977#define SHADOW(tempreg) ((tempreg)+1)
978
979
980/* ---------------------------------------------------------------------
981 Exports of vg_translate.c
982 ------------------------------------------------------------------ */
983
sewardj1e8cdc92002-04-18 11:37:52 +0000984extern void VG_(translate) ( ThreadState* tst,
985 Addr orig_addr,
sewardjde4a1d02002-03-22 01:27:54 +0000986 UInt* orig_size,
987 Addr* trans_addr,
988 UInt* trans_size );
989
990extern void VG_(emptyUInstr) ( UInstr* u );
991extern void VG_(newUInstr0) ( UCodeBlock* cb, Opcode opcode, Int sz );
992extern void VG_(newUInstr1) ( UCodeBlock* cb, Opcode opcode, Int sz,
993 Tag tag1, UInt val1 );
994extern void VG_(newUInstr2) ( UCodeBlock* cb, Opcode opcode, Int sz,
995 Tag tag1, UInt val1,
996 Tag tag2, UInt val2 );
997extern void VG_(newUInstr3) ( UCodeBlock* cb, Opcode opcode, Int sz,
998 Tag tag1, UInt val1,
999 Tag tag2, UInt val2,
1000 Tag tag3, UInt val3 );
1001extern void VG_(setFlagRW) ( UInstr* u,
1002 FlagSet fr, FlagSet fw );
1003
1004extern void VG_(setLiteralField) ( UCodeBlock* cb, UInt lit32 );
1005extern Bool VG_(anyFlagUse) ( UInstr* u );
1006
1007
1008
1009extern void VG_(ppUInstr) ( Int instrNo, UInstr* u );
1010extern void VG_(ppUCodeBlock) ( UCodeBlock* cb, Char* title );
1011
1012extern Char* VG_(nameCondcode) ( Condcode cond );
1013extern Bool VG_(saneUInstr) ( Bool beforeRA, UInstr* u );
1014extern Bool VG_(saneUCodeBlock) ( UCodeBlock* cb );
1015extern Char* VG_(nameUOpcode) ( Bool upper, Opcode opc );
1016extern Int VG_(rankToRealRegNo) ( Int rank );
1017
1018extern void* VG_(jitmalloc) ( Int nbytes );
1019extern void VG_(jitfree) ( void* ptr );
1020
1021
1022/* ---------------------------------------------------------------------
1023 Exports of vg_execontext.c.
1024 ------------------------------------------------------------------ */
1025
1026/* Records the PC and a bit of the call chain. The first 4 %eip
1027 values are used in comparisons do remove duplicate errors, and for
1028 comparing against suppression specifications. The rest are purely
1029 informational (but often important). */
1030
1031typedef
1032 struct _ExeContextRec {
1033 struct _ExeContextRec * next;
1034 /* The size of this array is VG_(clo_backtrace_size); at least
1035 2, at most VG_DEEPEST_BACKTRACE. [0] is the current %eip,
1036 [1] is its caller, [2] is the caller of [1], etc. */
1037 Addr eips[0];
1038 }
1039 ExeContext;
1040
1041
1042/* Initialise the ExeContext storage mechanism. */
1043extern void VG_(init_ExeContext_storage) ( void );
1044
1045/* Print stats (informational only). */
1046extern void VG_(show_ExeContext_stats) ( void );
1047
1048
1049/* Take a snapshot of the client's stack. Search our collection of
1050 ExeContexts to see if we already have it, and if not, allocate a
1051 new one. Either way, return a pointer to the context. */
sewardj8c824512002-04-14 04:16:48 +00001052extern ExeContext* VG_(get_ExeContext) ( Bool skip_top_frame,
1053 Addr eip, Addr ebp );
sewardjde4a1d02002-03-22 01:27:54 +00001054
1055/* Print an ExeContext. */
1056extern void VG_(pp_ExeContext) ( ExeContext* );
1057
1058/* Compare two ExeContexts, just comparing the top two callers. */
1059extern Bool VG_(eq_ExeContext_top2) ( ExeContext* e1, ExeContext* e2 );
1060
1061/* Compare two ExeContexts, just comparing the top four callers. */
1062extern Bool VG_(eq_ExeContext_top4) ( ExeContext* e1, ExeContext* e2 );
1063
1064/* Compare two ExeContexts, comparing all callers. */
1065extern Bool VG_(eq_ExeContext_all) ( ExeContext* e1, ExeContext* e2 );
1066
1067
1068
1069/* ---------------------------------------------------------------------
1070 Exports of vg_errcontext.c.
1071 ------------------------------------------------------------------ */
1072
1073extern void VG_(load_suppressions) ( void );
1074extern void VG_(show_all_errors) ( void );
1075extern void VG_(record_value_error) ( Int size );
sewardjaabd5ad2002-04-19 15:43:37 +00001076extern void VG_(record_free_error) ( ThreadState* tst, Addr a );
1077extern void VG_(record_freemismatch_error) ( ThreadState* tst, Addr a );
sewardjde4a1d02002-03-22 01:27:54 +00001078extern void VG_(record_address_error) ( Addr a, Int size,
1079 Bool isWrite );
sewardj1e8cdc92002-04-18 11:37:52 +00001080
1081extern void VG_(record_jump_error) ( ThreadState* tst, Addr a );
sewardj8c824512002-04-14 04:16:48 +00001082
1083extern void VG_(record_param_err) ( ThreadState* tst,
1084 Addr a,
sewardjde4a1d02002-03-22 01:27:54 +00001085 Bool isWriteLack,
1086 Char* msg );
sewardj8c824512002-04-14 04:16:48 +00001087extern void VG_(record_user_err) ( ThreadState* tst,
1088 Addr a, Bool isWriteLack );
sewardjde4a1d02002-03-22 01:27:54 +00001089
1090
1091/* The classification of a faulting address. */
1092typedef
1093 enum { Stack, Unknown, Freed, Mallocd, UserG, UserS }
1094 AddrKind;
1095
1096/* Records info about a faulting address. */
1097typedef
1098 struct {
1099 /* ALL */
1100 AddrKind akind;
1101 /* Freed, Mallocd */
1102 Int blksize;
1103 /* Freed, Mallocd */
1104 Int rwoffset;
1105 /* Freed, Mallocd */
1106 ExeContext* lastchange;
sewardj1e8cdc92002-04-18 11:37:52 +00001107 /* Stack */
1108 ThreadId stack_tid;
sewardjde4a1d02002-03-22 01:27:54 +00001109 }
1110 AddrInfo;
1111
1112
1113/* ---------------------------------------------------------------------
1114 Exports of vg_clientperms.c
1115 ------------------------------------------------------------------ */
1116
1117extern Bool VG_(client_perm_maybe_describe)( Addr a, AddrInfo* ai );
1118
sewardj8c824512002-04-14 04:16:48 +00001119extern UInt VG_(handle_client_request) ( ThreadState* tst, UInt* arg_block );
sewardjde4a1d02002-03-22 01:27:54 +00001120
1121extern void VG_(delete_client_stack_blocks_following_ESP_change) ( void );
1122
1123extern void VG_(show_client_block_stats) ( void );
1124
1125
1126/* ---------------------------------------------------------------------
1127 Exports of vg_procselfmaps.c
1128 ------------------------------------------------------------------ */
1129
1130extern
1131void VG_(read_procselfmaps) (
1132 void (*record_mapping)( Addr, UInt, Char, Char, Char, UInt, UChar* )
1133);
1134
1135
1136/* ---------------------------------------------------------------------
1137 Exports of vg_symtab2.c
1138 ------------------------------------------------------------------ */
1139
1140/* We assume the executable is loaded here ... can't really find
1141 out. There is a hacky sanity check in vg_init_memory_audit()
1142 which should trip up most stupidities.
1143*/
1144#define VG_ASSUMED_EXE_BASE (Addr)0x8048000
1145
1146extern void VG_(read_symbols) ( void );
1147extern void VG_(mini_stack_dump) ( ExeContext* ec );
1148extern void VG_(what_obj_and_fun_is_this)
1149 ( Addr a,
1150 Char* obj_buf, Int n_obj_buf,
1151 Char* fun_buf, Int n_fun_buf );
1152
1153extern void VG_(symtab_notify_munmap) ( Addr start, UInt length );
1154
1155
1156/* ---------------------------------------------------------------------
1157 Exports of vg_clientmalloc.c
1158 ------------------------------------------------------------------ */
1159
sewardjde4a1d02002-03-22 01:27:54 +00001160typedef
1161 enum {
1162 Vg_AllocMalloc = 0,
sewardj2e93c502002-04-12 11:12:52 +00001163 Vg_AllocNew = 1,
sewardjde4a1d02002-03-22 01:27:54 +00001164 Vg_AllocNewVec = 2
1165 }
1166 VgAllocKind;
1167
1168/* Description of a malloc'd chunk. */
1169typedef
1170 struct _ShadowChunk {
1171 struct _ShadowChunk* next;
1172 ExeContext* where; /* where malloc'd/free'd */
1173 UInt size : 30; /* size requested. */
1174 VgAllocKind allockind : 2; /* which wrapper did the allocation */
1175 Addr data; /* ptr to actual block. */
1176 }
1177 ShadowChunk;
1178
1179extern void VG_(clientmalloc_done) ( void );
1180extern void VG_(describe_addr) ( Addr a, AddrInfo* ai );
1181extern ShadowChunk** VG_(get_malloc_shadows) ( /*OUT*/ UInt* n_shadows );
1182
sewardj2e93c502002-04-12 11:12:52 +00001183/* These are called from the scheduler, when it intercepts a user
1184 request. */
sewardj8c824512002-04-14 04:16:48 +00001185extern void* VG_(client_malloc) ( ThreadState* tst,
1186 UInt size, VgAllocKind kind );
1187extern void* VG_(client_memalign) ( ThreadState* tst,
1188 UInt align, UInt size );
1189extern void VG_(client_free) ( ThreadState* tst,
1190 void* ptrV, VgAllocKind kind );
1191extern void* VG_(client_calloc) ( ThreadState* tst,
1192 UInt nmemb, UInt size1 );
1193extern void* VG_(client_realloc) ( ThreadState* tst,
1194 void* ptrV, UInt size_new );
sewardjde4a1d02002-03-22 01:27:54 +00001195
1196
1197/* ---------------------------------------------------------------------
1198 Exports of vg_main.c
1199 ------------------------------------------------------------------ */
1200
sewardjde4a1d02002-03-22 01:27:54 +00001201/* A structure used as an intermediary when passing the simulated
1202 CPU's state to some assembly fragments, particularly system calls.
1203 Stuff is copied from baseBlock to here, the assembly magic runs,
1204 and then the inverse copy is done. */
1205
1206extern UInt VG_(m_state_static) [8 /* int regs, in Intel order */
1207 + 1 /* %eflags */
1208 + 1 /* %eip */
1209 + VG_SIZE_OF_FPUSTATE_W /* FPU state */
1210 ];
1211
1212/* Handy fns for doing the copy back and forth. */
1213extern void VG_(copy_baseBlock_to_m_state_static) ( void );
1214extern void VG_(copy_m_state_static_to_baseBlock) ( void );
1215
sewardjde4a1d02002-03-22 01:27:54 +00001216/* Called when some unhandleable client behaviour is detected.
1217 Prints a msg and aborts. */
1218extern void VG_(unimplemented) ( Char* msg );
1219
1220/* The stack on which Valgrind runs. We can't use the same stack as the
1221 simulatee -- that's an important design decision. */
1222extern UInt VG_(stack)[10000];
1223
1224/* Similarly, we have to ask for signals to be delivered on an
1225 alternative stack, since it is possible, although unlikely, that
1226 we'll have to run client code from inside the Valgrind-installed
1227 signal handler. If this happens it will be done by
1228 vg_deliver_signal_immediately(). */
1229extern UInt VG_(sigstack)[10000];
1230
sewardjde4a1d02002-03-22 01:27:54 +00001231/* Holds client's %esp at the point we gained control. From this the
1232 client's argc, argv and envp are deduced. */
1233extern Addr VG_(esp_at_startup);
1234extern Int VG_(client_argc);
1235extern Char** VG_(client_argv);
1236extern Char** VG_(client_envp);
1237
1238/* Remove valgrind.so from a LD_PRELOAD=... string so child processes
1239 don't get traced into. */
1240extern void VG_(mash_LD_PRELOAD_string)( Char* ld_preload_str );
1241
1242/* Something of a function looking for a home ... start up GDB. This
1243 is called from VG_(swizzle_esp_then_start_GDB) and so runs on the
1244 *client's* stack. This is necessary to give GDB the illusion that
1245 the client program really was running on the real cpu. */
1246extern void VG_(start_GDB_whilst_on_client_stack) ( void );
1247
1248/* Spew out vast amounts of junk during JITting? */
1249extern Bool VG_(disassemble);
1250
1251/* 64-bit counter for the number of basic blocks done. */
1252extern ULong VG_(bbs_done);
1253/* 64-bit counter for the number of bbs to go before a debug exit. */
1254extern ULong VG_(bbs_to_go);
1255
1256/* Counts downwards in vg_run_innerloop. */
1257extern UInt VG_(dispatch_ctr);
1258
sewardjde4a1d02002-03-22 01:27:54 +00001259/* Is the client running on the simulated CPU or the real one? */
1260extern Bool VG_(running_on_simd_CPU); /* Initially False */
1261
1262/* The current LRU epoch. */
1263extern UInt VG_(current_epoch);
1264
1265
1266/* --- Counters, for informational purposes only. --- */
1267
1268/* Number of lookups which miss the fast tt helper. */
1269extern UInt VG_(tt_fast_misses);
1270
1271/* Counts for LRU informational messages. */
1272
1273/* Number and total o/t size of new translations this epoch. */
1274extern UInt VG_(this_epoch_in_count);
1275extern UInt VG_(this_epoch_in_osize);
1276extern UInt VG_(this_epoch_in_tsize);
1277/* Number and total o/t size of discarded translations this epoch. */
1278extern UInt VG_(this_epoch_out_count);
1279extern UInt VG_(this_epoch_out_osize);
1280extern UInt VG_(this_epoch_out_tsize);
1281/* Number and total o/t size of translations overall. */
1282extern UInt VG_(overall_in_count);
1283extern UInt VG_(overall_in_osize);
1284extern UInt VG_(overall_in_tsize);
1285/* Number and total o/t size of discards overall. */
1286extern UInt VG_(overall_out_count);
1287extern UInt VG_(overall_out_osize);
1288extern UInt VG_(overall_out_tsize);
1289
1290/* The number of LRU-clearings of TT/TC. */
1291extern UInt VG_(number_of_lrus);
1292
1293/* Counts pertaining to the register allocator. */
1294
1295/* total number of uinstrs input to reg-alloc */
1296extern UInt VG_(uinstrs_prealloc);
1297
1298/* total number of uinstrs added due to spill code */
1299extern UInt VG_(uinstrs_spill);
1300
1301/* number of bbs requiring spill code */
1302extern UInt VG_(translations_needing_spill);
1303
1304/* total of register ranks over all translations */
1305extern UInt VG_(total_reg_rank);
1306
1307/* Counts pertaining to the self-modifying-code detection machinery. */
1308
1309/* Total number of writes checked. */
1310//extern UInt VG_(smc_total_check4s);
1311
1312/* Number of writes which the fast smc check couldn't show were
1313 harmless. */
1314extern UInt VG_(smc_cache_passed);
1315
1316/* Numnber of writes which really did write on original code. */
1317extern UInt VG_(smc_fancy_passed);
1318
1319/* Number of translations discarded as a result. */
1320//extern UInt VG_(smc_discard_count);
1321
1322/* Counts pertaining to internal sanity checking. */
1323extern UInt VG_(sanity_fast_count);
1324extern UInt VG_(sanity_slow_count);
1325
sewardj2e93c502002-04-12 11:12:52 +00001326/* Counts pertaining to the scheduler. */
1327extern UInt VG_(num_scheduling_events_MINOR);
1328extern UInt VG_(num_scheduling_events_MAJOR);
1329
sewardjde4a1d02002-03-22 01:27:54 +00001330
1331/* ---------------------------------------------------------------------
1332 Exports of vg_memory.c
1333 ------------------------------------------------------------------ */
1334
1335extern void VGM_(init_memory_audit) ( void );
1336extern Addr VGM_(curr_dataseg_end);
1337extern void VG_(show_reg_tags) ( void );
1338extern void VG_(detect_memory_leaks) ( void );
1339extern void VG_(done_prof_mem) ( void );
1340
1341/* Set permissions for an address range. Not speed-critical. */
1342extern void VGM_(make_noaccess) ( Addr a, UInt len );
1343extern void VGM_(make_writable) ( Addr a, UInt len );
1344extern void VGM_(make_readable) ( Addr a, UInt len );
1345/* Use with care! (read: use for shmat only) */
1346extern void VGM_(make_readwritable) ( Addr a, UInt len );
1347extern void VGM_(copy_address_range_perms) ( Addr src, Addr dst,
1348 UInt len );
1349
1350/* Check permissions for an address range. Not speed-critical. */
1351extern Bool VGM_(check_writable) ( Addr a, UInt len, Addr* bad_addr );
1352extern Bool VGM_(check_readable) ( Addr a, UInt len, Addr* bad_addr );
1353extern Bool VGM_(check_readable_asciiz) ( Addr a, Addr* bad_addr );
1354
1355/* Sanity checks which may be done at any time. Doing them at
1356 signal-delivery time turns out to be convenient. */
sewardj2e93c502002-04-12 11:12:52 +00001357extern void VG_(do_sanity_checks) ( ThreadId tid, Bool force_expensive );
sewardjde4a1d02002-03-22 01:27:54 +00001358/* Very cheap ... */
1359extern Bool VG_(first_and_last_secondaries_look_plausible) ( void );
1360
1361/* These functions are called from generated code. */
1362extern void VG_(helperc_STOREV4) ( UInt, Addr );
1363extern void VG_(helperc_STOREV2) ( UInt, Addr );
1364extern void VG_(helperc_STOREV1) ( UInt, Addr );
1365
1366extern UInt VG_(helperc_LOADV1) ( Addr );
1367extern UInt VG_(helperc_LOADV2) ( Addr );
1368extern UInt VG_(helperc_LOADV4) ( Addr );
1369
1370extern void VGM_(handle_esp_assignment) ( Addr new_espA );
1371extern void VGM_(fpu_write_check) ( Addr addr, Int size );
1372extern void VGM_(fpu_read_check) ( Addr addr, Int size );
1373
1374/* Safely (avoiding SIGSEGV / SIGBUS) scan the entire valid address
1375 space and pass the addresses and values of all addressible,
1376 defined, aligned words to notify_word. This is the basis for the
1377 leak detector. Returns the number of calls made to notify_word. */
1378UInt VG_(scan_all_valid_memory) ( void (*notify_word)( Addr, UInt ) );
1379
1380/* Is this address within some small distance below %ESP? Used only
1381 for the --workaround-gcc296-bugs kludge. */
sewardj8c824512002-04-14 04:16:48 +00001382extern Bool VG_(is_just_below_ESP)( Addr esp, Addr aa );
sewardjde4a1d02002-03-22 01:27:54 +00001383
1384/* Nasty kludgery to deal with applications which switch stacks,
1385 like netscape. */
sewardjde4a1d02002-03-22 01:27:54 +00001386#define VG_PLAUSIBLE_STACK_SIZE 8000000
1387
sewardjde4a1d02002-03-22 01:27:54 +00001388
1389/* ---------------------------------------------------------------------
1390 Exports of vg_syscall_mem.c
1391 ------------------------------------------------------------------ */
1392
sewardj2e93c502002-04-12 11:12:52 +00001393extern void VG_(perform_assumed_nonblocking_syscall) ( ThreadId tid );
sewardjde4a1d02002-03-22 01:27:54 +00001394
sewardj2e93c502002-04-12 11:12:52 +00001395extern void VG_(check_known_blocking_syscall) ( ThreadId tid,
1396 Int syscallno,
1397 Int* /*IN*/ res );
sewardjde4a1d02002-03-22 01:27:54 +00001398
1399extern Bool VG_(is_kerror) ( Int res );
1400
sewardj2e93c502002-04-12 11:12:52 +00001401#define KERNEL_DO_SYSCALL(thread_id, result_lvalue) \
1402 VG_(load_thread_state)(thread_id); \
sewardjde4a1d02002-03-22 01:27:54 +00001403 VG_(copy_baseBlock_to_m_state_static)(); \
1404 VG_(do_syscall)(); \
1405 VG_(copy_m_state_static_to_baseBlock)(); \
sewardj2e93c502002-04-12 11:12:52 +00001406 VG_(save_thread_state)(thread_id); \
1407 result_lvalue = VG_(get_thread_state)(thread_id)->m_eax;
sewardjde4a1d02002-03-22 01:27:54 +00001408
1409
1410/* ---------------------------------------------------------------------
1411 Exports of vg_transtab.c
1412 ------------------------------------------------------------------ */
1413
1414/* An entry in the translation table (TT). */
1415typedef
1416 struct {
1417 /* +0 */ Addr orig_addr;
1418 /* +4 */ Addr trans_addr;
1419 /* +8 */ UInt mru_epoch;
1420 /* +12 */ UShort orig_size;
1421 /* +14 */ UShort trans_size;
1422 }
1423 TTEntry;
1424
1425/* The number of basic blocks in an epoch (one age-step). */
1426#define VG_BBS_PER_EPOCH 20000
1427
1428extern void VG_(get_tt_tc_used) ( UInt* tt_used, UInt* tc_used );
1429extern void VG_(maybe_do_lru_pass) ( void );
1430extern void VG_(flush_transtab) ( void );
1431extern Addr VG_(copy_to_transcache) ( Addr trans_addr, Int trans_size );
1432extern void VG_(add_to_trans_tab) ( TTEntry* tte );
1433
1434extern void VG_(smc_mark_original) ( Addr original_addr,
1435 Int original_len );
1436
1437extern void VG_(init_transtab_and_SMC) ( void );
1438
1439extern void VG_(sanity_check_tc_tt) ( void );
1440extern Addr VG_(search_transtab) ( Addr original_addr );
1441
1442extern void VG_(invalidate_tt_fast)( void );
1443
1444
1445/* ---------------------------------------------------------------------
1446 Exports of vg_vtagops.c
1447 ------------------------------------------------------------------ */
1448
1449/* Lists the names of value-tag operations used in instrumented
1450 code. These are the third argument to TAG1 and TAG2 uinsns. */
1451
1452typedef
1453 enum {
1454 /* Unary. */
1455 VgT_PCast40, VgT_PCast20, VgT_PCast10,
1456 VgT_PCast01, VgT_PCast02, VgT_PCast04,
1457
1458 VgT_PCast14, VgT_PCast12, VgT_PCast11,
1459
1460 VgT_Left4, VgT_Left2, VgT_Left1,
1461
1462 VgT_SWiden14, VgT_SWiden24, VgT_SWiden12,
1463 VgT_ZWiden14, VgT_ZWiden24, VgT_ZWiden12,
1464
1465 /* Binary; 1st is rd; 2nd is rd+wr */
1466 VgT_UifU4, VgT_UifU2, VgT_UifU1, VgT_UifU0,
1467 VgT_DifD4, VgT_DifD2, VgT_DifD1,
1468
1469 VgT_ImproveAND4_TQ, VgT_ImproveAND2_TQ, VgT_ImproveAND1_TQ,
1470 VgT_ImproveOR4_TQ, VgT_ImproveOR2_TQ, VgT_ImproveOR1_TQ,
1471 VgT_DebugFn
1472 }
1473 VgTagOp;
1474
1475extern Char* VG_(nameOfTagOp) ( VgTagOp );
1476extern UInt VG_(DebugFn) ( UInt a1, UInt a2 );
1477
1478
1479/* ---------------------------------------------------------------------
1480 Exports of vg_syscall.S
1481 ------------------------------------------------------------------ */
1482
1483extern void VG_(do_syscall) ( void );
1484
1485
1486/* ---------------------------------------------------------------------
1487 Exports of vg_startup.S
1488 ------------------------------------------------------------------ */
1489
1490extern void VG_(shutdown);
1491extern void VG_(switch_to_real_CPU) ( void );
1492
sewardj35805422002-04-21 13:05:34 +00001493extern void VG_(swizzle_esp_then_start_GDB) ( Addr m_eip_at_error,
1494 Addr m_esp_at_error,
1495 Addr m_ebp_at_error );
sewardjde4a1d02002-03-22 01:27:54 +00001496
1497
1498/* ---------------------------------------------------------------------
1499 Exports of vg_dispatch.S
1500 ------------------------------------------------------------------ */
1501
sewardj2e93c502002-04-12 11:12:52 +00001502/* Run a thread for a (very short) while, until some event happens
1503 which means we need to defer to the scheduler. */
1504extern UInt VG_(run_innerloop) ( void );
sewardjde4a1d02002-03-22 01:27:54 +00001505
1506
1507/* ---------------------------------------------------------------------
1508 Exports of vg_helpers.S
1509 ------------------------------------------------------------------ */
1510
sewardjde4a1d02002-03-22 01:27:54 +00001511/* SMC fast checks. */
1512extern void VG_(helper_smc_check4);
1513
1514/* Mul, div, etc, -- we don't codegen these directly. */
1515extern void VG_(helper_idiv_64_32);
1516extern void VG_(helper_div_64_32);
1517extern void VG_(helper_idiv_32_16);
1518extern void VG_(helper_div_32_16);
1519extern void VG_(helper_idiv_16_8);
1520extern void VG_(helper_div_16_8);
1521
1522extern void VG_(helper_imul_32_64);
1523extern void VG_(helper_mul_32_64);
1524extern void VG_(helper_imul_16_32);
1525extern void VG_(helper_mul_16_32);
1526extern void VG_(helper_imul_8_16);
1527extern void VG_(helper_mul_8_16);
1528
1529extern void VG_(helper_CLD);
1530extern void VG_(helper_STD);
1531extern void VG_(helper_get_dirflag);
1532
1533extern void VG_(helper_shldl);
1534extern void VG_(helper_shldw);
1535extern void VG_(helper_shrdl);
1536extern void VG_(helper_shrdw);
1537
1538extern void VG_(helper_RDTSC);
1539extern void VG_(helper_CPUID);
1540
sewardjde4a1d02002-03-22 01:27:54 +00001541extern void VG_(helper_bsf);
1542extern void VG_(helper_bsr);
1543
1544extern void VG_(helper_fstsw_AX);
1545extern void VG_(helper_SAHF);
sewardj4d0ab1f2002-03-24 10:00:09 +00001546extern void VG_(helper_DAS);
sewardjfe8a1662002-03-24 11:54:07 +00001547extern void VG_(helper_DAA);
sewardjde4a1d02002-03-22 01:27:54 +00001548
1549extern void VG_(helper_value_check4_fail);
1550extern void VG_(helper_value_check2_fail);
1551extern void VG_(helper_value_check1_fail);
1552extern void VG_(helper_value_check0_fail);
1553
sewardjbc5b99f2002-04-13 00:08:51 +00001554/* NOT FUNCTIONS; these are bogus RETURN ADDRESS. */
sewardj54cacf02002-04-12 23:24:59 +00001555extern void VG_(signalreturn_bogusRA)( void );
sewardjbc5b99f2002-04-13 00:08:51 +00001556extern void VG_(pthreadreturn_bogusRA)( void );
sewardj54cacf02002-04-12 23:24:59 +00001557
sewardjde4a1d02002-03-22 01:27:54 +00001558
1559/* ---------------------------------------------------------------------
1560 The state of the simulated CPU.
1561 ------------------------------------------------------------------ */
1562
1563/* This is the Intel register encoding. */
1564#define R_EAX 0
1565#define R_ECX 1
1566#define R_EDX 2
1567#define R_EBX 3
1568#define R_ESP 4
1569#define R_EBP 5
1570#define R_ESI 6
1571#define R_EDI 7
1572
1573#define R_AL (0+R_EAX)
1574#define R_CL (0+R_ECX)
1575#define R_DL (0+R_EDX)
1576#define R_BL (0+R_EBX)
1577#define R_AH (4+R_EAX)
1578#define R_CH (4+R_ECX)
1579#define R_DH (4+R_EDX)
1580#define R_BH (4+R_EBX)
1581
1582
1583/* ---------------------------------------------------------------------
1584 Offsets into baseBlock for everything which needs to referred to
1585 from generated code. The order of these decls does not imply
1586 what the order of the actual offsets is. The latter is important
1587 and is set up in vg_main.c.
1588 ------------------------------------------------------------------ */
1589
1590/* An array of words. In generated code, %ebp always points to the
1591 start of this array. Useful stuff, like the simulated CPU state,
1592 and the addresses of helper functions, can then be found by
1593 indexing off %ebp. The following declares variables which, at
1594 startup time, are given values denoting offsets into baseBlock.
1595 These offsets are in *words* from the start of baseBlock. */
1596
1597#define VG_BASEBLOCK_WORDS 200
1598
1599extern UInt VG_(baseBlock)[VG_BASEBLOCK_WORDS];
1600
1601
1602/* -----------------------------------------------------
1603 Read-write parts of baseBlock.
1604 -------------------------------------------------- */
1605
1606/* State of the simulated CPU. */
1607extern Int VGOFF_(m_eax);
1608extern Int VGOFF_(m_ecx);
1609extern Int VGOFF_(m_edx);
1610extern Int VGOFF_(m_ebx);
1611extern Int VGOFF_(m_esp);
1612extern Int VGOFF_(m_ebp);
1613extern Int VGOFF_(m_esi);
1614extern Int VGOFF_(m_edi);
1615extern Int VGOFF_(m_eflags);
1616extern Int VGOFF_(m_fpustate);
1617extern Int VGOFF_(m_eip);
1618
1619/* Reg-alloc spill area (VG_MAX_SPILLSLOTS words long). */
1620extern Int VGOFF_(spillslots);
1621
1622/* Records the valid bits for the 8 integer regs & flags reg. */
1623extern Int VGOFF_(sh_eax);
1624extern Int VGOFF_(sh_ecx);
1625extern Int VGOFF_(sh_edx);
1626extern Int VGOFF_(sh_ebx);
1627extern Int VGOFF_(sh_esp);
1628extern Int VGOFF_(sh_ebp);
1629extern Int VGOFF_(sh_esi);
1630extern Int VGOFF_(sh_edi);
1631extern Int VGOFF_(sh_eflags);
1632
1633
1634/* -----------------------------------------------------
1635 Read-only parts of baseBlock.
1636 -------------------------------------------------- */
1637
1638/* Offsets of addresses of helper functions. A "helper" function is
1639 one which is called from generated code. */
1640
1641extern Int VGOFF_(helper_idiv_64_32);
1642extern Int VGOFF_(helper_div_64_32);
1643extern Int VGOFF_(helper_idiv_32_16);
1644extern Int VGOFF_(helper_div_32_16);
1645extern Int VGOFF_(helper_idiv_16_8);
1646extern Int VGOFF_(helper_div_16_8);
1647
1648extern Int VGOFF_(helper_imul_32_64);
1649extern Int VGOFF_(helper_mul_32_64);
1650extern Int VGOFF_(helper_imul_16_32);
1651extern Int VGOFF_(helper_mul_16_32);
1652extern Int VGOFF_(helper_imul_8_16);
1653extern Int VGOFF_(helper_mul_8_16);
1654
1655extern Int VGOFF_(helper_CLD);
1656extern Int VGOFF_(helper_STD);
1657extern Int VGOFF_(helper_get_dirflag);
1658
1659extern Int VGOFF_(helper_shldl);
1660extern Int VGOFF_(helper_shldw);
1661extern Int VGOFF_(helper_shrdl);
1662extern Int VGOFF_(helper_shrdw);
1663
1664extern Int VGOFF_(helper_RDTSC);
1665extern Int VGOFF_(helper_CPUID);
1666
sewardjde4a1d02002-03-22 01:27:54 +00001667extern Int VGOFF_(helper_bsf);
1668extern Int VGOFF_(helper_bsr);
1669
1670extern Int VGOFF_(helper_fstsw_AX);
1671extern Int VGOFF_(helper_SAHF);
sewardj4d0ab1f2002-03-24 10:00:09 +00001672extern Int VGOFF_(helper_DAS);
sewardjfe8a1662002-03-24 11:54:07 +00001673extern Int VGOFF_(helper_DAA);
sewardjde4a1d02002-03-22 01:27:54 +00001674
1675extern Int VGOFF_(helper_value_check4_fail);
1676extern Int VGOFF_(helper_value_check2_fail);
1677extern Int VGOFF_(helper_value_check1_fail);
1678extern Int VGOFF_(helper_value_check0_fail);
1679
sewardjde4a1d02002-03-22 01:27:54 +00001680extern Int VGOFF_(helperc_STOREV4); /* :: UInt -> Addr -> void */
1681extern Int VGOFF_(helperc_STOREV2); /* :: UInt -> Addr -> void */
1682extern Int VGOFF_(helperc_STOREV1); /* :: UInt -> Addr -> void */
1683
1684extern Int VGOFF_(helperc_LOADV4); /* :: Addr -> UInt -> void */
1685extern Int VGOFF_(helperc_LOADV2); /* :: Addr -> UInt -> void */
1686extern Int VGOFF_(helperc_LOADV1); /* :: Addr -> UInt -> void */
1687
1688extern Int VGOFF_(handle_esp_assignment); /* :: Addr -> void */
1689extern Int VGOFF_(fpu_write_check); /* :: Addr -> Int -> void */
1690extern Int VGOFF_(fpu_read_check); /* :: Addr -> Int -> void */
1691
sewardjde4a1d02002-03-22 01:27:54 +00001692
1693
1694#endif /* ndef __VG_INCLUDE_H */
1695
sewardj3b2736a2002-03-24 12:18:35 +00001696
1697/* ---------------------------------------------------------------------
1698 Finally - autoconf-generated settings
1699 ------------------------------------------------------------------ */
1700
1701#include "config.h"
1702
sewardjde4a1d02002-03-22 01:27:54 +00001703/*--------------------------------------------------------------------*/
1704/*--- end vg_include.h ---*/
1705/*--------------------------------------------------------------------*/