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 | |
| 30 | #include "pub_drd_bitmap.h" // BmAccessTypeT |
| 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, |
| 42 | CondRaceErr = 3, |
bart | e883bc8 | 2008-02-26 19:13:04 +0000 | [diff] [blame^] | 43 | CondErr = 4, |
| 44 | GenericErr = 5, |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 45 | } DrdErrorKind; |
| 46 | |
| 47 | /* The classification of a faulting address. */ |
| 48 | typedef |
| 49 | enum { |
| 50 | //Undescribed, // as-yet unclassified |
| 51 | eStack, |
| 52 | eUnknown, // classification yielded nothing useful |
| 53 | //Freed, |
| 54 | eMallocd, |
| 55 | eSegment, // in a segment (as defined in pub_tool_debuginfo.h) |
| 56 | //UserG, // in a user-defined block |
| 57 | //Mempool, // in a mempool |
| 58 | //Register, // in a register; for Param errors only |
| 59 | } |
| 60 | AddrKind; |
| 61 | |
| 62 | /* Records info about a faulting address. */ |
| 63 | typedef |
| 64 | struct { // Used by: |
| 65 | AddrKind akind; // ALL |
| 66 | SizeT size; // ALL |
| 67 | OffT rwoffset; // ALL |
| 68 | ExeContext* lastchange; // Mallocd |
| 69 | DrdThreadId stack_tid; // Stack |
| 70 | SegInfo* seginfo; // Segment |
| 71 | Char name[256]; // Segment |
| 72 | Char descr[256]; // Segment |
| 73 | } |
| 74 | AddrInfo; |
| 75 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 76 | typedef struct { |
| 77 | ThreadId tid; // Thread ID of the running thread. |
| 78 | Addr addr; // Conflicting address in current thread. |
| 79 | SizeT size; // Size in bytes of conflicting operation. |
| 80 | BmAccessTypeT access_type; // Access type: load or store. |
| 81 | } DataRaceErrInfo; |
| 82 | |
| 83 | typedef struct { |
| 84 | Addr mutex; |
| 85 | Int recursion_count; |
| 86 | DrdThreadId owner; |
| 87 | } MutexErrInfo; |
| 88 | |
| 89 | typedef struct { |
| 90 | Addr cond; |
| 91 | Addr mutex; |
| 92 | } CondRaceErrInfo; |
| 93 | |
| 94 | typedef struct { |
| 95 | Addr cond; |
| 96 | } CondErrInfo; |
| 97 | |
bart | e883bc8 | 2008-02-26 19:13:04 +0000 | [diff] [blame^] | 98 | typedef struct { |
| 99 | } GenericErrInfo; |
| 100 | |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 101 | void describe_addr(Addr const a, SizeT const len, AddrInfo* const ai); |
| 102 | Char* describe_addr_text(Addr const a, SizeT const len, AddrInfo* const ai, |
| 103 | Char* const buf, UInt const n_buf); |
sewardj | af44c82 | 2007-11-25 14:01:38 +0000 | [diff] [blame] | 104 | void drd_register_error_handlers(void); |
| 105 | |
| 106 | |
| 107 | #endif /* __DRD_ERROR_H */ |
| 108 | |
| 109 | |
| 110 | /* |
| 111 | * Local variables: |
| 112 | * c-basic-offset: 3 |
| 113 | * End: |
| 114 | */ |