nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 1 | /*-*- c -*- ----------------------------------------------------------*/ |
njn | d01fef7 | 2005-03-25 23:35:48 +0000 | [diff] [blame] | 2 | /*--- Header for lots of tool stuff. tool.h ---*/ |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 3 | /*--------------------------------------------------------------------*/ |
| 4 | |
| 5 | /* |
njn | b9c427c | 2004-12-01 14:14:42 +0000 | [diff] [blame] | 6 | This file is part of Valgrind, a dynamic binary instrumentation |
| 7 | framework. |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 8 | |
njn | 5361242 | 2005-03-12 16:22:54 +0000 | [diff] [blame] | 9 | Copyright (C) 2000-2005 Julian Seward |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 10 | jseward@acm.org |
| 11 | |
| 12 | This program is free software; you can redistribute it and/or |
| 13 | modify it under the terms of the GNU General Public License as |
| 14 | published by the Free Software Foundation; either version 2 of the |
| 15 | License, or (at your option) any later version. |
| 16 | |
| 17 | This program is distributed in the hope that it will be useful, but |
| 18 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 20 | General Public License for more details. |
| 21 | |
| 22 | You should have received a copy of the GNU General Public License |
| 23 | along with this program; if not, write to the Free Software |
| 24 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 25 | 02111-1307, USA. |
| 26 | |
| 27 | The GNU General Public License is contained in the file COPYING. |
| 28 | */ |
| 29 | |
| 30 | #ifndef __TOOL_H |
| 31 | #define __TOOL_H |
| 32 | |
| 33 | #include <stdarg.h> /* ANSI varargs stuff */ |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 34 | |
nethercote | ebf1d86 | 2004-11-01 18:22:05 +0000 | [diff] [blame] | 35 | #include "basic_types.h" |
sewardj | b5f6f51 | 2005-03-10 23:59:00 +0000 | [diff] [blame] | 36 | #include "tool_asm.h" /* asm stuff */ |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 37 | |
njn | 4de47b1 | 2005-05-16 03:25:12 +0000 | [diff] [blame] | 38 | #if defined(VGO_linux) |
| 39 | # include "vki-linux.h" |
| 40 | #else |
| 41 | # error Unknown OS |
| 42 | #endif |
| 43 | |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 44 | /*====================================================================*/ |
| 45 | /*=== Build options and table sizes. ===*/ |
| 46 | /*====================================================================*/ |
| 47 | |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 48 | /* The maximum number of pthreads that we support. This is |
| 49 | deliberately not very high since our implementation of some of the |
| 50 | scheduler algorithms is surely O(N) in the number of threads, since |
| 51 | that's simple, at least. And (in practice) we hope that most |
| 52 | programs do not need many threads. */ |
| 53 | #define VG_N_THREADS 100 |
| 54 | |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 55 | /*====================================================================*/ |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 56 | /*=== Useful stuff to call from generated code ===*/ |
| 57 | /*====================================================================*/ |
| 58 | |
| 59 | /* ------------------------------------------------------------------ */ |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 60 | /* Thread-related stuff */ |
| 61 | |
sewardj | b5f6f51 | 2005-03-10 23:59:00 +0000 | [diff] [blame] | 62 | /* Get the TID of the thread which currently has the CPU. */ |
| 63 | extern ThreadId VG_(get_running_tid) ( void ); |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 64 | |
| 65 | /* Searches through all thread's stacks to see if any match. Returns |
| 66 | VG_INVALID_THREADID if none match. */ |
| 67 | extern ThreadId VG_(first_matching_thread_stack) |
| 68 | ( Bool (*p) ( Addr stack_min, Addr stack_max, void* d ), |
| 69 | void* d ); |
| 70 | |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 71 | /*====================================================================*/ |
| 72 | /*=== Valgrind's version of libc ===*/ |
| 73 | /*====================================================================*/ |
| 74 | |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 75 | /* ------------------------------------------------------------------ */ |
sewardj | b5f6f51 | 2005-03-10 23:59:00 +0000 | [diff] [blame] | 76 | /* Register an interest in apparently internal faults; used code which |
| 77 | wanders around dangerous memory (ie, leakcheck). The catcher is |
| 78 | not expected to return. */ |
| 79 | extern void VG_(set_fault_catcher)(void (*catcher)(Int sig, Addr addr)); |
| 80 | |
sewardj | b5f6f51 | 2005-03-10 23:59:00 +0000 | [diff] [blame] | 81 | /* Calls "mark_addr" with register values (which may or may not be pointers) */ |
| 82 | extern void VG_(mark_from_registers)(void (*mark_addr)(Addr addr)); |
| 83 | |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 84 | /* ------------------------------------------------------------------ */ |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 85 | /* other, randomly useful functions */ |
sewardj | b5f6f51 | 2005-03-10 23:59:00 +0000 | [diff] [blame] | 86 | extern Bool VG_(has_cpuid) ( void ); |
| 87 | |
nethercote | 37aac2e | 2004-09-02 08:54:27 +0000 | [diff] [blame] | 88 | extern void VG_(cpuid) ( UInt eax, |
| 89 | UInt *eax_ret, UInt *ebx_ret, |
| 90 | UInt *ecx_ret, UInt *edx_ret ); |
| 91 | |
njn | 51d827b | 2005-05-09 01:02:08 +0000 | [diff] [blame] | 92 | #endif /* __TOOL_H */ |
| 93 | |
| 94 | |