blob: 60cb335e22496edf7e5d624a4746367d4f4e3a20 [file] [log] [blame]
nethercote37aac2e2004-09-02 08:54:27 +00001/*-*- c -*- ----------------------------------------------------------*/
njnd01fef72005-03-25 23:35:48 +00002/*--- Header for lots of tool stuff. tool.h ---*/
nethercote37aac2e2004-09-02 08:54:27 +00003/*--------------------------------------------------------------------*/
4
5/*
njnb9c427c2004-12-01 14:14:42 +00006 This file is part of Valgrind, a dynamic binary instrumentation
7 framework.
nethercote37aac2e2004-09-02 08:54:27 +00008
njn53612422005-03-12 16:22:54 +00009 Copyright (C) 2000-2005 Julian Seward
nethercote37aac2e2004-09-02 08:54:27 +000010 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 */
nethercote37aac2e2004-09-02 08:54:27 +000034
nethercoteebf1d862004-11-01 18:22:05 +000035#include "basic_types.h"
sewardjb5f6f512005-03-10 23:59:00 +000036#include "tool_asm.h" /* asm stuff */
nethercote37aac2e2004-09-02 08:54:27 +000037
njn4de47b12005-05-16 03:25:12 +000038#if defined(VGO_linux)
39# include "vki-linux.h"
40#else
41# error Unknown OS
42#endif
43
nethercote37aac2e2004-09-02 08:54:27 +000044/*====================================================================*/
45/*=== Build options and table sizes. ===*/
46/*====================================================================*/
47
nethercote37aac2e2004-09-02 08:54:27 +000048/* 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
nethercote37aac2e2004-09-02 08:54:27 +000055/*====================================================================*/
nethercote37aac2e2004-09-02 08:54:27 +000056/*=== Useful stuff to call from generated code ===*/
57/*====================================================================*/
58
59/* ------------------------------------------------------------------ */
nethercote37aac2e2004-09-02 08:54:27 +000060/* Thread-related stuff */
61
sewardjb5f6f512005-03-10 23:59:00 +000062/* Get the TID of the thread which currently has the CPU. */
63extern ThreadId VG_(get_running_tid) ( void );
nethercote37aac2e2004-09-02 08:54:27 +000064
65/* Searches through all thread's stacks to see if any match. Returns
66 VG_INVALID_THREADID if none match. */
67extern ThreadId VG_(first_matching_thread_stack)
68 ( Bool (*p) ( Addr stack_min, Addr stack_max, void* d ),
69 void* d );
70
nethercote37aac2e2004-09-02 08:54:27 +000071/*====================================================================*/
72/*=== Valgrind's version of libc ===*/
73/*====================================================================*/
74
nethercote37aac2e2004-09-02 08:54:27 +000075/* ------------------------------------------------------------------ */
sewardjb5f6f512005-03-10 23:59:00 +000076/* 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. */
79extern void VG_(set_fault_catcher)(void (*catcher)(Int sig, Addr addr));
80
sewardjb5f6f512005-03-10 23:59:00 +000081/* Calls "mark_addr" with register values (which may or may not be pointers) */
82extern void VG_(mark_from_registers)(void (*mark_addr)(Addr addr));
83
nethercote37aac2e2004-09-02 08:54:27 +000084/* ------------------------------------------------------------------ */
nethercote37aac2e2004-09-02 08:54:27 +000085/* other, randomly useful functions */
sewardjb5f6f512005-03-10 23:59:00 +000086extern Bool VG_(has_cpuid) ( void );
87
nethercote37aac2e2004-09-02 08:54:27 +000088extern void VG_(cpuid) ( UInt eax,
89 UInt *eax_ret, UInt *ebx_ret,
90 UInt *ecx_ret, UInt *edx_ret );
91
njn51d827b2005-05-09 01:02:08 +000092#endif /* __TOOL_H */
93
94