blob: 1bbd066a22d61bd690ecedcf9f3723bd191ac70c [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 {
40 DataRaceErr = 1,
41 MutexErr = 2,
bart3b1ee452008-02-29 19:28:15 +000042 CondErr = 3,
43 CondRaceErr = 4,
44 CondDestrErr = 5,
45 SemaphoreErr = 6,
46 BarrierErr = 7,
bart777f7fe2008-03-02 17:43:18 +000047 RwlockErr = 8,
48 GenericErr = 9,
sewardjaf44c822007-11-25 14:01:38 +000049} DrdErrorKind;
50
51/* The classification of a faulting address. */
52typedef
53enum {
54 //Undescribed, // as-yet unclassified
55 eStack,
56 eUnknown, // classification yielded nothing useful
57 //Freed,
58 eMallocd,
59 eSegment, // in a segment (as defined in pub_tool_debuginfo.h)
60 //UserG, // in a user-defined block
61 //Mempool, // in a mempool
62 //Register, // in a register; for Param errors only
63}
64 AddrKind;
65
66/* Records info about a faulting address. */
67typedef
68struct { // Used by:
69 AddrKind akind; // ALL
70 SizeT size; // ALL
71 OffT rwoffset; // ALL
72 ExeContext* lastchange; // Mallocd
73 DrdThreadId stack_tid; // Stack
sewardjb8b79ad2008-03-03 01:35:41 +000074 DebugInfo* debuginfo; // Segment
sewardjaf44c822007-11-25 14:01:38 +000075 Char name[256]; // Segment
76 Char descr[256]; // Segment
77}
78 AddrInfo;
79
sewardjaf44c822007-11-25 14:01:38 +000080typedef struct {
bart354009c2008-03-16 10:42:33 +000081 DrdThreadId tid; // Thread ID of the running thread.
sewardjaf44c822007-11-25 14:01:38 +000082 Addr addr; // Conflicting address in current thread.
83 SizeT size; // Size in bytes of conflicting operation.
84 BmAccessTypeT access_type; // Access type: load or store.
85} DataRaceErrInfo;
86
87typedef struct {
88 Addr mutex;
89 Int recursion_count;
90 DrdThreadId owner;
91} MutexErrInfo;
92
93typedef struct {
94 Addr cond;
bart3b1ee452008-02-29 19:28:15 +000095} CondErrInfo;
96
97typedef struct {
98 Addr cond;
sewardjaf44c822007-11-25 14:01:38 +000099 Addr mutex;
100} CondRaceErrInfo;
101
102typedef struct {
bart3b1ee452008-02-29 19:28:15 +0000103 Addr cond;
104 Addr mutex;
105 DrdThreadId tid;
106} CondDestrErrInfo;
107
108typedef struct {
109 Addr semaphore;
110} SemaphoreErrInfo;
111
112typedef struct {
113 Addr barrier;
114} BarrierErrInfo;
sewardjaf44c822007-11-25 14:01:38 +0000115
barte883bc82008-02-26 19:13:04 +0000116typedef struct {
bart777f7fe2008-03-02 17:43:18 +0000117 Addr rwlock;
118} RwlockErrInfo;
119
120typedef struct {
barte883bc82008-02-26 19:13:04 +0000121} GenericErrInfo;
122
bart16d76e52008-03-18 17:08:08 +0000123
124void set_show_conflicting_segments(const Bool scs);
sewardjaf44c822007-11-25 14:01:38 +0000125void drd_register_error_handlers(void);
126
127
128#endif /* __DRD_ERROR_H */