xref: /aosp_15_r20/prebuilts/clang-tools/linux-x86/clang-headers/sanitizer/tsan_interface.h (revision bed243d3d9cd544cfb038bfa7be843dedc6e6bf7)
1*bed243d3SAndroid Build Coastguard Worker //===-- tsan_interface.h ----------------------------------------*- C++ -*-===//
2*bed243d3SAndroid Build Coastguard Worker //
3*bed243d3SAndroid Build Coastguard Worker // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*bed243d3SAndroid Build Coastguard Worker // See https://llvm.org/LICENSE.txt for license information.
5*bed243d3SAndroid Build Coastguard Worker // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*bed243d3SAndroid Build Coastguard Worker //
7*bed243d3SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
8*bed243d3SAndroid Build Coastguard Worker //
9*bed243d3SAndroid Build Coastguard Worker // This file is a part of ThreadSanitizer (TSan), a race detector.
10*bed243d3SAndroid Build Coastguard Worker //
11*bed243d3SAndroid Build Coastguard Worker // Public interface header for TSan.
12*bed243d3SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*bed243d3SAndroid Build Coastguard Worker #ifndef SANITIZER_TSAN_INTERFACE_H
14*bed243d3SAndroid Build Coastguard Worker #define SANITIZER_TSAN_INTERFACE_H
15*bed243d3SAndroid Build Coastguard Worker 
16*bed243d3SAndroid Build Coastguard Worker #include <sanitizer/common_interface_defs.h>
17*bed243d3SAndroid Build Coastguard Worker 
18*bed243d3SAndroid Build Coastguard Worker #ifdef __cplusplus
19*bed243d3SAndroid Build Coastguard Worker extern "C" {
20*bed243d3SAndroid Build Coastguard Worker #endif
21*bed243d3SAndroid Build Coastguard Worker 
22*bed243d3SAndroid Build Coastguard Worker // __tsan_release establishes a happens-before relation with a preceding
23*bed243d3SAndroid Build Coastguard Worker // __tsan_acquire on the same address.
24*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_acquire(void *addr);
25*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_release(void *addr);
26*bed243d3SAndroid Build Coastguard Worker 
27*bed243d3SAndroid Build Coastguard Worker // Annotations for custom mutexes.
28*bed243d3SAndroid Build Coastguard Worker // The annotations allow to get better reports (with sets of locked mutexes),
29*bed243d3SAndroid Build Coastguard Worker // detect more types of bugs (e.g. mutex misuses, races between lock/unlock and
30*bed243d3SAndroid Build Coastguard Worker // destruction and potential deadlocks) and improve precision and performance
31*bed243d3SAndroid Build Coastguard Worker // (by ignoring individual atomic operations in mutex code). However, the
32*bed243d3SAndroid Build Coastguard Worker // downside is that annotated mutex code itself is not checked for correctness.
33*bed243d3SAndroid Build Coastguard Worker 
34*bed243d3SAndroid Build Coastguard Worker // Mutex creation flags are passed to __tsan_mutex_create annotation.
35*bed243d3SAndroid Build Coastguard Worker // If mutex has no constructor and __tsan_mutex_create is not called,
36*bed243d3SAndroid Build Coastguard Worker // the flags may be passed to __tsan_mutex_pre_lock/__tsan_mutex_post_lock
37*bed243d3SAndroid Build Coastguard Worker // annotations.
38*bed243d3SAndroid Build Coastguard Worker 
39*bed243d3SAndroid Build Coastguard Worker // Mutex has static storage duration and no-op constructor and destructor.
40*bed243d3SAndroid Build Coastguard Worker // This effectively makes tsan ignore destroy annotation.
41*bed243d3SAndroid Build Coastguard Worker static const unsigned __tsan_mutex_linker_init      = 1 << 0;
42*bed243d3SAndroid Build Coastguard Worker // Mutex is write reentrant.
43*bed243d3SAndroid Build Coastguard Worker static const unsigned __tsan_mutex_write_reentrant  = 1 << 1;
44*bed243d3SAndroid Build Coastguard Worker // Mutex is read reentrant.
45*bed243d3SAndroid Build Coastguard Worker static const unsigned __tsan_mutex_read_reentrant   = 1 << 2;
46*bed243d3SAndroid Build Coastguard Worker // Mutex does not have static storage duration, and must not be used after
47*bed243d3SAndroid Build Coastguard Worker // its destructor runs.  The opposite of __tsan_mutex_linker_init.
48*bed243d3SAndroid Build Coastguard Worker // If this flag is passed to __tsan_mutex_destroy, then the destruction
49*bed243d3SAndroid Build Coastguard Worker // is ignored unless this flag was previously set on the mutex.
50*bed243d3SAndroid Build Coastguard Worker static const unsigned __tsan_mutex_not_static       = 1 << 8;
51*bed243d3SAndroid Build Coastguard Worker 
52*bed243d3SAndroid Build Coastguard Worker // Mutex operation flags:
53*bed243d3SAndroid Build Coastguard Worker 
54*bed243d3SAndroid Build Coastguard Worker // Denotes read lock operation.
55*bed243d3SAndroid Build Coastguard Worker static const unsigned __tsan_mutex_read_lock = 1 << 3;
56*bed243d3SAndroid Build Coastguard Worker // Denotes try lock operation.
57*bed243d3SAndroid Build Coastguard Worker static const unsigned __tsan_mutex_try_lock = 1 << 4;
58*bed243d3SAndroid Build Coastguard Worker // Denotes that a try lock operation has failed to acquire the mutex.
59*bed243d3SAndroid Build Coastguard Worker static const unsigned __tsan_mutex_try_lock_failed = 1 << 5;
60*bed243d3SAndroid Build Coastguard Worker // Denotes that the lock operation acquires multiple recursion levels.
61*bed243d3SAndroid Build Coastguard Worker // Number of levels is passed in recursion parameter.
62*bed243d3SAndroid Build Coastguard Worker // This is useful for annotation of e.g. Java builtin monitors,
63*bed243d3SAndroid Build Coastguard Worker // for which wait operation releases all recursive acquisitions of the mutex.
64*bed243d3SAndroid Build Coastguard Worker static const unsigned __tsan_mutex_recursive_lock = 1 << 6;
65*bed243d3SAndroid Build Coastguard Worker // Denotes that the unlock operation releases all recursion levels.
66*bed243d3SAndroid Build Coastguard Worker // Number of released levels is returned and later must be passed to
67*bed243d3SAndroid Build Coastguard Worker // the corresponding __tsan_mutex_post_lock annotation.
68*bed243d3SAndroid Build Coastguard Worker static const unsigned __tsan_mutex_recursive_unlock = 1 << 7;
69*bed243d3SAndroid Build Coastguard Worker 
70*bed243d3SAndroid Build Coastguard Worker // Convenient composed constants.
71*bed243d3SAndroid Build Coastguard Worker static const unsigned __tsan_mutex_try_read_lock =
72*bed243d3SAndroid Build Coastguard Worker     __tsan_mutex_read_lock | __tsan_mutex_try_lock;
73*bed243d3SAndroid Build Coastguard Worker static const unsigned __tsan_mutex_try_read_lock_failed =
74*bed243d3SAndroid Build Coastguard Worker     __tsan_mutex_try_read_lock | __tsan_mutex_try_lock_failed;
75*bed243d3SAndroid Build Coastguard Worker 
76*bed243d3SAndroid Build Coastguard Worker // Annotate creation of a mutex.
77*bed243d3SAndroid Build Coastguard Worker // Supported flags: mutex creation flags.
78*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_mutex_create(void *addr, unsigned flags);
79*bed243d3SAndroid Build Coastguard Worker 
80*bed243d3SAndroid Build Coastguard Worker // Annotate destruction of a mutex.
81*bed243d3SAndroid Build Coastguard Worker // Supported flags:
82*bed243d3SAndroid Build Coastguard Worker //   - __tsan_mutex_linker_init
83*bed243d3SAndroid Build Coastguard Worker //   - __tsan_mutex_not_static
84*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_mutex_destroy(void *addr, unsigned flags);
85*bed243d3SAndroid Build Coastguard Worker 
86*bed243d3SAndroid Build Coastguard Worker // Annotate start of lock operation.
87*bed243d3SAndroid Build Coastguard Worker // Supported flags:
88*bed243d3SAndroid Build Coastguard Worker //   - __tsan_mutex_read_lock
89*bed243d3SAndroid Build Coastguard Worker //   - __tsan_mutex_try_lock
90*bed243d3SAndroid Build Coastguard Worker //   - all mutex creation flags
91*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_mutex_pre_lock(void *addr, unsigned flags);
92*bed243d3SAndroid Build Coastguard Worker 
93*bed243d3SAndroid Build Coastguard Worker // Annotate end of lock operation.
94*bed243d3SAndroid Build Coastguard Worker // Supported flags:
95*bed243d3SAndroid Build Coastguard Worker //   - __tsan_mutex_read_lock (must match __tsan_mutex_pre_lock)
96*bed243d3SAndroid Build Coastguard Worker //   - __tsan_mutex_try_lock (must match __tsan_mutex_pre_lock)
97*bed243d3SAndroid Build Coastguard Worker //   - __tsan_mutex_try_lock_failed
98*bed243d3SAndroid Build Coastguard Worker //   - __tsan_mutex_recursive_lock
99*bed243d3SAndroid Build Coastguard Worker //   - all mutex creation flags
100*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_mutex_post_lock(void *addr, unsigned flags,
101*bed243d3SAndroid Build Coastguard Worker                                             int recursion);
102*bed243d3SAndroid Build Coastguard Worker 
103*bed243d3SAndroid Build Coastguard Worker // Annotate start of unlock operation.
104*bed243d3SAndroid Build Coastguard Worker // Supported flags:
105*bed243d3SAndroid Build Coastguard Worker //   - __tsan_mutex_read_lock
106*bed243d3SAndroid Build Coastguard Worker //   - __tsan_mutex_recursive_unlock
107*bed243d3SAndroid Build Coastguard Worker int SANITIZER_CDECL __tsan_mutex_pre_unlock(void *addr, unsigned flags);
108*bed243d3SAndroid Build Coastguard Worker 
109*bed243d3SAndroid Build Coastguard Worker // Annotate end of unlock operation.
110*bed243d3SAndroid Build Coastguard Worker // Supported flags:
111*bed243d3SAndroid Build Coastguard Worker //   - __tsan_mutex_read_lock (must match __tsan_mutex_pre_unlock)
112*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_mutex_post_unlock(void *addr, unsigned flags);
113*bed243d3SAndroid Build Coastguard Worker 
114*bed243d3SAndroid Build Coastguard Worker // Annotate start/end of notify/signal/broadcast operation.
115*bed243d3SAndroid Build Coastguard Worker // Supported flags: none.
116*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_mutex_pre_signal(void *addr, unsigned flags);
117*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_mutex_post_signal(void *addr, unsigned flags);
118*bed243d3SAndroid Build Coastguard Worker 
119*bed243d3SAndroid Build Coastguard Worker // Annotate start/end of a region of code where lock/unlock/signal operation
120*bed243d3SAndroid Build Coastguard Worker // diverts to do something else unrelated to the mutex. This can be used to
121*bed243d3SAndroid Build Coastguard Worker // annotate, for example, calls into cooperative scheduler or contention
122*bed243d3SAndroid Build Coastguard Worker // profiling code.
123*bed243d3SAndroid Build Coastguard Worker // These annotations must be called only from within
124*bed243d3SAndroid Build Coastguard Worker // __tsan_mutex_pre/post_lock, __tsan_mutex_pre/post_unlock,
125*bed243d3SAndroid Build Coastguard Worker // __tsan_mutex_pre/post_signal regions.
126*bed243d3SAndroid Build Coastguard Worker // Supported flags: none.
127*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_mutex_pre_divert(void *addr, unsigned flags);
128*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_mutex_post_divert(void *addr, unsigned flags);
129*bed243d3SAndroid Build Coastguard Worker 
130*bed243d3SAndroid Build Coastguard Worker // Check that the current thread does not hold any mutexes,
131*bed243d3SAndroid Build Coastguard Worker // report a bug report otherwise.
132*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_check_no_mutexes_held();
133*bed243d3SAndroid Build Coastguard Worker 
134*bed243d3SAndroid Build Coastguard Worker // External race detection API.
135*bed243d3SAndroid Build Coastguard Worker // Can be used by non-instrumented libraries to detect when their objects are
136*bed243d3SAndroid Build Coastguard Worker // being used in an unsafe manner.
137*bed243d3SAndroid Build Coastguard Worker //   - __tsan_external_read/__tsan_external_write annotates the logical reads
138*bed243d3SAndroid Build Coastguard Worker //       and writes of the object at the specified address. 'caller_pc' should
139*bed243d3SAndroid Build Coastguard Worker //       be the PC of the library user, which the library can obtain with e.g.
140*bed243d3SAndroid Build Coastguard Worker //       `__builtin_return_address(0)`.
141*bed243d3SAndroid Build Coastguard Worker //   - __tsan_external_register_tag registers a 'tag' with the specified name,
142*bed243d3SAndroid Build Coastguard Worker //       which is later used in read/write annotations to denote the object type
143*bed243d3SAndroid Build Coastguard Worker //   - __tsan_external_assign_tag can optionally mark a heap object with a tag
144*bed243d3SAndroid Build Coastguard Worker void *SANITIZER_CDECL __tsan_external_register_tag(const char *object_type);
145*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_external_register_header(void *tag,
146*bed243d3SAndroid Build Coastguard Worker                                                      const char *header);
147*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_external_assign_tag(void *addr, void *tag);
148*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_external_read(void *addr, void *caller_pc,
149*bed243d3SAndroid Build Coastguard Worker                                           void *tag);
150*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_external_write(void *addr, void *caller_pc,
151*bed243d3SAndroid Build Coastguard Worker                                            void *tag);
152*bed243d3SAndroid Build Coastguard Worker 
153*bed243d3SAndroid Build Coastguard Worker // Fiber switching API.
154*bed243d3SAndroid Build Coastguard Worker //   - TSAN context for fiber can be created by __tsan_create_fiber
155*bed243d3SAndroid Build Coastguard Worker //     and freed by __tsan_destroy_fiber.
156*bed243d3SAndroid Build Coastguard Worker //   - TSAN context of current fiber or thread can be obtained
157*bed243d3SAndroid Build Coastguard Worker //     by calling __tsan_get_current_fiber.
158*bed243d3SAndroid Build Coastguard Worker //   - __tsan_switch_to_fiber should be called immediately before switch
159*bed243d3SAndroid Build Coastguard Worker //     to fiber, such as call of swapcontext.
160*bed243d3SAndroid Build Coastguard Worker //   - Fiber name can be set by __tsan_set_fiber_name.
161*bed243d3SAndroid Build Coastguard Worker void *SANITIZER_CDECL __tsan_get_current_fiber(void);
162*bed243d3SAndroid Build Coastguard Worker void *SANITIZER_CDECL __tsan_create_fiber(unsigned flags);
163*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_destroy_fiber(void *fiber);
164*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_switch_to_fiber(void *fiber, unsigned flags);
165*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_set_fiber_name(void *fiber, const char *name);
166*bed243d3SAndroid Build Coastguard Worker 
167*bed243d3SAndroid Build Coastguard Worker // Flags for __tsan_switch_to_fiber:
168*bed243d3SAndroid Build Coastguard Worker // Do not establish a happens-before relation between fibers
169*bed243d3SAndroid Build Coastguard Worker static const unsigned __tsan_switch_to_fiber_no_sync = 1 << 0;
170*bed243d3SAndroid Build Coastguard Worker 
171*bed243d3SAndroid Build Coastguard Worker // User-provided callback invoked on TSan initialization.
172*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_on_initialize();
173*bed243d3SAndroid Build Coastguard Worker 
174*bed243d3SAndroid Build Coastguard Worker // User-provided callback invoked on TSan shutdown.
175*bed243d3SAndroid Build Coastguard Worker // `failed` - Nonzero if TSan did detect issues, zero otherwise.
176*bed243d3SAndroid Build Coastguard Worker // Return `0` if TSan should exit as if no issues were detected.  Return nonzero
177*bed243d3SAndroid Build Coastguard Worker // if TSan should exit as if issues were detected.
178*bed243d3SAndroid Build Coastguard Worker int SANITIZER_CDECL __tsan_on_finalize(int failed);
179*bed243d3SAndroid Build Coastguard Worker 
180*bed243d3SAndroid Build Coastguard Worker // Release TSan internal memory in a best-effort manner.
181*bed243d3SAndroid Build Coastguard Worker void SANITIZER_CDECL __tsan_flush_memory();
182*bed243d3SAndroid Build Coastguard Worker 
183*bed243d3SAndroid Build Coastguard Worker // User-provided default TSAN options.
184*bed243d3SAndroid Build Coastguard Worker const char *SANITIZER_CDECL __tsan_default_options(void);
185*bed243d3SAndroid Build Coastguard Worker 
186*bed243d3SAndroid Build Coastguard Worker // User-provided default TSAN suppressions.
187*bed243d3SAndroid Build Coastguard Worker const char *SANITIZER_CDECL __tsan_default_suppressions(void);
188*bed243d3SAndroid Build Coastguard Worker 
189*bed243d3SAndroid Build Coastguard Worker /// Returns a report's description.
190*bed243d3SAndroid Build Coastguard Worker ///
191*bed243d3SAndroid Build Coastguard Worker /// Returns a report's description (issue type), number of duplicate issues
192*bed243d3SAndroid Build Coastguard Worker /// found, counts of array data (stack traces, memory operations, locations,
193*bed243d3SAndroid Build Coastguard Worker /// mutexes, threads, unique thread IDs) and a stack trace of a <c>sleep()</c>
194*bed243d3SAndroid Build Coastguard Worker /// call (if one was involved in the issue).
195*bed243d3SAndroid Build Coastguard Worker ///
196*bed243d3SAndroid Build Coastguard Worker /// \param report Opaque pointer to the current report.
197*bed243d3SAndroid Build Coastguard Worker /// \param[out] description Report type description.
198*bed243d3SAndroid Build Coastguard Worker /// \param[out] count Count of duplicate issues.
199*bed243d3SAndroid Build Coastguard Worker /// \param[out] stack_count Count of stack traces.
200*bed243d3SAndroid Build Coastguard Worker /// \param[out] mop_count Count of memory operations.
201*bed243d3SAndroid Build Coastguard Worker /// \param[out] loc_count Count of locations.
202*bed243d3SAndroid Build Coastguard Worker /// \param[out] mutex_count Count of mutexes.
203*bed243d3SAndroid Build Coastguard Worker /// \param[out] thread_count Count of threads.
204*bed243d3SAndroid Build Coastguard Worker /// \param[out] unique_tid_count Count of unique thread IDs.
205*bed243d3SAndroid Build Coastguard Worker /// \param sleep_trace A buffer to store the stack trace of a <c>sleep()</c>
206*bed243d3SAndroid Build Coastguard Worker /// call.
207*bed243d3SAndroid Build Coastguard Worker /// \param trace_size Size in bytes of the trace buffer.
208*bed243d3SAndroid Build Coastguard Worker /// \returns Returns 1 if successful, 0 if not.
209*bed243d3SAndroid Build Coastguard Worker int SANITIZER_CDECL __tsan_get_report_data(
210*bed243d3SAndroid Build Coastguard Worker     void *report, const char **description, int *count, int *stack_count,
211*bed243d3SAndroid Build Coastguard Worker     int *mop_count, int *loc_count, int *mutex_count, int *thread_count,
212*bed243d3SAndroid Build Coastguard Worker     int *unique_tid_count, void **sleep_trace, unsigned long trace_size);
213*bed243d3SAndroid Build Coastguard Worker 
214*bed243d3SAndroid Build Coastguard Worker /// Returns information about stack traces included in the report.
215*bed243d3SAndroid Build Coastguard Worker ///
216*bed243d3SAndroid Build Coastguard Worker /// \param report Opaque pointer to the current report.
217*bed243d3SAndroid Build Coastguard Worker /// \param idx Index to the report's stacks.
218*bed243d3SAndroid Build Coastguard Worker /// \param trace A buffer to store the stack trace.
219*bed243d3SAndroid Build Coastguard Worker /// \param trace_size Size in bytes of the trace buffer.
220*bed243d3SAndroid Build Coastguard Worker /// \returns Returns 1 if successful, 0 if not.
221*bed243d3SAndroid Build Coastguard Worker int SANITIZER_CDECL __tsan_get_report_stack(void *report, unsigned long idx,
222*bed243d3SAndroid Build Coastguard Worker                                             void **trace,
223*bed243d3SAndroid Build Coastguard Worker                                             unsigned long trace_size);
224*bed243d3SAndroid Build Coastguard Worker 
225*bed243d3SAndroid Build Coastguard Worker /// Returns information about memory operations included in the report.
226*bed243d3SAndroid Build Coastguard Worker ///
227*bed243d3SAndroid Build Coastguard Worker /// \param report Opaque pointer to the current report.
228*bed243d3SAndroid Build Coastguard Worker /// \param idx Index to the report's memory operations.
229*bed243d3SAndroid Build Coastguard Worker /// \param[out] tid Thread ID of the memory operation.
230*bed243d3SAndroid Build Coastguard Worker /// \param[out] addr Address of the memory operation.
231*bed243d3SAndroid Build Coastguard Worker /// \param[out] size Size of the memory operation.
232*bed243d3SAndroid Build Coastguard Worker /// \param[out] write Write flag of the memory operation.
233*bed243d3SAndroid Build Coastguard Worker /// \param[out] atomic Atomicity flag of the memory operation.
234*bed243d3SAndroid Build Coastguard Worker /// \param trace A buffer to store the stack trace.
235*bed243d3SAndroid Build Coastguard Worker /// \param trace_size Size in bytes of the trace buffer.
236*bed243d3SAndroid Build Coastguard Worker /// \returns Returns 1 if successful, 0 if not.
237*bed243d3SAndroid Build Coastguard Worker int SANITIZER_CDECL __tsan_get_report_mop(void *report, unsigned long idx,
238*bed243d3SAndroid Build Coastguard Worker                                           int *tid, void **addr, int *size,
239*bed243d3SAndroid Build Coastguard Worker                                           int *write, int *atomic, void **trace,
240*bed243d3SAndroid Build Coastguard Worker                                           unsigned long trace_size);
241*bed243d3SAndroid Build Coastguard Worker 
242*bed243d3SAndroid Build Coastguard Worker /// Returns information about locations included in the report.
243*bed243d3SAndroid Build Coastguard Worker ///
244*bed243d3SAndroid Build Coastguard Worker /// \param report Opaque pointer to the current report.
245*bed243d3SAndroid Build Coastguard Worker /// \param idx Index to the report's locations.
246*bed243d3SAndroid Build Coastguard Worker /// \param[out] type Type of the location.
247*bed243d3SAndroid Build Coastguard Worker /// \param[out] addr Address of the location.
248*bed243d3SAndroid Build Coastguard Worker /// \param[out] start Start of the location.
249*bed243d3SAndroid Build Coastguard Worker /// \param[out] size Size of the location.
250*bed243d3SAndroid Build Coastguard Worker /// \param[out] tid Thread ID of the location.
251*bed243d3SAndroid Build Coastguard Worker /// \param[out] fd File descriptor of the location.
252*bed243d3SAndroid Build Coastguard Worker /// \param[out] suppressable Suppressable flag.
253*bed243d3SAndroid Build Coastguard Worker /// \param trace A buffer to store the stack trace.
254*bed243d3SAndroid Build Coastguard Worker /// \param trace_size Size in bytes of the trace buffer.
255*bed243d3SAndroid Build Coastguard Worker /// \returns Returns 1 if successful, 0 if not.
256*bed243d3SAndroid Build Coastguard Worker int SANITIZER_CDECL __tsan_get_report_loc(void *report, unsigned long idx,
257*bed243d3SAndroid Build Coastguard Worker                                           const char **type, void **addr,
258*bed243d3SAndroid Build Coastguard Worker                                           void **start, unsigned long *size,
259*bed243d3SAndroid Build Coastguard Worker                                           int *tid, int *fd, int *suppressable,
260*bed243d3SAndroid Build Coastguard Worker                                           void **trace,
261*bed243d3SAndroid Build Coastguard Worker                                           unsigned long trace_size);
262*bed243d3SAndroid Build Coastguard Worker 
263*bed243d3SAndroid Build Coastguard Worker /// Returns information about mutexes included in the report.
264*bed243d3SAndroid Build Coastguard Worker ///
265*bed243d3SAndroid Build Coastguard Worker /// \param report Opaque pointer to the current report.
266*bed243d3SAndroid Build Coastguard Worker /// \param idx Index to the report's mutexes.
267*bed243d3SAndroid Build Coastguard Worker /// \param[out] mutex_id Id of the mutex.
268*bed243d3SAndroid Build Coastguard Worker /// \param[out] addr Address of the mutex.
269*bed243d3SAndroid Build Coastguard Worker /// \param[out] destroyed Destroyed mutex flag.
270*bed243d3SAndroid Build Coastguard Worker /// \param trace A buffer to store the stack trace.
271*bed243d3SAndroid Build Coastguard Worker /// \param trace_size Size in bytes of the trace buffer.
272*bed243d3SAndroid Build Coastguard Worker /// \returns Returns 1 if successful, 0 if not.
273*bed243d3SAndroid Build Coastguard Worker int SANITIZER_CDECL __tsan_get_report_mutex(void *report, unsigned long idx,
274*bed243d3SAndroid Build Coastguard Worker                                             uint64_t *mutex_id, void **addr,
275*bed243d3SAndroid Build Coastguard Worker                                             int *destroyed, void **trace,
276*bed243d3SAndroid Build Coastguard Worker                                             unsigned long trace_size);
277*bed243d3SAndroid Build Coastguard Worker 
278*bed243d3SAndroid Build Coastguard Worker /// Returns information about threads included in the report.
279*bed243d3SAndroid Build Coastguard Worker ///
280*bed243d3SAndroid Build Coastguard Worker /// \param report Opaque pointer to the current report.
281*bed243d3SAndroid Build Coastguard Worker /// \param idx Index to the report's threads.
282*bed243d3SAndroid Build Coastguard Worker /// \param[out] tid Thread ID of the thread.
283*bed243d3SAndroid Build Coastguard Worker /// \param[out] os_id Operating system's ID of the thread.
284*bed243d3SAndroid Build Coastguard Worker /// \param[out] running Running flag of the thread.
285*bed243d3SAndroid Build Coastguard Worker /// \param[out] name Name of the thread.
286*bed243d3SAndroid Build Coastguard Worker /// \param[out] parent_tid ID of the parent thread.
287*bed243d3SAndroid Build Coastguard Worker /// \param trace A buffer to store the stack trace.
288*bed243d3SAndroid Build Coastguard Worker /// \param trace_size Size in bytes of the trace buffer.
289*bed243d3SAndroid Build Coastguard Worker /// \returns Returns 1 if successful, 0 if not.
290*bed243d3SAndroid Build Coastguard Worker int SANITIZER_CDECL __tsan_get_report_thread(void *report, unsigned long idx,
291*bed243d3SAndroid Build Coastguard Worker                                              int *tid, uint64_t *os_id,
292*bed243d3SAndroid Build Coastguard Worker                                              int *running, const char **name,
293*bed243d3SAndroid Build Coastguard Worker                                              int *parent_tid, void **trace,
294*bed243d3SAndroid Build Coastguard Worker                                              unsigned long trace_size);
295*bed243d3SAndroid Build Coastguard Worker 
296*bed243d3SAndroid Build Coastguard Worker /// Returns information about unique thread IDs included in the report.
297*bed243d3SAndroid Build Coastguard Worker ///
298*bed243d3SAndroid Build Coastguard Worker /// \param report Opaque pointer to the current report.
299*bed243d3SAndroid Build Coastguard Worker /// \param idx Index to the report's unique thread IDs.
300*bed243d3SAndroid Build Coastguard Worker /// \param[out] tid Unique thread ID of the report.
301*bed243d3SAndroid Build Coastguard Worker /// \returns Returns 1 if successful, 0 if not.
302*bed243d3SAndroid Build Coastguard Worker int SANITIZER_CDECL __tsan_get_report_unique_tid(void *report,
303*bed243d3SAndroid Build Coastguard Worker                                                  unsigned long idx, int *tid);
304*bed243d3SAndroid Build Coastguard Worker 
305*bed243d3SAndroid Build Coastguard Worker /// Returns the current report.
306*bed243d3SAndroid Build Coastguard Worker ///
307*bed243d3SAndroid Build Coastguard Worker /// If TSan is currently reporting a detected issue on the current thread,
308*bed243d3SAndroid Build Coastguard Worker /// returns an opaque pointer to the current report. Otherwise returns NULL.
309*bed243d3SAndroid Build Coastguard Worker /// \returns An opaque pointer to the current report. Otherwise returns NULL.
310*bed243d3SAndroid Build Coastguard Worker void *SANITIZER_CDECL __tsan_get_current_report();
311*bed243d3SAndroid Build Coastguard Worker 
312*bed243d3SAndroid Build Coastguard Worker #ifdef __cplusplus
313*bed243d3SAndroid Build Coastguard Worker } // extern "C"
314*bed243d3SAndroid Build Coastguard Worker #endif
315*bed243d3SAndroid Build Coastguard Worker 
316*bed243d3SAndroid Build Coastguard Worker #endif // SANITIZER_TSAN_INTERFACE_H
317