blob: 948df5ac6c1bada853afe41503327fd69c637d2b [file] [log] [blame]
njnf536bbb2005-06-13 04:21:38 +00001
2/*--------------------------------------------------------------------*/
3/*--- Machine-related stuff. pub_tool_machine.h ---*/
4/*--------------------------------------------------------------------*/
5
6/*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
9
10 Copyright (C) 2000-2005 Julian Seward
11 jseward@acm.org
12
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
26 02111-1307, USA.
27
28 The GNU General Public License is contained in the file COPYING.
29*/
30
njn4a164d02005-06-18 18:49:40 +000031#ifndef __PUB_TOOL_MACHINE_H
32#define __PUB_TOOL_MACHINE_H
njnf536bbb2005-06-13 04:21:38 +000033
njnf536bbb2005-06-13 04:21:38 +000034#if defined(VGA_x86)
njna5ad9ba2005-11-10 15:20:37 +000035# define VG_MIN_INSTR_SZB 1 // min length of native instruction
36# define VG_MAX_INSTR_SZB 16 // max length of native instruction
37# define VG_CLREQ_SZB 18 // length of a client request, may
38 // be larger than VG_MAX_INSTR_SZB
39# define VG_STACK_REDZONE_SZB 0 // number of addressable bytes below SP
njnf536bbb2005-06-13 04:21:38 +000040#elif defined(VGA_amd64)
njnaf839f52005-06-23 03:27:57 +000041# define VG_MIN_INSTR_SZB 1
42# define VG_MAX_INSTR_SZB 16
njna5ad9ba2005-11-10 15:20:37 +000043# define VG_CLREQ_SZB 18
njnaf839f52005-06-23 03:27:57 +000044# define VG_STACK_REDZONE_SZB 128
cerion85665ca2005-06-20 15:51:07 +000045#elif defined(VGA_ppc32)
njnaf839f52005-06-23 03:27:57 +000046# define VG_MIN_INSTR_SZB 4
47# define VG_MAX_INSTR_SZB 4
njna5ad9ba2005-11-10 15:20:37 +000048# define VG_CLREQ_SZB 24
njnaf839f52005-06-23 03:27:57 +000049# define VG_STACK_REDZONE_SZB 0
sewardj2c48c7b2005-11-29 13:05:56 +000050#elif defined(VGA_ppc64)
51# define VG_MIN_INSTR_SZB 4
52# define VG_MAX_INSTR_SZB 4
53# define VG_CLREQ_SZB 24
54# define VG_STACK_REDZONE_SZB 0
njnf536bbb2005-06-13 04:21:38 +000055#else
56# error Unknown arch
57#endif
58
59// Guest state accessors
60extern Addr VG_(get_SP) ( ThreadId tid );
61extern Addr VG_(get_IP) ( ThreadId tid );
62extern Addr VG_(get_FP) ( ThreadId tid );
sewardjacaec5f2005-08-19 16:02:59 +000063extern Addr VG_(get_LR) ( ThreadId tid );
njnf536bbb2005-06-13 04:21:38 +000064
65extern void VG_(set_SP) ( ThreadId tid, Addr sp );
66extern void VG_(set_IP) ( ThreadId tid, Addr ip );
67
68// For get/set, 'area' is where the asked-for shadow state will be copied
69// into/from.
70extern void VG_(get_shadow_regs_area) ( ThreadId tid, OffT guest_state_offset,
71 SizeT size, UChar* area );
72extern void VG_(set_shadow_regs_area) ( ThreadId tid, OffT guest_state_offset,
73 SizeT size, const UChar* area );
74
njn6ace3ea2005-06-17 03:06:27 +000075// Apply a function 'f' to all the general purpose registers in all the
76// current threads.
77// This is very Memcheck-specific -- it's used to find the roots when
78// doing leak checking.
79extern void VG_(apply_to_GP_regs)(void (*f)(UWord val));
80
njn1d0cb0d2005-08-15 01:52:02 +000081// This iterator lets you inspect each live thread's stack bounds. The
82// params are all 'out' params. Returns False at the end.
83extern void VG_(thread_stack_reset_iter) ( void );
84extern Bool VG_(thread_stack_next) ( ThreadId* tid, Addr* stack_min,
85 Addr* stack_max );
njnb506bd82005-06-21 04:01:51 +000086
sewardj53ee1fc2005-12-23 02:29:58 +000087// Given a pointer to a function as obtained by "& functionname" in C,
88// produce a pointer to the actual entry point for the function. For
89// most platforms it's the identity function. Unfortunately, on
90// ppc64-linux it isn't (sigh).
91extern void* VG_(fnptr_to_fnentry)( void* );
92
njn4a164d02005-06-18 18:49:40 +000093#endif // __PUB_TOOL_MACHINE_H
njnf536bbb2005-06-13 04:21:38 +000094
95/*--------------------------------------------------------------------*/
96/*--- end ---*/
97/*--------------------------------------------------------------------*/