blob: 4035122940f913b054b23df6777a84ddcb9b1cc3 [file] [log] [blame]
sewardjaf44c822007-11-25 14:01:38 +00001/*
2 This file is part of drd, a data race detector.
3
sewardj85642922008-01-14 11:54:56 +00004 Copyright (C) 2006-2008 Bart Van Assche
sewardjaf44c822007-11-25 14:01:38 +00005 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
bartb515eb12008-03-07 18:52:38 +000030#include "pub_drd_bitmap.h" // BmAccessTypeT
sewardjaf44c822007-11-25 14:01:38 +000031#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
39typedef enum {
bart5fc70e62008-03-23 07:54:02 +000040#define STR_DataRaceErr "ConflictingAccess"
sewardjaf44c822007-11-25 14:01:38 +000041 DataRaceErr = 1,
bart5fc70e62008-03-23 07:54:02 +000042#define STR_MutexErr "MutexErr"
sewardjaf44c822007-11-25 14:01:38 +000043 MutexErr = 2,
bart5fc70e62008-03-23 07:54:02 +000044#define STR_CondErr "CondErr"
bart3b1ee452008-02-29 19:28:15 +000045 CondErr = 3,
bart5fc70e62008-03-23 07:54:02 +000046#define STR_CondDestrErr "CondDestrErr"
bart3bb1cec2008-06-28 16:01:43 +000047 CondDestrErr = 4,
48#define STR_CondRaceErr "CondRaceErr"
49 CondRaceErr = 5,
50#define STR_CondWaitErr "CondWaitErr"
51 CondWaitErr = 6,
bart5fc70e62008-03-23 07:54:02 +000052#define STR_SemaphoreErr "SemaphoreErr"
bart3bb1cec2008-06-28 16:01:43 +000053 SemaphoreErr = 7,
bart5fc70e62008-03-23 07:54:02 +000054#define STR_BarrierErr "BarrierErr"
bart3bb1cec2008-06-28 16:01:43 +000055 BarrierErr = 8,
bart5fc70e62008-03-23 07:54:02 +000056#define STR_RwlockErr "RwlockErr"
bart3bb1cec2008-06-28 16:01:43 +000057 RwlockErr = 9,
bart9d5b7962008-05-14 12:25:00 +000058#define STR_HoldtimeErr "HoldtimeErr"
bart3bb1cec2008-06-28 16:01:43 +000059 HoldtimeErr = 10,
bart5fc70e62008-03-23 07:54:02 +000060#define STR_GenericErr "GenericErr"
bart3bb1cec2008-06-28 16:01:43 +000061 GenericErr = 11,
sewardjaf44c822007-11-25 14:01:38 +000062} DrdErrorKind;
63
64/* The classification of a faulting address. */
65typedef
66enum {
67 //Undescribed, // as-yet unclassified
68 eStack,
69 eUnknown, // classification yielded nothing useful
70 //Freed,
71 eMallocd,
72 eSegment, // in a segment (as defined in pub_tool_debuginfo.h)
73 //UserG, // in a user-defined block
74 //Mempool, // in a mempool
75 //Register, // in a register; for Param errors only
76}
77 AddrKind;
78
79/* Records info about a faulting address. */
80typedef
81struct { // Used by:
82 AddrKind akind; // ALL
83 SizeT size; // ALL
njnc4431bf2009-01-15 21:29:24 +000084 PtrdiffT rwoffset; // ALL
sewardjaf44c822007-11-25 14:01:38 +000085 ExeContext* lastchange; // Mallocd
86 DrdThreadId stack_tid; // Stack
sewardjb8b79ad2008-03-03 01:35:41 +000087 DebugInfo* debuginfo; // Segment
sewardjaf44c822007-11-25 14:01:38 +000088 Char name[256]; // Segment
89 Char descr[256]; // Segment
90}
91 AddrInfo;
92
sewardjaf44c822007-11-25 14:01:38 +000093typedef struct {
bart354009c2008-03-16 10:42:33 +000094 DrdThreadId tid; // Thread ID of the running thread.
sewardjaf44c822007-11-25 14:01:38 +000095 Addr addr; // Conflicting address in current thread.
96 SizeT size; // Size in bytes of conflicting operation.
97 BmAccessTypeT access_type; // Access type: load or store.
98} DataRaceErrInfo;
99
100typedef struct {
101 Addr mutex;
102 Int recursion_count;
103 DrdThreadId owner;
104} MutexErrInfo;
105
106typedef struct {
107 Addr cond;
bart3b1ee452008-02-29 19:28:15 +0000108} CondErrInfo;
109
110typedef struct {
bart3bb1cec2008-06-28 16:01:43 +0000111 Addr cond;
112 Addr mutex;
113 DrdThreadId tid;
114} CondDestrErrInfo;
115
116typedef struct {
bart3b1ee452008-02-29 19:28:15 +0000117 Addr cond;
sewardjaf44c822007-11-25 14:01:38 +0000118 Addr mutex;
119} CondRaceErrInfo;
120
121typedef struct {
bart3bb1cec2008-06-28 16:01:43 +0000122 Addr cond;
123 Addr mutex1;
124 Addr mutex2;
125} CondWaitErrInfo;
bart3b1ee452008-02-29 19:28:15 +0000126
127typedef struct {
128 Addr semaphore;
129} SemaphoreErrInfo;
130
131typedef struct {
132 Addr barrier;
133} BarrierErrInfo;
sewardjaf44c822007-11-25 14:01:38 +0000134
barte883bc82008-02-26 19:13:04 +0000135typedef struct {
bart777f7fe2008-03-02 17:43:18 +0000136 Addr rwlock;
137} RwlockErrInfo;
138
139typedef struct {
bart9d5b7962008-05-14 12:25:00 +0000140 Addr synchronization_object;
141 ExeContext* acquired_at;
142 UInt hold_time_ms;
143 UInt threshold_ms;
144} HoldtimeErrInfo;
145
146typedef struct {
barte883bc82008-02-26 19:13:04 +0000147} GenericErrInfo;
148
bart16d76e52008-03-18 17:08:08 +0000149
150void set_show_conflicting_segments(const Bool scs);
bart1335ecc2009-02-14 16:10:53 +0000151void DRD_(register_error_handlers)(void);
sewardjaf44c822007-11-25 14:01:38 +0000152
153
154#endif /* __DRD_ERROR_H */