njn | c953984 | 2002-10-02 13:26:35 +0000 | [diff] [blame] | 1 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 2 | /*--------------------------------------------------------------------*/ |
nethercote | 137bc55 | 2003-11-14 17:47:54 +0000 | [diff] [blame] | 3 | /*--- A header file for all parts of the MemCheck tool. ---*/ |
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 | /* |
nethercote | 137bc55 | 2003-11-14 17:47:54 +0000 | [diff] [blame] | 8 | This file is part of MemCheck, a heavyweight Valgrind tool for |
njn | c953984 | 2002-10-02 13:26:35 +0000 | [diff] [blame] | 9 | detecting memory errors. |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 10 | |
nethercote | bb1c991 | 2004-01-04 16:43:23 +0000 | [diff] [blame] | 11 | Copyright (C) 2000-2004 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" |
nethercote | 5a2664c | 2004-09-02 15:37:39 +0000 | [diff] [blame] | 40 | #include "mc_asm.h" |
njn | 43c799e | 2003-04-08 00:08:52 +0000 | [diff] [blame] | 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 | |
njn | 66fe05a | 2003-07-22 09:12:33 +0000 | [diff] [blame] | 122 | /* Functions defined in mc_main.c */ |
nethercote | eec4630 | 2004-08-23 15:06:23 +0000 | [diff] [blame] | 123 | extern REGPARM(2) void MC_(helperc_STOREV4) ( Addr, UInt ); |
| 124 | extern REGPARM(2) void MC_(helperc_STOREV2) ( Addr, UInt ); |
| 125 | extern REGPARM(2) void MC_(helperc_STOREV1) ( Addr, UInt ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 126 | |
nethercote | eec4630 | 2004-08-23 15:06:23 +0000 | [diff] [blame] | 127 | extern REGPARM(1) UInt MC_(helperc_LOADV1) ( Addr ); |
| 128 | extern REGPARM(1) UInt MC_(helperc_LOADV2) ( Addr ); |
| 129 | extern REGPARM(1) UInt MC_(helperc_LOADV4) ( Addr ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 130 | |
nethercote | 451eae9 | 2004-11-02 13:06:32 +0000 | [diff] [blame] | 131 | extern REGPARM(2) void MC_(fpu_write_check) ( Addr addr, SizeT size ); |
| 132 | extern REGPARM(2) void MC_(fpu_read_check) ( Addr addr, SizeT size ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 133 | |
njn | 66fe05a | 2003-07-22 09:12:33 +0000 | [diff] [blame] | 134 | /* Functions defined in mc_errcontext.c */ |
njn | 7271864 | 2003-07-24 08:45:32 +0000 | [diff] [blame] | 135 | extern void MC_(record_value_error) ( ThreadId tid, Int size ); |
nethercote | 8b76fe5 | 2004-11-08 19:20:09 +0000 | [diff] [blame] | 136 | extern void MC_(record_user_error) ( ThreadId tid, Addr a, Bool isWrite, |
| 137 | Bool isUnaddr ); |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 138 | |
njn | 9b007f6 | 2003-04-07 14:40:25 +0000 | [diff] [blame] | 139 | |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 140 | #endif |
| 141 | |
| 142 | /*--------------------------------------------------------------------*/ |
nethercote | 8b76fe5 | 2004-11-08 19:20:09 +0000 | [diff] [blame] | 143 | /*--- end ---*/ |
njn25 | e49d8e7 | 2002-09-23 09:36:25 +0000 | [diff] [blame] | 144 | /*--------------------------------------------------------------------*/ |
| 145 | |