njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- The only header your skin will ever need to #include... ---*/ |
| 4 | /*--- vg_skin.h ---*/ |
| 5 | /*--------------------------------------------------------------------*/ |
| 6 | |
| 7 | /* |
| 8 | This file is part of Valgrind, an x86 protected-mode emulator |
| 9 | designed for debugging and profiling binaries on x86-Unixes. |
| 10 | |
| 11 | Copyright (C) 2000-2002 Julian Seward |
| 12 | jseward@acm.org |
| 13 | |
| 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 | |
| 29 | The GNU General Public License is contained in the file COPYING. |
| 30 | */ |
| 31 | |
| 32 | #ifndef __VG_SKIN_H |
| 33 | #define __VG_SKIN_H |
| 34 | |
| 35 | #include <stdarg.h> /* ANSI varargs stuff */ |
| 36 | #include <setjmp.h> /* for jmp_buf */ |
| 37 | |
| 38 | #include "vg_constants_skin.h" |
| 39 | |
| 40 | |
| 41 | /*====================================================================*/ |
| 42 | /*=== Build options and table sizes. ===*/ |
| 43 | /*====================================================================*/ |
| 44 | |
| 45 | /* You should be able to change these options or sizes, recompile, and |
| 46 | still have a working system. */ |
| 47 | |
| 48 | /* The maximum number of pthreads that we support. This is |
| 49 | deliberately not very high since our implementation of some of the |
| 50 | scheduler algorithms is surely O(N) in the number of threads, since |
| 51 | that's simple, at least. And (in practice) we hope that most |
| 52 | programs do not need many threads. */ |
| 53 | #define VG_N_THREADS 50 |
| 54 | |
| 55 | /* Maximum number of pthread keys available. Again, we start low until |
| 56 | the need for a higher number presents itself. */ |
| 57 | #define VG_N_THREAD_KEYS 50 |
| 58 | |
| 59 | /* Total number of integer registers available for allocation -- all of |
| 60 | them except %esp, %ebp. %ebp permanently points at VG_(baseBlock). |
| 61 | |
| 62 | If you change this you'll have to also change at least these: |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 63 | - VG_(rank_to_realreg)() |
| 64 | - VG_(realreg_to_rank)() |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 65 | - ppRegsLiveness() |
| 66 | - the RegsLive type (maybe -- RegsLive type must have more than |
| 67 | VG_MAX_REALREGS bits) |
| 68 | |
| 69 | Do not change this unless you really know what you are doing! */ |
| 70 | #define VG_MAX_REALREGS 6 |
| 71 | |
| 72 | |
| 73 | /*====================================================================*/ |
njn | 1a1dd8b | 2002-09-27 10:42:20 +0000 | [diff] [blame] | 74 | /*=== Basic types, useful macros ===*/ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 75 | /*====================================================================*/ |
| 76 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 77 | typedef unsigned char UChar; |
| 78 | typedef unsigned short UShort; |
| 79 | typedef unsigned int UInt; |
| 80 | typedef unsigned long long int ULong; |
| 81 | |
| 82 | typedef signed char Char; |
| 83 | typedef signed short Short; |
| 84 | typedef signed int Int; |
| 85 | typedef signed long long int Long; |
| 86 | |
| 87 | typedef unsigned int Addr; |
| 88 | |
| 89 | typedef unsigned char Bool; |
| 90 | #define False ((Bool)0) |
| 91 | #define True ((Bool)1) |
| 92 | |
| 93 | |
njn | 1a1dd8b | 2002-09-27 10:42:20 +0000 | [diff] [blame] | 94 | #define mycat_wrk(aaa,bbb) aaa##bbb |
| 95 | #define mycat(aaa,bbb) mycat_wrk(aaa,bbb) |
| 96 | |
| 97 | /* No, really. I _am_ that strange. */ |
| 98 | #define OINK(nnn) VG_(message)(Vg_DebugMsg, "OINK %d",nnn) |
| 99 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 100 | /* --------------------------------------------------------------------- |
| 101 | Now the basic types are set up, we can haul in the kernel-interface |
| 102 | definitions. |
| 103 | ------------------------------------------------------------------ */ |
| 104 | |
njn25 | 74bb476 | 2002-09-24 11:23:50 +0000 | [diff] [blame] | 105 | #include "../coregrind/vg_kerneliface.h" |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 106 | |
| 107 | |
| 108 | /*====================================================================*/ |
| 109 | /*=== Command-line options ===*/ |
| 110 | /*====================================================================*/ |
| 111 | |
| 112 | /* Verbosity level: 0 = silent, 1 (default), > 1 = more verbose. */ |
| 113 | extern Int VG_(clo_verbosity); |
| 114 | |
| 115 | /* Profile? */ |
| 116 | extern Bool VG_(clo_profile); |
| 117 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 118 | /* Call this if a recognised option was bad for some reason. |
| 119 | Note: don't use it just because an option was unrecognised -- return 'False' |
| 120 | from SKN_(process_cmd_line_option) to indicate that. */ |
| 121 | extern void VG_(bad_option) ( Char* opt ); |
| 122 | |
| 123 | /* Client args */ |
| 124 | extern Int VG_(client_argc); |
| 125 | extern Char** VG_(client_argv); |
| 126 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 127 | /* Client environment. Can be inspected with VG_(getenv)() */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 128 | extern Char** VG_(client_envp); |
| 129 | |
| 130 | |
| 131 | /*====================================================================*/ |
| 132 | /*=== Printing messages for the user ===*/ |
| 133 | /*====================================================================*/ |
| 134 | |
| 135 | /* Print a message prefixed by "??<pid>?? "; '?' depends on the VgMsgKind. |
| 136 | Should be used for all user output. */ |
| 137 | |
| 138 | typedef |
| 139 | enum { Vg_UserMsg, /* '?' == '=' */ |
| 140 | Vg_DebugMsg, /* '?' == '-' */ |
| 141 | Vg_DebugExtraMsg /* '?' == '+' */ |
| 142 | } |
| 143 | VgMsgKind; |
| 144 | |
| 145 | /* Functions for building a message from multiple parts. */ |
| 146 | extern void VG_(start_msg) ( VgMsgKind kind ); |
| 147 | extern void VG_(add_to_msg) ( Char* format, ... ); |
| 148 | /* Ends and prints the message. Appends a newline. */ |
| 149 | extern void VG_(end_msg) ( void ); |
| 150 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 151 | /* Send a single-part message. Appends a newline. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 152 | extern void VG_(message) ( VgMsgKind kind, Char* format, ... ); |
| 153 | |
| 154 | |
| 155 | /*====================================================================*/ |
| 156 | /*=== Profiling ===*/ |
| 157 | /*====================================================================*/ |
| 158 | |
| 159 | /* Nb: VGP_(register_profile_event)() relies on VgpUnc being the first one */ |
| 160 | #define VGP_CORE_LIST \ |
| 161 | /* These ones depend on the core */ \ |
| 162 | VGP_PAIR(VgpUnc, "unclassified"), \ |
| 163 | VGP_PAIR(VgpRun, "running"), \ |
| 164 | VGP_PAIR(VgpSched, "scheduler"), \ |
| 165 | VGP_PAIR(VgpMalloc, "low-lev malloc/free"), \ |
| 166 | VGP_PAIR(VgpCliMalloc, "client malloc/free"), \ |
| 167 | VGP_PAIR(VgpStack, "adjust-stack"), \ |
| 168 | VGP_PAIR(VgpTranslate, "translate-main"), \ |
| 169 | VGP_PAIR(VgpToUCode, "to-ucode"), \ |
| 170 | VGP_PAIR(VgpFromUcode, "from-ucode"), \ |
| 171 | VGP_PAIR(VgpImprove, "improve"), \ |
| 172 | VGP_PAIR(VgpRegAlloc, "reg-alloc"), \ |
| 173 | VGP_PAIR(VgpLiveness, "liveness-analysis"), \ |
| 174 | VGP_PAIR(VgpDoLRU, "do-lru"), \ |
| 175 | VGP_PAIR(VgpSlowFindT, "slow-search-transtab"), \ |
| 176 | VGP_PAIR(VgpInitMem, "init-memory"), \ |
| 177 | VGP_PAIR(VgpExeContext, "exe-context"), \ |
| 178 | VGP_PAIR(VgpReadSyms, "read-syms"), \ |
| 179 | VGP_PAIR(VgpSearchSyms, "search-syms"), \ |
| 180 | VGP_PAIR(VgpAddToT, "add-to-transtab"), \ |
| 181 | VGP_PAIR(VgpCoreSysWrap, "core-syscall-wrapper"), \ |
| 182 | VGP_PAIR(VgpDemangle, "demangle"), \ |
njn | 37cea30 | 2002-09-30 11:24:00 +0000 | [diff] [blame] | 183 | VGP_PAIR(VgpCoreCheapSanity, "core-cheap-sanity"), \ |
| 184 | VGP_PAIR(VgpCoreExpensiveSanity, "core-expensive-sanity"), \ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 185 | /* These ones depend on the skin */ \ |
| 186 | VGP_PAIR(VgpPreCloInit, "pre-clo-init"), \ |
| 187 | VGP_PAIR(VgpPostCloInit, "post-clo-init"), \ |
| 188 | VGP_PAIR(VgpInstrument, "instrument"), \ |
| 189 | VGP_PAIR(VgpSkinSysWrap, "skin-syscall-wrapper"), \ |
njn | 37cea30 | 2002-09-30 11:24:00 +0000 | [diff] [blame] | 190 | VGP_PAIR(VgpSkinCheapSanity, "skin-cheap-sanity"), \ |
| 191 | VGP_PAIR(VgpSkinExpensiveSanity, "skin-expensive-sanity"), \ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 192 | VGP_PAIR(VgpFini, "fini") |
| 193 | |
| 194 | #define VGP_PAIR(n,name) n |
| 195 | typedef enum { VGP_CORE_LIST } VgpCoreCC; |
| 196 | #undef VGP_PAIR |
| 197 | |
| 198 | /* When registering skin profiling events, ensure that the 'n' value is in |
| 199 | * the range (VgpFini+1..) */ |
| 200 | extern void VGP_(register_profile_event) ( Int n, Char* name ); |
| 201 | |
| 202 | extern void VGP_(pushcc) ( UInt cc ); |
| 203 | extern void VGP_(popcc) ( UInt cc ); |
| 204 | |
| 205 | /* Define them only if they haven't already been defined by vg_profile.c */ |
| 206 | #ifndef VGP_PUSHCC |
| 207 | # define VGP_PUSHCC(x) |
| 208 | #endif |
| 209 | #ifndef VGP_POPCC |
| 210 | # define VGP_POPCC(x) |
| 211 | #endif |
| 212 | |
| 213 | |
| 214 | /*====================================================================*/ |
| 215 | /*=== Useful stuff to call from generated code ===*/ |
| 216 | /*====================================================================*/ |
| 217 | |
| 218 | /* ------------------------------------------------------------------ */ |
| 219 | /* General stuff */ |
| 220 | |
| 221 | /* Get the simulated %esp */ |
| 222 | extern Addr VG_(get_stack_pointer) ( void ); |
| 223 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 224 | /* Detect if an address is within Valgrind's stack or Valgrind's |
| 225 | m_state_static; useful for memory leak detectors to tell if a block |
| 226 | is used by Valgrind (and thus can be ignored). */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 227 | extern Bool VG_(within_stack)(Addr a); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 228 | extern Bool VG_(within_m_state_static)(Addr a); |
| 229 | |
| 230 | /* Check if an address is 4-byte aligned */ |
| 231 | #define IS_ALIGNED4_ADDR(aaa_p) (0 == (((UInt)(aaa_p)) & 3)) |
| 232 | |
| 233 | |
| 234 | /* ------------------------------------------------------------------ */ |
| 235 | /* Thread-related stuff */ |
| 236 | |
| 237 | /* Special magic value for an invalid ThreadId. It corresponds to |
| 238 | LinuxThreads using zero as the initial value for |
| 239 | pthread_mutex_t.__m_owner and pthread_cond_t.__c_waiting. */ |
| 240 | #define VG_INVALID_THREADID ((ThreadId)(0)) |
| 241 | |
| 242 | /* ThreadIds are simply indices into the vg_threads[] array. */ |
| 243 | typedef |
| 244 | UInt |
| 245 | ThreadId; |
| 246 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 247 | /* struct _ThreadState defined elsewhere; ThreadState is abstract as its |
| 248 | definition is not important for skins. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 249 | typedef |
| 250 | struct _ThreadState |
| 251 | ThreadState; |
| 252 | |
| 253 | extern ThreadId VG_(get_current_tid_1_if_root) ( void ); |
| 254 | extern ThreadState* VG_(get_ThreadState) ( ThreadId tid ); |
| 255 | |
| 256 | |
| 257 | /*====================================================================*/ |
| 258 | /*=== Valgrind's version of libc ===*/ |
| 259 | /*====================================================================*/ |
| 260 | |
| 261 | /* Valgrind doesn't use libc at all, for good reasons (trust us). So here |
| 262 | are its own versions of C library functions, but with VG_ prefixes. Note |
| 263 | that the types of some are slightly different to the real ones. Some |
| 264 | extra useful functions are provided too; descriptions of how they work |
| 265 | are given below. */ |
| 266 | |
| 267 | #if !defined(NULL) |
| 268 | # define NULL ((void*)0) |
| 269 | #endif |
| 270 | |
| 271 | |
| 272 | /* ------------------------------------------------------------------ */ |
| 273 | /* stdio.h |
| 274 | * |
| 275 | * Note that they all output to the file descriptor given by the |
| 276 | * --logfile-fd=N argument, which defaults to 2 (stderr). Hence no |
| 277 | * need for VG_(fprintf)(). |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 278 | */ |
| 279 | extern void VG_(printf) ( const char *format, ... ); |
| 280 | /* too noisy ... __attribute__ ((format (printf, 1, 2))) ; */ |
| 281 | extern void VG_(sprintf) ( Char* buf, Char *format, ... ); |
| 282 | extern void VG_(vprintf) ( void(*send)(Char), |
| 283 | const Char *format, va_list vargs ); |
| 284 | |
| 285 | /* ------------------------------------------------------------------ */ |
| 286 | /* stdlib.h */ |
| 287 | |
| 288 | extern void* VG_(malloc) ( Int nbytes ); |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 289 | extern void VG_(free) ( void* p ); |
| 290 | extern void* VG_(calloc) ( Int n, Int nbytes ); |
| 291 | extern void* VG_(realloc) ( void* p, Int size ); |
| 292 | extern void* VG_(malloc_aligned) ( Int align_bytes, Int nbytes ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 293 | |
| 294 | extern void VG_(print_malloc_stats) ( void ); |
| 295 | |
| 296 | |
| 297 | extern void VG_(exit)( Int status ) |
| 298 | __attribute__ ((__noreturn__)); |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 299 | /* Prints a panic message (a constant string), appends newline, aborts. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 300 | extern void VG_(panic) ( Char* str ) |
| 301 | __attribute__ ((__noreturn__)); |
| 302 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 303 | /* Looks up VG_(client_envp) */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 304 | extern Char* VG_(getenv) ( Char* name ); |
| 305 | |
| 306 | /* Crude stand-in for the glibc system() call. */ |
| 307 | extern Int VG_(system) ( Char* cmd ); |
| 308 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 309 | extern Long VG_(atoll) ( Char* str ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 310 | |
| 311 | /* Like atoll(), but converts a number of base 2..36 */ |
| 312 | extern Long VG_(atoll36) ( UInt base, Char* str ); |
| 313 | |
| 314 | |
| 315 | /* ------------------------------------------------------------------ */ |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 316 | /* ctype.h */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 317 | extern Bool VG_(isspace) ( Char c ); |
| 318 | extern Bool VG_(isdigit) ( Char c ); |
| 319 | extern Char VG_(toupper) ( Char c ); |
| 320 | |
| 321 | |
| 322 | /* ------------------------------------------------------------------ */ |
| 323 | /* string.h */ |
| 324 | extern Int VG_(strlen) ( const Char* str ); |
| 325 | extern Char* VG_(strcat) ( Char* dest, const Char* src ); |
| 326 | extern Char* VG_(strncat) ( Char* dest, const Char* src, Int n ); |
| 327 | extern Char* VG_(strpbrk) ( const Char* s, const Char* accept ); |
| 328 | extern Char* VG_(strcpy) ( Char* dest, const Char* src ); |
| 329 | extern Char* VG_(strncpy) ( Char* dest, const Char* src, Int ndest ); |
| 330 | extern Int VG_(strcmp) ( const Char* s1, const Char* s2 ); |
| 331 | extern Int VG_(strncmp) ( const Char* s1, const Char* s2, Int nmax ); |
| 332 | extern Char* VG_(strstr) ( const Char* haystack, Char* needle ); |
| 333 | extern Char* VG_(strchr) ( const Char* s, Char c ); |
| 334 | extern Char* VG_(strdup) ( const Char* s); |
| 335 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 336 | /* Like strcmp() and strncmp(), but stop comparing at any whitespace. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 337 | extern Int VG_(strcmp_ws) ( const Char* s1, const Char* s2 ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 338 | extern Int VG_(strncmp_ws) ( const Char* s1, const Char* s2, Int nmax ); |
| 339 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 340 | /* Like strncpy(), but if 'src' is longer than 'ndest' inserts a '\0' as the |
| 341 | last character. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 342 | extern void VG_(strncpy_safely) ( Char* dest, const Char* src, Int ndest ); |
| 343 | |
| 344 | /* Mini-regexp function. Searches for 'pat' in 'str'. Supports |
| 345 | * meta-symbols '*' and '?'. '\' escapes meta-symbols. */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 346 | extern Bool VG_(string_match) ( Char* pat, Char* str ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 347 | |
| 348 | |
| 349 | /* ------------------------------------------------------------------ */ |
| 350 | /* math.h */ |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 351 | /* Returns the base-2 logarithm of x. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 352 | extern Int VG_(log2) ( Int x ); |
| 353 | |
| 354 | |
| 355 | /* ------------------------------------------------------------------ */ |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 356 | /* unistd.h, fcntl.h, sys/stat.h */ |
| 357 | extern Int VG_(getpid) ( void ); |
| 358 | |
| 359 | extern Int VG_(open) ( const Char* pathname, Int flags, Int mode ); |
| 360 | extern Int VG_(read) ( Int fd, void* buf, Int count); |
| 361 | extern Int VG_(write) ( Int fd, void* buf, Int count); |
| 362 | extern void VG_(close) ( Int fd ); |
| 363 | |
| 364 | extern Int VG_(stat) ( Char* file_name, struct vki_stat* buf ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 365 | |
| 366 | |
| 367 | /* ------------------------------------------------------------------ */ |
| 368 | /* assert.h */ |
| 369 | /* Asserts permanently enabled -- no turning off with NDEBUG. Hurrah! */ |
| 370 | #define VG__STRING(__str) #__str |
| 371 | |
| 372 | #define vg_assert(expr) \ |
| 373 | ((void) ((expr) ? 0 : \ |
| 374 | (VG_(assert_fail) (VG__STRING(expr), \ |
| 375 | __FILE__, __LINE__, \ |
| 376 | __PRETTY_FUNCTION__), 0))) |
| 377 | |
| 378 | extern void VG_(assert_fail) ( Char* expr, Char* file, |
| 379 | Int line, Char* fn ) |
| 380 | __attribute__ ((__noreturn__)); |
| 381 | |
| 382 | |
| 383 | /* ------------------------------------------------------------------ */ |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 384 | /* system/mman.h */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 385 | extern void* VG_(mmap)( void* start, UInt length, |
| 386 | UInt prot, UInt flags, UInt fd, UInt offset ); |
| 387 | extern Int VG_(munmap)( void* start, Int length ); |
| 388 | |
| 389 | /* Get memory by anonymous mmap. */ |
| 390 | extern void* VG_(get_memory_from_mmap) ( Int nBytes, Char* who ); |
| 391 | |
| 392 | |
| 393 | /* ------------------------------------------------------------------ */ |
| 394 | /* signal.h. |
| 395 | |
| 396 | Note that these use the vk_ (kernel) structure |
| 397 | definitions, which are different in places from those that glibc |
| 398 | defines -- hence the 'k' prefix. Since we're operating right at the |
| 399 | kernel interface, glibc's view of the world is entirely irrelevant. */ |
| 400 | |
| 401 | /* --- Signal set ops --- */ |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 402 | extern Int VG_(ksigfillset) ( vki_ksigset_t* set ); |
| 403 | extern Int VG_(ksigemptyset) ( vki_ksigset_t* set ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 404 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 405 | extern Bool VG_(kisfullsigset) ( vki_ksigset_t* set ); |
| 406 | extern Bool VG_(kisemptysigset) ( vki_ksigset_t* set ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 407 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 408 | extern Int VG_(ksigaddset) ( vki_ksigset_t* set, Int signum ); |
| 409 | extern Int VG_(ksigdelset) ( vki_ksigset_t* set, Int signum ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 410 | extern Int VG_(ksigismember) ( vki_ksigset_t* set, Int signum ); |
| 411 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 412 | extern void VG_(ksigaddset_from_set) ( vki_ksigset_t* dst, vki_ksigset_t* src ); |
| 413 | extern void VG_(ksigdelset_from_set) ( vki_ksigset_t* dst, vki_ksigset_t* src ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 414 | |
| 415 | /* --- Mess with the kernel's sig state --- */ |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 416 | extern Int VG_(ksigprocmask) ( Int how, const vki_ksigset_t* set, |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 417 | vki_ksigset_t* oldset ); |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 418 | extern Int VG_(ksigaction) ( Int signum, |
| 419 | const vki_ksigaction* act, |
| 420 | vki_ksigaction* oldact ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 421 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 422 | extern Int VG_(ksignal) ( Int signum, void (*sighandler)(Int) ); |
| 423 | extern Int VG_(ksigaltstack) ( const vki_kstack_t* ss, vki_kstack_t* oss ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 424 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 425 | extern Int VG_(kill) ( Int pid, Int signo ); |
| 426 | extern Int VG_(sigpending) ( vki_ksigset_t* set ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 427 | |
| 428 | |
| 429 | /*====================================================================*/ |
| 430 | /*=== UCode definition ===*/ |
| 431 | /*====================================================================*/ |
| 432 | |
sewardj | e104247 | 2002-09-30 12:33:11 +0000 | [diff] [blame^] | 433 | /* Tags which describe what operands are. Must fit into 4 bits, which |
| 434 | they clearly do. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 435 | typedef |
sewardj | e104247 | 2002-09-30 12:33:11 +0000 | [diff] [blame^] | 436 | enum { TempReg =0, /* virtual temp-reg */ |
| 437 | ArchReg =1, /* simulated integer reg */ |
| 438 | ArchRegS =2, /* simulated segment reg */ |
| 439 | RealReg =3, /* real machine's real reg */ |
| 440 | SpillNo =4, /* spill slot location */ |
| 441 | Literal =5, /* literal; .lit32 field has actual value */ |
| 442 | Lit16 =6, /* literal; .val[123] field has actual value */ |
| 443 | NoValue =7 /* operand not in use */ |
| 444 | } |
| 445 | Tag; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 446 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 447 | /* Invalid register numbers (can't be negative) */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 448 | #define INVALID_TEMPREG 999999999 |
| 449 | #define INVALID_REALREG 999999999 |
| 450 | |
| 451 | /* Microinstruction opcodes. */ |
| 452 | typedef |
| 453 | enum { |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 454 | NOP, /* Null op */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 455 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 456 | /* Moving values around */ |
| 457 | GET, PUT, /* simulated register <--> TempReg */ |
| 458 | GETF, PUTF, /* simulated %eflags <--> TempReg */ |
| 459 | LOAD, STORE, /* memory <--> TempReg */ |
| 460 | MOV, /* TempReg <--> TempReg */ |
| 461 | CMOV, /* Used for cmpxchg and cmov */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 462 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 463 | /* Arithmetic/logical ops */ |
| 464 | ADD, ADC, SUB, SBB, /* Add/subtract (w/wo carry) */ |
| 465 | AND, OR, XOR, NOT, /* Boolean ops */ |
| 466 | SHL, SHR, SAR, ROL, ROR, RCL, RCR, /* Shift/rotate (w/wo carry) */ |
| 467 | NEG, /* Negate */ |
| 468 | INC, DEC, /* Increment/decrement */ |
| 469 | BSWAP, /* Big-endian <--> little-endian */ |
| 470 | CC2VAL, /* Condition code --> 0 or 1 */ |
| 471 | WIDEN, /* Signed or unsigned widening */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 472 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 473 | /* Conditional or unconditional jump */ |
| 474 | JMP, |
| 475 | |
| 476 | /* FPU ops */ |
| 477 | FPU, /* Doesn't touch memory */ |
| 478 | FPU_R, FPU_W, /* Reads/writes memory */ |
| 479 | |
| 480 | /* Not strictly needed, but improve address calculation translations. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 481 | LEA1, /* reg2 := const + reg1 */ |
| 482 | LEA2, /* reg3 := const + reg1 + reg2 * 1,2,4 or 8 */ |
| 483 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 484 | /* Hack for x86 REP insns. Jump to literal if TempReg/RealReg is zero. */ |
| 485 | JIFZ, |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 486 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 487 | /* Advance the simulated %eip by some small (< 128) number. */ |
| 488 | INCEIP, |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 489 | |
sewardj | e104247 | 2002-09-30 12:33:11 +0000 | [diff] [blame^] | 490 | /* Dealing with segment registers */ |
| 491 | GETSEG, PUTSEG, /* simulated segment register <--> TempReg */ |
| 492 | USESEG, /* (LDT/GDT index, virtual addr) --> linear addr */ |
| 493 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 494 | /* Not for translating x86 calls -- only to call helpers */ |
| 495 | CALLM_S, CALLM_E, /* Mark start/end of CALLM push/pop sequence */ |
| 496 | PUSH, POP, CLEAR, /* Add/remove/zap args for helpers */ |
| 497 | CALLM, /* Call assembly-code helper */ |
| 498 | |
| 499 | /* Not for translating x86 calls -- only to call C helper functions of |
| 500 | up to three arguments (or two if the functions has a return value). |
| 501 | Arguments and return value must be word-sized. More arguments can |
| 502 | be faked with global variables (eg. use VG_(set_global_var)()). |
| 503 | |
| 504 | Seven possibilities: 'arg[123]' show where args go, 'ret' shows |
| 505 | where return value goes (if present). |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 506 | |
| 507 | CCALL(-, -, - ) void f(void) |
| 508 | CCALL(arg1, -, - ) void f(UInt arg1) |
| 509 | CCALL(arg1, arg2, - ) void f(UInt arg1, UInt arg2) |
| 510 | CCALL(arg1, arg2, arg3) void f(UInt arg1, UInt arg2, UInt arg3) |
| 511 | CCALL(-, -, ret ) UInt f(UInt) |
| 512 | CCALL(arg1, -, ret ) UInt f(UInt arg1) |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 513 | CCALL(arg1, arg2, ret ) UInt f(UInt arg1, UInt arg2) */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 514 | CCALL, |
| 515 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 516 | /* This opcode makes it easy for skins that extend UCode to do this to |
| 517 | avoid opcode overlap: |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 518 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 519 | enum { EU_OP1 = DUMMY_FINAL_UOPCODE + 1, ... } |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 520 | |
| 521 | WARNING: Do not add new opcodes after this one! They can be added |
| 522 | before, though. */ |
| 523 | DUMMY_FINAL_UOPCODE |
| 524 | } |
| 525 | Opcode; |
| 526 | |
| 527 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 528 | /* Condition codes, using the Intel encoding. CondAlways is an extra. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 529 | typedef |
| 530 | enum { |
| 531 | CondO = 0, /* overflow */ |
| 532 | CondNO = 1, /* no overflow */ |
| 533 | CondB = 2, /* below */ |
| 534 | CondNB = 3, /* not below */ |
| 535 | CondZ = 4, /* zero */ |
| 536 | CondNZ = 5, /* not zero */ |
| 537 | CondBE = 6, /* below or equal */ |
| 538 | CondNBE = 7, /* not below or equal */ |
| 539 | CondS = 8, /* negative */ |
sewardj | e104247 | 2002-09-30 12:33:11 +0000 | [diff] [blame^] | 540 | CondNS = 9, /* not negative */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 541 | CondP = 10, /* parity even */ |
| 542 | CondNP = 11, /* not parity even */ |
| 543 | CondL = 12, /* jump less */ |
| 544 | CondNL = 13, /* not less */ |
| 545 | CondLE = 14, /* less or equal */ |
| 546 | CondNLE = 15, /* not less or equal */ |
| 547 | CondAlways = 16 /* Jump always */ |
| 548 | } |
| 549 | Condcode; |
| 550 | |
| 551 | |
| 552 | /* Descriptions of additional properties of *unconditional* jumps. */ |
| 553 | typedef |
| 554 | enum { |
| 555 | JmpBoring=0, /* boring unconditional jump */ |
| 556 | JmpCall=1, /* jump due to an x86 call insn */ |
| 557 | JmpRet=2, /* jump due to an x86 ret insn */ |
| 558 | JmpSyscall=3, /* do a system call, then jump */ |
| 559 | JmpClientReq=4 /* do a client request, then jump */ |
| 560 | } |
| 561 | JmpKind; |
| 562 | |
| 563 | |
| 564 | /* Flags. User-level code can only read/write O(verflow), S(ign), |
| 565 | Z(ero), A(ux-carry), C(arry), P(arity), and may also write |
| 566 | D(irection). That's a total of 7 flags. A FlagSet is a bitset, |
| 567 | thusly: |
| 568 | 76543210 |
| 569 | DOSZACP |
| 570 | and bit 7 must always be zero since it is unused. |
| 571 | */ |
| 572 | typedef UChar FlagSet; |
| 573 | |
| 574 | #define FlagD (1<<6) |
| 575 | #define FlagO (1<<5) |
| 576 | #define FlagS (1<<4) |
| 577 | #define FlagZ (1<<3) |
| 578 | #define FlagA (1<<2) |
| 579 | #define FlagC (1<<1) |
| 580 | #define FlagP (1<<0) |
| 581 | |
| 582 | #define FlagsOSZACP (FlagO | FlagS | FlagZ | FlagA | FlagC | FlagP) |
| 583 | #define FlagsOSZAP (FlagO | FlagS | FlagZ | FlagA | FlagP) |
| 584 | #define FlagsOSZCP (FlagO | FlagS | FlagZ | FlagC | FlagP) |
| 585 | #define FlagsOSACP (FlagO | FlagS | FlagA | FlagC | FlagP) |
| 586 | #define FlagsSZACP ( FlagS | FlagZ | FlagA | FlagC | FlagP) |
| 587 | #define FlagsSZAP ( FlagS | FlagZ | FlagA | FlagP) |
| 588 | #define FlagsZCP ( FlagZ | FlagC | FlagP) |
| 589 | #define FlagsOC (FlagO | FlagC ) |
| 590 | #define FlagsAC ( FlagA | FlagC ) |
| 591 | |
| 592 | #define FlagsALL (FlagsOSZACP | FlagD) |
| 593 | #define FlagsEmpty (FlagSet)0 |
| 594 | |
| 595 | |
| 596 | /* Liveness of general purpose registers, useful for code generation. |
| 597 | Reg rank order 0..N-1 corresponds to bits 0..N-1, ie. first |
| 598 | reg's liveness in bit 0, last reg's in bit N-1. Note that |
| 599 | these rankings don't match the Intel register ordering. */ |
| 600 | typedef UInt RRegSet; |
| 601 | |
| 602 | #define ALL_RREGS_DEAD 0 /* 0000...00b */ |
| 603 | #define ALL_RREGS_LIVE (1 << (VG_MAX_REALREGS-1)) /* 0011...11b */ |
| 604 | #define UNIT_RREGSET(rank) (1 << (rank)) |
| 605 | |
| 606 | #define IS_RREG_LIVE(rank,rregs_live) (rregs_live & UNIT_RREGSET(rank)) |
| 607 | #define SET_RREG_LIVENESS(rank,rregs_live,b) \ |
| 608 | do { RRegSet unit = UNIT_RREGSET(rank); \ |
| 609 | if (b) rregs_live |= unit; \ |
| 610 | else rregs_live &= ~unit; \ |
| 611 | } while(0) |
| 612 | |
| 613 | |
| 614 | /* A Micro (u)-instruction. */ |
| 615 | typedef |
| 616 | struct { |
| 617 | /* word 1 */ |
| 618 | UInt lit32; /* 32-bit literal */ |
| 619 | |
| 620 | /* word 2 */ |
| 621 | UShort val1; /* first operand */ |
| 622 | UShort val2; /* second operand */ |
| 623 | |
| 624 | /* word 3 */ |
| 625 | UShort val3; /* third operand */ |
| 626 | UChar opcode; /* opcode */ |
| 627 | UChar size; /* data transfer size */ |
| 628 | |
| 629 | /* word 4 */ |
| 630 | FlagSet flags_r; /* :: FlagSet */ |
| 631 | FlagSet flags_w; /* :: FlagSet */ |
| 632 | UChar tag1:4; /* first operand tag */ |
| 633 | UChar tag2:4; /* second operand tag */ |
| 634 | UChar tag3:4; /* third operand tag */ |
| 635 | UChar extra4b:4; /* Spare field, used by WIDEN for src |
| 636 | -size, and by LEA2 for scale (1,2,4 or 8), |
| 637 | and by JMPs for original x86 instr size */ |
| 638 | |
| 639 | /* word 5 */ |
| 640 | UChar cond; /* condition, for jumps */ |
| 641 | Bool signed_widen:1; /* signed or unsigned WIDEN ? */ |
| 642 | JmpKind jmpkind:3; /* additional properties of unconditional JMP */ |
| 643 | |
| 644 | /* Additional properties for UInstrs that call C functions: |
| 645 | - CCALL |
| 646 | - PUT (when %ESP is the target) |
| 647 | - possibly skin-specific UInstrs |
| 648 | */ |
| 649 | UChar argc:2; /* Number of args, max 3 */ |
| 650 | UChar regparms_n:2; /* Number of args passed in registers */ |
| 651 | Bool has_ret_val:1; /* Function has return value? */ |
| 652 | |
| 653 | /* RealReg liveness; only sensical after reg alloc and liveness |
| 654 | analysis done. This info is a little bit arch-specific -- |
| 655 | VG_MAX_REALREGS can vary on different architectures. Note that |
| 656 | to use this information requires converting between register ranks |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 657 | and the Intel register numbers, using VG_(realreg_to_rank)() |
| 658 | and/or VG_(rank_to_realreg)() */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 659 | RRegSet regs_live_after:VG_MAX_REALREGS; |
| 660 | } |
| 661 | UInstr; |
| 662 | |
| 663 | |
| 664 | /* Expandable arrays of uinstrs. */ |
| 665 | typedef |
| 666 | struct { |
| 667 | Int used; |
| 668 | Int size; |
| 669 | UInstr* instrs; |
| 670 | Int nextTemp; |
| 671 | } |
| 672 | UCodeBlock; |
| 673 | |
| 674 | |
| 675 | /*====================================================================*/ |
| 676 | /*=== Instrumenting UCode ===*/ |
| 677 | /*====================================================================*/ |
| 678 | |
| 679 | /* A structure for communicating TempReg and RealReg uses of UInstrs. */ |
| 680 | typedef |
| 681 | struct { |
| 682 | Int num; |
| 683 | Bool isWrite; |
| 684 | } |
| 685 | RegUse; |
| 686 | |
| 687 | /* Find what this instruction does to its regs. Tag indicates whether we're |
| 688 | * considering TempRegs (pre-reg-alloc) or RealRegs (post-reg-alloc). |
| 689 | * Useful for analysis/optimisation passes. */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 690 | extern Int VG_(get_reg_usage) ( UInstr* u, Tag tag, RegUse* arr ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 691 | |
| 692 | |
| 693 | /* ------------------------------------------------------------------ */ |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 694 | /* Used to register helper functions to be called from generated code. A |
| 695 | limited number of compact helpers can be registered; the code generated |
| 696 | to call them is slightly shorter -- so register the mostly frequently |
| 697 | called helpers as compact. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 698 | extern void VG_(register_compact_helper) ( Addr a ); |
| 699 | extern void VG_(register_noncompact_helper) ( Addr a ); |
| 700 | |
| 701 | |
| 702 | /* ------------------------------------------------------------------ */ |
| 703 | /* Virtual register allocation */ |
| 704 | |
| 705 | /* Get a new virtual register */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 706 | extern Int VG_(get_new_temp) ( UCodeBlock* cb ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 707 | |
| 708 | /* Get a new virtual shadow register */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 709 | extern Int VG_(get_new_shadow) ( UCodeBlock* cb ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 710 | |
| 711 | /* Get a virtual register's corresponding virtual shadow register */ |
| 712 | #define SHADOW(tempreg) ((tempreg)+1) |
| 713 | |
| 714 | |
| 715 | /* ------------------------------------------------------------------ */ |
| 716 | /* Low-level UInstr builders */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 717 | extern void VG_(new_NOP) ( UInstr* u ); |
| 718 | extern void VG_(new_UInstr0) ( UCodeBlock* cb, Opcode opcode, Int sz ); |
| 719 | extern void VG_(new_UInstr1) ( UCodeBlock* cb, Opcode opcode, Int sz, |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 720 | Tag tag1, UInt val1 ); |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 721 | extern void VG_(new_UInstr2) ( UCodeBlock* cb, Opcode opcode, Int sz, |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 722 | Tag tag1, UInt val1, |
| 723 | Tag tag2, UInt val2 ); |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 724 | extern void VG_(new_UInstr3) ( UCodeBlock* cb, Opcode opcode, Int sz, |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 725 | Tag tag1, UInt val1, |
| 726 | Tag tag2, UInt val2, |
| 727 | Tag tag3, UInt val3 ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 728 | |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 729 | extern void VG_(set_flag_RW) ( UInstr* u, FlagSet fr, FlagSet fw ); |
| 730 | extern void VG_(set_lit_field) ( UCodeBlock* cb, UInt lit32 ); |
| 731 | extern void VG_(set_ccall_fields) ( UCodeBlock* cb, Addr fn, UChar argc, |
| 732 | UChar regparms_n, Bool has_ret_val ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 733 | |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 734 | extern void VG_(copy_UInstr) ( UCodeBlock* cb, UInstr* instr ); |
| 735 | |
| 736 | extern Bool VG_(any_flag_use)( UInstr* u ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 737 | |
| 738 | /* Refer to `the last instruction stuffed in' (can be lvalue). */ |
| 739 | #define LAST_UINSTR(cb) (cb)->instrs[(cb)->used-1] |
| 740 | |
| 741 | |
| 742 | /* ------------------------------------------------------------------ */ |
| 743 | /* Higher-level UInstr sequence builders */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 744 | extern void VG_(call_helper_0_0) ( UCodeBlock* cb, Addr f); |
| 745 | extern void VG_(call_helper_1_0) ( UCodeBlock* cb, Addr f, UInt arg1, |
| 746 | UInt regparms_n); |
| 747 | extern void VG_(call_helper_2_0) ( UCodeBlock* cb, Addr f, UInt arg1, UInt arg2, |
| 748 | UInt regparms_n); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 749 | |
| 750 | /* One way around the 3-arg C function limit is to pass args via global |
| 751 | * variables... ugly, but it works. */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 752 | extern void VG_(set_global_var) ( UCodeBlock* cb, Addr globvar_ptr, UInt val); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 753 | |
| 754 | /* ------------------------------------------------------------------ */ |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 755 | /* Allocating/freeing basic blocks of UCode */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 756 | extern UCodeBlock* VG_(alloc_UCodeBlock) ( void ); |
| 757 | extern void VG_(free_UCodeBlock) ( UCodeBlock* cb ); |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 758 | |
| 759 | /* ------------------------------------------------------------------ */ |
| 760 | /* UCode pretty/ugly printing. Probably only useful to call from a skin |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 761 | if VG_(needs).extended_UCode == True. */ |
| 762 | |
| 763 | /* When True, all generated code is/should be printed. */ |
| 764 | extern Bool VG_(print_codegen); |
| 765 | |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 766 | /* Pretty/ugly printing functions */ |
| 767 | extern void VG_(pp_UCodeBlock) ( UCodeBlock* cb, Char* title ); |
| 768 | extern void VG_(pp_UInstr) ( Int instrNo, UInstr* u ); |
| 769 | extern void VG_(pp_UInstr_regs) ( Int instrNo, UInstr* u ); |
| 770 | extern void VG_(up_UInstr) ( Int instrNo, UInstr* u ); |
| 771 | extern Char* VG_(name_UOpcode) ( Bool upper, Opcode opc ); |
| 772 | extern void VG_(pp_UOperand) ( UInstr* u, Int operandNo, |
| 773 | Int sz, Bool parens ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 774 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 775 | |
| 776 | /*====================================================================*/ |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 777 | /*=== Generating x86 code from UCode ===*/ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 778 | /*====================================================================*/ |
| 779 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 780 | /* All this only necessary for skins with VG_(needs).extends_UCode == True. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 781 | |
sewardj | e104247 | 2002-09-30 12:33:11 +0000 | [diff] [blame^] | 782 | /* This is the Intel register encoding -- integer regs. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 783 | #define R_EAX 0 |
| 784 | #define R_ECX 1 |
| 785 | #define R_EDX 2 |
| 786 | #define R_EBX 3 |
| 787 | #define R_ESP 4 |
| 788 | #define R_EBP 5 |
| 789 | #define R_ESI 6 |
| 790 | #define R_EDI 7 |
| 791 | |
| 792 | #define R_AL (0+R_EAX) |
| 793 | #define R_CL (0+R_ECX) |
| 794 | #define R_DL (0+R_EDX) |
| 795 | #define R_BL (0+R_EBX) |
| 796 | #define R_AH (4+R_EAX) |
| 797 | #define R_CH (4+R_ECX) |
| 798 | #define R_DH (4+R_EDX) |
| 799 | #define R_BH (4+R_EBX) |
| 800 | |
sewardj | e104247 | 2002-09-30 12:33:11 +0000 | [diff] [blame^] | 801 | /* This is the Intel register encoding -- segment regs. */ |
| 802 | #define R_ES 0 |
| 803 | #define R_CS 1 |
| 804 | #define R_SS 2 |
| 805 | #define R_DS 3 |
| 806 | #define R_FS 4 |
| 807 | #define R_GS 5 |
| 808 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 809 | /* For pretty printing x86 code */ |
sewardj | e104247 | 2002-09-30 12:33:11 +0000 | [diff] [blame^] | 810 | extern Char* VG_(name_of_seg_reg) ( Int sreg ); |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 811 | extern Char* VG_(name_of_int_reg) ( Int size, Int reg ); |
| 812 | extern Char VG_(name_of_int_size) ( Int size ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 813 | |
| 814 | /* Randomly useful things */ |
| 815 | extern UInt VG_(extend_s_8to32) ( UInt x ); |
| 816 | |
| 817 | /* Code emitters */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 818 | extern void VG_(emitB) ( UInt b ); |
| 819 | extern void VG_(emitW) ( UInt w ); |
| 820 | extern void VG_(emitL) ( UInt l ); |
| 821 | extern void VG_(new_emit) ( void ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 822 | |
| 823 | /* Finding offsets */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 824 | extern Int VG_(helper_offset) ( Addr a ); |
| 825 | extern Int VG_(shadow_reg_offset) ( Int arch ); |
| 826 | extern Int VG_(shadow_flags_offset) ( void ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 827 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 828 | /* Convert reg ranks <-> Intel register ordering, for using register |
| 829 | liveness information. */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 830 | extern Int VG_(realreg_to_rank) ( Int realreg ); |
| 831 | extern Int VG_(rank_to_realreg) ( Int rank ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 832 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 833 | /* Call a subroutine. Does no argument passing, stack manipulations, etc. */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 834 | extern void VG_(synth_call) ( Bool ensure_shortform, Int word_offset ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 835 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 836 | /* For calling C functions -- saves caller save regs, pushes args, calls, |
| 837 | clears the stack, restores caller save regs. `fn' must be registered in |
| 838 | the baseBlock first. Acceptable tags are RealReg and Literal. Optimises |
| 839 | things, eg. by not preserving non-live caller-save registers. |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 840 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 841 | WARNING: a UInstr should *not* be translated with synth_ccall() followed |
| 842 | by some other x86 assembly code; this will invalidate the results of |
| 843 | vg_realreg_liveness_analysis() and everything will fall over. */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 844 | extern void VG_(synth_ccall) ( Addr fn, Int argc, Int regparms_n, UInt argv[], |
| 845 | Tag tagv[], Int ret_reg, |
| 846 | RRegSet regs_live_before, |
| 847 | RRegSet regs_live_after ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 848 | |
| 849 | /* Addressing modes */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 850 | extern void VG_(emit_amode_offregmem_reg)( Int off, Int regmem, Int reg ); |
| 851 | extern void VG_(emit_amode_ereg_greg) ( Int e_reg, Int g_reg ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 852 | |
| 853 | /* v-size (4, or 2 with OSO) insn emitters */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 854 | extern void VG_(emit_movv_offregmem_reg) ( Int sz, Int off, Int areg, Int reg ); |
| 855 | extern void VG_(emit_movv_reg_offregmem) ( Int sz, Int reg, Int off, Int areg ); |
| 856 | extern void VG_(emit_movv_reg_reg) ( Int sz, Int reg1, Int reg2 ); |
| 857 | extern void VG_(emit_nonshiftopv_lit_reg)( Int sz, Opcode opc, UInt lit, |
| 858 | Int reg ); |
| 859 | extern void VG_(emit_shiftopv_lit_reg) ( Int sz, Opcode opc, UInt lit, |
| 860 | Int reg ); |
| 861 | extern void VG_(emit_nonshiftopv_reg_reg)( Int sz, Opcode opc, |
| 862 | Int reg1, Int reg2 ); |
| 863 | extern void VG_(emit_movv_lit_reg) ( Int sz, UInt lit, Int reg ); |
| 864 | extern void VG_(emit_unaryopv_reg) ( Int sz, Opcode opc, Int reg ); |
| 865 | extern void VG_(emit_pushv_reg) ( Int sz, Int reg ); |
| 866 | extern void VG_(emit_popv_reg) ( Int sz, Int reg ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 867 | |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 868 | extern void VG_(emit_pushl_lit32) ( UInt int32 ); |
| 869 | extern void VG_(emit_pushl_lit8) ( Int lit8 ); |
| 870 | extern void VG_(emit_cmpl_zero_reg) ( Int reg ); |
| 871 | extern void VG_(emit_swapl_reg_EAX) ( Int reg ); |
| 872 | extern void VG_(emit_movv_lit_offregmem) ( Int sz, UInt lit, Int off, |
| 873 | Int memreg ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 874 | |
| 875 | /* b-size (1 byte) instruction emitters */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 876 | extern void VG_(emit_movb_lit_offregmem) ( UInt lit, Int off, Int memreg ); |
| 877 | extern void VG_(emit_movb_reg_offregmem) ( Int reg, Int off, Int areg ); |
| 878 | extern void VG_(emit_unaryopb_reg) ( Opcode opc, Int reg ); |
| 879 | extern void VG_(emit_testb_lit_reg) ( UInt lit, Int reg ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 880 | |
| 881 | /* zero-extended load emitters */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 882 | extern void VG_(emit_movzbl_offregmem_reg) ( Int off, Int regmem, Int reg ); |
| 883 | extern void VG_(emit_movzwl_offregmem_reg) ( Int off, Int areg, Int reg ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 884 | |
| 885 | /* misc instruction emitters */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 886 | extern void VG_(emit_call_reg) ( Int reg ); |
| 887 | extern void VG_(emit_add_lit_to_esp) ( Int lit ); |
| 888 | extern void VG_(emit_jcondshort_delta) ( Condcode cond, Int delta ); |
| 889 | extern void VG_(emit_pushal) ( void ); |
| 890 | extern void VG_(emit_popal) ( void ); |
| 891 | extern void VG_(emit_AMD_prefetch_reg) ( Int reg ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 892 | |
| 893 | |
| 894 | /*====================================================================*/ |
| 895 | /*=== Execution contexts ===*/ |
| 896 | /*====================================================================*/ |
| 897 | |
| 898 | /* Generic resolution type used in a few different ways, such as deciding |
| 899 | how closely to compare two errors for equality. */ |
| 900 | typedef |
| 901 | enum { Vg_LowRes, Vg_MedRes, Vg_HighRes } |
| 902 | VgRes; |
| 903 | |
| 904 | typedef |
| 905 | struct _ExeContext |
| 906 | ExeContext; |
| 907 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 908 | /* Compare two ExeContexts. Number of callers considered depends on `res': |
| 909 | Vg_LowRes: 2 |
| 910 | Vg_MedRes: 4 |
| 911 | Vg_HighRes: all */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 912 | extern Bool VG_(eq_ExeContext) ( VgRes res, |
| 913 | ExeContext* e1, ExeContext* e2 ); |
| 914 | |
| 915 | /* Print an ExeContext. */ |
| 916 | extern void VG_(pp_ExeContext) ( ExeContext* ); |
| 917 | |
| 918 | /* Take a snapshot of the client's stack. Search our collection of |
| 919 | ExeContexts to see if we already have it, and if not, allocate a |
| 920 | new one. Either way, return a pointer to the context. */ |
| 921 | extern ExeContext* VG_(get_ExeContext) ( ThreadState *tst ); |
| 922 | |
| 923 | |
| 924 | /*====================================================================*/ |
| 925 | /*=== Error reporting ===*/ |
| 926 | /*====================================================================*/ |
| 927 | |
| 928 | /* ------------------------------------------------------------------ */ |
| 929 | /* Suppressions describe errors which we want to suppress, ie, not |
| 930 | show the user, usually because it is caused by a problem in a library |
| 931 | which we can't fix, replace or work around. Suppressions are read from |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 932 | a file at startup time. This gives flexibility so that new |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 933 | suppressions can be added to the file as and when needed. |
| 934 | */ |
| 935 | |
| 936 | typedef |
| 937 | Int /* Do not make this unsigned! */ |
| 938 | SuppKind; |
| 939 | |
| 940 | /* An extensible (via the 'extra' field) suppression record. This holds |
| 941 | the suppression details of interest to a skin. Skins can use a normal |
| 942 | enum (with element values in the normal range (0..)) for `skind'. |
| 943 | |
| 944 | If VG_(needs).report_errors==True, for each suppression read in by core |
| 945 | SKN_(recognised_suppression)() and SKN_(read_extra_suppression_info) will |
| 946 | be called. The `skind' field is filled in by the value returned in the |
| 947 | argument of the first function; the second function can fill in the |
| 948 | `string' and `extra' fields if it wants. |
| 949 | */ |
| 950 | typedef |
| 951 | struct { |
| 952 | /* What kind of suppression. Must use the range (0..) */ |
| 953 | SuppKind skind; |
| 954 | /* String -- use is optional. NULL by default. */ |
| 955 | Char* string; |
| 956 | /* Anything else -- use is optional. NULL by default. */ |
| 957 | void* extra; |
| 958 | } |
| 959 | SkinSupp; |
| 960 | |
| 961 | |
| 962 | /* ------------------------------------------------------------------ */ |
| 963 | /* Error records contain enough info to generate an error report. The idea |
| 964 | is that (typically) the same few points in the program generate thousands |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 965 | of errors, and we don't want to spew out a fresh error message for each |
| 966 | one. Instead, we use these structures to common up duplicates. |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 967 | */ |
| 968 | |
| 969 | typedef |
| 970 | Int /* Do not make this unsigned! */ |
| 971 | ErrorKind; |
| 972 | |
| 973 | /* An extensible (via the 'extra' field) error record. This holds |
| 974 | the error details of interest to a skin. Skins can use a normal |
| 975 | enum (with element values in the normal range (0..)) for `ekind'. |
| 976 | |
| 977 | When errors are found and recorded with VG_(maybe_record_error)(), all |
| 978 | the skin must do is pass in the four parameters; core will |
| 979 | allocate/initialise the error record. |
| 980 | */ |
| 981 | typedef |
| 982 | struct { |
| 983 | /* Used by ALL. Must be in the range (0..) */ |
| 984 | Int ekind; |
| 985 | /* Used frequently */ |
| 986 | Addr addr; |
| 987 | /* Used frequently */ |
| 988 | Char* string; |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 989 | /* For any skin-specific extras */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 990 | void* extra; |
| 991 | } |
| 992 | SkinError; |
| 993 | |
| 994 | |
| 995 | /* ------------------------------------------------------------------ */ |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 996 | /* Call this when an error occurs. It will be recorded if it hasn't been |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 997 | seen before. If it has, the existing error record will have its count |
| 998 | incremented. |
| 999 | |
| 1000 | If the error occurs in generated code, 'tst' should be NULL. If the |
| 1001 | error occurs in non-generated code, 'tst' should be non-NULL. The |
| 1002 | `extra' field can be stack-allocated; it will be copied (using |
| 1003 | SKN_(dup_extra_and_update)()) if needed. But it won't be copied |
| 1004 | if it's NULL. |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1005 | |
| 1006 | If no 'a', 's' or 'extra' of interest needs to be recorded, just use |
| 1007 | NULL for them. |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1008 | */ |
| 1009 | extern void VG_(maybe_record_error) ( ThreadState* tst, ErrorKind ekind, |
| 1010 | Addr a, Char* s, void* extra ); |
| 1011 | |
| 1012 | /* Gets a non-blank, non-comment line of at most nBuf chars from fd. |
| 1013 | Skips leading spaces on the line. Returns True if EOF was hit instead. |
| 1014 | Useful for reading in extra skin-specific suppression lines. |
| 1015 | */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 1016 | extern Bool VG_(get_line) ( Int fd, Char* buf, Int nBuf ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1017 | |
| 1018 | |
| 1019 | /*====================================================================*/ |
| 1020 | /*=== Obtaining debug information ===*/ |
| 1021 | /*====================================================================*/ |
| 1022 | |
| 1023 | /* Get the file/function/line number of the instruction at address 'a'. |
| 1024 | For these four, if debug info for the address is found, it copies the |
| 1025 | info into the buffer/UInt and returns True. If not, it returns False and |
| 1026 | nothing is copied. VG_(get_fnname) always demangles C++ function names. |
| 1027 | */ |
| 1028 | extern Bool VG_(get_filename) ( Addr a, Char* filename, Int n_filename ); |
| 1029 | extern Bool VG_(get_fnname) ( Addr a, Char* fnname, Int n_fnname ); |
| 1030 | extern Bool VG_(get_linenum) ( Addr a, UInt* linenum ); |
| 1031 | |
| 1032 | /* This one is more efficient if getting both filename and line number, |
| 1033 | because the two lookups are done together. */ |
| 1034 | extern Bool VG_(get_filename_linenum) |
| 1035 | ( Addr a, Char* filename, Int n_filename, |
| 1036 | UInt* linenum ); |
| 1037 | |
| 1038 | /* Succeeds only if we find from debug info that 'a' is the address of the |
| 1039 | first instruction in a function -- as opposed to VG_(get_fnname) which |
| 1040 | succeeds if we find from debug info that 'a' is the address of any |
| 1041 | instruction in a function. Use this to instrument the start of |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1042 | a particular function. Nb: if an executable/shared object is stripped |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1043 | of its symbols, this function will not be able to recognise function |
| 1044 | entry points within it. */ |
| 1045 | extern Bool VG_(get_fnname_if_entry) ( Addr a, Char* filename, Int n_filename ); |
| 1046 | |
| 1047 | /* Succeeds if the address is within a shared object or the main executable. |
| 1048 | It doesn't matter if debug info is present or not. */ |
| 1049 | extern Bool VG_(get_objname) ( Addr a, Char* objname, Int n_objname ); |
| 1050 | |
| 1051 | |
| 1052 | /*====================================================================*/ |
| 1053 | /*=== Shadow chunks and block-finding ===*/ |
| 1054 | /*====================================================================*/ |
| 1055 | |
| 1056 | typedef |
| 1057 | enum { |
| 1058 | Vg_AllocMalloc = 0, |
| 1059 | Vg_AllocNew = 1, |
| 1060 | Vg_AllocNewVec = 2 |
| 1061 | } |
| 1062 | VgAllocKind; |
| 1063 | |
| 1064 | /* Description of a malloc'd chunk. skin_extra[] part can be used by |
| 1065 | the skin; size of array is given by VG_(needs).sizeof_shadow_chunk. */ |
| 1066 | typedef |
| 1067 | struct _ShadowChunk { |
| 1068 | struct _ShadowChunk* next; |
| 1069 | UInt size : 30; /* size requested */ |
| 1070 | VgAllocKind allockind : 2; /* which wrapper did the allocation */ |
| 1071 | Addr data; /* ptr to actual block */ |
| 1072 | UInt skin_extra[0]; /* extra skin-specific info */ |
| 1073 | } |
| 1074 | ShadowChunk; |
| 1075 | |
| 1076 | /* Use this to free blocks if VG_(needs).alternative_free == True. |
| 1077 | It frees the ShadowChunk and the malloc'd block it points to. */ |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 1078 | extern void VG_(free_ShadowChunk) ( ShadowChunk* sc ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1079 | |
| 1080 | /* Makes an array of pointers to all the shadow chunks of malloc'd blocks */ |
| 1081 | extern ShadowChunk** VG_(get_malloc_shadows) ( /*OUT*/ UInt* n_shadows ); |
| 1082 | |
| 1083 | /* Determines if address 'a' is within the bounds of the block at start. |
| 1084 | Allows a little 'slop' round the edges. */ |
| 1085 | extern Bool VG_(addr_is_in_block) ( Addr a, Addr start, UInt size ); |
| 1086 | |
| 1087 | /* Searches through currently malloc'd blocks until a matching one is found. |
| 1088 | Returns NULL if none match. Extra arguments can be implicitly passed to |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1089 | p using nested functions; see memcheck/mc_errcontext.c for an example. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1090 | extern ShadowChunk* VG_(any_matching_mallocd_ShadowChunks) |
| 1091 | ( Bool (*p) ( ShadowChunk* )); |
| 1092 | |
| 1093 | /* Searches through all thread's stacks to see if any match. Returns |
| 1094 | * VG_INVALID_THREADID if none match. */ |
| 1095 | extern ThreadId VG_(any_matching_thread_stack) |
| 1096 | ( Bool (*p) ( Addr stack_min, Addr stack_max )); |
| 1097 | |
| 1098 | /*====================================================================*/ |
| 1099 | /*=== Skin-specific stuff ===*/ |
| 1100 | /*====================================================================*/ |
| 1101 | |
| 1102 | /* Skin-specific settings. |
| 1103 | * |
| 1104 | * If new fields are added to this type, update: |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1105 | * - vg_main.c:initialisation of VG_(needs) |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1106 | * - vg_main.c:sanity_check_needs() |
| 1107 | * |
| 1108 | * If the name of this type or any of its fields change, update: |
| 1109 | * - dependent comments (just search for "VG_(needs)"). |
| 1110 | */ |
| 1111 | typedef |
| 1112 | struct { |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1113 | /* Name and description used in the startup message. 'name' also |
| 1114 | determines the string used for identifying suppressions in a |
| 1115 | suppression file as belonging to this skin. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1116 | Char* name; |
| 1117 | Char* description; |
| 1118 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1119 | /* Booleans that decide core behaviour, but don't require extra |
| 1120 | operations to be defined if `True' */ |
| 1121 | |
| 1122 | /* Should __libc_freeres() be run? Bugs in it can crash the skin. */ |
| 1123 | Bool run_libc_freeres; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1124 | |
| 1125 | /* Want to have errors detected by Valgrind's core reported? Includes: |
| 1126 | - pthread API errors (many; eg. unlocking a non-locked mutex) |
| 1127 | - silly arguments to malloc() et al (eg. negative size) |
| 1128 | - invalid file descriptors to blocking syscalls read() and write() |
| 1129 | - bad signal numbers passed to sigaction() |
| 1130 | - attempt to install signal handler for SIGKILL or SIGSTOP */ |
| 1131 | Bool core_errors; |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1132 | |
| 1133 | /* Booleans that indicate extra operations are defined; if these are |
| 1134 | True, the corresponding template functions (given below) must be |
| 1135 | defined. A lot like being a member of a type class. */ |
| 1136 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1137 | /* Want to report errors from the skin? This implies use of |
| 1138 | suppressions, too. */ |
| 1139 | Bool skin_errors; |
| 1140 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1141 | /* Is information kept about specific individual basic blocks? (Eg. for |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1142 | cachegrind there are cost-centres for every instruction, stored at a |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1143 | basic block level.) If so, it sometimes has to be discarded, because |
| 1144 | .so mmap/munmap-ping or self-modifying code (informed by the |
| 1145 | DISCARD_TRANSLATIONS user request) can cause one instruction address |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1146 | to be used for more than one instruction in one program run... */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1147 | Bool basic_block_discards; |
| 1148 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1149 | /* Skin maintains information about each register? */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1150 | Bool shadow_regs; |
| 1151 | |
| 1152 | /* Skin defines its own command line options? */ |
| 1153 | Bool command_line_options; |
| 1154 | /* Skin defines its own client requests? */ |
| 1155 | Bool client_requests; |
| 1156 | |
| 1157 | /* Skin defines its own UInstrs? */ |
| 1158 | Bool extended_UCode; |
| 1159 | |
| 1160 | /* Skin does stuff before and/or after system calls? */ |
| 1161 | Bool syscall_wrapper; |
| 1162 | |
| 1163 | /* Size, in words, of extra info about malloc'd blocks recorded by |
| 1164 | skin. Be careful to get this right or you'll get seg faults! */ |
| 1165 | UInt sizeof_shadow_block; |
| 1166 | |
| 1167 | /* Skin does free()s itself? */ |
| 1168 | Bool alternative_free; |
| 1169 | |
| 1170 | /* Are skin-state sanity checks performed? */ |
| 1171 | Bool sanity_checks; |
| 1172 | } |
| 1173 | VgNeeds; |
| 1174 | |
| 1175 | extern VgNeeds VG_(needs); |
| 1176 | |
| 1177 | |
| 1178 | /* ------------------------------------------------------------------ */ |
| 1179 | /* Core events to track */ |
| 1180 | |
| 1181 | /* Part of the core from which this call was made. Useful for determining |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1182 | what kind of error message should be emitted. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1183 | typedef |
| 1184 | enum { Vg_CorePThread, Vg_CoreSignal, Vg_CoreSysCall, Vg_CoreTranslate } |
| 1185 | CorePart; |
| 1186 | |
| 1187 | /* Events happening in core to track. To be notified, assign a function |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1188 | to the function pointer. To ignore an event, don't do anything |
| 1189 | (default assignment is to NULL in which case the call is skipped). */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1190 | typedef |
| 1191 | struct { |
| 1192 | /* Memory events */ |
| 1193 | void (*new_mem_startup)( Addr a, UInt len, Bool rr, Bool ww, Bool xx ); |
| 1194 | void (*new_mem_heap) ( Addr a, UInt len, Bool is_inited ); |
| 1195 | void (*new_mem_stack) ( Addr a, UInt len ); |
| 1196 | void (*new_mem_stack_aligned) ( Addr a, UInt len ); |
| 1197 | void (*new_mem_stack_signal) ( Addr a, UInt len ); |
| 1198 | void (*new_mem_brk) ( Addr a, UInt len ); |
| 1199 | void (*new_mem_mmap) ( Addr a, UInt len, |
| 1200 | Bool nn, Bool rr, Bool ww, Bool xx ); |
| 1201 | |
| 1202 | void (*copy_mem_heap) ( Addr from, Addr to, UInt len ); |
| 1203 | void (*copy_mem_remap) ( Addr from, Addr to, UInt len ); |
| 1204 | void (*change_mem_mprotect) ( Addr a, UInt len, |
| 1205 | Bool nn, Bool rr, Bool ww, Bool xx ); |
| 1206 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1207 | /* Used on redzones around malloc'd blocks and at end of stack */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1208 | void (*ban_mem_heap) ( Addr a, UInt len ); |
| 1209 | void (*ban_mem_stack) ( Addr a, UInt len ); |
| 1210 | |
| 1211 | void (*die_mem_heap) ( Addr a, UInt len ); |
| 1212 | void (*die_mem_stack) ( Addr a, UInt len ); |
| 1213 | void (*die_mem_stack_aligned) ( Addr a, UInt len ); |
| 1214 | void (*die_mem_stack_signal) ( Addr a, UInt len ); |
| 1215 | void (*die_mem_brk) ( Addr a, UInt len ); |
| 1216 | void (*die_mem_munmap) ( Addr a, UInt len ); |
| 1217 | |
| 1218 | void (*bad_free) ( ThreadState* tst, Addr a ); |
| 1219 | void (*mismatched_free) ( ThreadState* tst, Addr a ); |
| 1220 | |
| 1221 | void (*pre_mem_read) ( CorePart part, ThreadState* tst, |
| 1222 | Char* s, Addr a, UInt size ); |
| 1223 | void (*pre_mem_read_asciiz) ( CorePart part, ThreadState* tst, |
| 1224 | Char* s, Addr a ); |
| 1225 | void (*pre_mem_write) ( CorePart part, ThreadState* tst, |
| 1226 | Char* s, Addr a, UInt size ); |
| 1227 | /* Not implemented yet -- have to add in lots of places, which is a |
| 1228 | pain. Won't bother unless/until there's a need. */ |
| 1229 | /* void (*post_mem_read) ( ThreadState* tst, Char* s, |
| 1230 | Addr a, UInt size ); */ |
| 1231 | void (*post_mem_write) ( Addr a, UInt size ); |
| 1232 | |
| 1233 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1234 | /* Scheduler events (not exhaustive) */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1235 | void (*thread_run) ( ThreadId tid ); |
| 1236 | |
| 1237 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1238 | /* Mutex events (not exhaustive) */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1239 | void (*post_mutex_lock) ( ThreadId tid, |
| 1240 | void* /*pthread_mutex_t* */ mutex ); |
| 1241 | void (*post_mutex_unlock) ( ThreadId tid, |
| 1242 | void* /*pthread_mutex_t* */ mutex ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1243 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1244 | |
| 1245 | /* Others... thread, condition variable, signal events... */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1246 | /* ... */ |
| 1247 | } |
| 1248 | VgTrackEvents; |
| 1249 | |
| 1250 | /* Declare the struct instance */ |
| 1251 | extern VgTrackEvents VG_(track_events); |
| 1252 | |
| 1253 | |
| 1254 | /* ------------------------------------------------------------------ */ |
| 1255 | /* Template functions */ |
| 1256 | |
| 1257 | /* These are the parameterised functions in the core. The default definitions |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1258 | are overridden by LD_PRELOADed skin version. At the very least, a skin |
| 1259 | must define the fundamental template functions. Depending on what needs |
| 1260 | are set, extra template functions will be used too. Functions are |
| 1261 | grouped under the needs that govern their use. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1262 | |
| 1263 | |
| 1264 | /* ------------------------------------------------------------------ */ |
| 1265 | /* Fundamental template functions */ |
| 1266 | |
| 1267 | /* Initialise skin. Must do the following: |
| 1268 | - initialise the 'needs' struct |
| 1269 | - register any helpers called by generated code |
| 1270 | |
| 1271 | May do the following: |
| 1272 | - indicate events to track by initialising part or all of the 'track' |
| 1273 | struct |
| 1274 | - register any skin-specific profiling events |
| 1275 | - any other skin-specific initialisation |
| 1276 | */ |
| 1277 | extern void SK_(pre_clo_init) ( VgNeeds* needs, VgTrackEvents* track ); |
| 1278 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1279 | /* Do initialisation that can only be done after command line processing. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1280 | extern void SK_(post_clo_init)( void ); |
| 1281 | |
| 1282 | /* Instrument a basic block. Must be a true function, ie. the same input |
| 1283 | always results in the same output, because basic blocks can be |
| 1284 | retranslated. Unless you're doing something really strange... |
| 1285 | 'orig_addr' is the address of the first instruction in the block. */ |
| 1286 | extern UCodeBlock* SK_(instrument) ( UCodeBlock* cb, Addr orig_addr ); |
| 1287 | |
| 1288 | /* Finish up, print out any results, etc. */ |
| 1289 | extern void SK_(fini) ( void ); |
| 1290 | |
| 1291 | |
| 1292 | /* ------------------------------------------------------------------ */ |
| 1293 | /* VG_(needs).report_errors */ |
| 1294 | |
| 1295 | /* Identify if two errors are equal, or equal enough. `res' indicates how |
| 1296 | close is "close enough". `res' should be passed on as necessary, eg. if |
| 1297 | the SkinError's extra field contains an ExeContext, `res' should be |
| 1298 | passed to VG_(eq_ExeContext)() if the ExeContexts are considered. Other |
| 1299 | than that, probably don't worry about it unless you have lots of very |
| 1300 | similar errors occurring. |
| 1301 | */ |
| 1302 | extern Bool SK_(eq_SkinError) ( VgRes res, |
| 1303 | SkinError* e1, SkinError* e2 ); |
| 1304 | |
| 1305 | /* Print error context. The passed function pp_ExeContext() can be (and |
| 1306 | probably should be) used to print the location of the error. */ |
| 1307 | extern void SK_(pp_SkinError) ( SkinError* ec, void (*pp_ExeContext)(void) ); |
| 1308 | |
| 1309 | /* Copy the ec->extra part and replace ec->extra with the new copy. This is |
| 1310 | necessary to move from a temporary stack copy to a permanent heap one. |
| 1311 | |
| 1312 | Then fill in any details that could be postponed until after the decision |
| 1313 | whether to ignore the error (ie. details not affecting the result of |
| 1314 | SK_(eq_SkinError)()). This saves time when errors are ignored. |
| 1315 | |
| 1316 | Yuk. |
| 1317 | */ |
| 1318 | extern void SK_(dup_extra_and_update)(SkinError* ec); |
| 1319 | |
| 1320 | /* Return value indicates recognition. If recognised, type goes in `skind'. */ |
| 1321 | extern Bool SK_(recognised_suppression) ( Char* name, SuppKind *skind ); |
| 1322 | |
| 1323 | /* Read any extra info for this suppression kind. For filling up the |
| 1324 | `string' and `extra' fields in a `SkinSupp' struct if necessary. */ |
| 1325 | extern Bool SK_(read_extra_suppression_info) ( Int fd, Char* buf, |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1326 | Int nBuf, SkinSupp *s ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1327 | |
| 1328 | /* This should just check the kinds match and maybe some stuff in the |
| 1329 | 'extra' field if appropriate */ |
| 1330 | extern Bool SK_(error_matches_suppression)(SkinError* ec, SkinSupp* su); |
| 1331 | |
| 1332 | |
| 1333 | /* ------------------------------------------------------------------ */ |
| 1334 | /* VG_(needs).basic_block_discards */ |
| 1335 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1336 | /* Should discard any information that pertains to specific basic blocks |
| 1337 | or instructions within the address range given. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1338 | extern void SK_(discard_basic_block_info) ( Addr a, UInt size ); |
| 1339 | |
| 1340 | |
| 1341 | /* ------------------------------------------------------------------ */ |
| 1342 | /* VG_(needs).shadow_regs */ |
| 1343 | |
| 1344 | /* Valid values for general registers and EFLAGS register, for initialising |
| 1345 | and updating registers when written in certain places in core. */ |
| 1346 | extern void SK_(written_shadow_regs_values) ( UInt* gen_reg, UInt* eflags ); |
| 1347 | |
| 1348 | |
| 1349 | /* ------------------------------------------------------------------ */ |
| 1350 | /* VG_(needs).command_line_options */ |
| 1351 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1352 | /* Return True if option was recognised. Presumably sets some state to |
| 1353 | record the option as well. */ |
| 1354 | extern Bool SK_(process_cmd_line_option) ( Char* argv ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1355 | |
| 1356 | /* Print out command line usage for skin options */ |
| 1357 | extern Char* SK_(usage) ( void ); |
| 1358 | |
| 1359 | |
| 1360 | /* ------------------------------------------------------------------ */ |
| 1361 | /* VG_(needs).client_requests */ |
| 1362 | |
| 1363 | extern UInt SK_(handle_client_request) ( ThreadState* tst, UInt* arg_block ); |
| 1364 | |
| 1365 | |
| 1366 | /* ------------------------------------------------------------------ */ |
| 1367 | /* VG_(needs).extends_UCode */ |
| 1368 | |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 1369 | /* Useful to use in VG_(get_Xreg_usage)() */ |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1370 | #define VG_UINSTR_READS_REG(ono) \ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1371 | { if (mycat(u->tag,ono) == tag) \ |
| 1372 | { arr[n].num = mycat(u->val,ono); \ |
| 1373 | arr[n].isWrite = False; \ |
| 1374 | n++; \ |
| 1375 | } \ |
| 1376 | } |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1377 | #define VG_UINSTR_WRITES_REG(ono) \ |
| 1378 | { if (mycat(u->tag,ono) == tag) \ |
| 1379 | { arr[n].num = mycat(u->val,ono); \ |
| 1380 | arr[n].isWrite = True; \ |
| 1381 | n++; \ |
| 1382 | } \ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1383 | } |
| 1384 | |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 1385 | /* 'X' prefix indicates eXtended UCode. */ |
| 1386 | extern Int SK_(get_Xreg_usage) ( UInstr* u, Tag tag, RegUse* arr ); |
| 1387 | extern void SK_(emit_XUInstr) ( UInstr* u, RRegSet regs_live_before ); |
| 1388 | extern Bool SK_(sane_XUInstr) ( Bool beforeRA, Bool beforeLiveness, |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1389 | UInstr* u ); |
njn | 4ba5a79 | 2002-09-30 10:23:54 +0000 | [diff] [blame] | 1390 | extern Char* SK_(name_XUOpcode) ( Opcode opc ); |
| 1391 | extern void SK_(pp_XUInstr) ( UInstr* u ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1392 | |
| 1393 | |
| 1394 | /* ------------------------------------------------------------------ */ |
| 1395 | /* VG_(needs).syscall_wrapper */ |
| 1396 | |
| 1397 | /* If either of the pre_ functions malloc() something to return, the |
| 1398 | * corresponding post_ function had better free() it! |
| 1399 | */ |
| 1400 | extern void* SK_( pre_syscall) ( ThreadId tid, UInt syscallno, |
| 1401 | Bool is_blocking ); |
| 1402 | extern void SK_(post_syscall) ( ThreadId tid, UInt syscallno, |
| 1403 | void* pre_result, Int res, |
| 1404 | Bool is_blocking ); |
| 1405 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1406 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1407 | /* ------------------------------------------------------------------ */ |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1408 | /* VG_(needs).sizeof_shadow_chunk (if > 0) */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1409 | |
| 1410 | extern void SK_(complete_shadow_chunk) ( ShadowChunk* sc, ThreadState* tst ); |
| 1411 | |
| 1412 | |
| 1413 | /* ------------------------------------------------------------------ */ |
| 1414 | /* VG_(needs).alternative_free */ |
| 1415 | |
| 1416 | extern void SK_(alt_free) ( ShadowChunk* sc, ThreadState* tst ); |
| 1417 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1418 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1419 | /* --------------------------------------------------------------------- |
| 1420 | VG_(needs).sanity_checks */ |
| 1421 | |
njn | d5bb0a5 | 2002-09-27 10:24:48 +0000 | [diff] [blame] | 1422 | /* Can be useful for ensuring a skin's correctness. SK_(cheap_sanity_check) |
| 1423 | is called very frequently; SK_(expensive_sanity_check) is called less |
| 1424 | frequently and can be more involved. */ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 1425 | extern Bool SK_(cheap_sanity_check) ( void ); |
| 1426 | extern Bool SK_(expensive_sanity_check) ( void ); |
| 1427 | |
| 1428 | |
| 1429 | #endif /* NDEF __VG_SKIN_H */ |
| 1430 | |
| 1431 | /*--------------------------------------------------------------------*/ |
| 1432 | /*--- end vg_skin.h ---*/ |
| 1433 | /*--------------------------------------------------------------------*/ |
| 1434 | |