]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/valgrind/src/valgrind-3.6.0-svn/include/pub_tool_machine.h
update
[l4.git] / l4 / pkg / valgrind / src / valgrind-3.6.0-svn / include / pub_tool_machine.h
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-2010 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
31 #ifndef __PUB_TOOL_MACHINE_H
32 #define __PUB_TOOL_MACHINE_H
33
34 #if defined(VGP_x86_linux)
35 #  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             14  // 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 %RSP
40
41 #elif defined(VGP_amd64_linux)
42 #  define VG_MIN_INSTR_SZB          1
43 #  define VG_MAX_INSTR_SZB         16
44 #  define VG_CLREQ_SZB             19
45 #  define VG_STACK_REDZONE_SZB    128
46
47 #elif defined(VGP_ppc32_linux)
48 #  define VG_MIN_INSTR_SZB          4
49 #  define VG_MAX_INSTR_SZB          4 
50 #  define VG_CLREQ_SZB             20
51 #  define VG_STACK_REDZONE_SZB      0
52
53 #elif defined(VGP_ppc64_linux)
54 #  define VG_MIN_INSTR_SZB          4
55 #  define VG_MAX_INSTR_SZB          4 
56 #  define VG_CLREQ_SZB             20
57 #  define VG_STACK_REDZONE_SZB    288  // number of addressable bytes below R1
58                                        // from 64-bit PowerPC ELF ABI 
59                                        // Supplement 1.7
60
61 #elif defined(VGP_arm_linux)
62 #  define VG_MIN_INSTR_SZB          2
63 #  define VG_MAX_INSTR_SZB          4 
64 #  define VG_CLREQ_SZB             20
65 #  define VG_STACK_REDZONE_SZB      0
66
67 #elif defined(VGP_ppc32_aix5)
68 #  define VG_MIN_INSTR_SZB          4
69 #  define VG_MAX_INSTR_SZB          4 
70 #  define VG_CLREQ_SZB             20
71    /* The PowerOpen ABI actually says 220 bytes, but that is not an
72       8-aligned number, and frequently forces Memcheck's
73       mc_{new,die}_mem_stack_N routines into slow cases by losing
74       8-alignment of the area to be messed with.  So let's just say
75       224 instead.  Gdb has a similar kludge. */
76 #  define VG_STACK_REDZONE_SZB    224
77
78 #elif defined(VGP_ppc64_aix5)
79 #  define VG_MIN_INSTR_SZB          4
80 #  define VG_MAX_INSTR_SZB          4 
81 #  define VG_CLREQ_SZB             20
82 #  define VG_STACK_REDZONE_SZB    288 // is this right?
83
84 #elif defined(VGP_s390x_linux)
85 #  define VG_MIN_INSTR_SZB          2
86 #  define VG_MAX_INSTR_SZB          6
87 #  define VG_CLREQ_SZB             10
88 #  define VG_STACK_REDZONE_SZB      0  // s390 has no redzone
89
90 #elif defined(VGP_x86_darwin)
91 #  define VG_MIN_INSTR_SZB          1  // min length of native instruction
92 #  define VG_MAX_INSTR_SZB         16  // max length of native instruction
93 #  define VG_CLREQ_SZB             14  // length of a client request, may
94                                        //   be larger than VG_MAX_INSTR_SZB
95 #  define VG_STACK_REDZONE_SZB      0  // number of addressable bytes below %RSP
96
97 #elif defined(VGP_amd64_darwin)
98 #  define VG_MIN_INSTR_SZB          1
99 #  define VG_MAX_INSTR_SZB         16
100 #  define VG_CLREQ_SZB             19
101 #  define VG_STACK_REDZONE_SZB    128
102
103 #elif defined(VGP_x86_l4re)
104 #  define VG_MIN_INSTR_SZB          1  // min length of native instruction
105 #  define VG_MAX_INSTR_SZB         16  // max length of native instruction
106 #  define VG_CLREQ_SZB             14  // length of a client request, may
107                                        //   be larger than VG_MAX_INSTR_SZB
108 #  define VG_STACK_REDZONE_SZB      0  // number of addressable bytes below %RSP
109
110 #else
111 #  error Unknown platform
112 #endif
113
114 // Guest state accessors
115 // Are mostly in the core_ header.
116 //  Only these two are available to tools.
117 Addr VG_(get_IP) ( ThreadId tid );
118 Addr VG_(get_SP) ( ThreadId tid );
119
120
121 // For get/set, 'area' is where the asked-for guest state will be copied
122 // into/from.  If shadowNo == 0, the real (non-shadow) guest state is
123 // accessed.  If shadowNo == 1, the first shadow area is accessed, and
124 // if shadowNo == 2, the second shadow area is accessed.  This gives a
125 // completely general way to read/modify a thread's guest register state
126 // providing you know the offsets you need.
127 void
128 VG_(get_shadow_regs_area) ( ThreadId tid, 
129                             /*DST*/UChar* dst,
130                             /*SRC*/Int shadowNo, PtrdiffT offset, SizeT size );
131 void
132 VG_(set_shadow_regs_area) ( ThreadId tid, 
133                             /*DST*/Int shadowNo, PtrdiffT offset, SizeT size,
134                             /*SRC*/const UChar* src );
135
136 // Sets the shadow values for the syscall return value register(s).
137 // This is platform specific.
138 void VG_(set_syscall_return_shadows) ( ThreadId tid,
139                                        /* shadow vals for the result */
140                                        UWord s1res, UWord s2res,
141                                        /* shadow vals for the error val */
142                                        UWord s1err, UWord s2err );
143
144 // Apply a function 'f' to all the general purpose registers in all the
145 // current threads.
146 // This is very Memcheck-specific -- it's used to find the roots when
147 // doing leak checking.
148 extern void VG_(apply_to_GP_regs)(void (*f)(UWord val));
149
150 // This iterator lets you inspect each live thread's stack bounds.
151 // Returns False at the end.  'tid' is the iterator and you can only
152 // safely change it by making calls to these functions.
153 extern void VG_(thread_stack_reset_iter) ( /*OUT*/ThreadId* tid );
154 extern Bool VG_(thread_stack_next)       ( /*MOD*/ThreadId* tid,
155                                            /*OUT*/Addr* stack_min, 
156                                            /*OUT*/Addr* stack_max );
157
158 // Returns .client_stack_highest_word for the given thread
159 extern Addr VG_(thread_get_stack_max) ( ThreadId tid );
160
161 // Returns how many bytes have been allocated for the stack of the given thread
162 extern SizeT VG_(thread_get_stack_size) ( ThreadId tid );
163
164 // Returns the bottommost address of the alternate signal stack.
165 // See also the man page of sigaltstack().
166 extern Addr VG_(thread_get_altstack_min) ( ThreadId tid );
167
168 // Returns how many bytes have been allocated for the alternate signal stack.
169 // See also the man page of sigaltstack().
170 extern SizeT VG_(thread_get_altstack_size) ( ThreadId tid );
171
172 // Given a pointer to a function as obtained by "& functionname" in C,
173 // produce a pointer to the actual entry point for the function.  For
174 // most platforms it's the identity function.  Unfortunately, on
175 // ppc64-linux it isn't (sigh).
176 extern void* VG_(fnptr_to_fnentry)( void* );
177
178 #endif   // __PUB_TOOL_MACHINE_H
179
180 /*--------------------------------------------------------------------*/
181 /*--- end                                                          ---*/
182 /*--------------------------------------------------------------------*/