blob: a9002913096d6c6bee2631a74e6164f0e9eb32c7 [file] [log] [blame]
bartbedfd232009-03-26 19:07:15 +00001/* -*- mode: C; c-basic-offset: 3; -*- */
sewardjaf44c822007-11-25 14:01:38 +00002/*
bart86562bd2009-02-16 19:43:56 +00003 This file is part of drd, a thread error detector.
sewardjaf44c822007-11-25 14:01:38 +00004
bart876cafd2010-10-10 18:07:31 +00005 Copyright (C) 2006-2010 Bart Van Assche <bvanassche@acm.org>.
sewardjaf44c822007-11-25 14:01:38 +00006
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,
bartb48bde22009-07-31 08:26:17 +000062#define STR_InvalidThreadId "InvalidThreadId"
63 InvalidThreadId = 12,
bart141a7ed2010-03-21 17:28:10 +000064#define STR_UnimpHgClReq "UnimpHgClReq"
65 UnimpHgClReq = 13,
66#define STR_UnimpDrdClReq "UnimpDrdClReq"
67 UnimpDrdClReq = 14,
sewardjaf44c822007-11-25 14:01:38 +000068} DrdErrorKind;
69
70/* The classification of a faulting address. */
bart31b983d2010-02-21 14:52:59 +000071typedef
72enum {
sewardjaf44c822007-11-25 14:01:38 +000073 //Undescribed, // as-yet unclassified
bart31b983d2010-02-21 14:52:59 +000074 eStack,
sewardjaf44c822007-11-25 14:01:38 +000075 eUnknown, // classification yielded nothing useful
76 //Freed,
bart31b983d2010-02-21 14:52:59 +000077 eMallocd,
sewardjaf44c822007-11-25 14:01:38 +000078 eSegment, // in a segment (as defined in pub_tool_debuginfo.h)
79 //UserG, // in a user-defined block
80 //Mempool, // in a mempool
81 //Register, // in a register; for Param errors only
82}
83 AddrKind;
84
85/* Records info about a faulting address. */
86typedef
87struct { // Used by:
88 AddrKind akind; // ALL
89 SizeT size; // ALL
njnc4431bf2009-01-15 21:29:24 +000090 PtrdiffT rwoffset; // ALL
sewardjaf44c822007-11-25 14:01:38 +000091 ExeContext* lastchange; // Mallocd
92 DrdThreadId stack_tid; // Stack
sewardjb8b79ad2008-03-03 01:35:41 +000093 DebugInfo* debuginfo; // Segment
sewardjaf44c822007-11-25 14:01:38 +000094 Char name[256]; // Segment
95 Char descr[256]; // Segment
bartd45d9952009-05-31 18:53:54 +000096} AddrInfo;
sewardjaf44c822007-11-25 14:01:38 +000097
bartd45d9952009-05-31 18:53:54 +000098/*
99 * NOTE: the first member of each error info structure MUST be the thread ID
100 * in which the error has been observed.
101 */
sewardjaf44c822007-11-25 14:01:38 +0000102typedef struct {
bart354009c2008-03-16 10:42:33 +0000103 DrdThreadId tid; // Thread ID of the running thread.
sewardjaf44c822007-11-25 14:01:38 +0000104 Addr addr; // Conflicting address in current thread.
105 SizeT size; // Size in bytes of conflicting operation.
106 BmAccessTypeT access_type; // Access type: load or store.
107} DataRaceErrInfo;
108
109typedef struct {
bartd45d9952009-05-31 18:53:54 +0000110 DrdThreadId tid;
111 Addr mutex;
112 Int recursion_count;
sewardjaf44c822007-11-25 14:01:38 +0000113 DrdThreadId owner;
114} MutexErrInfo;
115
116typedef struct {
bartd45d9952009-05-31 18:53:54 +0000117 DrdThreadId tid;
118 Addr cond;
bart3b1ee452008-02-29 19:28:15 +0000119} CondErrInfo;
120
121typedef struct {
bartd45d9952009-05-31 18:53:54 +0000122 DrdThreadId tid;
bart3bb1cec2008-06-28 16:01:43 +0000123 Addr cond;
124 Addr mutex;
bartd45d9952009-05-31 18:53:54 +0000125 DrdThreadId owner;
bart3bb1cec2008-06-28 16:01:43 +0000126} CondDestrErrInfo;
127
128typedef struct {
bartd45d9952009-05-31 18:53:54 +0000129 DrdThreadId tid;
130 Addr cond;
131 Addr mutex;
sewardjaf44c822007-11-25 14:01:38 +0000132} CondRaceErrInfo;
133
134typedef struct {
bartd45d9952009-05-31 18:53:54 +0000135 DrdThreadId tid;
136 Addr cond;
137 Addr mutex1;
138 Addr mutex2;
bart3bb1cec2008-06-28 16:01:43 +0000139} CondWaitErrInfo;
bart3b1ee452008-02-29 19:28:15 +0000140
141typedef struct {
bartd45d9952009-05-31 18:53:54 +0000142 DrdThreadId tid;
143 Addr semaphore;
bart3b1ee452008-02-29 19:28:15 +0000144} SemaphoreErrInfo;
145
146typedef struct {
bartd45d9952009-05-31 18:53:54 +0000147 DrdThreadId tid;
bartd2c5eae2009-02-21 15:27:04 +0000148 Addr barrier;
149 DrdThreadId other_tid;
150 ExeContext* other_context;
bart3b1ee452008-02-29 19:28:15 +0000151} BarrierErrInfo;
sewardjaf44c822007-11-25 14:01:38 +0000152
barte883bc82008-02-26 19:13:04 +0000153typedef struct {
bartd45d9952009-05-31 18:53:54 +0000154 DrdThreadId tid;
155 Addr rwlock;
bart777f7fe2008-03-02 17:43:18 +0000156} RwlockErrInfo;
157
158typedef struct {
bartd45d9952009-05-31 18:53:54 +0000159 DrdThreadId tid;
bartbedfd232009-03-26 19:07:15 +0000160 Addr synchronization_object;
161 ExeContext* acquired_at;
162 UInt hold_time_ms;
163 UInt threshold_ms;
bart9d5b7962008-05-14 12:25:00 +0000164} HoldtimeErrInfo;
165
166typedef struct {
bartd45d9952009-05-31 18:53:54 +0000167 DrdThreadId tid;
bart62cc2322010-03-07 10:54:21 +0000168 Addr addr;
barte883bc82008-02-26 19:13:04 +0000169} GenericErrInfo;
170
bartb48bde22009-07-31 08:26:17 +0000171typedef struct {
172 DrdThreadId tid;
173 ULong ptid;
174} InvalidThreadIdInfo;
bart16d76e52008-03-18 17:08:08 +0000175
bart66f196d2009-08-15 10:50:35 +0000176typedef struct {
177 DrdThreadId tid;
178 Char* descr;
179} UnimpClReqInfo;
180
bart246fbf22009-02-15 14:46:17 +0000181void DRD_(set_show_conflicting_segments)(const Bool scs);
bart1335ecc2009-02-14 16:10:53 +0000182void DRD_(register_error_handlers)(void);
sewardjaf44c822007-11-25 14:01:38 +0000183
184
185#endif /* __DRD_ERROR_H */