blob: 948cef8ab6c65bf12d035b062bfc0dd8dde3ab27 [file] [log] [blame]
njnc9539842002-10-02 13:26:35 +00001
njn25e49d8e72002-09-23 09:36:25 +00002/*--------------------------------------------------------------------*/
nethercote137bc552003-11-14 17:47:54 +00003/*--- A header file for all parts of the MemCheck tool. ---*/
njn25cac76cb2002-09-23 11:21:57 +00004/*--- mc_include.h ---*/
njn25e49d8e72002-09-23 09:36:25 +00005/*--------------------------------------------------------------------*/
6
7/*
nethercote137bc552003-11-14 17:47:54 +00008 This file is part of MemCheck, a heavyweight Valgrind tool for
njnc9539842002-10-02 13:26:35 +00009 detecting memory errors.
njn25e49d8e72002-09-23 09:36:25 +000010
nethercotebb1c9912004-01-04 16:43:23 +000011 Copyright (C) 2000-2004 Julian Seward
njn25e49d8e72002-09-23 09:36:25 +000012 jseward@acm.org
13
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License as
16 published by the Free Software Foundation; either version 2 of the
17 License, or (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27 02111-1307, USA.
28
29 The GNU General Public License is contained in the file COPYING.
30*/
31
njn43c799e2003-04-08 00:08:52 +000032/* Note: this header should contain declarations that are for use by
33 Memcheck only -- declarations shared with Addrcheck go in mac_shared.h.
34*/
35
njn25cac76cb2002-09-23 11:21:57 +000036#ifndef __MC_INCLUDE_H
37#define __MC_INCLUDE_H
njn25e49d8e72002-09-23 09:36:25 +000038
njn43c799e2003-04-08 00:08:52 +000039#include "mac_shared.h"
nethercote5a2664c2004-09-02 15:37:39 +000040#include "mc_asm.h"
njn43c799e2003-04-08 00:08:52 +000041
42/*------------------------------------------------------------*/
43/*--- Types ---*/
44/*------------------------------------------------------------*/
njn25e49d8e72002-09-23 09:36:25 +000045
46/* UCode extension for efficient memory checking operations */
47typedef
48 enum {
49 /* uinstrs which are not needed for mere translation of x86 code,
50 only for instrumentation of it. */
51 LOADV = DUMMY_FINAL_UOPCODE + 1,
52 STOREV,
53 GETV,
54 PUTV,
55 TESTV,
56 SETV,
57 /* Get/set the v-bit (and it is only one bit) for the simulated
58 %eflags register. */
59 GETVF,
60 PUTVF,
61
62 /* Do a unary or binary tag op. Only for post-instrumented
63 code. For TAG1, first and only arg is a TempReg, and is both
64 arg and result reg. For TAG2, first arg is src, second is
65 dst, in the normal way; both are TempRegs. In both cases,
66 3rd arg is a RiCHelper with a Lit16 tag. This indicates
67 which tag op to do. */
68 TAG1,
69 TAG2
70 }
71 MemCheckOpcode;
72
73
74/* Lists the names of value-tag operations used in instrumented
75 code. These are the third argument to TAG1 and TAG2 uinsns. */
76typedef
77 enum {
78 /* Unary. */
79 Tag_PCast40, Tag_PCast20, Tag_PCast10,
80 Tag_PCast01, Tag_PCast02, Tag_PCast04,
81
82 Tag_PCast14, Tag_PCast12, Tag_PCast11,
83
84 Tag_Left4, Tag_Left2, Tag_Left1,
85
86 Tag_SWiden14, Tag_SWiden24, Tag_SWiden12,
87 Tag_ZWiden14, Tag_ZWiden24, Tag_ZWiden12,
88
89 /* Binary; 1st is rd; 2nd is rd+wr */
90 Tag_UifU4, Tag_UifU2, Tag_UifU1, Tag_UifU0,
91 Tag_DifD4, Tag_DifD2, Tag_DifD1,
92
93 Tag_ImproveAND4_TQ, Tag_ImproveAND2_TQ, Tag_ImproveAND1_TQ,
94 Tag_ImproveOR4_TQ, Tag_ImproveOR2_TQ, Tag_ImproveOR1_TQ,
95 Tag_DebugFn
96 }
97 TagOp;
98
njn25e49d8e72002-09-23 09:36:25 +000099
100/*------------------------------------------------------------*/
njn43c799e2003-04-08 00:08:52 +0000101/*--- Command line options ---*/
102/*------------------------------------------------------------*/
103
104/* DEBUG: clean up instrumented code? default: YES */
105extern Bool MC_(clo_cleanup);
106
107/* When instrumenting, omit some checks if tell-tale literals for
108 inlined strlen() are visible in the basic block. default: YES */
109extern Bool MC_(clo_avoid_strlen_errors);
110
111
112/*------------------------------------------------------------*/
njn25e49d8e72002-09-23 09:36:25 +0000113/*--- Functions ---*/
114/*------------------------------------------------------------*/
115
njn66fe05a2003-07-22 09:12:33 +0000116/* Functions defined in mc_helpers.S */
njn5c004e42002-11-18 11:04:50 +0000117extern void MC_(helper_value_check4_fail) ( void );
118extern void MC_(helper_value_check2_fail) ( void );
119extern void MC_(helper_value_check1_fail) ( void );
120extern void MC_(helper_value_check0_fail) ( void );
121
njn25e49d8e72002-09-23 09:36:25 +0000122
njn66fe05a2003-07-22 09:12:33 +0000123/* Functions defined in mc_main.c */
nethercoteeec46302004-08-23 15:06:23 +0000124extern REGPARM(2) void MC_(helperc_STOREV4) ( Addr, UInt );
125extern REGPARM(2) void MC_(helperc_STOREV2) ( Addr, UInt );
126extern REGPARM(2) void MC_(helperc_STOREV1) ( Addr, UInt );
njn25e49d8e72002-09-23 09:36:25 +0000127
nethercoteeec46302004-08-23 15:06:23 +0000128extern REGPARM(1) UInt MC_(helperc_LOADV1) ( Addr );
129extern REGPARM(1) UInt MC_(helperc_LOADV2) ( Addr );
130extern REGPARM(1) UInt MC_(helperc_LOADV4) ( Addr );
njn25e49d8e72002-09-23 09:36:25 +0000131
nethercoteeec46302004-08-23 15:06:23 +0000132extern REGPARM(2) void MC_(fpu_write_check) ( Addr addr, Int size );
133extern REGPARM(2) void MC_(fpu_read_check) ( Addr addr, Int size );
njn25e49d8e72002-09-23 09:36:25 +0000134
njn25e49d8e72002-09-23 09:36:25 +0000135
136/* For client requests */
njn5c004e42002-11-18 11:04:50 +0000137extern void MC_(make_noaccess) ( Addr a, UInt len );
138extern void MC_(make_readable) ( Addr a, UInt len );
139extern void MC_(make_writable) ( Addr a, UInt len );
njn25e49d8e72002-09-23 09:36:25 +0000140
njn5c004e42002-11-18 11:04:50 +0000141extern Bool MC_(check_writable) ( Addr a, UInt len, Addr* bad_addr );
142extern Bool MC_(check_readable) ( Addr a, UInt len, Addr* bad_addr );
njn25e49d8e72002-09-23 09:36:25 +0000143
njn5c004e42002-11-18 11:04:50 +0000144extern void MC_(detect_memory_leaks) ( void );
njn25e49d8e72002-09-23 09:36:25 +0000145
sewardjee070842003-07-05 17:53:55 +0000146extern Int MC_(get_or_set_vbits_for_client) (
njn72718642003-07-24 08:45:32 +0000147 ThreadId tid,
sewardjee070842003-07-05 17:53:55 +0000148 Addr dataV,
149 Addr vbitsV,
150 UInt size,
151 Bool setting /* True <=> set vbits, False <=> get vbits */
152 );
njn25e49d8e72002-09-23 09:36:25 +0000153
njn66fe05a2003-07-22 09:12:33 +0000154/* Functions defined in mc_clientreqs.c */
njn5c004e42002-11-18 11:04:50 +0000155extern Bool MC_(client_perm_maybe_describe)( Addr a, AddrInfo* ai );
156extern void MC_(show_client_block_stats) ( void );
157
njn25e49d8e72002-09-23 09:36:25 +0000158
njn66fe05a2003-07-22 09:12:33 +0000159/* Functions defined in mc_errcontext.c */
njn72718642003-07-24 08:45:32 +0000160extern void MC_(record_value_error) ( ThreadId tid, Int size );
161extern void MC_(record_user_error) ( ThreadId tid, Addr a, Bool isWrite );
njn25e49d8e72002-09-23 09:36:25 +0000162
njn9b007f62003-04-07 14:40:25 +0000163
njn25e49d8e72002-09-23 09:36:25 +0000164#endif
165
166/*--------------------------------------------------------------------*/
njn25cac76cb2002-09-23 11:21:57 +0000167/*--- end mc_include.h ---*/
njn25e49d8e72002-09-23 09:36:25 +0000168/*--------------------------------------------------------------------*/
169