njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 1 | |
| 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 | |
njn | 4a164d0 | 2005-06-18 18:49:40 +0000 | [diff] [blame] | 31 | #ifndef __PUB_TOOL_MACHINE_H |
| 32 | #define __PUB_TOOL_MACHINE_H |
njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 33 | |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame^] | 34 | /* VG_STACK_REDZONE_SZB: how many bytes below the stack pointer are validly |
njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 35 | * addressible? */ |
| 36 | #if defined(VGA_x86) |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame^] | 37 | # define VG_MIN_INSTR_SZB 1 |
| 38 | # define VG_MAX_INSTR_SZB 16 |
| 39 | # define VG_STACK_REDZONE_SZB 0 |
njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 40 | #elif defined(VGA_amd64) |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame^] | 41 | # define VG_MIN_INSTR_SZB 1 |
| 42 | # define VG_MAX_INSTR_SZB 16 |
| 43 | # define VG_STACK_REDZONE_SZB 128 |
njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 44 | #elif defined(VGA_arm) |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame^] | 45 | # define VG_MIN_INSTR_SZB 4 |
| 46 | # define VG_MAX_INSTR_SZB 4 |
| 47 | # define VG_STACK_REDZONE_SZB 0 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 48 | #elif defined(VGA_ppc32) |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame^] | 49 | # define VG_MIN_INSTR_SZB 4 |
| 50 | # define VG_MAX_INSTR_SZB 4 |
| 51 | # define VG_STACK_REDZONE_SZB 0 |
njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 52 | #else |
| 53 | # error Unknown arch |
| 54 | #endif |
| 55 | |
| 56 | // Guest state accessors |
| 57 | extern Addr VG_(get_SP) ( ThreadId tid ); |
| 58 | extern Addr VG_(get_IP) ( ThreadId tid ); |
| 59 | extern Addr VG_(get_FP) ( ThreadId tid ); |
| 60 | |
| 61 | extern void VG_(set_SP) ( ThreadId tid, Addr sp ); |
| 62 | extern void VG_(set_IP) ( ThreadId tid, Addr ip ); |
| 63 | |
| 64 | // For get/set, 'area' is where the asked-for shadow state will be copied |
| 65 | // into/from. |
| 66 | extern void VG_(get_shadow_regs_area) ( ThreadId tid, OffT guest_state_offset, |
| 67 | SizeT size, UChar* area ); |
| 68 | extern void VG_(set_shadow_regs_area) ( ThreadId tid, OffT guest_state_offset, |
| 69 | SizeT size, const UChar* area ); |
| 70 | |
njn | 6ace3ea | 2005-06-17 03:06:27 +0000 | [diff] [blame] | 71 | // Apply a function 'f' to all the general purpose registers in all the |
| 72 | // current threads. |
| 73 | // This is very Memcheck-specific -- it's used to find the roots when |
| 74 | // doing leak checking. |
| 75 | extern void VG_(apply_to_GP_regs)(void (*f)(UWord val)); |
| 76 | |
njn | b506bd8 | 2005-06-21 04:01:51 +0000 | [diff] [blame] | 77 | // Searches through all thread stacks to see if any match. Returns |
| 78 | // VG_INVALID_THREADID if none match. |
| 79 | extern ThreadId VG_(first_matching_thread_stack) |
| 80 | ( Bool (*p) ( Addr stack_min, Addr stack_max, void* d ), |
| 81 | void* d ); |
| 82 | |
njn | 4a164d0 | 2005-06-18 18:49:40 +0000 | [diff] [blame] | 83 | #endif // __PUB_TOOL_MACHINE_H |
njn | f536bbb | 2005-06-13 04:21:38 +0000 | [diff] [blame] | 84 | |
| 85 | /*--------------------------------------------------------------------*/ |
| 86 | /*--- end ---*/ |
| 87 | /*--------------------------------------------------------------------*/ |