blob: fbff475d5959dcb061f011d194488c40ba9b44f5 [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_CondRaceErr "CondRaceErr"
bart3b1ee452008-02-29 19:28:15 +000047 CondRaceErr = 4,
bart5fc70e62008-03-23 07:54:02 +000048#define STR_CondDestrErr "CondDestrErr"
bart3b1ee452008-02-29 19:28:15 +000049 CondDestrErr = 5,
bart5fc70e62008-03-23 07:54:02 +000050#define STR_SemaphoreErr "SemaphoreErr"
bart3b1ee452008-02-29 19:28:15 +000051 SemaphoreErr = 6,
bart5fc70e62008-03-23 07:54:02 +000052#define STR_BarrierErr "BarrierErr"
bart3b1ee452008-02-29 19:28:15 +000053 BarrierErr = 7,
bart5fc70e62008-03-23 07:54:02 +000054#define STR_RwlockErr "RwlockErr"
bart777f7fe2008-03-02 17:43:18 +000055 RwlockErr = 8,
bart9d5b7962008-05-14 12:25:00 +000056#define STR_HoldtimeErr "HoldtimeErr"
57 HoldtimeErr = 9,
bart5fc70e62008-03-23 07:54:02 +000058#define STR_GenericErr "GenericErr"
bart9d5b7962008-05-14 12:25:00 +000059 GenericErr = 10,
sewardjaf44c822007-11-25 14:01:38 +000060} DrdErrorKind;
61
62/* The classification of a faulting address. */
63typedef
64enum {
65 //Undescribed, // as-yet unclassified
66 eStack,
67 eUnknown, // classification yielded nothing useful
68 //Freed,
69 eMallocd,
70 eSegment, // in a segment (as defined in pub_tool_debuginfo.h)
71 //UserG, // in a user-defined block
72 //Mempool, // in a mempool
73 //Register, // in a register; for Param errors only
74}
75 AddrKind;
76
77/* Records info about a faulting address. */
78typedef
79struct { // Used by:
80 AddrKind akind; // ALL
81 SizeT size; // ALL
82 OffT rwoffset; // ALL
83 ExeContext* lastchange; // Mallocd
84 DrdThreadId stack_tid; // Stack
sewardjb8b79ad2008-03-03 01:35:41 +000085 DebugInfo* debuginfo; // Segment
sewardjaf44c822007-11-25 14:01:38 +000086 Char name[256]; // Segment
87 Char descr[256]; // Segment
88}
89 AddrInfo;
90
sewardjaf44c822007-11-25 14:01:38 +000091typedef struct {
bart354009c2008-03-16 10:42:33 +000092 DrdThreadId tid; // Thread ID of the running thread.
sewardjaf44c822007-11-25 14:01:38 +000093 Addr addr; // Conflicting address in current thread.
94 SizeT size; // Size in bytes of conflicting operation.
95 BmAccessTypeT access_type; // Access type: load or store.
96} DataRaceErrInfo;
97
98typedef struct {
99 Addr mutex;
100 Int recursion_count;
101 DrdThreadId owner;
102} MutexErrInfo;
103
104typedef struct {
105 Addr cond;
bart3b1ee452008-02-29 19:28:15 +0000106} CondErrInfo;
107
108typedef struct {
109 Addr cond;
sewardjaf44c822007-11-25 14:01:38 +0000110 Addr mutex;
111} CondRaceErrInfo;
112
113typedef struct {
bart3b1ee452008-02-29 19:28:15 +0000114 Addr cond;
115 Addr mutex;
116 DrdThreadId tid;
117} CondDestrErrInfo;
118
119typedef struct {
120 Addr semaphore;
121} SemaphoreErrInfo;
122
123typedef struct {
124 Addr barrier;
125} BarrierErrInfo;
sewardjaf44c822007-11-25 14:01:38 +0000126
barte883bc82008-02-26 19:13:04 +0000127typedef struct {
bart777f7fe2008-03-02 17:43:18 +0000128 Addr rwlock;
129} RwlockErrInfo;
130
131typedef struct {
bart9d5b7962008-05-14 12:25:00 +0000132 Addr synchronization_object;
133 ExeContext* acquired_at;
134 UInt hold_time_ms;
135 UInt threshold_ms;
136} HoldtimeErrInfo;
137
138typedef struct {
barte883bc82008-02-26 19:13:04 +0000139} GenericErrInfo;
140
bart16d76e52008-03-18 17:08:08 +0000141
142void set_show_conflicting_segments(const Bool scs);
sewardjaf44c822007-11-25 14:01:38 +0000143void drd_register_error_handlers(void);
144
145
146#endif /* __DRD_ERROR_H */