blob: 34fd62b1142b2b2116177dad8112e788edddd7c1 [file] [log] [blame]
sewardjaf44c822007-11-25 14:01:38 +00001/*
bart86562bd2009-02-16 19:43:56 +00002 This file is part of drd, a thread error detector.
sewardjaf44c822007-11-25 14:01:38 +00003
bart86562bd2009-02-16 19:43:56 +00004 Copyright (C) 2006-2009 Bart Van Assche <bart.vanassche@gmail.com>.
sewardjaf44c822007-11-25 14:01:38 +00005
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307, USA.
20
21 The GNU General Public License is contained in the file COPYING.
22*/
23
24
25#ifndef __DRD_ERROR_H
26#define __DRD_ERROR_H
27
28
bartb515eb12008-03-07 18:52:38 +000029#include "pub_drd_bitmap.h" // BmAccessTypeT
sewardjaf44c822007-11-25 14:01:38 +000030#include "drd_thread.h" // DrdThreadId
31#include "pub_tool_basics.h" // SizeT
32#include "pub_tool_debuginfo.h" // SegInfo
33#include "pub_tool_errormgr.h" // ExeContext
34
35
36/* DRD error types. */
37
38typedef enum {
bart5fc70e62008-03-23 07:54:02 +000039#define STR_DataRaceErr "ConflictingAccess"
sewardjaf44c822007-11-25 14:01:38 +000040 DataRaceErr = 1,
bart5fc70e62008-03-23 07:54:02 +000041#define STR_MutexErr "MutexErr"
sewardjaf44c822007-11-25 14:01:38 +000042 MutexErr = 2,
bart5fc70e62008-03-23 07:54:02 +000043#define STR_CondErr "CondErr"
bart3b1ee452008-02-29 19:28:15 +000044 CondErr = 3,
bart5fc70e62008-03-23 07:54:02 +000045#define STR_CondDestrErr "CondDestrErr"
bart3bb1cec2008-06-28 16:01:43 +000046 CondDestrErr = 4,
47#define STR_CondRaceErr "CondRaceErr"
48 CondRaceErr = 5,
49#define STR_CondWaitErr "CondWaitErr"
50 CondWaitErr = 6,
bart5fc70e62008-03-23 07:54:02 +000051#define STR_SemaphoreErr "SemaphoreErr"
bart3bb1cec2008-06-28 16:01:43 +000052 SemaphoreErr = 7,
bart5fc70e62008-03-23 07:54:02 +000053#define STR_BarrierErr "BarrierErr"
bart3bb1cec2008-06-28 16:01:43 +000054 BarrierErr = 8,
bart5fc70e62008-03-23 07:54:02 +000055#define STR_RwlockErr "RwlockErr"
bart3bb1cec2008-06-28 16:01:43 +000056 RwlockErr = 9,
bart9d5b7962008-05-14 12:25:00 +000057#define STR_HoldtimeErr "HoldtimeErr"
bart3bb1cec2008-06-28 16:01:43 +000058 HoldtimeErr = 10,
bart5fc70e62008-03-23 07:54:02 +000059#define STR_GenericErr "GenericErr"
bart3bb1cec2008-06-28 16:01:43 +000060 GenericErr = 11,
sewardjaf44c822007-11-25 14:01:38 +000061} DrdErrorKind;
62
63/* The classification of a faulting address. */
64typedef
65enum {
66 //Undescribed, // as-yet unclassified
67 eStack,
68 eUnknown, // classification yielded nothing useful
69 //Freed,
70 eMallocd,
71 eSegment, // in a segment (as defined in pub_tool_debuginfo.h)
72 //UserG, // in a user-defined block
73 //Mempool, // in a mempool
74 //Register, // in a register; for Param errors only
75}
76 AddrKind;
77
78/* Records info about a faulting address. */
79typedef
80struct { // Used by:
81 AddrKind akind; // ALL
82 SizeT size; // ALL
njnc4431bf2009-01-15 21:29:24 +000083 PtrdiffT rwoffset; // ALL
sewardjaf44c822007-11-25 14:01:38 +000084 ExeContext* lastchange; // Mallocd
85 DrdThreadId stack_tid; // Stack
sewardjb8b79ad2008-03-03 01:35:41 +000086 DebugInfo* debuginfo; // Segment
sewardjaf44c822007-11-25 14:01:38 +000087 Char name[256]; // Segment
88 Char descr[256]; // Segment
89}
90 AddrInfo;
91
sewardjaf44c822007-11-25 14:01:38 +000092typedef struct {
bart354009c2008-03-16 10:42:33 +000093 DrdThreadId tid; // Thread ID of the running thread.
sewardjaf44c822007-11-25 14:01:38 +000094 Addr addr; // Conflicting address in current thread.
95 SizeT size; // Size in bytes of conflicting operation.
96 BmAccessTypeT access_type; // Access type: load or store.
97} DataRaceErrInfo;
98
99typedef struct {
100 Addr mutex;
101 Int recursion_count;
102 DrdThreadId owner;
103} MutexErrInfo;
104
105typedef struct {
106 Addr cond;
bart3b1ee452008-02-29 19:28:15 +0000107} CondErrInfo;
108
109typedef struct {
bart3bb1cec2008-06-28 16:01:43 +0000110 Addr cond;
111 Addr mutex;
112 DrdThreadId tid;
113} CondDestrErrInfo;
114
115typedef struct {
bart3b1ee452008-02-29 19:28:15 +0000116 Addr cond;
sewardjaf44c822007-11-25 14:01:38 +0000117 Addr mutex;
118} CondRaceErrInfo;
119
120typedef struct {
bart3bb1cec2008-06-28 16:01:43 +0000121 Addr cond;
122 Addr mutex1;
123 Addr mutex2;
124} CondWaitErrInfo;
bart3b1ee452008-02-29 19:28:15 +0000125
126typedef struct {
127 Addr semaphore;
128} SemaphoreErrInfo;
129
130typedef struct {
bartd2c5eae2009-02-21 15:27:04 +0000131 Addr barrier;
132 DrdThreadId other_tid;
133 ExeContext* other_context;
bart3b1ee452008-02-29 19:28:15 +0000134} BarrierErrInfo;
sewardjaf44c822007-11-25 14:01:38 +0000135
barte883bc82008-02-26 19:13:04 +0000136typedef struct {
bart777f7fe2008-03-02 17:43:18 +0000137 Addr rwlock;
138} RwlockErrInfo;
139
140typedef struct {
bart9d5b7962008-05-14 12:25:00 +0000141 Addr synchronization_object;
142 ExeContext* acquired_at;
143 UInt hold_time_ms;
144 UInt threshold_ms;
145} HoldtimeErrInfo;
146
147typedef struct {
barte883bc82008-02-26 19:13:04 +0000148} GenericErrInfo;
149
bart16d76e52008-03-18 17:08:08 +0000150
bart246fbf22009-02-15 14:46:17 +0000151void DRD_(set_show_conflicting_segments)(const Bool scs);
bart1335ecc2009-02-14 16:10:53 +0000152void DRD_(register_error_handlers)(void);
sewardjaf44c822007-11-25 14:01:38 +0000153
154
155#endif /* __DRD_ERROR_H */