blob: 3f8aec31a603f20dac216705923cbbf4c97e1300 [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001
2/*--------------------------------------------------------------------*/
njn717cde52005-05-10 02:47:21 +00003/*--- A header file for various private parts of Valgrind's core. ---*/
rjwalsh7109a8c2004-09-02 00:31:02 +00004/*--- core.h ---*/
sewardjde4a1d02002-03-22 01:27:54 +00005/*--------------------------------------------------------------------*/
6
7/*
njnb9c427c2004-12-01 14:14:42 +00008 This file is part of Valgrind, a dynamic binary instrumentation
9 framework.
sewardjde4a1d02002-03-22 01:27:54 +000010
njn53612422005-03-12 16:22:54 +000011 Copyright (C) 2000-2005 Julian Seward
sewardjde4a1d02002-03-22 01:27:54 +000012 jseward@acm.org
sewardjde4a1d02002-03-22 01:27:54 +000013
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License as
16 published by the Free Software Foundation; either version 2 of the
17 License, or (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27 02111-1307, USA.
28
njn25e49d8e72002-09-23 09:36:25 +000029 The GNU General Public License is contained in the file COPYING.
sewardjde4a1d02002-03-22 01:27:54 +000030*/
31
rjwalsh7109a8c2004-09-02 00:31:02 +000032#ifndef __CORE_H
33#define __CORE_H
sewardjde4a1d02002-03-22 01:27:54 +000034
nethercote13343132004-09-02 15:49:09 +000035#include "tool.h" // tool stuff
nethercotebb4222b2004-09-10 17:42:11 +000036#include "core_arch.h" // arch-specific stuff, eg. x86/core_arch.h
nethercote8ff888f2004-11-17 17:11:45 +000037
sewardjb5f6f512005-03-10 23:59:00 +000038#include "core_os.h" // OS-specific stuff, eg. linux/core_os.h
sewardjde4a1d02002-03-22 01:27:54 +000039
njn278b3d62005-05-30 23:20:51 +000040#include <setjmp.h> // for jmp_buf
njnd01fef72005-03-25 23:35:48 +000041
njn278b3d62005-05-30 23:20:51 +000042#include "pub_core_mallocfree.h" // for type 'ArenaId'
43#include "pub_core_scheduler.h" // for types 'ThreadState', 'ThreadArchState'
44#include "pub_core_stacktrace.h" // for type 'StackTrace'
njn4f6e3702005-05-16 20:50:52 +000045
nethercote7be47252004-09-02 16:02:58 +000046/* ---------------------------------------------------------------------
njn14319cc2005-03-13 06:26:22 +000047 Global macros.
nethercote7be47252004-09-02 16:02:58 +000048 ------------------------------------------------------------------ */
49
sewardjde4a1d02002-03-22 01:27:54 +000050/* Max length of a text fragment used to construct error messages. */
njn47b209a2005-03-25 23:47:16 +000051#define VG_ERRTXT_LEN 4096
sewardjde4a1d02002-03-22 01:27:54 +000052
sewardjde4a1d02002-03-22 01:27:54 +000053/* The maximum number of calls we're prepared to save in a
54 backtrace. */
55#define VG_DEEPEST_BACKTRACE 50
56
fitzhardinge98abfc72003-12-16 02:05:15 +000057/* Useful macros */
58/* a - alignment - must be a power of 2 */
tomde2ec262005-03-29 12:16:10 +000059#define ROUNDDN(p, a) ((Addr)(p) & ~((Addr)(a)-1))
fitzhardinge98abfc72003-12-16 02:05:15 +000060#define ROUNDUP(p, a) ROUNDDN((p)+(a)-1, (a))
nethercote73b526f2004-10-31 18:48:21 +000061#define PGROUNDDN(p) ROUNDDN(p, VKI_PAGE_SIZE)
62#define PGROUNDUP(p) ROUNDUP(p, VKI_PAGE_SIZE)
fitzhardinge98abfc72003-12-16 02:05:15 +000063
sewardj51ac0872004-12-21 01:20:49 +000064
nethercote80013e92004-09-05 20:39:51 +000065/* ---------------------------------------------------------------------
66 Environment variables
67 ------------------------------------------------------------------ */
68
69/* The directory we look for all our auxillary files in */
70#define VALGRINDLIB "VALGRINDLIB"
71
72/* Additional command-line arguments; they are overridden by actual
73 command-line option. Each argument is separated by spaces. There
74 is no quoting mechanism.
75 */
76#define VALGRINDOPTS "VALGRIND_OPTS"
77
78/* If this variable is present in the environment, then valgrind will
79 not parse the command line for options at all; all options come
80 from this variable. Arguments are terminated by ^A (\001). There
81 is no quoting mechanism.
82
83 This variable is not expected to be set by anything other than
84 Valgrind itself, as part of its handling of execve with
85 --trace-children=yes. This variable should not be present in the
86 client environment.
87 */
88#define VALGRINDCLO "_VALGRIND_CLO"
89
fitzhardinge98abfc72003-12-16 02:05:15 +000090
thughesad1c9562004-06-26 11:27:52 +000091/* Application-visible file descriptor limits */
92extern Int VG_(fd_soft_limit);
93extern Int VG_(fd_hard_limit);
fitzhardingef0046f22003-12-18 02:39:22 +000094
sewardjde4a1d02002-03-22 01:27:54 +000095/* ---------------------------------------------------------------------
nethercote85cdd342004-08-01 22:36:40 +000096 Profiling stuff
sewardjde4a1d02002-03-22 01:27:54 +000097 ------------------------------------------------------------------ */
98
njn31066fd2005-03-26 00:42:02 +000099extern void VG_(init_profiling) ( void );
100extern void VG_(done_profiling) ( void );
sewardjde4a1d02002-03-22 01:27:54 +0000101
njn25e49d8e72002-09-23 09:36:25 +0000102#undef VGP_PUSHCC
103#undef VGP_POPCC
njn31066fd2005-03-26 00:42:02 +0000104#define VGP_PUSHCC(x) if (VG_(clo_profile)) VG_(pushcc)(x)
105#define VGP_POPCC(x) if (VG_(clo_profile)) VG_(popcc)(x)
sewardjde4a1d02002-03-22 01:27:54 +0000106
sewardj51ac0872004-12-21 01:20:49 +0000107
sewardjde4a1d02002-03-22 01:27:54 +0000108/* ---------------------------------------------------------------------
njn3e884182003-04-15 13:03:23 +0000109 Exports of vg_intercept.c
sewardj2e93c502002-04-12 11:12:52 +0000110 ------------------------------------------------------------------ */
111
njna91498f2005-05-11 22:32:39 +0000112/* These are the internal client request codes. The publically-visible
113 request codes are also defined in valgrind.h, and similar headers for
114 some tools. */
sewardj2e93c502002-04-12 11:12:52 +0000115
njna91498f2005-05-11 22:32:39 +0000116/* Get the tool's malloc-wrapping functions */
fitzhardinge98abfc72003-12-16 02:05:15 +0000117#define VG_USERREQ__GET_MALLOCFUNCS 0x3030
sewardjb5f6f512005-03-10 23:59:00 +0000118
fitzhardinge39de4b42003-10-31 07:12:21 +0000119/* Internal equivalent of VALGRIND_PRINTF . */
120#define VG_USERREQ__INTERNAL_PRINTF 0x3103
sewardj45b4b372002-04-16 22:50:32 +0000121
sewardjb5f6f512005-03-10 23:59:00 +0000122/* Denote the finish of __libc_freeres_wrapper().
123 A synonym for exit. */
124#define VG_USERREQ__LIBC_FREERES_DONE 0x3029
sewardj54cacf02002-04-12 23:24:59 +0000125
njn717cde52005-05-10 02:47:21 +0000126/* Intercept prefix stuff. See
127 coregrind/m_replace_malloc/vg_replace_malloc.c for details.
128 Unfortunately the "_vgi_" literal is also hardcoded in that file, so if
129 you change this one you must also change the other one. */
sewardj9ee81f52005-04-02 17:38:59 +0000130#define VG_INTERCEPT_PREFIX "_vgi_"
131#define VG_INTERCEPT_PREFIX_LEN 5
rjwalshe4e779d2004-04-16 23:02:29 +0000132
sewardj9ee81f52005-04-02 17:38:59 +0000133/* Not sure what these are for. Todo: clarify */
134#define VG_WRAPPER_PREFIX "_vgw_"
135#define VG_WRAPPER_PREFIX_LEN 5
136#define VG_WRAPPER(name) _vgw_##name
137#define VG_WRAPPER_ALIAS(name) "_vgw_" #name
rjwalshe4e779d2004-04-16 23:02:29 +0000138
njn4c791212003-05-02 17:53:54 +0000139
sewardj2e93c502002-04-12 11:12:52 +0000140/* ---------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +0000141 Exports of vg_signals.c
142 ------------------------------------------------------------------ */
143
sewardjb5f6f512005-03-10 23:59:00 +0000144/* Highest signal the kernel will let us use */
145extern Int VG_(max_signal);
jsgf855d93d2003-10-13 22:26:55 +0000146
sewardjde4a1d02002-03-22 01:27:54 +0000147extern void VG_(sigstartup_actions) ( void );
148
sewardjb5f6f512005-03-10 23:59:00 +0000149/* Poll a thread's set of pending signals, and update the Thread's context to deliver one */
150extern void VG_(poll_signals) ( ThreadId );
sewardjde4a1d02002-03-22 01:27:54 +0000151
152/* Fake system calls for signal handling. */
njn502badb2005-05-08 02:04:49 +0000153extern Int VG_(do_sys_sigaltstack) ( ThreadId tid, vki_stack_t* ss,
154 vki_stack_t* oss );
155extern Int VG_(do_sys_sigaction) ( Int signo,
156 const struct vki_sigaction *new_act,
157 struct vki_sigaction *old_act );
158extern Int VG_(do_sys_sigprocmask) ( ThreadId tid, Int how,
159 vki_sigset_t* set,
160 vki_sigset_t* oldset );
sewardjefbfcdf2002-06-19 17:35:45 +0000161
njn444eba12005-05-12 03:47:31 +0000162extern void VG_(clear_out_queued_signals)
163 ( ThreadId tid, /* OUT */ vki_sigset_t* saved_mask );
sewardjde4a1d02002-03-22 01:27:54 +0000164
jsgf855d93d2003-10-13 22:26:55 +0000165extern void VG_(kill_self)(Int sigNo);
166
fitzhardingef1beb252004-03-16 09:49:08 +0000167/* These function synthesize a fault, as if the running instruction
168 had had a fault. These functions do not return - they longjmp back
169 into the scheduler so the signal can be delivered. */
170extern void VG_(synth_fault) (ThreadId tid);
171extern void VG_(synth_fault_mapping)(ThreadId tid, Addr addr);
172extern void VG_(synth_fault_perms) (ThreadId tid, Addr addr);
sewardj5e2f0012004-12-13 14:10:34 +0000173extern void VG_(synth_sigill) (ThreadId tid, Addr addr);
fitzhardingef1beb252004-03-16 09:49:08 +0000174
sewardjb5f6f512005-03-10 23:59:00 +0000175/* Extend the stack to cover addr, if possible */
176extern Bool VG_(extend_stack)(Addr addr, UInt maxsize);
177
178/* Returns True if the signal is OK for the client to use */
179extern Bool VG_(client_signal_OK)(Int sigNo);
180
181/* Forces the client's signal handler to SIG_DFL - generally just
182 before using that signal to kill the process. */
183extern void VG_(set_default_handler)(Int sig);
184
sewardjde4a1d02002-03-22 01:27:54 +0000185/* ---------------------------------------------------------------------
186 Exports of vg_mylibc.c
187 ------------------------------------------------------------------ */
188
njnca0518d2004-11-26 19:34:36 +0000189// Useful for making failing stubs, when certain things haven't yet been
190// implemented.
njn50ae1a72005-04-08 23:28:23 +0000191#define I_die_here \
sewardj0ab10c42005-05-12 08:26:36 +0000192 VG_(assert_fail) (/*isCore*//*BOGUS*/True, \
193 "Unimplemented functionality", \
njn50ae1a72005-04-08 23:28:23 +0000194 __FILE__, __LINE__, __PRETTY_FUNCTION__, \
195 "valgrind", VG_BUGS_TO, "")
njnca0518d2004-11-26 19:34:36 +0000196
njn50ae1a72005-04-08 23:28:23 +0000197#define vg_assert(expr) \
198 ((void) ((expr) ? 0 : \
199 (VG_(assert_fail) (/*isCore*/True, VG_STRINGIFY(expr), \
200 __FILE__, __LINE__, __PRETTY_FUNCTION__, \
201 ""), \
202 0)))
203
204#define vg_assert2(expr, format, args...) \
205 ((void) ((expr) ? 0 : \
206 (VG_(assert_fail) (/*isCore*/True, VG_STRINGIFY(expr), \
207 __FILE__, __LINE__, __PRETTY_FUNCTION__, \
208 format, ##args), \
209 0)))
210
njne427a662002-10-02 11:08:25 +0000211__attribute__ ((__noreturn__))
212extern void VG_(core_panic) ( Char* str );
thughes5876d552004-09-26 18:44:06 +0000213__attribute__ ((__noreturn__))
njnd01fef72005-03-25 23:35:48 +0000214extern void VG_(core_panic_at) ( Char* str, StackTrace ips );
sewardjde4a1d02002-03-22 01:27:54 +0000215
njn04e16982005-05-31 00:23:43 +0000216/* Called when some unhandleable client behaviour is detected.
217 Prints a msg and aborts. */
218extern void VG_(unimplemented) ( Char* msg )
219 __attribute__((__noreturn__));
220
221/* Tell the logging mechanism whether we are logging to a file
222 descriptor or a socket descriptor. */
223extern Bool VG_(logging_to_socket);
224
nethercote05675c82004-08-04 10:37:49 +0000225/* Tools use VG_(strdup)() which doesn't expose ArenaId */
njn25e49d8e72002-09-23 09:36:25 +0000226extern Char* VG_(arena_strdup) ( ArenaId aid, const Char* s);
sewardjde4a1d02002-03-22 01:27:54 +0000227
njn25e49d8e72002-09-23 09:36:25 +0000228extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg );
jsgf855d93d2003-10-13 22:26:55 +0000229extern Int VG_(poll)( struct vki_pollfd *, UInt nfds, Int timeout);
sewardj2e93c502002-04-12 11:12:52 +0000230
fitzhardinge98abfc72003-12-16 02:05:15 +0000231/* system/mman.h */
njn7df470b2005-05-29 18:46:38 +0000232extern void* VG_(mmap) ( void* start, SizeT length, UInt prot, UInt flags,
233 UInt sf_flags, UInt fd, OffT offset );
234extern void* VG_(mmap_native)( void* start, SizeT length, UInt prot, UInt flags,
235 UInt fd, OffT offset );
236extern Int VG_(munmap) ( void* start, SizeT length );
237extern Int VG_(mprotect) ( void *start, SizeT length, UInt prot );
sewardj79048ce2005-02-18 08:28:32 +0000238extern Int VG_(mprotect_native)( void *start, SizeT length, UInt prot );
fitzhardinge98abfc72003-12-16 02:05:15 +0000239
240
jsgf855d93d2003-10-13 22:26:55 +0000241/* Move an fd into the Valgrind-safe range */
242Int VG_(safe_fd)(Int oldfd);
243
sewardj570f8902002-11-03 11:44:36 +0000244extern Int VG_(write_socket)( Int sd, void *msg, Int count );
sewardj73cf3bc2002-11-03 03:20:15 +0000245
246/* --- Connecting over the network --- */
247extern Int VG_(connect_via_socket)( UChar* str );
248
fitzhardinge98abfc72003-12-16 02:05:15 +0000249/* Environment manipulations */
nethercote60a96c52004-08-03 13:08:31 +0000250extern Char **VG_(env_setenv) ( Char ***envp, const Char* varname,
251 const Char *val );
252extern void VG_(env_unsetenv) ( Char **env, const Char *varname );
253extern void VG_(env_remove_valgrind_env_stuff) ( Char** env );
sewardj570f8902002-11-03 11:44:36 +0000254
sewardjb5f6f512005-03-10 23:59:00 +0000255extern void VG_(nanosleep)(struct vki_timespec *);
njn2521d322005-05-08 14:45:13 +0000256
sewardj570f8902002-11-03 11:44:36 +0000257/* ---------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +0000258 Exports of vg_symtab2.c
259 ------------------------------------------------------------------ */
260
fitzhardinge98abfc72003-12-16 02:05:15 +0000261typedef struct _Segment Segment;
sewardjb5f6f512005-03-10 23:59:00 +0000262typedef struct _CodeRedirect CodeRedirect;
fitzhardinge98abfc72003-12-16 02:05:15 +0000263
264extern Bool VG_(is_object_file) ( const void *hdr );
fitzhardinge98abfc72003-12-16 02:05:15 +0000265extern SegInfo * VG_(read_seg_symbols) ( Segment *seg );
njn36ef6ba2005-05-14 18:42:26 +0000266extern void VG_(seginfo_incref) ( SegInfo * );
267extern void VG_(seginfo_decref) ( SegInfo *, Addr a );
sewardjde4a1d02002-03-22 01:27:54 +0000268
njn25e49d8e72002-09-23 09:36:25 +0000269extern Bool VG_(get_fnname_nodemangle)( Addr a, Char* fnname, Int n_fnname );
sewardj25c7c3a2003-07-10 00:17:58 +0000270
sewardjb5f6f512005-03-10 23:59:00 +0000271extern Addr VG_(reverse_search_one_symtab) ( const SegInfo* si, const Char* name );
272
sewardj35165532005-04-30 18:47:48 +0000273extern Bool VG_(use_CFI_info) ( /*MOD*/Addr* ipP,
274 /*MOD*/Addr* spP,
275 /*MOD*/Addr* fpP,
276 Addr min_accessible,
277 Addr max_accessible );
278
279
sewardjb5f6f512005-03-10 23:59:00 +0000280/* ---------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +0000281 Exports of vg_syscall.S
282 ------------------------------------------------------------------ */
283
njnca6fef02004-11-29 16:49:18 +0000284// We use a full prototype rather than "..." here to ensure that all
285// arguments get converted to a UWord appropriately. Not doing so can
286// cause problems when passing 32-bit integers on 64-bit platforms, because
287// the top 32-bits might not be zeroed appropriately, eg. as would happen
288// with the 6th arg on AMD64 which is passed on the stack.
njnf4aeaea2004-11-29 17:33:31 +0000289extern Word VG_(do_syscall) ( UInt, UWord, UWord, UWord, UWord, UWord, UWord );
njnca6fef02004-11-29 16:49:18 +0000290
291// Macros make life easier.
292#define vgPlain_do_syscall0(s) VG_(do_syscall)((s),0,0,0,0,0,0)
293#define vgPlain_do_syscall1(s,a) VG_(do_syscall)((s),(a),0,0,0,0,0)
294#define vgPlain_do_syscall2(s,a,b) VG_(do_syscall)((s),(a),(b),0,0,0,0)
295#define vgPlain_do_syscall3(s,a,b,c) VG_(do_syscall)((s),(a),(b),(c),0,0,0)
296#define vgPlain_do_syscall4(s,a,b,c,d) VG_(do_syscall)((s),(a),(b),(c),(d),0,0)
297#define vgPlain_do_syscall5(s,a,b,c,d,e) VG_(do_syscall)((s),(a),(b),(c),(d),(e),0)
298#define vgPlain_do_syscall6(s,a,b,c,d,e,f) VG_(do_syscall)((s),(a),(b),(c),(d),(e),(f))
299
fitzhardinge4f10ada2004-06-03 10:00:42 +0000300extern void VG_(sigreturn)(void);
sewardjde4a1d02002-03-22 01:27:54 +0000301
302/* ---------------------------------------------------------------------
sewardjde4a1d02002-03-22 01:27:54 +0000303 Exports of vg_helpers.S
304 ------------------------------------------------------------------ */
305
fitzhardinge92360792003-12-24 10:11:11 +0000306/* Information about trampoline code (for signal return and syscalls) */
307extern const Char VG_(trampoline_code_start);
308extern const Int VG_(trampoline_code_length);
309extern const Int VG_(tramp_sigreturn_offset);
sewardjb5f6f512005-03-10 23:59:00 +0000310extern const Int VG_(tramp_rt_sigreturn_offset);
fitzhardinge92360792003-12-24 10:11:11 +0000311extern const Int VG_(tramp_syscall_offset);
tomee0bcbf2005-05-02 10:28:42 +0000312extern const Int VG_(tramp_gettimeofday_offset);
313extern const Int VG_(tramp_time_offset);
sewardj20917d82002-05-28 01:36:45 +0000314
nethercotec06e2132004-09-03 13:45:29 +0000315// ---------------------------------------------------------------------
316// Architecture-specific things defined in eg. x86/*.c
317// ---------------------------------------------------------------------
318
sewardj51ac0872004-12-21 01:20:49 +0000319// Returns the architecture and subarchitecture, or indicates
320// that this subarchitecture is unable to run Valgrind
321// Returns False to indicate we cannot proceed further.
sewardj51ac0872004-12-21 01:20:49 +0000322extern Bool VGA_(getArchAndSubArch)( /*OUT*/VexArch*,
323 /*OUT*/VexSubArch* );
njncf45fd42004-11-24 16:30:22 +0000324// Accessors for the ThreadArchState
njn35172bc2005-03-26 00:04:03 +0000325#define INSTR_PTR(regs) ((regs).vex.VGA_INSTR_PTR)
326#define STACK_PTR(regs) ((regs).vex.VGA_STACK_PTR)
327#define FRAME_PTR(regs) ((regs).vex.VGA_FRAME_PTR)
328#define CLREQ_ARGS(regs) ((regs).vex.VGA_CLREQ_ARGS)
njn35172bc2005-03-26 00:04:03 +0000329#define CLREQ_RET(regs) ((regs).vex.VGA_CLREQ_RET)
njn16de5572004-11-27 14:27:21 +0000330// Offsets for the Vex state
njn35172bc2005-03-26 00:04:03 +0000331#define O_STACK_PTR (offsetof(VexGuestArchState, VGA_STACK_PTR))
332#define O_FRAME_PTR (offsetof(VexGuestArchState, VGA_FRAME_PTR))
333#define O_CLREQ_RET (offsetof(VexGuestArchState, VGA_CLREQ_RET))
njncf45fd42004-11-24 16:30:22 +0000334
335
sewardj2a99cf62004-11-24 10:44:19 +0000336// Setting up the initial thread (1) state
337extern void
338 VGA_(init_thread1state) ( Addr client_eip,
339 Addr esp_at_startup,
340 /*MOD*/ ThreadArchState* arch );
sewardjde4a1d02002-03-22 01:27:54 +0000341
sewardjb5f6f512005-03-10 23:59:00 +0000342// OS/Platform-specific thread clear (after thread exit)
sewardj1d887112005-05-30 21:44:08 +0000343extern void VGO_(os_state_clear)(ThreadState *);
sewardjb5f6f512005-03-10 23:59:00 +0000344
345// OS/Platform-specific thread init (at scheduler init time)
sewardj1d887112005-05-30 21:44:08 +0000346extern void VGO_(os_state_init)(ThreadState *);
sewardjb5f6f512005-03-10 23:59:00 +0000347
sewardj1d887112005-05-30 21:44:08 +0000348// Run a thread from beginning to end.
349extern VgSchedReturnCode VGO_(thread_wrapper)(Word /*ThreadId*/ tid);
sewardjb5f6f512005-03-10 23:59:00 +0000350
sewardj1d887112005-05-30 21:44:08 +0000351// Call here to exit the entire Valgrind system.
352extern void VGO_(terminate_NORETURN)(ThreadId tid, VgSchedReturnCode src);
353
354// Allocates a stack for the first thread, then runs it,
355// as if the thread had been set up by clone()
356extern void VGP_(main_thread_wrapper_NORETURN)(ThreadId tid);
sewardjb5f6f512005-03-10 23:59:00 +0000357
358// Return how many bytes of a thread's Valgrind stack are unused
sewardj1d887112005-05-30 21:44:08 +0000359extern SSizeT VGA_(stack_unused)(ThreadId tid);
sewardjb5f6f512005-03-10 23:59:00 +0000360
sewardjb5f6f512005-03-10 23:59:00 +0000361// wait until all other threads are dead
362extern void VGA_(reap_threads)(ThreadId self);
363
364// handle an arch-specific client request
365extern Bool VGA_(client_request)(ThreadId tid, UWord *args);
366
nethercotefedd8102004-09-13 15:19:34 +0000367// Pointercheck
njn04e16982005-05-31 00:23:43 +0000368extern Bool VGA_(setup_pointercheck) ( Addr client_base, Addr client_end );
nethercotefedd8102004-09-13 15:19:34 +0000369
370// For attaching the debugger
sewardj2a99cf62004-11-24 10:44:19 +0000371extern Int VGA_(ptrace_setregs_from_tst) ( Int pid, ThreadArchState* arch );
nethercotefedd8102004-09-13 15:19:34 +0000372
sewardjb5f6f512005-03-10 23:59:00 +0000373// Used by leakcheck
374extern void VGA_(mark_from_registers)(ThreadId tid, void (*marker)(Addr));
375
njn20242342005-05-16 23:31:24 +0000376// Set up the libc freeres wrapper
377extern void VGA_(intercept_libc_freeres_wrapper)(Addr);
378
379// Clean up the client by calling before the final reports
380extern void VGA_(final_tidyup)(ThreadId tid);
381
382// Arch-specific client requests
383extern Bool VGA_(client_requests)(ThreadId tid, UWord *args);
384
nethercote9b3c7652004-10-19 13:18:00 +0000385
sewardjb5f6f512005-03-10 23:59:00 +0000386///* ---------------------------------------------------------------------
387// Thread modelling
388// ------------------------------------------------------------------ */
389//extern void VG_(tm_thread_create) (ThreadId creator, ThreadId tid, Bool detached);
390//extern void VG_(tm_thread_exit) (ThreadId tid);
391//extern Bool VG_(tm_thread_exists) (ThreadId tid);
392//extern void VG_(tm_thread_detach) (ThreadId tid);
393//extern void VG_(tm_thread_join) (ThreadId joiner, ThreadId joinee);
394//extern void VG_(tm_thread_switchto)(ThreadId tid);
395//
396//extern void VG_(tm_mutex_init) (ThreadId tid, Addr mutexp);
397//extern void VG_(tm_mutex_destroy)(ThreadId tid, Addr mutexp);
398//extern void VG_(tm_mutex_trylock)(ThreadId tid, Addr mutexp);
399//extern void VG_(tm_mutex_giveup) (ThreadId tid, Addr mutexp);
400//extern void VG_(tm_mutex_acquire)(ThreadId tid, Addr mutexp);
401//extern void VG_(tm_mutex_tryunlock)(ThreadId tid, Addr mutexp);
402//extern void VG_(tm_mutex_unlock) (ThreadId tid, Addr mutexp);
403//extern Bool VG_(tm_mutex_exists) (Addr mutexp);
404//
405//extern UInt VG_(tm_error_update_extra) (Error *err);
406//extern Bool VG_(tm_error_equal) (VgRes res, Error *e1, Error *e2);
407//extern void VG_(tm_error_print) (Error *err);
408//
409//extern void VG_(tm_init) ();
410//
411//extern void VG_(tm_cond_init) (ThreadId tid, Addr condp);
412//extern void VG_(tm_cond_destroy) (ThreadId tid, Addr condp);
413//extern void VG_(tm_cond_wait) (ThreadId tid, Addr condp, Addr mutexp);
414//extern void VG_(tm_cond_wakeup) (ThreadId tid, Addr condp, Addr mutexp);
415//extern void VG_(tm_cond_signal) (ThreadId tid, Addr condp);
416//
417///* ----- pthreads ----- */
418//extern void VG_(pthread_init) ();
419//extern void VG_(pthread_startfunc_wrapper)(Addr wrapper);
420//
421//struct vg_pthread_newthread_data {
422// void *(*startfunc)(void *arg);
423// void *arg;
424//};
sewardj3b2736a2002-03-24 12:18:35 +0000425
426/* ---------------------------------------------------------------------
427 Finally - autoconf-generated settings
428 ------------------------------------------------------------------ */
429
430#include "config.h"
431
nethercotec06e2132004-09-03 13:45:29 +0000432#endif /* ndef __CORE_H */
433
sewardjde4a1d02002-03-22 01:27:54 +0000434/*--------------------------------------------------------------------*/
nethercote109d0df2004-09-02 08:10:13 +0000435/*--- end ---*/
sewardjde4a1d02002-03-22 01:27:54 +0000436/*--------------------------------------------------------------------*/