Helgrind: add suppression for libnss from getaddrinfo
[valgrind.git] / drd / drd_clientobj.h
blob5a99f1e372a8c1fa7a089e3ea7e2ea90e0096f30
1 /*
2 This file is part of drd, a thread error detector.
4 Copyright (C) 2006-2020 Bart Van Assche <bvanassche@acm.org>.
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
19 The GNU General Public License is contained in the file COPYING.
23 #ifndef __DRD_CLIENTOBJ_H
24 #define __DRD_CLIENTOBJ_H
27 #include "drd_basics.h" /* DrdThreadId */
28 #include "drd_clientreq.h" /* MutexT */
29 #include "pub_tool_basics.h"
30 #include "pub_tool_execontext.h" /* ExeContext */
31 #include "pub_tool_oset.h"
32 #include "pub_tool_xarray.h"
35 /* Forward declarations. */
37 union drd_clientobj;
40 /* Type definitions. */
42 typedef enum {
43 ClientMutex = 1,
44 ClientCondvar = 2,
45 ClientHbvar = 3,
46 ClientSemaphore = 4,
47 ClientBarrier = 5,
48 ClientRwlock = 6,
49 } ObjType;
51 struct any
53 Addr a1;
54 ObjType type;
55 void (*cleanup)(union drd_clientobj*);
56 void (*delete_thread)(union drd_clientobj*, DrdThreadId);
57 ExeContext* first_observed_at;
60 struct mutex_info
62 Addr a1;
63 ObjType type;
64 void (*cleanup)(union drd_clientobj*);
65 void (*delete_thread)(union drd_clientobj*, DrdThreadId);
66 ExeContext* first_observed_at;
67 MutexT mutex_type; // pthread_mutex_t or pthread_spinlock_t.
68 int recursion_count; // 0 if free, >= 1 if locked.
69 Bool ignore_ordering;
70 DrdThreadId owner; // owner if locked, last owner if free.
71 struct segment* last_locked_segment;
72 ULong acquiry_time_ms;
73 ExeContext* acquired_at;
76 struct cond_info
78 Addr a1;
79 ObjType type;
80 void (*cleanup)(union drd_clientobj*);
81 void (*delete_thread)(union drd_clientobj*, DrdThreadId);
82 ExeContext* first_observed_at;
83 int waiter_count;
84 Addr mutex; // Client mutex specified in pthread_cond_wait() call, and
85 // null if no client threads are currently waiting on this cond.var.
88 struct hb_info
90 Addr a1;
91 ObjType type;
92 void (*cleanup)(union drd_clientobj*);
93 void (*delete_thread)(union drd_clientobj*, DrdThreadId);
94 ExeContext* first_observed_at;
95 OSet* oset; // Per-thread order annotation information.
98 struct semaphore_info
100 Addr a1;
101 ObjType type;
102 void (*cleanup)(union drd_clientobj*);
103 void (*delete_thread)(union drd_clientobj*, DrdThreadId);
104 ExeContext* first_observed_at;
105 UInt waits_to_skip; // Number of sem_wait() calls to skip
106 // (due to the value assigned by sem_init()).
107 UInt value; // Semaphore value.
108 UWord waiters; // Number of threads inside sem_wait().
109 DrdThreadId last_sem_post_tid; // Thread ID associated with last sem_post().
110 XArray* last_sem_post_seg; // array of Segment*, used as a stack.
113 struct barrier_info
115 Addr a1;
116 ObjType type;
117 void (*cleanup)(union drd_clientobj*);
118 void (*delete_thread)(union drd_clientobj*, DrdThreadId);
119 ExeContext* first_observed_at;
120 BarrierT barrier_type; // pthread_barrier or gomp_barrier.
121 Word count; // Participant count in a barrier wait.
122 Word pre_iteration; // pre barrier completion count modulo two.
123 Word post_iteration; // post barrier completion count modulo two.
124 Word pre_waiters_left; // number of waiters left for a complete barrier.
125 Word post_waiters_left; // number of waiters left for a complete barrier.
126 OSet* oset[2]; // Per-thread barrier information for the latest
127 // two barrier iterations.
130 struct rwlock_info
132 Addr a1;
133 ObjType type;
134 void (*cleanup)(union drd_clientobj*);
135 void (*delete_thread)(union drd_clientobj*, DrdThreadId);
136 ExeContext* first_observed_at;
137 RwLockT rwlock_type;
138 OSet* thread_info;
139 ULong acquiry_time_ms;
140 ExeContext* acquired_at;
143 typedef union drd_clientobj
145 struct any any;
146 struct mutex_info mutex;
147 struct cond_info cond;
148 struct hb_info hb;
149 struct semaphore_info semaphore;
150 struct barrier_info barrier;
151 struct rwlock_info rwlock;
152 } DrdClientobj;
155 /* Function declarations. */
157 void DRD_(clientobj_set_trace)(const Bool trace);
158 void DRD_(clientobj_init)(void);
159 void DRD_(clientobj_cleanup)(void);
160 DrdClientobj* DRD_(clientobj_get_any)(const Addr addr);
161 DrdClientobj* DRD_(clientobj_get)(const Addr addr, const ObjType t);
162 Bool DRD_(clientobj_present)(const Addr a1, const Addr a2);
163 DrdClientobj* DRD_(clientobj_add)(const Addr a1, const ObjType t);
164 Bool DRD_(clientobj_remove)(const Addr addr, const ObjType t);
165 void DRD_(clientobj_stop_using_mem)(const Addr a1, const Addr a2);
166 void DRD_(clientobj_delete_thread)(const DrdThreadId tid);
167 const HChar* DRD_(clientobj_type_name)(const ObjType t);
170 #endif /* __DRD_CLIENTOBJ_H */