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 { |
| 40 | DataRaceErr = 1, |
| 41 | MutexErr = 2, |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 42 | CondErr = 3, |
| 43 | CondRaceErr = 4, |
| 44 | CondDestrErr = 5, |
| 45 | SemaphoreErr = 6, |
| 46 | BarrierErr = 7, |
bart | 777f7fe | 2008-03-02 17:43:18 +0000 | [diff] [blame] | 47 | RwlockErr = 8, |
| 48 | GenericErr = 9, |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 49 | } DrdErrorKind; |
| 50 | |
| 51 | /* The classification of a faulting address. */ |
| 52 | typedef |
| 53 | enum { |
| 54 | //Undescribed, // as-yet unclassified |
| 55 | eStack, |
| 56 | eUnknown, // classification yielded nothing useful |
| 57 | //Freed, |
| 58 | eMallocd, |
| 59 | eSegment, // in a segment (as defined in pub_tool_debuginfo.h) |
| 60 | //UserG, // in a user-defined block |
| 61 | //Mempool, // in a mempool |
| 62 | //Register, // in a register; for Param errors only |
| 63 | } |
| 64 | AddrKind; |
| 65 | |
| 66 | /* Records info about a faulting address. */ |
| 67 | typedef |
| 68 | struct { // Used by: |
| 69 | AddrKind akind; // ALL |
| 70 | SizeT size; // ALL |
| 71 | OffT rwoffset; // ALL |
| 72 | ExeContext* lastchange; // Mallocd |
| 73 | DrdThreadId stack_tid; // Stack |
sewardj | b8b79ad | 2008-03-03 01:35:41 +0000 | [diff] [blame] | 74 | DebugInfo* debuginfo; // Segment |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 75 | Char name[256]; // Segment |
| 76 | Char descr[256]; // Segment |
| 77 | } |
| 78 | AddrInfo; |
| 79 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 80 | typedef struct { |
bart | 354009c | 2008-03-16 10:42:33 +0000 | [diff] [blame] | 81 | DrdThreadId tid; // Thread ID of the running thread. |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 82 | Addr addr; // Conflicting address in current thread. |
| 83 | SizeT size; // Size in bytes of conflicting operation. |
| 84 | BmAccessTypeT access_type; // Access type: load or store. |
| 85 | } DataRaceErrInfo; |
| 86 | |
| 87 | typedef struct { |
| 88 | Addr mutex; |
| 89 | Int recursion_count; |
| 90 | DrdThreadId owner; |
| 91 | } MutexErrInfo; |
| 92 | |
| 93 | typedef struct { |
| 94 | Addr cond; |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 95 | } CondErrInfo; |
| 96 | |
| 97 | typedef struct { |
| 98 | Addr cond; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 99 | Addr mutex; |
| 100 | } CondRaceErrInfo; |
| 101 | |
| 102 | typedef struct { |
bart | 3b1ee45 | 2008-02-29 19:28:15 +0000 | [diff] [blame] | 103 | Addr cond; |
| 104 | Addr mutex; |
| 105 | DrdThreadId tid; |
| 106 | } CondDestrErrInfo; |
| 107 | |
| 108 | typedef struct { |
| 109 | Addr semaphore; |
| 110 | } SemaphoreErrInfo; |
| 111 | |
| 112 | typedef struct { |
| 113 | Addr barrier; |
| 114 | } BarrierErrInfo; |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 115 | |
bart | e883bc8 | 2008-02-26 19:13:04 +0000 | [diff] [blame] | 116 | typedef struct { |
bart | 777f7fe | 2008-03-02 17:43:18 +0000 | [diff] [blame] | 117 | Addr rwlock; |
| 118 | } RwlockErrInfo; |
| 119 | |
| 120 | typedef struct { |
bart | e883bc8 | 2008-02-26 19:13:04 +0000 | [diff] [blame] | 121 | } GenericErrInfo; |
| 122 | |
bart | 16d76e5 | 2008-03-18 17:08:08 +0000 | [diff] [blame^] | 123 | |
| 124 | void set_show_conflicting_segments(const Bool scs); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 125 | void drd_register_error_handlers(void); |
| 126 | |
| 127 | |
| 128 | #endif /* __DRD_ERROR_H */ |