blob: e9a54c48b3c269bf3d8362fa68960c1961bb10a1 [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,
42 CondRaceErr = 3,
barte883bc82008-02-26 19:13:04 +000043 CondErr = 4,
44 GenericErr = 5,
sewardjaf44c822007-11-25 14:01:38 +000045} DrdErrorKind;
46
47/* The classification of a faulting address. */
48typedef
49enum {
50 //Undescribed, // as-yet unclassified
51 eStack,
52 eUnknown, // classification yielded nothing useful
53 //Freed,
54 eMallocd,
55 eSegment, // in a segment (as defined in pub_tool_debuginfo.h)
56 //UserG, // in a user-defined block
57 //Mempool, // in a mempool
58 //Register, // in a register; for Param errors only
59}
60 AddrKind;
61
62/* Records info about a faulting address. */
63typedef
64struct { // Used by:
65 AddrKind akind; // ALL
66 SizeT size; // ALL
67 OffT rwoffset; // ALL
68 ExeContext* lastchange; // Mallocd
69 DrdThreadId stack_tid; // Stack
70 SegInfo* seginfo; // Segment
71 Char name[256]; // Segment
72 Char descr[256]; // Segment
73}
74 AddrInfo;
75
sewardjaf44c822007-11-25 14:01:38 +000076typedef struct {
77 ThreadId tid; // Thread ID of the running thread.
78 Addr addr; // Conflicting address in current thread.
79 SizeT size; // Size in bytes of conflicting operation.
80 BmAccessTypeT access_type; // Access type: load or store.
81} DataRaceErrInfo;
82
83typedef struct {
84 Addr mutex;
85 Int recursion_count;
86 DrdThreadId owner;
87} MutexErrInfo;
88
89typedef struct {
90 Addr cond;
91 Addr mutex;
92} CondRaceErrInfo;
93
94typedef struct {
95 Addr cond;
96} CondErrInfo;
97
barte883bc82008-02-26 19:13:04 +000098typedef struct {
99} GenericErrInfo;
100
sewardjaf44c822007-11-25 14:01:38 +0000101void describe_addr(Addr const a, SizeT const len, AddrInfo* const ai);
102Char* describe_addr_text(Addr const a, SizeT const len, AddrInfo* const ai,
103 Char* const buf, UInt const n_buf);
sewardjaf44c822007-11-25 14:01:38 +0000104void drd_register_error_handlers(void);
105
106
107#endif /* __DRD_ERROR_H */
108
109
110/*
111 * Local variables:
112 * c-basic-offset: 3
113 * End:
114 */