sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- A header file for all parts of Valgrind. ---*/ |
| 4 | /*--- Include no other! ---*/ |
| 5 | /*--- vg_include.h ---*/ |
| 6 | /*--------------------------------------------------------------------*/ |
| 7 | |
| 8 | /* |
| 9 | This file is part of Valgrind, an x86 protected-mode emulator |
| 10 | designed for debugging and profiling binaries on x86-Unixes. |
| 11 | |
| 12 | Copyright (C) 2000-2002 Julian Seward |
| 13 | jseward@acm.org |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 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 LICENSE. |
| 31 | */ |
| 32 | |
| 33 | #ifndef __VG_INCLUDE_H |
| 34 | #define __VG_INCLUDE_H |
| 35 | |
| 36 | |
| 37 | #include <stdarg.h> /* ANSI varargs stuff */ |
| 38 | #include <setjmp.h> /* for jmp_buf */ |
| 39 | |
| 40 | |
| 41 | /* --------------------------------------------------------------------- |
| 42 | Build options and table sizes. You should be able to change these |
| 43 | options or sizes, recompile, and still have a working system. |
| 44 | ------------------------------------------------------------------ */ |
| 45 | |
| 46 | #include "vg_constants.h" |
| 47 | |
| 48 | |
| 49 | /* Set to 1 to enable time profiling. Since this uses SIGPROF, we |
| 50 | don't want this permanently enabled -- only for profiling |
| 51 | builds. */ |
| 52 | #if 0 |
| 53 | # define VG_PROFILE |
| 54 | #endif |
| 55 | |
| 56 | |
| 57 | /* Total number of integer registers available for allocation. That's |
| 58 | all of them except %esp, %edi and %ebp. %edi is a general spare |
| 59 | temporary. %ebp permanently points at VG_(baseBlock). Note that |
| 60 | it's important that this tie in with what rankToRealRegNo() says. |
| 61 | DO NOT CHANGE THIS VALUE FROM 5. ! */ |
| 62 | #define VG_MAX_REALREGS 5 |
| 63 | |
| 64 | /* Total number of spill slots available for allocation, if a TempReg |
| 65 | doesn't make it into a RealReg. Just bomb the entire system if |
| 66 | this value is too small; we don't expect it will ever get |
| 67 | particularly high. */ |
| 68 | #define VG_MAX_SPILLSLOTS 24 |
| 69 | |
| 70 | |
| 71 | /* Constants for the slow translation lookup cache. */ |
| 72 | #define VG_TRANSTAB_SLOW_BITS 11 |
| 73 | #define VG_TRANSTAB_SLOW_SIZE (1 << VG_TRANSTAB_SLOW_BITS) |
| 74 | #define VG_TRANSTAB_SLOW_MASK ((VG_TRANSTAB_SLOW_SIZE) - 1) |
| 75 | |
| 76 | /* Size of a buffer used for creating messages. */ |
| 77 | #define M_VG_MSGBUF 10000 |
| 78 | |
| 79 | /* Size of a smallish table used to read /proc/self/map entries. */ |
sewardj | ebc8233 | 2002-04-24 14:44:23 +0000 | [diff] [blame] | 80 | #define M_PROCMAP_BUF 50000 |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 81 | |
| 82 | /* Max length of pathname to a .so/executable file. */ |
| 83 | #define M_VG_LIBNAMESTR 100 |
| 84 | |
| 85 | /* Max length of a text fragment used to construct error messages. */ |
| 86 | #define M_VG_ERRTXT 512 |
| 87 | |
| 88 | /* Max length of the string copied from env var VG_ARGS at startup. */ |
| 89 | #define M_VG_CMDLINE_STRLEN 1000 |
| 90 | |
| 91 | /* Max number of options for Valgrind which we can handle. */ |
| 92 | #define M_VG_CMDLINE_OPTS 100 |
| 93 | |
| 94 | /* After this many different unsuppressed errors have been observed, |
| 95 | be more conservative about collecting new ones. */ |
| 96 | #define M_VG_COLLECT_ERRORS_SLOWLY_AFTER 50 |
| 97 | |
| 98 | /* After this many different unsuppressed errors have been observed, |
| 99 | stop collecting errors at all, and tell the user their program is |
| 100 | evidently a steaming pile of camel dung. */ |
sewardj | 1bebcbf | 2002-04-24 21:24:18 +0000 | [diff] [blame] | 101 | #define M_VG_COLLECT_NO_ERRORS_AFTER_SHOWN 300 |
sewardj | f2537be | 2002-04-24 21:03:47 +0000 | [diff] [blame] | 102 | |
| 103 | /* After this many total errors have been observed, stop collecting |
| 104 | errors at all. Counterpart to M_VG_COLLECT_NO_ERRORS_AFTER_SHOWN. */ |
sewardj | 1bebcbf | 2002-04-24 21:24:18 +0000 | [diff] [blame] | 105 | #define M_VG_COLLECT_NO_ERRORS_AFTER_FOUND 30000 |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 106 | |
| 107 | /* These many bytes below %ESP are considered addressible if we're |
| 108 | doing the --workaround-gcc296-bugs hack. */ |
sewardj | b581a13 | 2002-05-08 00:32:50 +0000 | [diff] [blame] | 109 | #define VG_GCC296_BUG_STACK_SLOP 1024 |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 110 | |
| 111 | /* The maximum number of calls we're prepared to save in a |
| 112 | backtrace. */ |
| 113 | #define VG_DEEPEST_BACKTRACE 50 |
| 114 | |
| 115 | /* Number of lists in which we keep track of malloc'd but not free'd |
| 116 | blocks. Should be prime. */ |
| 117 | #define VG_N_MALLOCLISTS 997 |
| 118 | |
| 119 | /* Number of lists in which we keep track of ExeContexts. Should be |
| 120 | prime. */ |
| 121 | #define VG_N_EC_LISTS /*997*/ 4999 |
| 122 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 123 | /* Defines the thread-scheduling timeslice, in terms of the number of |
| 124 | basic blocks we attempt to run each thread for. Smaller values |
| 125 | give finer interleaving but much increased scheduling overheads. */ |
sewardj | 4505b9e | 2002-05-28 11:27:31 +0000 | [diff] [blame] | 126 | #define VG_SCHEDULING_QUANTUM 50000 |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 127 | |
| 128 | /* The maximum number of pthreads that we support. This is |
| 129 | deliberately not very high since our implementation of some of the |
sewardj | 5f07b66 | 2002-04-23 16:52:51 +0000 | [diff] [blame] | 130 | scheduler algorithms is surely O(N) in the number of threads, since |
| 131 | that's simple, at least. And (in practice) we hope that most |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 132 | programs do not need many threads. */ |
sewardj | 7989d0c | 2002-05-28 11:00:01 +0000 | [diff] [blame] | 133 | #define VG_N_THREADS 20 |
sewardj | 5f07b66 | 2002-04-23 16:52:51 +0000 | [diff] [blame] | 134 | |
| 135 | /* Maximum number of pthread keys available. Again, we start low until |
| 136 | the need for a higher number presents itself. */ |
| 137 | #define VG_N_THREAD_KEYS 10 |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 138 | |
| 139 | /* Number of file descriptors that can simultaneously be waited on for |
| 140 | I/O to complete. Perhaps this should be the same as VG_N_THREADS |
| 141 | (surely a thread can't wait on more than one fd at once?. Who |
| 142 | knows.) */ |
| 143 | #define VG_N_WAITING_FDS 10 |
| 144 | |
sewardj | bf290b9 | 2002-05-01 02:28:01 +0000 | [diff] [blame] | 145 | /* Stack size for a thread. We try and check that they do not go |
| 146 | beyond it. */ |
| 147 | #define VG_PTHREAD_STACK_SIZE 65536 |
| 148 | |
sewardj | 20917d8 | 2002-05-28 01:36:45 +0000 | [diff] [blame] | 149 | /* Number of entries in the semaphore-remapping table. */ |
| 150 | #define VG_N_SEMAPHORES 50 |
| 151 | |
| 152 | /* Number of entries in the rwlock-remapping table. */ |
| 153 | #define VG_N_RWLOCKS 50 |
| 154 | |
sewardj | 8ad94e1 | 2002-05-29 00:10:20 +0000 | [diff] [blame] | 155 | /* Number of entries in each thread's cleanup stack. */ |
| 156 | #define VG_N_CLEANUPSTACK 8 |
| 157 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 158 | |
| 159 | /* --------------------------------------------------------------------- |
| 160 | Basic types |
| 161 | ------------------------------------------------------------------ */ |
| 162 | |
| 163 | typedef unsigned char UChar; |
| 164 | typedef unsigned short UShort; |
| 165 | typedef unsigned int UInt; |
| 166 | typedef unsigned long long int ULong; |
| 167 | |
| 168 | typedef signed char Char; |
| 169 | typedef signed short Short; |
| 170 | typedef signed int Int; |
| 171 | typedef signed long long int Long; |
| 172 | |
| 173 | typedef unsigned int Addr; |
| 174 | |
| 175 | typedef unsigned char Bool; |
| 176 | #define False ((Bool)0) |
| 177 | #define True ((Bool)1) |
| 178 | |
| 179 | #define mycat_wrk(aaa,bbb) aaa##bbb |
| 180 | #define mycat(aaa,bbb) mycat_wrk(aaa,bbb) |
| 181 | |
| 182 | /* Just pray that gcc's constant folding works properly ... */ |
| 183 | #define BITS(bit7,bit6,bit5,bit4,bit3,bit2,bit1,bit0) \ |
| 184 | ( ((bit7) << 7) | ((bit6) << 6) | ((bit5) << 5) | ((bit4) << 4) \ |
| 185 | | ((bit3) << 3) | ((bit2) << 2) | ((bit1) << 1) | (bit0)) |
| 186 | |
| 187 | |
| 188 | /* --------------------------------------------------------------------- |
| 189 | Now the basic types are set up, we can haul in the kernel-interface |
| 190 | definitions. |
| 191 | ------------------------------------------------------------------ */ |
| 192 | |
| 193 | #include "./vg_kerneliface.h" |
| 194 | |
| 195 | |
| 196 | /* --------------------------------------------------------------------- |
| 197 | Command-line-settable options |
| 198 | ------------------------------------------------------------------ */ |
| 199 | |
| 200 | #define VG_CLO_SMC_NONE 0 |
| 201 | #define VG_CLO_SMC_SOME 1 |
| 202 | #define VG_CLO_SMC_ALL 2 |
| 203 | |
| 204 | #define VG_CLO_MAX_SFILES 10 |
| 205 | |
sewardj | 97ced73 | 2002-03-25 00:07:36 +0000 | [diff] [blame] | 206 | /* Shall we V-check addrs (they are always A checked too): default: YES */ |
| 207 | extern Bool VG_(clo_check_addrVs); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 208 | /* Enquire about whether to attach to GDB at errors? default: NO */ |
| 209 | extern Bool VG_(clo_GDB_attach); |
| 210 | /* Sanity-check level: 0 = none, 1 (default), > 1 = expensive. */ |
| 211 | extern Int VG_(sanity_level); |
| 212 | /* Verbosity level: 0 = silent, 1 (default), > 1 = more verbose. */ |
| 213 | extern Int VG_(clo_verbosity); |
| 214 | /* Automatically attempt to demangle C++ names? default: YES */ |
| 215 | extern Bool VG_(clo_demangle); |
| 216 | /* Do leak check at exit? default: NO */ |
| 217 | extern Bool VG_(clo_leak_check); |
| 218 | /* In leak check, show reachable-but-not-freed blocks? default: NO */ |
| 219 | extern Bool VG_(clo_show_reachable); |
| 220 | /* How closely should we compare ExeContexts in leak records? default: 2 */ |
| 221 | extern Int VG_(clo_leak_resolution); |
| 222 | /* Round malloc sizes upwards to integral number of words? default: |
| 223 | NO */ |
| 224 | extern Bool VG_(clo_sloppy_malloc); |
| 225 | /* Allow loads from partially-valid addresses? default: YES */ |
| 226 | extern Bool VG_(clo_partial_loads_ok); |
| 227 | /* Simulate child processes? default: NO */ |
| 228 | extern Bool VG_(clo_trace_children); |
| 229 | /* The file id on which we send all messages. default: 2 (stderr). */ |
| 230 | extern Int VG_(clo_logfile_fd); |
| 231 | /* Max volume of the freed blocks queue. */ |
| 232 | extern Int VG_(clo_freelist_vol); |
| 233 | /* Assume accesses immediately below %esp are due to gcc-2.96 bugs. |
| 234 | default: NO */ |
| 235 | extern Bool VG_(clo_workaround_gcc296_bugs); |
| 236 | |
| 237 | /* The number of suppression files specified. */ |
| 238 | extern Int VG_(clo_n_suppressions); |
| 239 | /* The names of the suppression files. */ |
| 240 | extern Char* VG_(clo_suppressions)[VG_CLO_MAX_SFILES]; |
| 241 | |
| 242 | /* Single stepping? default: NO */ |
| 243 | extern Bool VG_(clo_single_step); |
| 244 | /* Code improvement? default: YES */ |
| 245 | extern Bool VG_(clo_optimise); |
| 246 | /* Memory-check instrumentation? default: YES */ |
| 247 | extern Bool VG_(clo_instrument); |
| 248 | /* DEBUG: clean up instrumented code? default: YES */ |
| 249 | extern Bool VG_(clo_cleanup); |
njn | 4f9c934 | 2002-04-29 16:03:24 +0000 | [diff] [blame] | 250 | /* Cache simulation instrumentation? default: NO */ |
| 251 | extern Bool VG_(clo_cachesim); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 252 | /* SMC write checks? default: SOME (1,2,4 byte movs to mem) */ |
| 253 | extern Int VG_(clo_smc_check); |
| 254 | /* DEBUG: print system calls? default: NO */ |
| 255 | extern Bool VG_(clo_trace_syscalls); |
| 256 | /* DEBUG: print signal details? default: NO */ |
| 257 | extern Bool VG_(clo_trace_signals); |
| 258 | /* DEBUG: print symtab details? default: NO */ |
| 259 | extern Bool VG_(clo_trace_symtab); |
| 260 | /* DEBUG: print malloc details? default: NO */ |
| 261 | extern Bool VG_(clo_trace_malloc); |
sewardj | 8937c81 | 2002-04-12 20:12:20 +0000 | [diff] [blame] | 262 | /* DEBUG: print thread scheduling events? default: NO */ |
| 263 | extern Bool VG_(clo_trace_sched); |
sewardj | 45b4b37 | 2002-04-16 22:50:32 +0000 | [diff] [blame] | 264 | /* DEBUG: print pthread (mutex etc) events? default: 0 (none), 1 |
| 265 | (some), 2 (all) */ |
| 266 | extern Int VG_(clo_trace_pthread_level); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 267 | /* Stop after this many basic blocks. default: Infinity. */ |
| 268 | extern ULong VG_(clo_stop_after); |
| 269 | /* Display gory details for the k'th most popular error. default: |
| 270 | Infinity. */ |
| 271 | extern Int VG_(clo_dump_error); |
| 272 | /* Number of parents of a backtrace. Default: 8. */ |
| 273 | extern Int VG_(clo_backtrace_size); |
sewardj | 3984b85 | 2002-05-12 03:00:17 +0000 | [diff] [blame] | 274 | /* Engage miscellaneous wierd hacks needed for some progs. */ |
sewardj | 8d365b5 | 2002-05-12 10:52:16 +0000 | [diff] [blame] | 275 | extern Char* VG_(clo_weird_hacks); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 276 | |
| 277 | |
| 278 | /* --------------------------------------------------------------------- |
| 279 | Debugging and profiling stuff |
| 280 | ------------------------------------------------------------------ */ |
| 281 | |
| 282 | /* No, really. I _am_ that strange. */ |
| 283 | #define OINK(nnn) VG_(message)(Vg_DebugMsg, "OINK %d",nnn) |
| 284 | |
| 285 | /* Tools for building messages from multiple parts. */ |
| 286 | typedef |
| 287 | enum { Vg_UserMsg, Vg_DebugMsg, Vg_DebugExtraMsg } |
| 288 | VgMsgKind; |
| 289 | |
| 290 | extern void VG_(start_msg) ( VgMsgKind kind ); |
| 291 | extern void VG_(add_to_msg) ( Char* format, ... ); |
| 292 | extern void VG_(end_msg) ( void ); |
| 293 | |
| 294 | /* Send a simple, single-part message. */ |
| 295 | extern void VG_(message) ( VgMsgKind kind, Char* format, ... ); |
| 296 | |
| 297 | /* Create a logfile into which messages can be dumped. */ |
| 298 | extern void VG_(startup_logging) ( void ); |
| 299 | extern void VG_(shutdown_logging) ( void ); |
| 300 | |
| 301 | |
| 302 | /* Profiling stuff */ |
| 303 | #ifdef VG_PROFILE |
| 304 | |
| 305 | #define VGP_M_STACK 10 |
| 306 | |
sewardj | 671ff54 | 2002-05-07 09:25:30 +0000 | [diff] [blame] | 307 | #define VGP_M_CCS 26 /* == the # of elems in VGP_LIST */ |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 308 | #define VGP_LIST \ |
sewardj | 671ff54 | 2002-05-07 09:25:30 +0000 | [diff] [blame] | 309 | VGP_PAIR(VgpUnc=0, "unclassified"), \ |
| 310 | VGP_PAIR(VgpRun, "running"), \ |
| 311 | VGP_PAIR(VgpSched, "scheduler"), \ |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 312 | VGP_PAIR(VgpMalloc, "low-lev malloc/free"), \ |
| 313 | VGP_PAIR(VgpCliMalloc, "client malloc/free"), \ |
| 314 | VGP_PAIR(VgpTranslate, "translate-main"), \ |
| 315 | VGP_PAIR(VgpToUCode, "to-ucode"), \ |
| 316 | VGP_PAIR(VgpFromUcode, "from-ucode"), \ |
| 317 | VGP_PAIR(VgpImprove, "improve"), \ |
| 318 | VGP_PAIR(VgpInstrument, "instrument"), \ |
| 319 | VGP_PAIR(VgpCleanup, "cleanup"), \ |
| 320 | VGP_PAIR(VgpRegAlloc, "reg-alloc"), \ |
| 321 | VGP_PAIR(VgpDoLRU, "do-lru"), \ |
| 322 | VGP_PAIR(VgpSlowFindT, "slow-search-transtab"), \ |
| 323 | VGP_PAIR(VgpInitAudit, "init-mem-audit"), \ |
| 324 | VGP_PAIR(VgpExeContext, "exe-context"), \ |
| 325 | VGP_PAIR(VgpReadSyms, "read-syms"), \ |
| 326 | VGP_PAIR(VgpAddToT, "add-to-transtab"), \ |
| 327 | VGP_PAIR(VgpSARP, "set-addr-range-perms"), \ |
| 328 | VGP_PAIR(VgpSyscall, "syscall wrapper"), \ |
njn | 4f9c934 | 2002-04-29 16:03:24 +0000 | [diff] [blame] | 329 | VGP_PAIR(VgpCacheInstrument, "cache instrument"), \ |
| 330 | VGP_PAIR(VgpCacheGetBBCC,"cache get BBCC"), \ |
| 331 | VGP_PAIR(VgpCacheSimulate, "cache simulate"), \ |
| 332 | VGP_PAIR(VgpCacheDump, "cache stats dump"), \ |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 333 | VGP_PAIR(VgpSpare1, "spare 1"), \ |
| 334 | VGP_PAIR(VgpSpare2, "spare 2") |
| 335 | |
| 336 | #define VGP_PAIR(enumname,str) enumname |
| 337 | typedef enum { VGP_LIST } VgpCC; |
| 338 | #undef VGP_PAIR |
| 339 | |
| 340 | extern void VGP_(init_profiling) ( void ); |
| 341 | extern void VGP_(done_profiling) ( void ); |
| 342 | extern void VGP_(pushcc) ( VgpCC ); |
| 343 | extern void VGP_(popcc) ( void ); |
| 344 | |
| 345 | #define VGP_PUSHCC(cc) VGP_(pushcc)(cc) |
| 346 | #define VGP_POPCC VGP_(popcc)() |
| 347 | |
| 348 | #else |
| 349 | |
| 350 | #define VGP_PUSHCC(cc) /* */ |
| 351 | #define VGP_POPCC /* */ |
| 352 | |
| 353 | #endif /* VG_PROFILE */ |
| 354 | |
| 355 | |
| 356 | /* --------------------------------------------------------------------- |
| 357 | Exports of vg_malloc2.c |
| 358 | ------------------------------------------------------------------ */ |
| 359 | |
| 360 | /* Allocation arenas. |
| 361 | SYMTAB is for Valgrind's symbol table storage. |
| 362 | CLIENT is for the client's mallocs/frees. |
| 363 | DEMANGLE is for the C++ demangler. |
| 364 | EXECTXT is for storing ExeContexts. |
| 365 | ERRCTXT is for storing ErrContexts. |
| 366 | PRIVATE is for Valgrind general stuff. |
| 367 | TRANSIENT is for very short-term use. It should be empty |
| 368 | in between uses. |
| 369 | When adding a new arena, remember also to add it |
| 370 | to ensure_mm_init(). |
| 371 | */ |
| 372 | typedef Int ArenaId; |
| 373 | |
| 374 | #define VG_N_ARENAS 7 |
| 375 | |
| 376 | #define VG_AR_PRIVATE 0 /* :: ArenaId */ |
| 377 | #define VG_AR_SYMTAB 1 /* :: ArenaId */ |
| 378 | #define VG_AR_CLIENT 2 /* :: ArenaId */ |
| 379 | #define VG_AR_DEMANGLE 3 /* :: ArenaId */ |
| 380 | #define VG_AR_EXECTXT 4 /* :: ArenaId */ |
| 381 | #define VG_AR_ERRCTXT 5 /* :: ArenaId */ |
| 382 | #define VG_AR_TRANSIENT 6 /* :: ArenaId */ |
| 383 | |
| 384 | extern void* VG_(malloc) ( ArenaId arena, Int nbytes ); |
| 385 | extern void VG_(free) ( ArenaId arena, void* ptr ); |
| 386 | extern void* VG_(calloc) ( ArenaId arena, Int nmemb, Int nbytes ); |
| 387 | extern void* VG_(realloc) ( ArenaId arena, void* ptr, Int size ); |
| 388 | extern void* VG_(malloc_aligned) ( ArenaId aid, Int req_alignB, |
| 389 | Int req_pszB ); |
| 390 | |
| 391 | extern void VG_(mallocSanityCheckArena) ( ArenaId arena ); |
| 392 | extern void VG_(mallocSanityCheckAll) ( void ); |
| 393 | |
| 394 | extern void VG_(show_all_arena_stats) ( void ); |
| 395 | extern Bool VG_(is_empty_arena) ( ArenaId aid ); |
| 396 | |
| 397 | |
| 398 | /* The red-zone size for the client. This can be arbitrary, but |
| 399 | unfortunately must be set at compile time. */ |
| 400 | #define VG_AR_CLIENT_REDZONE_SZW 4 |
| 401 | |
| 402 | #define VG_AR_CLIENT_REDZONE_SZB \ |
| 403 | (VG_AR_CLIENT_REDZONE_SZW * VKI_BYTES_PER_WORD) |
| 404 | |
| 405 | |
| 406 | /* --------------------------------------------------------------------- |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 407 | Exports of vg_clientfuns.c |
| 408 | ------------------------------------------------------------------ */ |
| 409 | |
| 410 | /* This doesn't export code or data that valgrind.so needs to link |
| 411 | against. However, the scheduler does need to know the following |
| 412 | request codes. A few, publically-visible, request codes are also |
| 413 | defined in valgrind.h. */ |
| 414 | |
| 415 | #define VG_USERREQ__MALLOC 0x2001 |
| 416 | #define VG_USERREQ__BUILTIN_NEW 0x2002 |
| 417 | #define VG_USERREQ__BUILTIN_VEC_NEW 0x2003 |
| 418 | |
| 419 | #define VG_USERREQ__FREE 0x2004 |
| 420 | #define VG_USERREQ__BUILTIN_DELETE 0x2005 |
| 421 | #define VG_USERREQ__BUILTIN_VEC_DELETE 0x2006 |
| 422 | |
| 423 | #define VG_USERREQ__CALLOC 0x2007 |
| 424 | #define VG_USERREQ__REALLOC 0x2008 |
| 425 | #define VG_USERREQ__MEMALIGN 0x2009 |
| 426 | |
| 427 | |
sewardj | 20917d8 | 2002-05-28 01:36:45 +0000 | [diff] [blame] | 428 | /* (Fn, Arg): Create a new thread and run Fn applied to Arg in it. Fn |
| 429 | MUST NOT return -- ever. Eventually it will do either __QUIT or |
| 430 | __WAIT_JOINER. */ |
| 431 | #define VG_USERREQ__APPLY_IN_NEW_THREAD 0x3001 |
| 432 | |
| 433 | /* ( no-args ): calling thread disappears from the system forever. |
| 434 | Reclaim resources. */ |
| 435 | #define VG_USERREQ__QUIT 0x3002 |
| 436 | |
| 437 | /* ( void* ): calling thread waits for joiner and returns the void* to |
| 438 | it. */ |
| 439 | #define VG_USERREQ__WAIT_JOINER 0x3003 |
| 440 | |
| 441 | /* ( ThreadId, void** ): wait to join a thread. */ |
| 442 | #define VG_USERREQ__PTHREAD_JOIN 0x3004 |
| 443 | |
| 444 | /* Set cancellation state and type for this thread. */ |
| 445 | #define VG_USERREQ__SET_CANCELSTATE 0x3005 |
| 446 | #define VG_USERREQ__SET_CANCELTYPE 0x3006 |
| 447 | |
| 448 | /* ( no-args ): Test if we are at a cancellation point. */ |
| 449 | #define VG_USERREQ__TESTCANCEL 0x3007 |
| 450 | |
| 451 | /* ( ThreadId, &thread_exit_wrapper is the only allowable arg ): call |
| 452 | with this arg to indicate that a cancel is now pending for the |
| 453 | specified thread. */ |
| 454 | #define VG_USERREQ__SET_CANCELPEND 0x3008 |
| 455 | |
| 456 | /* Set/get detach state for this thread. */ |
| 457 | #define VG_USERREQ__SET_OR_GET_DETACH 0x3009 |
| 458 | |
| 459 | #define VG_USERREQ__PTHREAD_GET_THREADID 0x300B |
| 460 | #define VG_USERREQ__PTHREAD_MUTEX_LOCK 0x300C |
| 461 | #define VG_USERREQ__PTHREAD_MUTEX_TRYLOCK 0x300D |
| 462 | #define VG_USERREQ__PTHREAD_MUTEX_UNLOCK 0x300E |
| 463 | #define VG_USERREQ__PTHREAD_COND_WAIT 0x300F |
| 464 | #define VG_USERREQ__PTHREAD_COND_TIMEDWAIT 0x3010 |
| 465 | #define VG_USERREQ__PTHREAD_COND_SIGNAL 0x3011 |
| 466 | #define VG_USERREQ__PTHREAD_COND_BROADCAST 0x3012 |
| 467 | #define VG_USERREQ__PTHREAD_KEY_CREATE 0x3013 |
| 468 | #define VG_USERREQ__PTHREAD_KEY_DELETE 0x3014 |
| 469 | #define VG_USERREQ__PTHREAD_SETSPECIFIC 0x3015 |
| 470 | #define VG_USERREQ__PTHREAD_GETSPECIFIC 0x3016 |
| 471 | #define VG_USERREQ__READ_MILLISECOND_TIMER 0x3017 |
| 472 | #define VG_USERREQ__PTHREAD_SIGMASK 0x3018 |
| 473 | #define VG_USERREQ__SIGWAIT 0x3019 |
| 474 | #define VG_USERREQ__PTHREAD_KILL 0x301A |
| 475 | #define VG_USERREQ__PTHREAD_YIELD 0x301B |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 476 | |
sewardj | 8ad94e1 | 2002-05-29 00:10:20 +0000 | [diff] [blame] | 477 | #define VG_USERREQ__CLEANUP_PUSH 0x3020 |
| 478 | #define VG_USERREQ__CLEANUP_POP 0x3021 |
sewardj | 870497a | 2002-05-29 01:06:47 +0000 | [diff] [blame] | 479 | #define VG_USERREQ__GET_KEY_D_AND_S 0x3022 |
sewardj | 8ad94e1 | 2002-05-29 00:10:20 +0000 | [diff] [blame] | 480 | |
sewardj | ef037c7 | 2002-05-30 00:40:03 +0000 | [diff] [blame] | 481 | #define VG_USERREQ__NUKE_OTHER_THREADS 0x3023 |
| 482 | |
sewardj | 45b4b37 | 2002-04-16 22:50:32 +0000 | [diff] [blame] | 483 | /* Cosmetic ... */ |
| 484 | #define VG_USERREQ__GET_PTHREAD_TRACE_LEVEL 0x3101 |
| 485 | |
sewardj | 54cacf0 | 2002-04-12 23:24:59 +0000 | [diff] [blame] | 486 | /* |
| 487 | In vg_constants.h: |
| 488 | #define VG_USERREQ__SIGNAL_RETURNS 0x4001 |
sewardj | 54cacf0 | 2002-04-12 23:24:59 +0000 | [diff] [blame] | 489 | */ |
| 490 | |
| 491 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 492 | /* --------------------------------------------------------------------- |
| 493 | Constants pertaining to the simulated CPU state, VG_(baseBlock), |
| 494 | which need to go here to avoid ugly circularities. |
| 495 | ------------------------------------------------------------------ */ |
| 496 | |
| 497 | /* How big is the saved FPU state? */ |
| 498 | #define VG_SIZE_OF_FPUSTATE 108 |
| 499 | /* ... and in words ... */ |
| 500 | #define VG_SIZE_OF_FPUSTATE_W ((VG_SIZE_OF_FPUSTATE+3)/4) |
| 501 | |
| 502 | |
| 503 | /* --------------------------------------------------------------------- |
| 504 | Exports of vg_scheduler.c |
| 505 | ------------------------------------------------------------------ */ |
| 506 | |
| 507 | /* ThreadIds are simply indices into the vg_threads[] array. */ |
| 508 | typedef |
| 509 | UInt |
| 510 | ThreadId; |
| 511 | |
sewardj | 6072c36 | 2002-04-19 14:40:57 +0000 | [diff] [blame] | 512 | /* Special magic value for an invalid ThreadId. It corresponds to |
| 513 | LinuxThreads using zero as the initial value for |
| 514 | pthread_mutex_t.__m_owner and pthread_cond_t.__c_waiting. */ |
| 515 | #define VG_INVALID_THREADID ((ThreadId)(0)) |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 516 | |
| 517 | typedef |
| 518 | enum { |
| 519 | VgTs_Empty, /* this slot is not in use */ |
| 520 | VgTs_Runnable, /* waiting to be scheduled */ |
| 521 | VgTs_WaitJoiner, /* waiting for someone to do join on me */ |
| 522 | VgTs_WaitJoinee, /* waiting for the thread I did join on */ |
| 523 | VgTs_WaitFD, /* waiting for I/O completion on a fd */ |
| 524 | VgTs_WaitMX, /* waiting on a mutex */ |
sewardj | 3b5d886 | 2002-04-20 13:53:23 +0000 | [diff] [blame] | 525 | VgTs_WaitCV, /* waiting on a condition variable */ |
sewardj | b48e500 | 2002-05-13 00:16:03 +0000 | [diff] [blame] | 526 | VgTs_WaitSIG, /* waiting due to sigwait() */ |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 527 | VgTs_Sleeping /* sleeping for a while */ |
| 528 | } |
| 529 | ThreadStatus; |
sewardj | 8ad94e1 | 2002-05-29 00:10:20 +0000 | [diff] [blame] | 530 | |
| 531 | /* An entry in a threads's cleanup stack. */ |
| 532 | typedef |
| 533 | struct { |
| 534 | void (*fn)(void*); |
| 535 | void* arg; |
| 536 | } |
| 537 | CleanupEntry; |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 538 | |
| 539 | typedef |
| 540 | struct { |
sewardj | 6072c36 | 2002-04-19 14:40:57 +0000 | [diff] [blame] | 541 | /* ThreadId == 0 (and hence vg_threads[0]) is NEVER USED. |
| 542 | The thread identity is simply the index in vg_threads[]. |
| 543 | ThreadId == 1 is the root thread and has the special property |
sewardj | 1e8cdc9 | 2002-04-18 11:37:52 +0000 | [diff] [blame] | 544 | that we don't try and allocate or deallocate its stack. For |
| 545 | convenience of generating error message, we also put the |
| 546 | ThreadId in this tid field, but be aware that it should |
sewardj | 604ec3c | 2002-04-18 22:38:41 +0000 | [diff] [blame] | 547 | ALWAYS == the index in vg_threads[]. */ |
sewardj | 1e8cdc9 | 2002-04-18 11:37:52 +0000 | [diff] [blame] | 548 | ThreadId tid; |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 549 | |
sewardj | 5f07b66 | 2002-04-23 16:52:51 +0000 | [diff] [blame] | 550 | /* Current scheduling status. |
| 551 | |
| 552 | Complications: whenever this is set to VgTs_WaitMX, you |
| 553 | should also set .m_edx to whatever the required return value |
| 554 | is for pthread_mutex_lock / pthread_cond_timedwait for when |
| 555 | the mutex finally gets unblocked. */ |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 556 | ThreadStatus status; |
| 557 | |
sewardj | 3b5d886 | 2002-04-20 13:53:23 +0000 | [diff] [blame] | 558 | /* When .status == WaitMX, points to the mutex I am waiting for. |
| 559 | When .status == WaitCV, points to the mutex associated with |
| 560 | the condition variable indicated by the .associated_cv field. |
| 561 | In all other cases, should be NULL. */ |
| 562 | void* /* pthread_mutex_t* */ associated_mx; |
| 563 | |
| 564 | /* When .status == WaitCV, points to the condition variable I am |
| 565 | waiting for. In all other cases, should be NULL. */ |
| 566 | void* /* pthread_cond_t* */ associated_cv; |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 567 | |
sewardj | 5f07b66 | 2002-04-23 16:52:51 +0000 | [diff] [blame] | 568 | /* If VgTs_Sleeping, this is when we should wake up, measured in |
| 569 | milliseconds as supplied by VG_(read_millisecond_counter). |
| 570 | |
| 571 | If VgTs_WaitCV, this indicates the time at which |
| 572 | pthread_cond_timedwait should wake up. If == 0xFFFFFFFF, |
| 573 | this means infinitely far in the future, viz, |
| 574 | pthread_cond_wait. */ |
| 575 | UInt awaken_at; |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 576 | |
sewardj | 20917d8 | 2002-05-28 01:36:45 +0000 | [diff] [blame] | 577 | /* If VgTs_WaitJoiner, return value, as generated by joinees. */ |
| 578 | void* joinee_retval; |
| 579 | |
| 580 | /* If VgTs_WaitJoinee, place to copy the return value to, and |
| 581 | the identity of the thread we're waiting for. */ |
| 582 | void** joiner_thread_return; |
| 583 | ThreadId joiner_jee_tid; |
| 584 | |
sewardj | 8ad94e1 | 2002-05-29 00:10:20 +0000 | [diff] [blame] | 585 | /* Whether or not detached. */ |
| 586 | Bool detached; |
| 587 | |
sewardj | 20917d8 | 2002-05-28 01:36:45 +0000 | [diff] [blame] | 588 | /* Cancelability state and type. */ |
| 589 | Bool cancel_st; /* False==PTH_CANCEL_DISABLE; True==.._ENABLE */ |
| 590 | Bool cancel_ty; /* False==PTH_CANC_ASYNCH; True==..._DEFERRED */ |
| 591 | |
| 592 | /* Pointer to fn to call to do cancellation. Indicates whether |
| 593 | or not cancellation is pending. If NULL, not pending. Else |
| 594 | should be &thread_exit_wrapper(), indicating that |
| 595 | cancallation is pending. */ |
| 596 | void (*cancel_pend)(void*); |
| 597 | |
sewardj | 8ad94e1 | 2002-05-29 00:10:20 +0000 | [diff] [blame] | 598 | /* The cleanup stack. */ |
| 599 | Int custack_used; |
| 600 | CleanupEntry custack[VG_N_CLEANUPSTACK]; |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 601 | |
sewardj | 5f07b66 | 2002-04-23 16:52:51 +0000 | [diff] [blame] | 602 | /* thread-specific data */ |
| 603 | void* specifics[VG_N_THREAD_KEYS]; |
| 604 | |
sewardj | b48e500 | 2002-05-13 00:16:03 +0000 | [diff] [blame] | 605 | /* This thread's blocked-signals mask. Semantics is that for a |
| 606 | signal to be delivered to this thread, the signal must not be |
| 607 | blocked by either the process-wide signal mask nor by this |
| 608 | one. So, if this thread is prepared to handle any signal that |
| 609 | the process as a whole is prepared to handle, this mask should |
| 610 | be made empty -- and that it is its default, starting |
| 611 | state. */ |
| 612 | vki_ksigset_t sig_mask; |
| 613 | |
| 614 | /* When not VgTs_WaitSIG, has no meaning. When VgTs_WaitSIG, |
| 615 | is the set of signals for which we are sigwait()ing. */ |
| 616 | vki_ksigset_t sigs_waited_for; |
| 617 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 618 | /* Stacks. When a thread slot is freed, we don't deallocate its |
| 619 | stack; we just leave it lying around for the next use of the |
| 620 | slot. If the next use of the slot requires a larger stack, |
| 621 | only then is the old one deallocated and a new one |
| 622 | allocated. |
| 623 | |
| 624 | For the main thread (threadid == 0), this mechanism doesn't |
| 625 | apply. We don't know the size of the stack since we didn't |
| 626 | allocate it, and furthermore we never reallocate it. */ |
| 627 | |
| 628 | /* The allocated size of this thread's stack (permanently zero |
| 629 | if this is ThreadId == 0, since we didn't allocate its stack) */ |
| 630 | UInt stack_size; |
| 631 | |
| 632 | /* Address of the lowest word in this thread's stack. NULL means |
| 633 | not allocated yet. |
| 634 | */ |
| 635 | Addr stack_base; |
| 636 | |
sewardj | 1e8cdc9 | 2002-04-18 11:37:52 +0000 | [diff] [blame] | 637 | /* Address of the highest legitimate word in this stack. This is |
| 638 | used for error messages only -- not critical for execution |
| 639 | correctness. Is is set for all stacks, specifically including |
| 640 | ThreadId == 0 (the main thread). */ |
| 641 | Addr stack_highest_word; |
| 642 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 643 | /* Saved machine context. */ |
| 644 | UInt m_eax; |
| 645 | UInt m_ebx; |
| 646 | UInt m_ecx; |
| 647 | UInt m_edx; |
| 648 | UInt m_esi; |
| 649 | UInt m_edi; |
| 650 | UInt m_ebp; |
| 651 | UInt m_esp; |
| 652 | UInt m_eflags; |
| 653 | UInt m_eip; |
| 654 | UInt m_fpu[VG_SIZE_OF_FPUSTATE_W]; |
| 655 | |
| 656 | UInt sh_eax; |
| 657 | UInt sh_ebx; |
| 658 | UInt sh_ecx; |
| 659 | UInt sh_edx; |
| 660 | UInt sh_esi; |
| 661 | UInt sh_edi; |
| 662 | UInt sh_ebp; |
| 663 | UInt sh_esp; |
| 664 | UInt sh_eflags; |
| 665 | } |
| 666 | ThreadState; |
| 667 | |
| 668 | |
sewardj | 018f762 | 2002-05-15 21:13:39 +0000 | [diff] [blame] | 669 | /* The thread table. */ |
| 670 | extern ThreadState VG_(threads)[VG_N_THREADS]; |
| 671 | |
| 672 | /* Check that tid is in range and denotes a non-Empty thread. */ |
sewardj | b48e500 | 2002-05-13 00:16:03 +0000 | [diff] [blame] | 673 | extern Bool VG_(is_valid_tid) ( ThreadId tid ); |
| 674 | |
sewardj | 018f762 | 2002-05-15 21:13:39 +0000 | [diff] [blame] | 675 | /* Check that tid is in range. */ |
| 676 | extern Bool VG_(is_valid_or_empty_tid) ( ThreadId tid ); |
| 677 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 678 | /* Copy the specified thread's state into VG_(baseBlock) in |
| 679 | preparation for running it. */ |
| 680 | extern void VG_(load_thread_state)( ThreadId ); |
| 681 | |
| 682 | /* Save the specified thread's state back in VG_(baseBlock), and fill |
| 683 | VG_(baseBlock) with junk, for sanity-check reasons. */ |
| 684 | extern void VG_(save_thread_state)( ThreadId ); |
| 685 | |
sewardj | 1e8cdc9 | 2002-04-18 11:37:52 +0000 | [diff] [blame] | 686 | /* And for the currently running one, if valid. */ |
| 687 | extern ThreadState* VG_(get_current_thread_state) ( void ); |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 688 | |
sewardj | 1e8cdc9 | 2002-04-18 11:37:52 +0000 | [diff] [blame] | 689 | /* Similarly ... */ |
| 690 | extern ThreadId VG_(get_current_tid) ( void ); |
| 691 | |
| 692 | /* Which thread is this address in the stack of, if any? Used for |
| 693 | error message generation. */ |
| 694 | extern ThreadId VG_(identify_stack_addr)( Addr a ); |
| 695 | |
sewardj | ccef2e6 | 2002-05-29 19:26:32 +0000 | [diff] [blame] | 696 | /* Nuke all threads except tid. */ |
| 697 | extern void VG_(nuke_all_threads_except) ( ThreadId me ); |
| 698 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 699 | |
| 700 | /* Return codes from the scheduler. */ |
| 701 | typedef |
sewardj | 7e87e38 | 2002-05-03 19:09:05 +0000 | [diff] [blame] | 702 | enum { |
| 703 | VgSrc_Deadlock, /* no runnable threads and no prospect of any |
| 704 | even if we wait for a long time */ |
| 705 | VgSrc_ExitSyscall, /* client called exit(). This is the normal |
| 706 | route out. */ |
| 707 | VgSrc_BbsDone /* In a debugging run, the specified number of |
| 708 | bbs has been completed. */ |
| 709 | } |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 710 | VgSchedReturnCode; |
| 711 | |
sewardj | 7e87e38 | 2002-05-03 19:09:05 +0000 | [diff] [blame] | 712 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 713 | /* The scheduler. */ |
| 714 | extern VgSchedReturnCode VG_(scheduler) ( void ); |
| 715 | |
| 716 | extern void VG_(scheduler_init) ( void ); |
| 717 | |
sewardj | 15a43e1 | 2002-04-17 19:35:12 +0000 | [diff] [blame] | 718 | extern void VG_(pp_sched_status) ( void ); |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 719 | |
| 720 | /* vg_oursignalhandler() might longjmp(). Here's the jmp_buf. */ |
| 721 | extern jmp_buf VG_(scheduler_jmpbuf); |
| 722 | /* ... and if so, here's the signal which caused it to do so. */ |
| 723 | extern Int VG_(longjmpd_on_signal); |
| 724 | |
| 725 | |
sewardj | a1679dd | 2002-05-10 22:31:40 +0000 | [diff] [blame] | 726 | /* Possible places where the main stack might be based. We check that |
| 727 | the initial stack, which we can't move, is allocated here. |
| 728 | VG_(scheduler_init) checks this. Andrea Archelangi's 2.4 kernels |
| 729 | have been rumoured to start stacks at 0x80000000, so that too is |
| 730 | considered. |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 731 | */ |
sewardj | a1679dd | 2002-05-10 22:31:40 +0000 | [diff] [blame] | 732 | #define VG_STARTUP_STACK_BASE_1 (Addr)0xC0000000 |
| 733 | #define VG_STARTUP_STACK_BASE_2 (Addr)0x80000000 |
| 734 | #define VG_STARTUP_STACK_SMALLERTHAN 0x100000 /* 1024k */ |
| 735 | |
| 736 | #define VG_STACK_MATCHES_BASE(zzstack, zzbase) \ |
| 737 | ( \ |
| 738 | ((zzstack) & ((zzbase) - VG_STARTUP_STACK_SMALLERTHAN)) \ |
| 739 | == \ |
| 740 | ((zzbase) - VG_STARTUP_STACK_SMALLERTHAN) \ |
| 741 | ) |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 742 | |
| 743 | |
| 744 | /* The red-zone size which we put at the bottom (highest address) of |
| 745 | thread stacks, for paranoia reasons. This can be arbitrary, and |
| 746 | doesn't really need to be set at compile time. */ |
| 747 | #define VG_AR_CLIENT_STACKBASE_REDZONE_SZW 4 |
| 748 | |
| 749 | #define VG_AR_CLIENT_STACKBASE_REDZONE_SZB \ |
| 750 | (VG_AR_CLIENT_STACKBASE_REDZONE_SZW * VKI_BYTES_PER_WORD) |
| 751 | |
| 752 | |
sewardj | 018f762 | 2002-05-15 21:13:39 +0000 | [diff] [blame] | 753 | /* Write a value to the client's %EDX (request return value register) |
| 754 | and set the shadow to indicate it is defined. */ |
| 755 | #define SET_EDX(zztid, zzval) \ |
| 756 | do { VG_(threads)[zztid].m_edx = (zzval); \ |
| 757 | VG_(threads)[zztid].sh_edx = VGM_WORD_VALID; \ |
| 758 | } while (0) |
| 759 | |
| 760 | #define SET_EAX(zztid, zzval) \ |
| 761 | do { VG_(threads)[zztid].m_eax = (zzval); \ |
| 762 | VG_(threads)[zztid].sh_eax = VGM_WORD_VALID; \ |
| 763 | } while (0) |
| 764 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 765 | |
| 766 | /* --------------------------------------------------------------------- |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 767 | Exports of vg_signals.c |
| 768 | ------------------------------------------------------------------ */ |
| 769 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 770 | extern void VG_(sigstartup_actions) ( void ); |
| 771 | |
sewardj | b48e500 | 2002-05-13 00:16:03 +0000 | [diff] [blame] | 772 | extern Bool VG_(deliver_signals) ( void ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 773 | extern void VG_(unblock_host_signal) ( Int sigNo ); |
sewardj | 018f762 | 2002-05-15 21:13:39 +0000 | [diff] [blame] | 774 | extern void VG_(handle_SCSS_change) ( Bool force_update ); |
| 775 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 776 | |
| 777 | /* Fake system calls for signal handling. */ |
sewardj | 2342c97 | 2002-05-22 23:34:20 +0000 | [diff] [blame] | 778 | extern void VG_(do__NR_sigaltstack) ( ThreadId tid ); |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 779 | extern void VG_(do__NR_sigaction) ( ThreadId tid ); |
sewardj | 018f762 | 2002-05-15 21:13:39 +0000 | [diff] [blame] | 780 | extern void VG_(do__NR_sigprocmask) ( ThreadId tid, |
| 781 | Int how, |
| 782 | vki_ksigset_t* set, |
| 783 | vki_ksigset_t* oldset ); |
| 784 | extern void VG_(do_pthread_sigmask_SCSS_upd) ( ThreadId tid, |
| 785 | Int how, |
| 786 | vki_ksigset_t* set, |
| 787 | vki_ksigset_t* oldset ); |
| 788 | extern void VG_(send_signal_to_thread) ( ThreadId thread, |
| 789 | Int signo ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 790 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 791 | /* Modify the current thread's state once we have detected it is |
| 792 | returning from a signal handler. */ |
sewardj | 77e466c | 2002-04-14 02:29:29 +0000 | [diff] [blame] | 793 | extern Bool VG_(signal_returns) ( ThreadId ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 794 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 795 | /* Handy utilities to block/restore all host signals. */ |
| 796 | extern void VG_(block_all_host_signals) |
| 797 | ( /* OUT */ vki_ksigset_t* saved_mask ); |
sewardj | 018f762 | 2002-05-15 21:13:39 +0000 | [diff] [blame] | 798 | extern void VG_(restore_all_host_signals) |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 799 | ( /* IN */ vki_ksigset_t* saved_mask ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 800 | |
| 801 | /* --------------------------------------------------------------------- |
| 802 | Exports of vg_mylibc.c |
| 803 | ------------------------------------------------------------------ */ |
| 804 | |
| 805 | |
sewardj | fbe18b9 | 2002-05-10 00:46:59 +0000 | [diff] [blame] | 806 | #if !defined(NULL) |
| 807 | # define NULL ((void*)0) |
| 808 | #endif |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 809 | |
| 810 | extern void VG_(exit)( Int status ) |
| 811 | __attribute__ ((__noreturn__)); |
| 812 | |
| 813 | extern void VG_(printf) ( const char *format, ... ); |
| 814 | /* too noisy ... __attribute__ ((format (printf, 1, 2))) ; */ |
| 815 | |
| 816 | extern void VG_(sprintf) ( Char* buf, Char *format, ... ); |
| 817 | |
| 818 | extern void VG_(vprintf) ( void(*send)(Char), |
| 819 | const Char *format, va_list vargs ); |
| 820 | |
| 821 | extern Bool VG_(isspace) ( Char c ); |
| 822 | |
| 823 | extern Int VG_(strlen) ( const Char* str ); |
| 824 | |
| 825 | extern Long VG_(atoll) ( Char* str ); |
sewardj | a70ca3f | 2002-05-30 01:22:20 +0000 | [diff] [blame] | 826 | extern Long VG_(atoll36) ( Char* str ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 827 | |
| 828 | extern Char* VG_(strcat) ( Char* dest, const Char* src ); |
| 829 | extern Char* VG_(strncat) ( Char* dest, const Char* src, Int n ); |
| 830 | extern Char* VG_(strpbrk) ( const Char* s, const Char* accept ); |
| 831 | |
| 832 | extern Char* VG_(strcpy) ( Char* dest, const Char* src ); |
| 833 | |
| 834 | extern Int VG_(strcmp) ( const Char* s1, const Char* s2 ); |
| 835 | extern Int VG_(strcmp_ws) ( const Char* s1, const Char* s2 ); |
| 836 | |
| 837 | extern Int VG_(strncmp) ( const Char* s1, const Char* s2, Int nmax ); |
| 838 | extern Int VG_(strncmp_ws) ( const Char* s1, const Char* s2, Int nmax ); |
| 839 | |
| 840 | extern Char* VG_(strstr) ( const Char* haystack, Char* needle ); |
| 841 | extern Char* VG_(strchr) ( const Char* s, Char c ); |
| 842 | extern Char* VG_(strdup) ( ArenaId aid, const Char* s); |
| 843 | |
| 844 | extern Char* VG_(getenv) ( Char* name ); |
| 845 | extern Int VG_(getpid) ( void ); |
sewardj | 5f07b66 | 2002-04-23 16:52:51 +0000 | [diff] [blame] | 846 | |
| 847 | extern void VG_(start_rdtsc_calibration) ( void ); |
| 848 | extern void VG_(end_rdtsc_calibration) ( void ); |
| 849 | extern UInt VG_(read_millisecond_timer) ( void ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 850 | |
| 851 | |
| 852 | extern Char VG_(toupper) ( Char c ); |
| 853 | |
| 854 | extern void VG_(strncpy_safely) ( Char* dest, const Char* src, Int ndest ); |
| 855 | |
| 856 | extern void VG_(strncpy) ( Char* dest, const Char* src, Int ndest ); |
| 857 | |
| 858 | extern Bool VG_(stringMatch) ( Char* pat, Char* str ); |
| 859 | |
| 860 | |
sewardj | 3e1eb1f | 2002-05-18 13:14:17 +0000 | [diff] [blame] | 861 | #define VG__STRING(__str) #__str |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 862 | |
| 863 | /* Asserts are permanently enabled. Hurrah! */ |
| 864 | #define vg_assert(expr) \ |
| 865 | ((void) ((expr) ? 0 : \ |
sewardj | 3e1eb1f | 2002-05-18 13:14:17 +0000 | [diff] [blame] | 866 | (VG_(assert_fail) (VG__STRING(expr), \ |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 867 | __FILE__, __LINE__, \ |
| 868 | __PRETTY_FUNCTION__), 0))) |
| 869 | |
| 870 | extern void VG_(assert_fail) ( Char* expr, Char* file, |
| 871 | Int line, Char* fn ) |
| 872 | __attribute__ ((__noreturn__)); |
| 873 | |
njn | 4f9c934 | 2002-04-29 16:03:24 +0000 | [diff] [blame] | 874 | /* Reading and writing files. */ |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 875 | extern Int VG_(open_read) ( Char* pathname ); |
njn | 4f9c934 | 2002-04-29 16:03:24 +0000 | [diff] [blame] | 876 | extern Int VG_(open_write) ( Char* pathname ); |
| 877 | extern Int VG_(create_and_write) ( Char* pathname ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 878 | extern void VG_(close) ( Int fd ); |
| 879 | extern Int VG_(read) ( Int fd, void* buf, Int count); |
| 880 | extern Int VG_(write) ( Int fd, void* buf, Int count); |
sewardj | b358620 | 2002-05-09 17:38:13 +0000 | [diff] [blame] | 881 | extern Int VG_(stat) ( Char* file_name, struct vki_stat* buf ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 882 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 883 | extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg ); |
| 884 | |
| 885 | extern Int VG_(select)( Int n, |
| 886 | vki_fd_set* readfds, |
| 887 | vki_fd_set* writefds, |
| 888 | vki_fd_set* exceptfds, |
| 889 | struct vki_timeval * timeout ); |
| 890 | extern Int VG_(nanosleep)( const struct vki_timespec *req, |
| 891 | struct vki_timespec *rem ); |
| 892 | |
| 893 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 894 | /* mmap-ery ... */ |
| 895 | extern void* VG_(mmap)( void* start, UInt length, |
| 896 | UInt prot, UInt flags, UInt fd, UInt offset ); |
| 897 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 898 | extern Int VG_(munmap)( void* start, Int length ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 899 | |
sewardj | b358620 | 2002-05-09 17:38:13 +0000 | [diff] [blame] | 900 | extern void* VG_(brk) ( void* end_data_segment ); |
| 901 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 902 | |
| 903 | /* Print a (panic) message, and abort. */ |
| 904 | extern void VG_(panic) ( Char* str ) |
| 905 | __attribute__ ((__noreturn__)); |
| 906 | |
| 907 | /* Get memory by anonymous mmap. */ |
sewardj | e6a2524 | 2002-04-21 22:03:07 +0000 | [diff] [blame] | 908 | extern void* VG_(get_memory_from_mmap) ( Int nBytes ); |
| 909 | |
| 910 | /* Crude stand-in for the glibc system() call. */ |
| 911 | extern Int VG_(system) ( Char* cmd ); |
| 912 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 913 | |
| 914 | /* Signal stuff. Note that these use the vk_ (kernel) structure |
| 915 | definitions, which are different in places from those that glibc |
| 916 | defines. Since we're operating right at the kernel interface, |
| 917 | glibc's view of the world is entirely irrelevant. */ |
sewardj | 018f762 | 2002-05-15 21:13:39 +0000 | [diff] [blame] | 918 | |
| 919 | /* --- Signal set ops --- */ |
sewardj | b48e500 | 2002-05-13 00:16:03 +0000 | [diff] [blame] | 920 | extern Int VG_(ksigfillset)( vki_ksigset_t* set ); |
| 921 | extern Int VG_(ksigemptyset)( vki_ksigset_t* set ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 922 | |
sewardj | 018f762 | 2002-05-15 21:13:39 +0000 | [diff] [blame] | 923 | extern Bool VG_(kisfullsigset)( vki_ksigset_t* set ); |
| 924 | extern Bool VG_(kisemptysigset)( vki_ksigset_t* set ); |
| 925 | |
| 926 | extern Int VG_(ksigaddset)( vki_ksigset_t* set, Int signum ); |
| 927 | extern Int VG_(ksigdelset)( vki_ksigset_t* set, Int signum ); |
| 928 | extern Int VG_(ksigismember) ( vki_ksigset_t* set, Int signum ); |
| 929 | |
sewardj | b48e500 | 2002-05-13 00:16:03 +0000 | [diff] [blame] | 930 | extern void VG_(ksigaddset_from_set)( vki_ksigset_t* dst, |
| 931 | vki_ksigset_t* src ); |
| 932 | extern void VG_(ksigdelset_from_set)( vki_ksigset_t* dst, |
| 933 | vki_ksigset_t* src ); |
| 934 | |
sewardj | 018f762 | 2002-05-15 21:13:39 +0000 | [diff] [blame] | 935 | /* --- Mess with the kernel's sig state --- */ |
| 936 | extern Int VG_(ksigprocmask)( Int how, const vki_ksigset_t* set, |
| 937 | vki_ksigset_t* oldset ); |
| 938 | extern Int VG_(ksigaction) ( Int signum, |
| 939 | const vki_ksigaction* act, |
| 940 | vki_ksigaction* oldact ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 941 | |
| 942 | extern Int VG_(ksignal)(Int signum, void (*sighandler)(Int)); |
| 943 | |
| 944 | extern Int VG_(ksigaltstack)( const vki_kstack_t* ss, vki_kstack_t* oss ); |
| 945 | |
sewardj | 018f762 | 2002-05-15 21:13:39 +0000 | [diff] [blame] | 946 | extern Int VG_(kill)( Int pid, Int signo ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 947 | |
| 948 | |
| 949 | /* --------------------------------------------------------------------- |
| 950 | Definitions for the JITter (vg_translate.c, vg_to_ucode.c, |
| 951 | vg_from_ucode.c). |
| 952 | ------------------------------------------------------------------ */ |
| 953 | |
| 954 | /* Tags which describe what operands are. */ |
| 955 | typedef |
| 956 | enum { TempReg=0, ArchReg=1, RealReg=2, |
| 957 | SpillNo=3, Literal=4, Lit16=5, |
| 958 | NoValue=6 } |
| 959 | Tag; |
| 960 | |
| 961 | |
| 962 | /* Microinstruction opcodes. */ |
| 963 | typedef |
| 964 | enum { |
| 965 | NOP, |
| 966 | GET, |
| 967 | PUT, |
| 968 | LOAD, |
| 969 | STORE, |
| 970 | MOV, |
| 971 | CMOV, /* Used for cmpxchg and cmov */ |
| 972 | WIDEN, |
| 973 | JMP, |
| 974 | |
| 975 | /* Read/write the %EFLAGS register into a TempReg. */ |
| 976 | GETF, PUTF, |
| 977 | |
| 978 | ADD, ADC, AND, OR, XOR, SUB, SBB, |
| 979 | SHL, SHR, SAR, ROL, ROR, RCL, RCR, |
| 980 | NOT, NEG, INC, DEC, BSWAP, |
| 981 | CC2VAL, |
| 982 | |
| 983 | /* Not strictly needed, but useful for making better |
| 984 | translations of address calculations. */ |
| 985 | LEA1, /* reg2 := const + reg1 */ |
| 986 | LEA2, /* reg3 := const + reg1 + reg2 * 1,2,4 or 8 */ |
| 987 | |
| 988 | /* not for translating x86 calls -- only to call helpers */ |
| 989 | CALLM_S, CALLM_E, /* Mark start and end of push/pop sequences |
| 990 | for CALLM. */ |
| 991 | PUSH, POP, CLEAR, /* Add/remove/zap args for helpers. */ |
| 992 | CALLM, /* call to a machine-code helper */ |
| 993 | |
| 994 | /* Hack for translating string (REP-) insns. Jump to literal if |
| 995 | TempReg/RealReg is zero. */ |
| 996 | JIFZ, |
| 997 | |
| 998 | /* FPU ops which read/write mem or don't touch mem at all. */ |
| 999 | FPU_R, |
| 1000 | FPU_W, |
| 1001 | FPU, |
| 1002 | |
| 1003 | /* Advance the simulated %eip by some small (< 128) number. */ |
| 1004 | INCEIP, |
| 1005 | |
| 1006 | /* uinstrs which are not needed for mere translation of x86 code, |
| 1007 | only for instrumentation of it. */ |
| 1008 | LOADV, |
| 1009 | STOREV, |
| 1010 | GETV, |
| 1011 | PUTV, |
| 1012 | TESTV, |
| 1013 | SETV, |
| 1014 | /* Get/set the v-bit (and it is only one bit) for the simulated |
| 1015 | %eflags register. */ |
| 1016 | GETVF, |
| 1017 | PUTVF, |
| 1018 | |
| 1019 | /* Do a unary or binary tag op. Only for post-instrumented |
| 1020 | code. For TAG1, first and only arg is a TempReg, and is both |
| 1021 | arg and result reg. For TAG2, first arg is src, second is |
| 1022 | dst, in the normal way; both are TempRegs. In both cases, |
| 1023 | 3rd arg is a RiCHelper with a Lit16 tag. This indicates |
| 1024 | which tag op to do. */ |
| 1025 | TAG1, |
| 1026 | TAG2 |
| 1027 | } |
| 1028 | Opcode; |
| 1029 | |
| 1030 | |
| 1031 | /* Condition codes, observing the Intel encoding. CondAlways is an |
| 1032 | extra. */ |
| 1033 | typedef |
| 1034 | enum { |
| 1035 | CondO = 0, /* overflow */ |
| 1036 | CondNO = 1, /* no overflow */ |
| 1037 | CondB = 2, /* below */ |
| 1038 | CondNB = 3, /* not below */ |
| 1039 | CondZ = 4, /* zero */ |
| 1040 | CondNZ = 5, /* not zero */ |
| 1041 | CondBE = 6, /* below or equal */ |
| 1042 | CondNBE = 7, /* not below or equal */ |
| 1043 | CondS = 8, /* negative */ |
| 1044 | ConsNS = 9, /* not negative */ |
| 1045 | CondP = 10, /* parity even */ |
| 1046 | CondNP = 11, /* not parity even */ |
| 1047 | CondL = 12, /* jump less */ |
| 1048 | CondNL = 13, /* not less */ |
| 1049 | CondLE = 14, /* less or equal */ |
| 1050 | CondNLE = 15, /* not less or equal */ |
| 1051 | CondAlways = 16 /* Jump always */ |
| 1052 | } |
| 1053 | Condcode; |
| 1054 | |
| 1055 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 1056 | /* Descriptions of additional properties of *unconditional* jumps. */ |
| 1057 | typedef |
| 1058 | enum { |
| 1059 | JmpBoring=0, /* boring unconditional jump */ |
| 1060 | JmpCall=1, /* jump due to an x86 call insn */ |
| 1061 | JmpRet=2, /* jump due to an x86 ret insn */ |
| 1062 | JmpSyscall=3, /* do a system call, then jump */ |
| 1063 | JmpClientReq=4 /* do a client request, then jump */ |
| 1064 | } |
| 1065 | JmpKind; |
| 1066 | |
| 1067 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1068 | /* Flags. User-level code can only read/write O(verflow), S(ign), |
| 1069 | Z(ero), A(ux-carry), C(arry), P(arity), and may also write |
| 1070 | D(irection). That's a total of 7 flags. A FlagSet is a bitset, |
| 1071 | thusly: |
| 1072 | 76543210 |
| 1073 | DOSZACP |
| 1074 | and bit 7 must always be zero since it is unused. |
| 1075 | */ |
| 1076 | typedef UChar FlagSet; |
| 1077 | |
| 1078 | #define FlagD (1<<6) |
| 1079 | #define FlagO (1<<5) |
| 1080 | #define FlagS (1<<4) |
| 1081 | #define FlagZ (1<<3) |
| 1082 | #define FlagA (1<<2) |
| 1083 | #define FlagC (1<<1) |
| 1084 | #define FlagP (1<<0) |
| 1085 | |
| 1086 | #define FlagsOSZACP (FlagO | FlagS | FlagZ | FlagA | FlagC | FlagP) |
| 1087 | #define FlagsOSZAP (FlagO | FlagS | FlagZ | FlagA | FlagP) |
| 1088 | #define FlagsOSZCP (FlagO | FlagS | FlagZ | FlagC | FlagP) |
| 1089 | #define FlagsOSACP (FlagO | FlagS | FlagA | FlagC | FlagP) |
| 1090 | #define FlagsSZACP ( FlagS | FlagZ | FlagA | FlagC | FlagP) |
| 1091 | #define FlagsSZAP ( FlagS | FlagZ | FlagA | FlagP) |
sewardj | 4a7456e | 2002-03-24 13:52:19 +0000 | [diff] [blame] | 1092 | #define FlagsZCP ( FlagZ | FlagC | FlagP) |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1093 | #define FlagsOC (FlagO | FlagC ) |
sewardj | 4d0ab1f | 2002-03-24 10:00:09 +0000 | [diff] [blame] | 1094 | #define FlagsAC ( FlagA | FlagC ) |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1095 | |
| 1096 | #define FlagsALL (FlagsOSZACP | FlagD) |
| 1097 | #define FlagsEmpty (FlagSet)0 |
| 1098 | |
| 1099 | #define VG_IS_FLAG_SUBSET(set1,set2) \ |
| 1100 | (( ((FlagSet)set1) & ((FlagSet)set2) ) == ((FlagSet)set1) ) |
| 1101 | |
| 1102 | #define VG_UNION_FLAG_SETS(set1,set2) \ |
| 1103 | ( ((FlagSet)set1) | ((FlagSet)set2) ) |
| 1104 | |
| 1105 | |
| 1106 | |
| 1107 | /* A Micro (u)-instruction. */ |
| 1108 | typedef |
| 1109 | struct { |
| 1110 | /* word 1 */ |
| 1111 | UInt lit32; /* 32-bit literal */ |
| 1112 | |
| 1113 | /* word 2 */ |
| 1114 | UShort val1; /* first operand */ |
| 1115 | UShort val2; /* second operand */ |
| 1116 | |
| 1117 | /* word 3 */ |
| 1118 | UShort val3; /* third operand */ |
| 1119 | UChar opcode; /* opcode */ |
| 1120 | UChar size; /* data transfer size */ |
| 1121 | |
| 1122 | /* word 4 */ |
| 1123 | FlagSet flags_r; /* :: FlagSet */ |
| 1124 | FlagSet flags_w; /* :: FlagSet */ |
| 1125 | UChar tag1:4; /* first operand tag */ |
| 1126 | UChar tag2:4; /* second operand tag */ |
| 1127 | UChar tag3:4; /* third operand tag */ |
| 1128 | UChar extra4b:4; /* Spare field, used by WIDEN for src |
| 1129 | -size, and by LEA2 for scale |
njn | 4f9c934 | 2002-04-29 16:03:24 +0000 | [diff] [blame] | 1130 | (1,2,4 or 8), and by unconditional JMPs for |
| 1131 | orig x86 instr size if --cachesim=yes */ |
| 1132 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1133 | |
| 1134 | /* word 5 */ |
| 1135 | UChar cond; /* condition, for jumps */ |
| 1136 | Bool smc_check:1; /* do a smc test, if writes memory. */ |
| 1137 | Bool signed_widen:1; /* signed or unsigned WIDEN ? */ |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 1138 | JmpKind jmpkind:3; /* additional properties of unconditional JMP */ |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1139 | } |
| 1140 | UInstr; |
| 1141 | |
| 1142 | |
| 1143 | /* Expandable arrays of uinstrs. */ |
| 1144 | typedef |
| 1145 | struct { |
| 1146 | Int used; |
| 1147 | Int size; |
| 1148 | UInstr* instrs; |
| 1149 | Int nextTemp; |
| 1150 | } |
| 1151 | UCodeBlock; |
| 1152 | |
| 1153 | /* Refer to `the last instruction stuffed in', including as an |
| 1154 | lvalue. */ |
| 1155 | #define LAST_UINSTR(cb) (cb)->instrs[(cb)->used-1] |
| 1156 | |
| 1157 | /* An invalid temporary number :-) */ |
| 1158 | #define INVALID_TEMPREG 999999999 |
| 1159 | |
| 1160 | |
| 1161 | /* --------------------------------------------------------------------- |
| 1162 | Exports of vg_demangle.c |
| 1163 | ------------------------------------------------------------------ */ |
| 1164 | |
| 1165 | extern void VG_(demangle) ( Char* orig, Char* result, Int result_size ); |
| 1166 | |
| 1167 | |
| 1168 | /* --------------------------------------------------------------------- |
| 1169 | Exports of vg_from_ucode.c |
| 1170 | ------------------------------------------------------------------ */ |
| 1171 | |
| 1172 | extern UChar* VG_(emit_code) ( UCodeBlock* cb, Int* nbytes ); |
| 1173 | |
| 1174 | |
| 1175 | /* --------------------------------------------------------------------- |
| 1176 | Exports of vg_to_ucode.c |
| 1177 | ------------------------------------------------------------------ */ |
| 1178 | |
| 1179 | extern Int VG_(disBB) ( UCodeBlock* cb, Addr eip0 ); |
| 1180 | extern Char* VG_(nameOfIntReg) ( Int size, Int reg ); |
| 1181 | extern Char VG_(nameOfIntSize) ( Int size ); |
| 1182 | extern UInt VG_(extend_s_8to32) ( UInt x ); |
| 1183 | extern Int VG_(getNewTemp) ( UCodeBlock* cb ); |
| 1184 | extern Int VG_(getNewShadow) ( UCodeBlock* cb ); |
| 1185 | |
| 1186 | #define SHADOW(tempreg) ((tempreg)+1) |
| 1187 | |
| 1188 | |
| 1189 | /* --------------------------------------------------------------------- |
| 1190 | Exports of vg_translate.c |
| 1191 | ------------------------------------------------------------------ */ |
| 1192 | |
sewardj | 1e8cdc9 | 2002-04-18 11:37:52 +0000 | [diff] [blame] | 1193 | extern void VG_(translate) ( ThreadState* tst, |
| 1194 | Addr orig_addr, |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1195 | UInt* orig_size, |
| 1196 | Addr* trans_addr, |
| 1197 | UInt* trans_size ); |
| 1198 | |
| 1199 | extern void VG_(emptyUInstr) ( UInstr* u ); |
| 1200 | extern void VG_(newUInstr0) ( UCodeBlock* cb, Opcode opcode, Int sz ); |
| 1201 | extern void VG_(newUInstr1) ( UCodeBlock* cb, Opcode opcode, Int sz, |
| 1202 | Tag tag1, UInt val1 ); |
| 1203 | extern void VG_(newUInstr2) ( UCodeBlock* cb, Opcode opcode, Int sz, |
| 1204 | Tag tag1, UInt val1, |
| 1205 | Tag tag2, UInt val2 ); |
| 1206 | extern void VG_(newUInstr3) ( UCodeBlock* cb, Opcode opcode, Int sz, |
| 1207 | Tag tag1, UInt val1, |
| 1208 | Tag tag2, UInt val2, |
| 1209 | Tag tag3, UInt val3 ); |
| 1210 | extern void VG_(setFlagRW) ( UInstr* u, |
| 1211 | FlagSet fr, FlagSet fw ); |
| 1212 | |
| 1213 | extern void VG_(setLiteralField) ( UCodeBlock* cb, UInt lit32 ); |
| 1214 | extern Bool VG_(anyFlagUse) ( UInstr* u ); |
| 1215 | |
| 1216 | |
| 1217 | |
| 1218 | extern void VG_(ppUInstr) ( Int instrNo, UInstr* u ); |
| 1219 | extern void VG_(ppUCodeBlock) ( UCodeBlock* cb, Char* title ); |
| 1220 | |
njn | 4f9c934 | 2002-04-29 16:03:24 +0000 | [diff] [blame] | 1221 | extern UCodeBlock* VG_(allocCodeBlock) ( void ); |
| 1222 | extern void VG_(freeCodeBlock) ( UCodeBlock* cb ); |
| 1223 | extern void VG_(copyUInstr) ( UCodeBlock* cb, UInstr* instr ); |
| 1224 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1225 | extern Char* VG_(nameCondcode) ( Condcode cond ); |
| 1226 | extern Bool VG_(saneUInstr) ( Bool beforeRA, UInstr* u ); |
| 1227 | extern Bool VG_(saneUCodeBlock) ( UCodeBlock* cb ); |
| 1228 | extern Char* VG_(nameUOpcode) ( Bool upper, Opcode opc ); |
| 1229 | extern Int VG_(rankToRealRegNo) ( Int rank ); |
| 1230 | |
| 1231 | extern void* VG_(jitmalloc) ( Int nbytes ); |
| 1232 | extern void VG_(jitfree) ( void* ptr ); |
| 1233 | |
| 1234 | |
| 1235 | /* --------------------------------------------------------------------- |
| 1236 | Exports of vg_execontext.c. |
| 1237 | ------------------------------------------------------------------ */ |
| 1238 | |
| 1239 | /* Records the PC and a bit of the call chain. The first 4 %eip |
| 1240 | values are used in comparisons do remove duplicate errors, and for |
| 1241 | comparing against suppression specifications. The rest are purely |
| 1242 | informational (but often important). */ |
| 1243 | |
| 1244 | typedef |
| 1245 | struct _ExeContextRec { |
| 1246 | struct _ExeContextRec * next; |
| 1247 | /* The size of this array is VG_(clo_backtrace_size); at least |
| 1248 | 2, at most VG_DEEPEST_BACKTRACE. [0] is the current %eip, |
| 1249 | [1] is its caller, [2] is the caller of [1], etc. */ |
| 1250 | Addr eips[0]; |
| 1251 | } |
| 1252 | ExeContext; |
| 1253 | |
| 1254 | |
| 1255 | /* Initialise the ExeContext storage mechanism. */ |
| 1256 | extern void VG_(init_ExeContext_storage) ( void ); |
| 1257 | |
| 1258 | /* Print stats (informational only). */ |
| 1259 | extern void VG_(show_ExeContext_stats) ( void ); |
| 1260 | |
| 1261 | |
| 1262 | /* Take a snapshot of the client's stack. Search our collection of |
| 1263 | ExeContexts to see if we already have it, and if not, allocate a |
| 1264 | new one. Either way, return a pointer to the context. */ |
sewardj | 8c82451 | 2002-04-14 04:16:48 +0000 | [diff] [blame] | 1265 | extern ExeContext* VG_(get_ExeContext) ( Bool skip_top_frame, |
| 1266 | Addr eip, Addr ebp ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1267 | |
| 1268 | /* Print an ExeContext. */ |
| 1269 | extern void VG_(pp_ExeContext) ( ExeContext* ); |
| 1270 | |
| 1271 | /* Compare two ExeContexts, just comparing the top two callers. */ |
| 1272 | extern Bool VG_(eq_ExeContext_top2) ( ExeContext* e1, ExeContext* e2 ); |
| 1273 | |
| 1274 | /* Compare two ExeContexts, just comparing the top four callers. */ |
| 1275 | extern Bool VG_(eq_ExeContext_top4) ( ExeContext* e1, ExeContext* e2 ); |
| 1276 | |
| 1277 | /* Compare two ExeContexts, comparing all callers. */ |
| 1278 | extern Bool VG_(eq_ExeContext_all) ( ExeContext* e1, ExeContext* e2 ); |
| 1279 | |
| 1280 | |
| 1281 | |
| 1282 | /* --------------------------------------------------------------------- |
| 1283 | Exports of vg_errcontext.c. |
| 1284 | ------------------------------------------------------------------ */ |
| 1285 | |
| 1286 | extern void VG_(load_suppressions) ( void ); |
| 1287 | extern void VG_(show_all_errors) ( void ); |
| 1288 | extern void VG_(record_value_error) ( Int size ); |
sewardj | aabd5ad | 2002-04-19 15:43:37 +0000 | [diff] [blame] | 1289 | extern void VG_(record_free_error) ( ThreadState* tst, Addr a ); |
| 1290 | extern void VG_(record_freemismatch_error) ( ThreadState* tst, Addr a ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1291 | extern void VG_(record_address_error) ( Addr a, Int size, |
| 1292 | Bool isWrite ); |
sewardj | 1e8cdc9 | 2002-04-18 11:37:52 +0000 | [diff] [blame] | 1293 | |
| 1294 | extern void VG_(record_jump_error) ( ThreadState* tst, Addr a ); |
sewardj | 8c82451 | 2002-04-14 04:16:48 +0000 | [diff] [blame] | 1295 | |
| 1296 | extern void VG_(record_param_err) ( ThreadState* tst, |
| 1297 | Addr a, |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1298 | Bool isWriteLack, |
| 1299 | Char* msg ); |
sewardj | 8c82451 | 2002-04-14 04:16:48 +0000 | [diff] [blame] | 1300 | extern void VG_(record_user_err) ( ThreadState* tst, |
| 1301 | Addr a, Bool isWriteLack ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1302 | |
| 1303 | |
| 1304 | /* The classification of a faulting address. */ |
| 1305 | typedef |
sewardj | b581a13 | 2002-05-08 00:32:50 +0000 | [diff] [blame] | 1306 | enum { Undescribed, /* as-yet unclassified */ |
| 1307 | Stack, |
| 1308 | Unknown, /* classification yielded nothing useful */ |
| 1309 | Freed, Mallocd, |
| 1310 | UserG, UserS } |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1311 | AddrKind; |
| 1312 | |
| 1313 | /* Records info about a faulting address. */ |
| 1314 | typedef |
| 1315 | struct { |
| 1316 | /* ALL */ |
| 1317 | AddrKind akind; |
| 1318 | /* Freed, Mallocd */ |
| 1319 | Int blksize; |
| 1320 | /* Freed, Mallocd */ |
| 1321 | Int rwoffset; |
| 1322 | /* Freed, Mallocd */ |
| 1323 | ExeContext* lastchange; |
sewardj | 1e8cdc9 | 2002-04-18 11:37:52 +0000 | [diff] [blame] | 1324 | /* Stack */ |
| 1325 | ThreadId stack_tid; |
sewardj | b581a13 | 2002-05-08 00:32:50 +0000 | [diff] [blame] | 1326 | /* True if is just-below %esp -- could be a gcc bug. */ |
| 1327 | Bool maybe_gcc; |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1328 | } |
| 1329 | AddrInfo; |
| 1330 | |
| 1331 | |
| 1332 | /* --------------------------------------------------------------------- |
| 1333 | Exports of vg_clientperms.c |
| 1334 | ------------------------------------------------------------------ */ |
| 1335 | |
| 1336 | extern Bool VG_(client_perm_maybe_describe)( Addr a, AddrInfo* ai ); |
| 1337 | |
sewardj | 8c82451 | 2002-04-14 04:16:48 +0000 | [diff] [blame] | 1338 | extern UInt VG_(handle_client_request) ( ThreadState* tst, UInt* arg_block ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1339 | |
| 1340 | extern void VG_(delete_client_stack_blocks_following_ESP_change) ( void ); |
| 1341 | |
| 1342 | extern void VG_(show_client_block_stats) ( void ); |
| 1343 | |
| 1344 | |
| 1345 | /* --------------------------------------------------------------------- |
| 1346 | Exports of vg_procselfmaps.c |
| 1347 | ------------------------------------------------------------------ */ |
| 1348 | |
| 1349 | extern |
| 1350 | void VG_(read_procselfmaps) ( |
| 1351 | void (*record_mapping)( Addr, UInt, Char, Char, Char, UInt, UChar* ) |
| 1352 | ); |
| 1353 | |
| 1354 | |
| 1355 | /* --------------------------------------------------------------------- |
| 1356 | Exports of vg_symtab2.c |
| 1357 | ------------------------------------------------------------------ */ |
| 1358 | |
| 1359 | /* We assume the executable is loaded here ... can't really find |
| 1360 | out. There is a hacky sanity check in vg_init_memory_audit() |
| 1361 | which should trip up most stupidities. |
| 1362 | */ |
| 1363 | #define VG_ASSUMED_EXE_BASE (Addr)0x8048000 |
| 1364 | |
| 1365 | extern void VG_(read_symbols) ( void ); |
| 1366 | extern void VG_(mini_stack_dump) ( ExeContext* ec ); |
| 1367 | extern void VG_(what_obj_and_fun_is_this) |
| 1368 | ( Addr a, |
| 1369 | Char* obj_buf, Int n_obj_buf, |
| 1370 | Char* fun_buf, Int n_fun_buf ); |
njn | 4f9c934 | 2002-04-29 16:03:24 +0000 | [diff] [blame] | 1371 | extern Bool VG_(what_line_is_this) ( Addr a, |
| 1372 | UChar* filename, Int n_filename, |
| 1373 | UInt* lineno ); |
| 1374 | extern Bool VG_(what_fn_is_this) ( Bool no_demangle, Addr a, |
| 1375 | Char* fn_name, Int n_fn_name); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1376 | |
sewardj | 18d7513 | 2002-05-16 11:06:21 +0000 | [diff] [blame] | 1377 | extern Bool VG_(symtab_notify_munmap) ( Addr start, UInt length ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1378 | |
| 1379 | |
| 1380 | /* --------------------------------------------------------------------- |
| 1381 | Exports of vg_clientmalloc.c |
| 1382 | ------------------------------------------------------------------ */ |
| 1383 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1384 | typedef |
| 1385 | enum { |
| 1386 | Vg_AllocMalloc = 0, |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 1387 | Vg_AllocNew = 1, |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1388 | Vg_AllocNewVec = 2 |
| 1389 | } |
| 1390 | VgAllocKind; |
| 1391 | |
| 1392 | /* Description of a malloc'd chunk. */ |
| 1393 | typedef |
| 1394 | struct _ShadowChunk { |
| 1395 | struct _ShadowChunk* next; |
| 1396 | ExeContext* where; /* where malloc'd/free'd */ |
| 1397 | UInt size : 30; /* size requested. */ |
| 1398 | VgAllocKind allockind : 2; /* which wrapper did the allocation */ |
| 1399 | Addr data; /* ptr to actual block. */ |
| 1400 | } |
| 1401 | ShadowChunk; |
| 1402 | |
| 1403 | extern void VG_(clientmalloc_done) ( void ); |
| 1404 | extern void VG_(describe_addr) ( Addr a, AddrInfo* ai ); |
| 1405 | extern ShadowChunk** VG_(get_malloc_shadows) ( /*OUT*/ UInt* n_shadows ); |
| 1406 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 1407 | /* These are called from the scheduler, when it intercepts a user |
| 1408 | request. */ |
sewardj | 8c82451 | 2002-04-14 04:16:48 +0000 | [diff] [blame] | 1409 | extern void* VG_(client_malloc) ( ThreadState* tst, |
| 1410 | UInt size, VgAllocKind kind ); |
| 1411 | extern void* VG_(client_memalign) ( ThreadState* tst, |
| 1412 | UInt align, UInt size ); |
| 1413 | extern void VG_(client_free) ( ThreadState* tst, |
| 1414 | void* ptrV, VgAllocKind kind ); |
| 1415 | extern void* VG_(client_calloc) ( ThreadState* tst, |
| 1416 | UInt nmemb, UInt size1 ); |
| 1417 | extern void* VG_(client_realloc) ( ThreadState* tst, |
| 1418 | void* ptrV, UInt size_new ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1419 | |
| 1420 | |
| 1421 | /* --------------------------------------------------------------------- |
| 1422 | Exports of vg_main.c |
| 1423 | ------------------------------------------------------------------ */ |
| 1424 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1425 | /* A structure used as an intermediary when passing the simulated |
| 1426 | CPU's state to some assembly fragments, particularly system calls. |
| 1427 | Stuff is copied from baseBlock to here, the assembly magic runs, |
| 1428 | and then the inverse copy is done. */ |
| 1429 | |
| 1430 | extern UInt VG_(m_state_static) [8 /* int regs, in Intel order */ |
| 1431 | + 1 /* %eflags */ |
| 1432 | + 1 /* %eip */ |
| 1433 | + VG_SIZE_OF_FPUSTATE_W /* FPU state */ |
| 1434 | ]; |
| 1435 | |
| 1436 | /* Handy fns for doing the copy back and forth. */ |
| 1437 | extern void VG_(copy_baseBlock_to_m_state_static) ( void ); |
| 1438 | extern void VG_(copy_m_state_static_to_baseBlock) ( void ); |
| 1439 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1440 | /* Called when some unhandleable client behaviour is detected. |
| 1441 | Prints a msg and aborts. */ |
| 1442 | extern void VG_(unimplemented) ( Char* msg ); |
sewardj | cfc39b2 | 2002-05-08 01:58:18 +0000 | [diff] [blame] | 1443 | extern void VG_(nvidia_moan) ( void ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1444 | |
| 1445 | /* The stack on which Valgrind runs. We can't use the same stack as the |
| 1446 | simulatee -- that's an important design decision. */ |
| 1447 | extern UInt VG_(stack)[10000]; |
| 1448 | |
| 1449 | /* Similarly, we have to ask for signals to be delivered on an |
| 1450 | alternative stack, since it is possible, although unlikely, that |
| 1451 | we'll have to run client code from inside the Valgrind-installed |
| 1452 | signal handler. If this happens it will be done by |
| 1453 | vg_deliver_signal_immediately(). */ |
| 1454 | extern UInt VG_(sigstack)[10000]; |
| 1455 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1456 | /* Holds client's %esp at the point we gained control. From this the |
| 1457 | client's argc, argv and envp are deduced. */ |
| 1458 | extern Addr VG_(esp_at_startup); |
| 1459 | extern Int VG_(client_argc); |
| 1460 | extern Char** VG_(client_argv); |
| 1461 | extern Char** VG_(client_envp); |
| 1462 | |
| 1463 | /* Remove valgrind.so from a LD_PRELOAD=... string so child processes |
sewardj | 3e1eb1f | 2002-05-18 13:14:17 +0000 | [diff] [blame] | 1464 | don't get traced into. Also mess up $libdir/valgrind so that our |
| 1465 | libpthread.so disappears from view. */ |
| 1466 | void VG_(mash_LD_PRELOAD_and_LD_LIBRARY_PATH) ( Char* ld_preload_str, |
| 1467 | Char* ld_library_path_str ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1468 | |
| 1469 | /* Something of a function looking for a home ... start up GDB. This |
| 1470 | is called from VG_(swizzle_esp_then_start_GDB) and so runs on the |
| 1471 | *client's* stack. This is necessary to give GDB the illusion that |
| 1472 | the client program really was running on the real cpu. */ |
| 1473 | extern void VG_(start_GDB_whilst_on_client_stack) ( void ); |
| 1474 | |
| 1475 | /* Spew out vast amounts of junk during JITting? */ |
| 1476 | extern Bool VG_(disassemble); |
| 1477 | |
| 1478 | /* 64-bit counter for the number of basic blocks done. */ |
| 1479 | extern ULong VG_(bbs_done); |
| 1480 | /* 64-bit counter for the number of bbs to go before a debug exit. */ |
| 1481 | extern ULong VG_(bbs_to_go); |
| 1482 | |
| 1483 | /* Counts downwards in vg_run_innerloop. */ |
| 1484 | extern UInt VG_(dispatch_ctr); |
| 1485 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1486 | /* Is the client running on the simulated CPU or the real one? */ |
| 1487 | extern Bool VG_(running_on_simd_CPU); /* Initially False */ |
| 1488 | |
| 1489 | /* The current LRU epoch. */ |
| 1490 | extern UInt VG_(current_epoch); |
| 1491 | |
sewardj | 7e87e38 | 2002-05-03 19:09:05 +0000 | [diff] [blame] | 1492 | /* This is the ThreadId of the last thread the scheduler ran. */ |
| 1493 | extern ThreadId VG_(last_run_tid); |
| 1494 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1495 | |
| 1496 | /* --- Counters, for informational purposes only. --- */ |
| 1497 | |
| 1498 | /* Number of lookups which miss the fast tt helper. */ |
| 1499 | extern UInt VG_(tt_fast_misses); |
| 1500 | |
| 1501 | /* Counts for LRU informational messages. */ |
| 1502 | |
| 1503 | /* Number and total o/t size of new translations this epoch. */ |
| 1504 | extern UInt VG_(this_epoch_in_count); |
| 1505 | extern UInt VG_(this_epoch_in_osize); |
| 1506 | extern UInt VG_(this_epoch_in_tsize); |
| 1507 | /* Number and total o/t size of discarded translations this epoch. */ |
| 1508 | extern UInt VG_(this_epoch_out_count); |
| 1509 | extern UInt VG_(this_epoch_out_osize); |
| 1510 | extern UInt VG_(this_epoch_out_tsize); |
| 1511 | /* Number and total o/t size of translations overall. */ |
| 1512 | extern UInt VG_(overall_in_count); |
| 1513 | extern UInt VG_(overall_in_osize); |
| 1514 | extern UInt VG_(overall_in_tsize); |
| 1515 | /* Number and total o/t size of discards overall. */ |
| 1516 | extern UInt VG_(overall_out_count); |
| 1517 | extern UInt VG_(overall_out_osize); |
| 1518 | extern UInt VG_(overall_out_tsize); |
| 1519 | |
| 1520 | /* The number of LRU-clearings of TT/TC. */ |
| 1521 | extern UInt VG_(number_of_lrus); |
| 1522 | |
| 1523 | /* Counts pertaining to the register allocator. */ |
| 1524 | |
| 1525 | /* total number of uinstrs input to reg-alloc */ |
| 1526 | extern UInt VG_(uinstrs_prealloc); |
| 1527 | |
| 1528 | /* total number of uinstrs added due to spill code */ |
| 1529 | extern UInt VG_(uinstrs_spill); |
| 1530 | |
| 1531 | /* number of bbs requiring spill code */ |
| 1532 | extern UInt VG_(translations_needing_spill); |
| 1533 | |
| 1534 | /* total of register ranks over all translations */ |
| 1535 | extern UInt VG_(total_reg_rank); |
| 1536 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1537 | /* Counts pertaining to internal sanity checking. */ |
| 1538 | extern UInt VG_(sanity_fast_count); |
| 1539 | extern UInt VG_(sanity_slow_count); |
| 1540 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 1541 | /* Counts pertaining to the scheduler. */ |
| 1542 | extern UInt VG_(num_scheduling_events_MINOR); |
| 1543 | extern UInt VG_(num_scheduling_events_MAJOR); |
| 1544 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1545 | |
| 1546 | /* --------------------------------------------------------------------- |
| 1547 | Exports of vg_memory.c |
| 1548 | ------------------------------------------------------------------ */ |
| 1549 | |
| 1550 | extern void VGM_(init_memory_audit) ( void ); |
| 1551 | extern Addr VGM_(curr_dataseg_end); |
| 1552 | extern void VG_(show_reg_tags) ( void ); |
| 1553 | extern void VG_(detect_memory_leaks) ( void ); |
| 1554 | extern void VG_(done_prof_mem) ( void ); |
| 1555 | |
| 1556 | /* Set permissions for an address range. Not speed-critical. */ |
| 1557 | extern void VGM_(make_noaccess) ( Addr a, UInt len ); |
| 1558 | extern void VGM_(make_writable) ( Addr a, UInt len ); |
| 1559 | extern void VGM_(make_readable) ( Addr a, UInt len ); |
| 1560 | /* Use with care! (read: use for shmat only) */ |
| 1561 | extern void VGM_(make_readwritable) ( Addr a, UInt len ); |
| 1562 | extern void VGM_(copy_address_range_perms) ( Addr src, Addr dst, |
| 1563 | UInt len ); |
| 1564 | |
| 1565 | /* Check permissions for an address range. Not speed-critical. */ |
| 1566 | extern Bool VGM_(check_writable) ( Addr a, UInt len, Addr* bad_addr ); |
| 1567 | extern Bool VGM_(check_readable) ( Addr a, UInt len, Addr* bad_addr ); |
| 1568 | extern Bool VGM_(check_readable_asciiz) ( Addr a, Addr* bad_addr ); |
| 1569 | |
sewardj | 0c3b53f | 2002-05-01 01:58:35 +0000 | [diff] [blame] | 1570 | /* Sanity checks which may be done at any time. The scheduler decides |
| 1571 | when. */ |
| 1572 | extern void VG_(do_sanity_checks) ( Bool force_expensive ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1573 | /* Very cheap ... */ |
| 1574 | extern Bool VG_(first_and_last_secondaries_look_plausible) ( void ); |
| 1575 | |
| 1576 | /* These functions are called from generated code. */ |
| 1577 | extern void VG_(helperc_STOREV4) ( UInt, Addr ); |
| 1578 | extern void VG_(helperc_STOREV2) ( UInt, Addr ); |
| 1579 | extern void VG_(helperc_STOREV1) ( UInt, Addr ); |
| 1580 | |
| 1581 | extern UInt VG_(helperc_LOADV1) ( Addr ); |
| 1582 | extern UInt VG_(helperc_LOADV2) ( Addr ); |
| 1583 | extern UInt VG_(helperc_LOADV4) ( Addr ); |
| 1584 | |
| 1585 | extern void VGM_(handle_esp_assignment) ( Addr new_espA ); |
| 1586 | extern void VGM_(fpu_write_check) ( Addr addr, Int size ); |
| 1587 | extern void VGM_(fpu_read_check) ( Addr addr, Int size ); |
| 1588 | |
| 1589 | /* Safely (avoiding SIGSEGV / SIGBUS) scan the entire valid address |
| 1590 | space and pass the addresses and values of all addressible, |
| 1591 | defined, aligned words to notify_word. This is the basis for the |
| 1592 | leak detector. Returns the number of calls made to notify_word. */ |
| 1593 | UInt VG_(scan_all_valid_memory) ( void (*notify_word)( Addr, UInt ) ); |
| 1594 | |
| 1595 | /* Is this address within some small distance below %ESP? Used only |
| 1596 | for the --workaround-gcc296-bugs kludge. */ |
sewardj | 8c82451 | 2002-04-14 04:16:48 +0000 | [diff] [blame] | 1597 | extern Bool VG_(is_just_below_ESP)( Addr esp, Addr aa ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1598 | |
| 1599 | /* Nasty kludgery to deal with applications which switch stacks, |
| 1600 | like netscape. */ |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1601 | #define VG_PLAUSIBLE_STACK_SIZE 8000000 |
| 1602 | |
sewardj | c3bd5f5 | 2002-05-01 03:24:23 +0000 | [diff] [blame] | 1603 | /* Needed by the pthreads implementation. */ |
| 1604 | #define VGM_WORD_VALID 0 |
| 1605 | #define VGM_WORD_INVALID 0xFFFFFFFF |
| 1606 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1607 | |
| 1608 | /* --------------------------------------------------------------------- |
| 1609 | Exports of vg_syscall_mem.c |
| 1610 | ------------------------------------------------------------------ */ |
| 1611 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 1612 | extern void VG_(perform_assumed_nonblocking_syscall) ( ThreadId tid ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1613 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 1614 | extern void VG_(check_known_blocking_syscall) ( ThreadId tid, |
| 1615 | Int syscallno, |
| 1616 | Int* /*IN*/ res ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1617 | |
| 1618 | extern Bool VG_(is_kerror) ( Int res ); |
| 1619 | |
sewardj | 018f762 | 2002-05-15 21:13:39 +0000 | [diff] [blame] | 1620 | #define KERNEL_DO_SYSCALL(thread_id, result_lvalue) \ |
| 1621 | VG_(load_thread_state)(thread_id); \ |
| 1622 | VG_(copy_baseBlock_to_m_state_static)(); \ |
| 1623 | VG_(do_syscall)(); \ |
| 1624 | VG_(copy_m_state_static_to_baseBlock)(); \ |
| 1625 | VG_(save_thread_state)(thread_id); \ |
| 1626 | VG_(threads)[thread_id].sh_eax = VGM_WORD_VALID; \ |
| 1627 | result_lvalue = VG_(threads)[thread_id].m_eax; |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1628 | |
| 1629 | |
| 1630 | /* --------------------------------------------------------------------- |
| 1631 | Exports of vg_transtab.c |
| 1632 | ------------------------------------------------------------------ */ |
| 1633 | |
| 1634 | /* An entry in the translation table (TT). */ |
| 1635 | typedef |
| 1636 | struct { |
| 1637 | /* +0 */ Addr orig_addr; |
| 1638 | /* +4 */ Addr trans_addr; |
| 1639 | /* +8 */ UInt mru_epoch; |
| 1640 | /* +12 */ UShort orig_size; |
| 1641 | /* +14 */ UShort trans_size; |
| 1642 | } |
| 1643 | TTEntry; |
| 1644 | |
| 1645 | /* The number of basic blocks in an epoch (one age-step). */ |
| 1646 | #define VG_BBS_PER_EPOCH 20000 |
| 1647 | |
| 1648 | extern void VG_(get_tt_tc_used) ( UInt* tt_used, UInt* tc_used ); |
| 1649 | extern void VG_(maybe_do_lru_pass) ( void ); |
| 1650 | extern void VG_(flush_transtab) ( void ); |
| 1651 | extern Addr VG_(copy_to_transcache) ( Addr trans_addr, Int trans_size ); |
| 1652 | extern void VG_(add_to_trans_tab) ( TTEntry* tte ); |
sewardj | 18d7513 | 2002-05-16 11:06:21 +0000 | [diff] [blame] | 1653 | extern void VG_(invalidate_translations) ( Addr start, UInt range ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1654 | |
sewardj | 18d7513 | 2002-05-16 11:06:21 +0000 | [diff] [blame] | 1655 | extern void VG_(init_tt_tc) ( void ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1656 | |
| 1657 | extern void VG_(sanity_check_tc_tt) ( void ); |
| 1658 | extern Addr VG_(search_transtab) ( Addr original_addr ); |
| 1659 | |
| 1660 | extern void VG_(invalidate_tt_fast)( void ); |
| 1661 | |
| 1662 | |
| 1663 | /* --------------------------------------------------------------------- |
| 1664 | Exports of vg_vtagops.c |
| 1665 | ------------------------------------------------------------------ */ |
| 1666 | |
| 1667 | /* Lists the names of value-tag operations used in instrumented |
| 1668 | code. These are the third argument to TAG1 and TAG2 uinsns. */ |
| 1669 | |
| 1670 | typedef |
| 1671 | enum { |
| 1672 | /* Unary. */ |
| 1673 | VgT_PCast40, VgT_PCast20, VgT_PCast10, |
| 1674 | VgT_PCast01, VgT_PCast02, VgT_PCast04, |
| 1675 | |
| 1676 | VgT_PCast14, VgT_PCast12, VgT_PCast11, |
| 1677 | |
| 1678 | VgT_Left4, VgT_Left2, VgT_Left1, |
| 1679 | |
| 1680 | VgT_SWiden14, VgT_SWiden24, VgT_SWiden12, |
| 1681 | VgT_ZWiden14, VgT_ZWiden24, VgT_ZWiden12, |
| 1682 | |
| 1683 | /* Binary; 1st is rd; 2nd is rd+wr */ |
| 1684 | VgT_UifU4, VgT_UifU2, VgT_UifU1, VgT_UifU0, |
| 1685 | VgT_DifD4, VgT_DifD2, VgT_DifD1, |
| 1686 | |
| 1687 | VgT_ImproveAND4_TQ, VgT_ImproveAND2_TQ, VgT_ImproveAND1_TQ, |
| 1688 | VgT_ImproveOR4_TQ, VgT_ImproveOR2_TQ, VgT_ImproveOR1_TQ, |
| 1689 | VgT_DebugFn |
| 1690 | } |
| 1691 | VgTagOp; |
| 1692 | |
| 1693 | extern Char* VG_(nameOfTagOp) ( VgTagOp ); |
| 1694 | extern UInt VG_(DebugFn) ( UInt a1, UInt a2 ); |
| 1695 | |
| 1696 | |
| 1697 | /* --------------------------------------------------------------------- |
| 1698 | Exports of vg_syscall.S |
| 1699 | ------------------------------------------------------------------ */ |
| 1700 | |
| 1701 | extern void VG_(do_syscall) ( void ); |
| 1702 | |
| 1703 | |
| 1704 | /* --------------------------------------------------------------------- |
| 1705 | Exports of vg_startup.S |
| 1706 | ------------------------------------------------------------------ */ |
| 1707 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1708 | extern void VG_(switch_to_real_CPU) ( void ); |
| 1709 | |
sewardj | 3580542 | 2002-04-21 13:05:34 +0000 | [diff] [blame] | 1710 | extern void VG_(swizzle_esp_then_start_GDB) ( Addr m_eip_at_error, |
| 1711 | Addr m_esp_at_error, |
| 1712 | Addr m_ebp_at_error ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1713 | |
| 1714 | |
| 1715 | /* --------------------------------------------------------------------- |
| 1716 | Exports of vg_dispatch.S |
| 1717 | ------------------------------------------------------------------ */ |
| 1718 | |
sewardj | 2e93c50 | 2002-04-12 11:12:52 +0000 | [diff] [blame] | 1719 | /* Run a thread for a (very short) while, until some event happens |
| 1720 | which means we need to defer to the scheduler. */ |
| 1721 | extern UInt VG_(run_innerloop) ( void ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1722 | |
| 1723 | |
| 1724 | /* --------------------------------------------------------------------- |
| 1725 | Exports of vg_helpers.S |
| 1726 | ------------------------------------------------------------------ */ |
| 1727 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1728 | /* Mul, div, etc, -- we don't codegen these directly. */ |
| 1729 | extern void VG_(helper_idiv_64_32); |
| 1730 | extern void VG_(helper_div_64_32); |
| 1731 | extern void VG_(helper_idiv_32_16); |
| 1732 | extern void VG_(helper_div_32_16); |
| 1733 | extern void VG_(helper_idiv_16_8); |
| 1734 | extern void VG_(helper_div_16_8); |
| 1735 | |
| 1736 | extern void VG_(helper_imul_32_64); |
| 1737 | extern void VG_(helper_mul_32_64); |
| 1738 | extern void VG_(helper_imul_16_32); |
| 1739 | extern void VG_(helper_mul_16_32); |
| 1740 | extern void VG_(helper_imul_8_16); |
| 1741 | extern void VG_(helper_mul_8_16); |
| 1742 | |
| 1743 | extern void VG_(helper_CLD); |
| 1744 | extern void VG_(helper_STD); |
| 1745 | extern void VG_(helper_get_dirflag); |
| 1746 | |
| 1747 | extern void VG_(helper_shldl); |
| 1748 | extern void VG_(helper_shldw); |
| 1749 | extern void VG_(helper_shrdl); |
| 1750 | extern void VG_(helper_shrdw); |
| 1751 | |
| 1752 | extern void VG_(helper_RDTSC); |
| 1753 | extern void VG_(helper_CPUID); |
| 1754 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1755 | extern void VG_(helper_bsf); |
| 1756 | extern void VG_(helper_bsr); |
| 1757 | |
| 1758 | extern void VG_(helper_fstsw_AX); |
| 1759 | extern void VG_(helper_SAHF); |
sewardj | 4d0ab1f | 2002-03-24 10:00:09 +0000 | [diff] [blame] | 1760 | extern void VG_(helper_DAS); |
sewardj | fe8a166 | 2002-03-24 11:54:07 +0000 | [diff] [blame] | 1761 | extern void VG_(helper_DAA); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1762 | |
| 1763 | extern void VG_(helper_value_check4_fail); |
| 1764 | extern void VG_(helper_value_check2_fail); |
| 1765 | extern void VG_(helper_value_check1_fail); |
| 1766 | extern void VG_(helper_value_check0_fail); |
| 1767 | |
sewardj | 20917d8 | 2002-05-28 01:36:45 +0000 | [diff] [blame] | 1768 | /* NOT A FUNCTION; this is a bogus RETURN ADDRESS. */ |
sewardj | 54cacf0 | 2002-04-12 23:24:59 +0000 | [diff] [blame] | 1769 | extern void VG_(signalreturn_bogusRA)( void ); |
sewardj | 20917d8 | 2002-05-28 01:36:45 +0000 | [diff] [blame] | 1770 | |
sewardj | 54cacf0 | 2002-04-12 23:24:59 +0000 | [diff] [blame] | 1771 | |
njn | 4f9c934 | 2002-04-29 16:03:24 +0000 | [diff] [blame] | 1772 | /* --------------------------------------------------------------------- |
| 1773 | Exports of vg_cachesim.c |
| 1774 | ------------------------------------------------------------------ */ |
| 1775 | |
| 1776 | extern UCodeBlock* VG_(cachesim_instrument)(UCodeBlock* cb_in, Addr orig_addr); |
| 1777 | |
| 1778 | typedef struct _iCC iCC; |
| 1779 | typedef struct _idCC idCC; |
| 1780 | |
| 1781 | extern void VG_(init_cachesim) ( void ); |
| 1782 | extern void VG_(show_cachesim_results)( Int client_argc, Char** client_argv ); |
| 1783 | |
| 1784 | extern void VG_(cachesim_log_non_mem_instr)( iCC* cc ); |
| 1785 | extern void VG_(cachesim_log_mem_instr) ( idCC* cc, Addr data_addr ); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1786 | |
sewardj | 18d7513 | 2002-05-16 11:06:21 +0000 | [diff] [blame] | 1787 | extern void VG_(cachesim_notify_discard) ( TTEntry* tte ); |
| 1788 | |
| 1789 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1790 | /* --------------------------------------------------------------------- |
| 1791 | The state of the simulated CPU. |
| 1792 | ------------------------------------------------------------------ */ |
| 1793 | |
| 1794 | /* This is the Intel register encoding. */ |
| 1795 | #define R_EAX 0 |
| 1796 | #define R_ECX 1 |
| 1797 | #define R_EDX 2 |
| 1798 | #define R_EBX 3 |
| 1799 | #define R_ESP 4 |
| 1800 | #define R_EBP 5 |
| 1801 | #define R_ESI 6 |
| 1802 | #define R_EDI 7 |
| 1803 | |
| 1804 | #define R_AL (0+R_EAX) |
| 1805 | #define R_CL (0+R_ECX) |
| 1806 | #define R_DL (0+R_EDX) |
| 1807 | #define R_BL (0+R_EBX) |
| 1808 | #define R_AH (4+R_EAX) |
| 1809 | #define R_CH (4+R_ECX) |
| 1810 | #define R_DH (4+R_EDX) |
| 1811 | #define R_BH (4+R_EBX) |
| 1812 | |
| 1813 | |
| 1814 | /* --------------------------------------------------------------------- |
| 1815 | Offsets into baseBlock for everything which needs to referred to |
| 1816 | from generated code. The order of these decls does not imply |
| 1817 | what the order of the actual offsets is. The latter is important |
| 1818 | and is set up in vg_main.c. |
| 1819 | ------------------------------------------------------------------ */ |
| 1820 | |
| 1821 | /* An array of words. In generated code, %ebp always points to the |
| 1822 | start of this array. Useful stuff, like the simulated CPU state, |
| 1823 | and the addresses of helper functions, can then be found by |
| 1824 | indexing off %ebp. The following declares variables which, at |
| 1825 | startup time, are given values denoting offsets into baseBlock. |
| 1826 | These offsets are in *words* from the start of baseBlock. */ |
| 1827 | |
| 1828 | #define VG_BASEBLOCK_WORDS 200 |
| 1829 | |
| 1830 | extern UInt VG_(baseBlock)[VG_BASEBLOCK_WORDS]; |
| 1831 | |
| 1832 | |
| 1833 | /* ----------------------------------------------------- |
| 1834 | Read-write parts of baseBlock. |
| 1835 | -------------------------------------------------- */ |
| 1836 | |
| 1837 | /* State of the simulated CPU. */ |
| 1838 | extern Int VGOFF_(m_eax); |
| 1839 | extern Int VGOFF_(m_ecx); |
| 1840 | extern Int VGOFF_(m_edx); |
| 1841 | extern Int VGOFF_(m_ebx); |
| 1842 | extern Int VGOFF_(m_esp); |
| 1843 | extern Int VGOFF_(m_ebp); |
| 1844 | extern Int VGOFF_(m_esi); |
| 1845 | extern Int VGOFF_(m_edi); |
| 1846 | extern Int VGOFF_(m_eflags); |
| 1847 | extern Int VGOFF_(m_fpustate); |
| 1848 | extern Int VGOFF_(m_eip); |
| 1849 | |
| 1850 | /* Reg-alloc spill area (VG_MAX_SPILLSLOTS words long). */ |
| 1851 | extern Int VGOFF_(spillslots); |
| 1852 | |
| 1853 | /* Records the valid bits for the 8 integer regs & flags reg. */ |
| 1854 | extern Int VGOFF_(sh_eax); |
| 1855 | extern Int VGOFF_(sh_ecx); |
| 1856 | extern Int VGOFF_(sh_edx); |
| 1857 | extern Int VGOFF_(sh_ebx); |
| 1858 | extern Int VGOFF_(sh_esp); |
| 1859 | extern Int VGOFF_(sh_ebp); |
| 1860 | extern Int VGOFF_(sh_esi); |
| 1861 | extern Int VGOFF_(sh_edi); |
| 1862 | extern Int VGOFF_(sh_eflags); |
| 1863 | |
| 1864 | |
| 1865 | /* ----------------------------------------------------- |
| 1866 | Read-only parts of baseBlock. |
| 1867 | -------------------------------------------------- */ |
| 1868 | |
| 1869 | /* Offsets of addresses of helper functions. A "helper" function is |
| 1870 | one which is called from generated code. */ |
| 1871 | |
| 1872 | extern Int VGOFF_(helper_idiv_64_32); |
| 1873 | extern Int VGOFF_(helper_div_64_32); |
| 1874 | extern Int VGOFF_(helper_idiv_32_16); |
| 1875 | extern Int VGOFF_(helper_div_32_16); |
| 1876 | extern Int VGOFF_(helper_idiv_16_8); |
| 1877 | extern Int VGOFF_(helper_div_16_8); |
| 1878 | |
| 1879 | extern Int VGOFF_(helper_imul_32_64); |
| 1880 | extern Int VGOFF_(helper_mul_32_64); |
| 1881 | extern Int VGOFF_(helper_imul_16_32); |
| 1882 | extern Int VGOFF_(helper_mul_16_32); |
| 1883 | extern Int VGOFF_(helper_imul_8_16); |
| 1884 | extern Int VGOFF_(helper_mul_8_16); |
| 1885 | |
| 1886 | extern Int VGOFF_(helper_CLD); |
| 1887 | extern Int VGOFF_(helper_STD); |
| 1888 | extern Int VGOFF_(helper_get_dirflag); |
| 1889 | |
| 1890 | extern Int VGOFF_(helper_shldl); |
| 1891 | extern Int VGOFF_(helper_shldw); |
| 1892 | extern Int VGOFF_(helper_shrdl); |
| 1893 | extern Int VGOFF_(helper_shrdw); |
| 1894 | |
| 1895 | extern Int VGOFF_(helper_RDTSC); |
| 1896 | extern Int VGOFF_(helper_CPUID); |
| 1897 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1898 | extern Int VGOFF_(helper_bsf); |
| 1899 | extern Int VGOFF_(helper_bsr); |
| 1900 | |
| 1901 | extern Int VGOFF_(helper_fstsw_AX); |
| 1902 | extern Int VGOFF_(helper_SAHF); |
sewardj | 4d0ab1f | 2002-03-24 10:00:09 +0000 | [diff] [blame] | 1903 | extern Int VGOFF_(helper_DAS); |
sewardj | fe8a166 | 2002-03-24 11:54:07 +0000 | [diff] [blame] | 1904 | extern Int VGOFF_(helper_DAA); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1905 | |
| 1906 | extern Int VGOFF_(helper_value_check4_fail); |
| 1907 | extern Int VGOFF_(helper_value_check2_fail); |
| 1908 | extern Int VGOFF_(helper_value_check1_fail); |
| 1909 | extern Int VGOFF_(helper_value_check0_fail); |
| 1910 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1911 | extern Int VGOFF_(helperc_STOREV4); /* :: UInt -> Addr -> void */ |
| 1912 | extern Int VGOFF_(helperc_STOREV2); /* :: UInt -> Addr -> void */ |
| 1913 | extern Int VGOFF_(helperc_STOREV1); /* :: UInt -> Addr -> void */ |
| 1914 | |
| 1915 | extern Int VGOFF_(helperc_LOADV4); /* :: Addr -> UInt -> void */ |
| 1916 | extern Int VGOFF_(helperc_LOADV2); /* :: Addr -> UInt -> void */ |
| 1917 | extern Int VGOFF_(helperc_LOADV1); /* :: Addr -> UInt -> void */ |
| 1918 | |
| 1919 | extern Int VGOFF_(handle_esp_assignment); /* :: Addr -> void */ |
| 1920 | extern Int VGOFF_(fpu_write_check); /* :: Addr -> Int -> void */ |
| 1921 | extern Int VGOFF_(fpu_read_check); /* :: Addr -> Int -> void */ |
| 1922 | |
njn | 4f9c934 | 2002-04-29 16:03:24 +0000 | [diff] [blame] | 1923 | extern Int VGOFF_(cachesim_log_non_mem_instr); |
| 1924 | extern Int VGOFF_(cachesim_log_mem_instr); |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1925 | |
| 1926 | #endif /* ndef __VG_INCLUDE_H */ |
| 1927 | |
sewardj | 3b2736a | 2002-03-24 12:18:35 +0000 | [diff] [blame] | 1928 | |
| 1929 | /* --------------------------------------------------------------------- |
| 1930 | Finally - autoconf-generated settings |
| 1931 | ------------------------------------------------------------------ */ |
| 1932 | |
| 1933 | #include "config.h" |
| 1934 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1935 | /*--------------------------------------------------------------------*/ |
| 1936 | /*--- end vg_include.h ---*/ |
| 1937 | /*--------------------------------------------------------------------*/ |