tsan_flags.h revision 6866dba92ac842fc513ba339ba849a953ffb7507
1//===-- tsan_flags.h --------------------------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file is a part of ThreadSanitizer (TSan), a race detector.
11// NOTE: This file may be included into user code.
12//===----------------------------------------------------------------------===//
13
14#ifndef TSAN_FLAGS_H
15#define TSAN_FLAGS_H
16
17// ----------- ATTENTION -------------
18// ThreadSanitizer user may provide its implementation of weak
19// symbol __tsan::OverrideFlags(__tsan::Flags). Therefore, this
20// header may be included in the user code, and shouldn't include
21// other headers from TSan or common sanitizer runtime.
22
23#include "sanitizer_common/sanitizer_flags.h"
24
25namespace __tsan {
26
27struct Flags : CommonFlags {
28  // Enable dynamic annotations, otherwise they are no-ops.
29  bool enable_annotations;
30  // Supress a race report if we've already output another race report
31  // with the same stack.
32  bool suppress_equal_stacks;
33  // Supress a race report if we've already output another race report
34  // on the same address.
35  bool suppress_equal_addresses;
36  // Suppress weird race reports that can be seen if JVM is embed
37  // into the process.
38  bool suppress_java;
39  // Turns off bug reporting entirely (useful for benchmarking).
40  bool report_bugs;
41  // Report thread leaks at exit?
42  bool report_thread_leaks;
43  // Report destruction of a locked mutex?
44  bool report_destroy_locked;
45  // Report violations of async signal-safety
46  // (e.g. malloc() call from a signal handler).
47  bool report_signal_unsafe;
48  // Report races between atomic and plain memory accesses.
49  bool report_atomic_races;
50  // If set, all atomics are effectively sequentially consistent (seq_cst),
51  // regardless of what user actually specified.
52  bool force_seq_cst_atomics;
53  // Suppressions filename.
54  const char *suppressions;
55  // Print matched suppressions at exit.
56  bool print_suppressions;
57  // Print matched "benign" races at exit.
58  bool print_benign;
59  // Override exit status if something was reported.
60  int exitcode;
61  // Exit after first reported error.
62  bool halt_on_error;
63  // Sleep in main thread before exiting for that many ms
64  // (useful to catch "at exit" races).
65  int atexit_sleep_ms;
66  // If set, periodically write memory profile to that file.
67  const char *profile_memory;
68  // Flush shadow memory every X ms.
69  int flush_memory_ms;
70  // Flush symbolizer caches every X ms.
71  int flush_symbolizer_ms;
72  // Resident memory limit in MB to aim at.
73  // If the process consumes more memory, then TSan will flush shadow memory.
74  int memory_limit_mb;
75  // Stops on start until __tsan_resume() is called (for debugging).
76  bool stop_on_start;
77  // Controls whether RunningOnValgrind() returns true or false.
78  bool running_on_valgrind;
79  // Per-thread history size, controls how many previous memory accesses
80  // are remembered per thread.  Possible values are [0..7].
81  // history_size=0 amounts to 32K memory accesses.  Each next value doubles
82  // the amount of memory accesses, up to history_size=7 that amounts to
83  // 4M memory accesses.  The default value is 2 (128K memory accesses).
84  int history_size;
85  // Controls level of synchronization implied by IO operations.
86  // 0 - no synchronization
87  // 1 - reasonable level of synchronization (write->read)
88  // 2 - global synchronization of all IO operations
89  int io_sync;
90};
91
92Flags *flags();
93void InitializeFlags(Flags *flags, const char *env);
94}  // namespace __tsan
95
96#endif  // TSAN_FLAGS_H
97