njn | c953984 | 2002-10-02 13:26:35 +0000 | [diff] [blame] | 1 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Default panicky definitions of template functions that skins ---*/ |
| 4 | /*--- should override. ---*/ |
| 5 | /*--- vg_defaults.c ---*/ |
| 6 | /*--------------------------------------------------------------------*/ |
| 7 | |
| 8 | /* |
njn | c953984 | 2002-10-02 13:26:35 +0000 | [diff] [blame] | 9 | This file is part of Valgrind, an extensible x86 protected-mode |
| 10 | emulator for monitoring program execution on x86-Unixes. |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 11 | |
| 12 | Copyright (C) 2000-2002 Nicholas Nethercote |
| 13 | njn25@cam.ac.uk |
| 14 | |
| 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 COPYING. |
| 31 | */ |
| 32 | |
| 33 | |
| 34 | /* These functions aren't intended to be run. Replacement functions used by |
| 35 | * the chosen skin are substituted by compiling the skin into a .so and |
| 36 | * LD_PRELOADing it. Nasty :) */ |
| 37 | |
| 38 | #include "vg_include.h" |
| 39 | |
| 40 | /* --------------------------------------------------------------------- |
| 41 | Error messages (for malformed skins) |
| 42 | ------------------------------------------------------------------ */ |
| 43 | |
| 44 | /* If the skin fails to define one or more of the required functions, |
| 45 | * make it very clear what went wrong! */ |
| 46 | |
| 47 | static __attribute__ ((noreturn)) |
| 48 | void fund_panic ( Char* fn ) |
| 49 | { |
| 50 | VG_(printf)( |
| 51 | "\nSkin error:\n" |
| 52 | " The skin you have selected is missing the function `%s',\n" |
| 53 | " which is required.\n\n", |
| 54 | fn); |
njn | e427a66 | 2002-10-02 11:08:25 +0000 | [diff] [blame] | 55 | VG_(skin_panic)("Missing skin function"); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | static __attribute__ ((noreturn)) |
| 59 | void non_fund_panic ( Char* fn ) |
| 60 | { |
| 61 | VG_(printf)( |
| 62 | "\nSkin error:\n" |
| 63 | " The skin you have selected is missing the function `%s'\n" |
| 64 | " required by one of its needs.\n\n", |
| 65 | fn); |
njn | e427a66 | 2002-10-02 11:08:25 +0000 | [diff] [blame] | 66 | VG_(skin_panic)("Missing skin function"); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | /* --------------------------------------------------------------------- |
| 70 | Fundamental template functions |
| 71 | ------------------------------------------------------------------ */ |
| 72 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 73 | __attribute__ ((weak)) |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 74 | void SK_(pre_clo_init)( void ) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 75 | { |
| 76 | fund_panic("SK_(pre_clo_init)"); |
| 77 | } |
| 78 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 79 | __attribute__ ((weak)) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 80 | void SK_(post_clo_init)(void) |
| 81 | { |
| 82 | fund_panic("SK_(post_clo_init)"); |
| 83 | } |
| 84 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 85 | __attribute__ ((weak)) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 86 | UCodeBlock* SK_(instrument)(UCodeBlock* cb, Addr not_used) |
| 87 | { |
| 88 | fund_panic("SK_(instrument)"); |
| 89 | } |
| 90 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 91 | __attribute__ ((weak)) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 92 | void SK_(fini)(void) |
| 93 | { |
| 94 | fund_panic("SK_(fini)"); |
| 95 | } |
| 96 | |
| 97 | /* --------------------------------------------------------------------- |
| 98 | For error reporting and suppression handling |
| 99 | ------------------------------------------------------------------ */ |
| 100 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 101 | __attribute__ ((weak)) |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 102 | Bool SK_(eq_SkinError)(VgRes res, Error* e1, Error* e2) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 103 | { |
| 104 | non_fund_panic("SK_(eq_SkinError)"); |
| 105 | } |
| 106 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 107 | __attribute__ ((weak)) |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 108 | void SK_(pp_SkinError)(Error* err, void (*pp_ExeContext)(void)) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 109 | { |
| 110 | non_fund_panic("SK_(pp_SkinError)"); |
| 111 | } |
| 112 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 113 | __attribute__ ((weak)) |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 114 | void* SK_(dup_extra_and_update)(Error* err) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 115 | { |
| 116 | non_fund_panic("SK_(dup_extra_and_update)"); |
| 117 | } |
| 118 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 119 | __attribute__ ((weak)) |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 120 | Bool SK_(recognised_suppression)(Char* name, Supp* su) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 121 | { |
| 122 | non_fund_panic("SK_(recognised_suppression)"); |
| 123 | } |
| 124 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 125 | __attribute__ ((weak)) |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 126 | Bool SK_(read_extra_suppression_info)(Int fd, Char* buf, Int nBuf, Supp* su) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 127 | { |
| 128 | non_fund_panic("SK_(read_extra_suppression_info)"); |
| 129 | } |
| 130 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 131 | __attribute__ ((weak)) |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 132 | Bool SK_(error_matches_suppression)(Error* err, Supp* su) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 133 | { |
| 134 | non_fund_panic("SK_(error_matches_suppression)"); |
| 135 | } |
| 136 | |
| 137 | |
| 138 | /* --------------------------------------------------------------------- |
| 139 | For throwing out basic block level info when code is invalidated |
| 140 | ------------------------------------------------------------------ */ |
| 141 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 142 | __attribute__ ((weak)) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 143 | void SK_(discard_basic_block_info)(Addr a, UInt size) |
| 144 | { |
| 145 | non_fund_panic("SK_(discard_basic_block_info)"); |
| 146 | } |
| 147 | |
| 148 | |
| 149 | /* --------------------------------------------------------------------- |
| 150 | For throwing out basic block level info when code is invalidated |
| 151 | ------------------------------------------------------------------ */ |
| 152 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 153 | __attribute__ ((weak)) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 154 | void SK_(written_shadow_regs_values)(UInt* gen_reg, UInt* eflags) |
| 155 | { |
| 156 | non_fund_panic("SK_(written_shadow_regs_values)"); |
| 157 | } |
| 158 | |
| 159 | |
| 160 | /* --------------------------------------------------------------------- |
| 161 | Command line arg template function |
| 162 | ------------------------------------------------------------------ */ |
| 163 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 164 | __attribute__ ((weak)) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 165 | Bool SK_(process_cmd_line_option)(Char* argv) |
| 166 | { |
| 167 | non_fund_panic("SK_(process_cmd_line_option)"); |
| 168 | } |
| 169 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 170 | __attribute__ ((weak)) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 171 | Char* SK_(usage)(void) |
| 172 | { |
| 173 | non_fund_panic("SK_(usage)"); |
| 174 | } |
| 175 | |
| 176 | /* --------------------------------------------------------------------- |
| 177 | Client request template function |
| 178 | ------------------------------------------------------------------ */ |
| 179 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 180 | __attribute__ ((weak)) |
sewardj | 3404251 | 2002-10-22 04:14:35 +0000 | [diff] [blame] | 181 | Bool SK_(handle_client_request)(ThreadState* tst, UInt* arg_block, UInt *ret) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 182 | { |
| 183 | non_fund_panic("SK_(handle_client_request)"); |
| 184 | } |
| 185 | |
| 186 | /* --------------------------------------------------------------------- |
| 187 | UCode extension |
| 188 | ------------------------------------------------------------------ */ |
| 189 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 190 | __attribute__ ((weak)) |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 191 | void SK_(emit_XUInstr)(UInstr* u, RRegSet regs_live_before) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 192 | { |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 193 | non_fund_panic("SK_(emit_XUInstr)"); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 194 | } |
| 195 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 196 | __attribute__ ((weak)) |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 197 | Bool SK_(sane_XUInstr)(Bool beforeRA, Bool beforeLiveness, UInstr* u) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 198 | { |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 199 | non_fund_panic("SK_(sane_XUInstr)"); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 200 | } |
| 201 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 202 | __attribute__ ((weak)) |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 203 | Char* SK_(name_XUOpcode)(Opcode opc) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 204 | { |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 205 | non_fund_panic("SK_(name_XUOpcode)"); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 206 | } |
| 207 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 208 | __attribute__ ((weak)) |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 209 | void SK_(pp_XUInstr)(UInstr* u) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 210 | { |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 211 | non_fund_panic("SK_(pp_XUInstr)"); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 212 | } |
| 213 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 214 | __attribute__ ((weak)) |
njn | 810086f | 2002-11-14 12:42:47 +0000 | [diff] [blame] | 215 | Int SK_(get_Xreg_usage)(UInstr* u, Tag tag, Int* regs, Bool* isWrites) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 216 | { |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 217 | non_fund_panic("SK_(get_Xreg_usage)"); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | /* --------------------------------------------------------------------- |
| 221 | Syscall wrapping |
| 222 | ------------------------------------------------------------------ */ |
| 223 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 224 | __attribute__ ((weak)) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 225 | void* SK_(pre_syscall)(ThreadId tid, UInt syscallno, Bool is_blocking) |
| 226 | { |
| 227 | non_fund_panic("SK_(pre_syscall)"); |
| 228 | } |
| 229 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 230 | __attribute__ ((weak)) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 231 | void SK_(post_syscall)(ThreadId tid, UInt syscallno, |
| 232 | void* pre_result, Int res, Bool is_blocking) |
| 233 | { |
| 234 | non_fund_panic("SK_(post_syscall)"); |
| 235 | } |
| 236 | |
| 237 | /* --------------------------------------------------------------------- |
| 238 | Shadow chunks |
| 239 | ------------------------------------------------------------------ */ |
| 240 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 241 | __attribute__ ((weak)) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 242 | void SK_(complete_shadow_chunk)( ShadowChunk* sc, ThreadState* tst ) |
| 243 | { |
| 244 | non_fund_panic("SK_(complete_shadow_chunk)"); |
| 245 | } |
| 246 | |
| 247 | /* --------------------------------------------------------------------- |
| 248 | Alternative free() |
| 249 | ------------------------------------------------------------------ */ |
| 250 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 251 | __attribute__ ((weak)) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 252 | void SK_(alt_free) ( ShadowChunk* sc, ThreadState* tst ) |
| 253 | { |
| 254 | non_fund_panic("SK_(alt_free)"); |
| 255 | } |
| 256 | |
| 257 | /* --------------------------------------------------------------------- |
| 258 | Sanity checks |
| 259 | ------------------------------------------------------------------ */ |
| 260 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 261 | __attribute__ ((weak)) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 262 | Bool SK_(cheap_sanity_check)(void) |
| 263 | { |
| 264 | non_fund_panic("SK_(cheap_sanity_check)"); |
| 265 | } |
| 266 | |
sewardj | c9b8252 | 2002-09-30 23:17:49 +0000 | [diff] [blame] | 267 | __attribute__ ((weak)) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 268 | Bool SK_(expensive_sanity_check)(void) |
| 269 | { |
| 270 | non_fund_panic("SK_(expensive_sanity_check)"); |
| 271 | } |
| 272 | |
| 273 | /*--------------------------------------------------------------------*/ |
| 274 | /*--- end vg_defaults.c ---*/ |
| 275 | /*--------------------------------------------------------------------*/ |