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