njn | c953984 | 2002-10-02 13:26:35 +0000 | [diff] [blame] | 1 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- A header file for all parts of the MemCheck skin. ---*/ |
njn25 | cac76cb | 2002-09-23 11:21:57 +0000 | [diff] [blame] | 4 | /*--- mc_include.h ---*/ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 5 | /*--------------------------------------------------------------------*/ |
| 6 | |
| 7 | /* |
njn | c953984 | 2002-10-02 13:26:35 +0000 | [diff] [blame] | 8 | This file is part of MemCheck, a heavyweight Valgrind skin for |
| 9 | detecting memory errors. |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 10 | |
njn | 0e1b514 | 2003-04-15 14:58:06 +0000 | [diff] [blame] | 11 | Copyright (C) 2000-2003 Julian Seward |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 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 | |
njn | 43c799e | 2003-04-08 00:08:52 +0000 | [diff] [blame] | 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 | |
njn25 | cac76cb | 2002-09-23 11:21:57 +0000 | [diff] [blame] | 36 | #ifndef __MC_INCLUDE_H |
| 37 | #define __MC_INCLUDE_H |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 38 | |
njn | 43c799e | 2003-04-08 00:08:52 +0000 | [diff] [blame] | 39 | #include "mac_shared.h" |
| 40 | #include "mc_constants.h" |
| 41 | |
| 42 | /*------------------------------------------------------------*/ |
| 43 | /*--- Types ---*/ |
| 44 | /*------------------------------------------------------------*/ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 45 | |
| 46 | /* UCode extension for efficient memory checking operations */ |
| 47 | typedef |
| 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. */ |
| 76 | typedef |
| 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 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 99 | |
| 100 | /*------------------------------------------------------------*/ |
njn | 43c799e | 2003-04-08 00:08:52 +0000 | [diff] [blame] | 101 | /*--- Command line options ---*/ |
| 102 | /*------------------------------------------------------------*/ |
| 103 | |
| 104 | /* DEBUG: clean up instrumented code? default: YES */ |
| 105 | extern 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 */ |
| 109 | extern Bool MC_(clo_avoid_strlen_errors); |
| 110 | |
| 111 | |
| 112 | /*------------------------------------------------------------*/ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 113 | /*--- Functions ---*/ |
| 114 | /*------------------------------------------------------------*/ |
| 115 | |
njn | 66fe05a | 2003-07-22 09:12:33 +0000 | [diff] [blame] | 116 | /* Functions defined in mc_helpers.S */ |
njn | 5c004e4 | 2002-11-18 11:04:50 +0000 | [diff] [blame] | 117 | extern void MC_(helper_value_check4_fail) ( void ); |
| 118 | extern void MC_(helper_value_check2_fail) ( void ); |
| 119 | extern void MC_(helper_value_check1_fail) ( void ); |
| 120 | extern void MC_(helper_value_check0_fail) ( void ); |
| 121 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 122 | |
njn | 66fe05a | 2003-07-22 09:12:33 +0000 | [diff] [blame] | 123 | /* Functions defined in mc_main.c */ |
njn | 5c004e4 | 2002-11-18 11:04:50 +0000 | [diff] [blame] | 124 | extern void MC_(helperc_STOREV4) ( Addr, UInt ); |
| 125 | extern void MC_(helperc_STOREV2) ( Addr, UInt ); |
| 126 | extern void MC_(helperc_STOREV1) ( Addr, UInt ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 127 | |
njn | 5c004e4 | 2002-11-18 11:04:50 +0000 | [diff] [blame] | 128 | extern UInt MC_(helperc_LOADV1) ( Addr ); |
| 129 | extern UInt MC_(helperc_LOADV2) ( Addr ); |
| 130 | extern UInt MC_(helperc_LOADV4) ( Addr ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 131 | |
njn | 5c004e4 | 2002-11-18 11:04:50 +0000 | [diff] [blame] | 132 | extern void MC_(fpu_write_check) ( Addr addr, Int size ); |
| 133 | extern void MC_(fpu_read_check) ( Addr addr, Int size ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 134 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 135 | |
| 136 | /* For client requests */ |
njn | 5c004e4 | 2002-11-18 11:04:50 +0000 | [diff] [blame] | 137 | extern void MC_(make_noaccess) ( Addr a, UInt len ); |
| 138 | extern void MC_(make_readable) ( Addr a, UInt len ); |
| 139 | extern void MC_(make_writable) ( Addr a, UInt len ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 140 | |
njn | 5c004e4 | 2002-11-18 11:04:50 +0000 | [diff] [blame] | 141 | extern Bool MC_(check_writable) ( Addr a, UInt len, Addr* bad_addr ); |
| 142 | extern Bool MC_(check_readable) ( Addr a, UInt len, Addr* bad_addr ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 143 | |
njn | 5c004e4 | 2002-11-18 11:04:50 +0000 | [diff] [blame] | 144 | extern void MC_(detect_memory_leaks) ( void ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 145 | |
sewardj | ee07084 | 2003-07-05 17:53:55 +0000 | [diff] [blame] | 146 | extern Int MC_(get_or_set_vbits_for_client) ( |
njn | 7271864 | 2003-07-24 08:45:32 +0000 | [diff] [blame^] | 147 | ThreadId tid, |
sewardj | ee07084 | 2003-07-05 17:53:55 +0000 | [diff] [blame] | 148 | Addr dataV, |
| 149 | Addr vbitsV, |
| 150 | UInt size, |
| 151 | Bool setting /* True <=> set vbits, False <=> get vbits */ |
| 152 | ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 153 | |
njn | 66fe05a | 2003-07-22 09:12:33 +0000 | [diff] [blame] | 154 | /* Functions defined in mc_clientreqs.c */ |
njn | 5c004e4 | 2002-11-18 11:04:50 +0000 | [diff] [blame] | 155 | extern Bool MC_(client_perm_maybe_describe)( Addr a, AddrInfo* ai ); |
| 156 | extern void MC_(show_client_block_stats) ( void ); |
| 157 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 158 | |
njn | 66fe05a | 2003-07-22 09:12:33 +0000 | [diff] [blame] | 159 | /* Functions defined in mc_errcontext.c */ |
njn | 7271864 | 2003-07-24 08:45:32 +0000 | [diff] [blame^] | 160 | extern void MC_(record_value_error) ( ThreadId tid, Int size ); |
| 161 | extern void MC_(record_user_error) ( ThreadId tid, Addr a, Bool isWrite ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 162 | |
njn | 9b007f6 | 2003-04-07 14:40:25 +0000 | [diff] [blame] | 163 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 164 | #endif |
| 165 | |
| 166 | /*--------------------------------------------------------------------*/ |
njn25 | cac76cb | 2002-09-23 11:21:57 +0000 | [diff] [blame] | 167 | /*--- end mc_include.h ---*/ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 168 | /*--------------------------------------------------------------------*/ |
| 169 | |