blob: 9dfdd61f161c032880c16762855c3dae1cf159fb [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
30#include "pub_drd_bitmap.h" // BmAccessTypeT
31#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,
47 GenericErr = 8,
sewardjaf44c822007-11-25 14:01:38 +000048} DrdErrorKind;
49
50/* The classification of a faulting address. */
51typedef
52enum {
53 //Undescribed, // as-yet unclassified
54 eStack,
55 eUnknown, // classification yielded nothing useful
56 //Freed,
57 eMallocd,
58 eSegment, // in a segment (as defined in pub_tool_debuginfo.h)
59 //UserG, // in a user-defined block
60 //Mempool, // in a mempool
61 //Register, // in a register; for Param errors only
62}
63 AddrKind;
64
65/* Records info about a faulting address. */
66typedef
67struct { // Used by:
68 AddrKind akind; // ALL
69 SizeT size; // ALL
70 OffT rwoffset; // ALL
71 ExeContext* lastchange; // Mallocd
72 DrdThreadId stack_tid; // Stack
73 SegInfo* seginfo; // Segment
74 Char name[256]; // Segment
75 Char descr[256]; // Segment
76}
77 AddrInfo;
78
sewardjaf44c822007-11-25 14:01:38 +000079typedef struct {
80 ThreadId tid; // Thread ID of the running thread.
81 Addr addr; // Conflicting address in current thread.
82 SizeT size; // Size in bytes of conflicting operation.
83 BmAccessTypeT access_type; // Access type: load or store.
84} DataRaceErrInfo;
85
86typedef struct {
87 Addr mutex;
88 Int recursion_count;
89 DrdThreadId owner;
90} MutexErrInfo;
91
92typedef struct {
93 Addr cond;
bart3b1ee452008-02-29 19:28:15 +000094} CondErrInfo;
95
96typedef struct {
97 Addr cond;
sewardjaf44c822007-11-25 14:01:38 +000098 Addr mutex;
99} CondRaceErrInfo;
100
101typedef struct {
bart3b1ee452008-02-29 19:28:15 +0000102 Addr cond;
103 Addr mutex;
104 DrdThreadId tid;
105} CondDestrErrInfo;
106
107typedef struct {
108 Addr semaphore;
109} SemaphoreErrInfo;
110
111typedef struct {
112 Addr barrier;
113} BarrierErrInfo;
sewardjaf44c822007-11-25 14:01:38 +0000114
barte883bc82008-02-26 19:13:04 +0000115typedef struct {
116} GenericErrInfo;
117
sewardjaf44c822007-11-25 14:01:38 +0000118void describe_addr(Addr const a, SizeT const len, AddrInfo* const ai);
119Char* describe_addr_text(Addr const a, SizeT const len, AddrInfo* const ai,
120 Char* const buf, UInt const n_buf);
sewardjaf44c822007-11-25 14:01:38 +0000121void drd_register_error_handlers(void);
122
123
124#endif /* __DRD_ERROR_H */
125
126
127/*
128 * Local variables:
129 * c-basic-offset: 3
130 * End:
131 */