mc_include.h revision af48a6052275dd1bf9e231813ee24e1f4111d1a7
1
2/*--------------------------------------------------------------------*/
3/*--- A header file for all parts of the MemCheck skin.            ---*/
4/*---                                                 mc_include.h ---*/
5/*--------------------------------------------------------------------*/
6
7/*
8   This file is part of MemCheck, a heavyweight Valgrind skin for
9   detecting memory errors.
10
11   Copyright (C) 2000-2003 Julian Seward
12      jseward@acm.org
13
14   This program is free software; you can redistribute it and/or
15   modify it under the terms of the GNU General Public License as
16   published by the Free Software Foundation; either version 2 of the
17   License, or (at your option) any later version.
18
19   This program is distributed in the hope that it will be useful, but
20   WITHOUT ANY WARRANTY; without even the implied warranty of
21   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22   General Public License for more details.
23
24   You should have received a copy of the GNU General Public License
25   along with this program; if not, write to the Free Software
26   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27   02111-1307, USA.
28
29   The GNU General Public License is contained in the file COPYING.
30*/
31
32/* 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
36#ifndef __MC_INCLUDE_H
37#define __MC_INCLUDE_H
38
39#include "mac_shared.h"
40#include "mc_constants.h"
41
42/*------------------------------------------------------------*/
43/*--- Types                                                ---*/
44/*------------------------------------------------------------*/
45
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
99
100/*------------------------------------------------------------*/
101/*--- 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/*------------------------------------------------------------*/
113/*--- Functions                                            ---*/
114/*------------------------------------------------------------*/
115
116/* Functions defined in vg_memcheck_helpers.S */
117extern 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
122
123/* Functions defined in vg_memcheck.c */
124extern void MC_(helperc_STOREV4) ( Addr, UInt );
125extern void MC_(helperc_STOREV2) ( Addr, UInt );
126extern void MC_(helperc_STOREV1) ( Addr, UInt );
127
128extern UInt MC_(helperc_LOADV1) ( Addr );
129extern UInt MC_(helperc_LOADV2) ( Addr );
130extern UInt MC_(helperc_LOADV4) ( Addr );
131
132extern void MC_(fpu_write_check) ( Addr addr, Int size );
133extern void MC_(fpu_read_check)  ( Addr addr, Int size );
134
135
136/* For client requests */
137extern 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 );
140
141extern Bool MC_(check_writable) ( Addr a, UInt len, Addr* bad_addr );
142extern Bool MC_(check_readable) ( Addr a, UInt len, Addr* bad_addr );
143
144extern void MC_(detect_memory_leaks) ( void );
145
146extern Int  MC_(get_or_set_vbits_for_client) (
147               ThreadState* tst,
148               Addr dataV,
149               Addr vbitsV,
150               UInt size,
151               Bool setting /* True <=> set vbits,  False <=> get vbits */
152            );
153
154/* Functions defined in vg_memcheck_clientreqs.c */
155extern Bool MC_(client_perm_maybe_describe)( Addr a, AddrInfo* ai );
156extern void MC_(show_client_block_stats) ( void );
157
158
159/* Functions defined in vg_memcheck_errcontext.c */
160extern void MC_(record_value_error)  ( ThreadState* tst, Int size );
161extern void MC_(record_user_error)   ( ThreadState* tst, Addr a, Bool isWrite );
162extern void MC_(record_overlap_error)( ThreadState* tst, Char* function );
163
164
165#endif
166
167/*--------------------------------------------------------------------*/
168/*--- end                                             mc_include.h ---*/
169/*--------------------------------------------------------------------*/
170
171