sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 1 | /* |
| 2 | This file is part of drd, a data race detector. |
| 3 | |
sewardj | 8564292 | 2008-01-14 11:54:56 +0000 | [diff] [blame] | 4 | Copyright (C) 2006-2008 Bart Van Assche |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 5 | bart.vanassche@gmail.com |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or |
| 8 | modify it under the terms of the GNU General Public License as |
| 9 | published by the Free Software Foundation; either version 2 of the |
| 10 | License, or (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, but |
| 13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program; if not, write to the Free Software |
| 19 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 20 | 02111-1307, USA. |
| 21 | |
| 22 | The GNU General Public License is contained in the file COPYING. |
| 23 | */ |
| 24 | |
| 25 | |
| 26 | #ifndef __DRD_ERROR_H |
| 27 | #define __DRD_ERROR_H |
| 28 | |
| 29 | |
bart | b515eb1 | 2008-03-07 18:52:38 +0000 | [diff] [blame] | 30 | #include "pub_drd_bitmap.h" // BmAccessTypeT |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 31 | #include "drd_thread.h" // DrdThreadId |
| 32 | #include "pub_tool_basics.h" // SizeT |
| 33 | #include "pub_tool_debuginfo.h" // SegInfo |
| 34 | #include "pub_tool_errormgr.h" // ExeContext |
| 35 | |
| 36 | |
| 37 | /* DRD error types. */ |
| 38 | |
| 39 | typedef enum { |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 40 | #define STR_DataRaceErr "ConflictingAccess" |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 41 | DataRaceErr = 1, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 42 | #define STR_MutexErr "MutexErr" |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 43 | MutexErr = 2, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 44 | #define STR_CondErr "CondErr" |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 45 | CondErr = 3, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 46 | #define STR_CondRaceErr "CondRaceErr" |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 47 | CondRaceErr = 4, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 48 | #define STR_CondDestrErr "CondDestrErr" |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 49 | CondDestrErr = 5, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 50 | #define STR_SemaphoreErr "SemaphoreErr" |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 51 | SemaphoreErr = 6, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 52 | #define STR_BarrierErr "BarrierErr" |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 53 | BarrierErr = 7, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 54 | #define STR_RwlockErr "RwlockErr" |
bart | 777f7fe | 2008-03-02 17:43:18 +0000 | [diff] [blame] | 55 | RwlockErr = 8, |
bart | 5fc70e6 | 2008-03-23 07:54:02 +0000 | [diff] [blame] | 56 | #define STR_GenericErr "GenericErr" |
bart | 777f7fe | 2008-03-02 17:43:18 +0000 | [diff] [blame] | 57 | GenericErr = 9, |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 58 | } DrdErrorKind; |
| 59 | |
| 60 | /* The classification of a faulting address. */ |
| 61 | typedef |
| 62 | enum { |
| 63 | //Undescribed, // as-yet unclassified |
| 64 | eStack, |
| 65 | eUnknown, // classification yielded nothing useful |
| 66 | //Freed, |
| 67 | eMallocd, |
| 68 | eSegment, // in a segment (as defined in pub_tool_debuginfo.h) |
| 69 | //UserG, // in a user-defined block |
| 70 | //Mempool, // in a mempool |
| 71 | //Register, // in a register; for Param errors only |
| 72 | } |
| 73 | AddrKind; |
| 74 | |
| 75 | /* Records info about a faulting address. */ |
| 76 | typedef |
| 77 | struct { // Used by: |
| 78 | AddrKind akind; // ALL |
| 79 | SizeT size; // ALL |
| 80 | OffT rwoffset; // ALL |
| 81 | ExeContext* lastchange; // Mallocd |
| 82 | DrdThreadId stack_tid; // Stack |
sewardj | b8b79ad | 2008-03-03 01:35:41 +0000 | [diff] [blame] | 83 | DebugInfo* debuginfo; // Segment |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 84 | Char name[256]; // Segment |
| 85 | Char descr[256]; // Segment |
| 86 | } |
| 87 | AddrInfo; |
| 88 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 89 | typedef struct { |
bart | 354009c | 2008-03-16 10:42:33 +0000 | [diff] [blame] | 90 | DrdThreadId tid; // Thread ID of the running thread. |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 91 | Addr addr; // Conflicting address in current thread. |
| 92 | SizeT size; // Size in bytes of conflicting operation. |
| 93 | BmAccessTypeT access_type; // Access type: load or store. |
| 94 | } DataRaceErrInfo; |
| 95 | |
| 96 | typedef struct { |
| 97 | Addr mutex; |
| 98 | Int recursion_count; |
| 99 | DrdThreadId owner; |
| 100 | } MutexErrInfo; |
| 101 | |
| 102 | typedef struct { |
| 103 | Addr cond; |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 104 | } CondErrInfo; |
| 105 | |
| 106 | typedef struct { |
| 107 | Addr cond; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 108 | Addr mutex; |
| 109 | } CondRaceErrInfo; |
| 110 | |
| 111 | typedef struct { |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 112 | Addr cond; |
| 113 | Addr mutex; |
| 114 | DrdThreadId tid; |
| 115 | } CondDestrErrInfo; |
| 116 | |
| 117 | typedef struct { |
| 118 | Addr semaphore; |
| 119 | } SemaphoreErrInfo; |
| 120 | |
| 121 | typedef struct { |
| 122 | Addr barrier; |
| 123 | } BarrierErrInfo; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 124 | |
bart | e883bc8 | 2008-02-26 19:13:04 +0000 | [diff] [blame] | 125 | typedef struct { |
bart | 777f7fe | 2008-03-02 17:43:18 +0000 | [diff] [blame] | 126 | Addr rwlock; |
| 127 | } RwlockErrInfo; |
| 128 | |
| 129 | typedef struct { |
bart | e883bc8 | 2008-02-26 19:13:04 +0000 | [diff] [blame] | 130 | } GenericErrInfo; |
| 131 | |
bart | 16d76e5 | 2008-03-18 17:08:08 +0000 | [diff] [blame] | 132 | |
| 133 | void set_show_conflicting_segments(const Bool scs); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 134 | void drd_register_error_handlers(void); |
| 135 | |
| 136 | |
| 137 | #endif /* __DRD_ERROR_H */ |