• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "sanitizer_common/sanitizer_flags.h"
18 #include "sanitizer_common/sanitizer_deadlock_detector_interface.h"
19 
20 namespace __tsan {
21 
22 struct Flags : CommonFlags, DDFlags {
23   // Enable dynamic annotations, otherwise they are no-ops.
24   bool enable_annotations;
25   // Suppress a race report if we've already output another race report
26   // with the same stack.
27   bool suppress_equal_stacks;
28   // Suppress a race report if we've already output another race report
29   // on the same address.
30   bool suppress_equal_addresses;
31   // Suppress weird race reports that can be seen if JVM is embed
32   // into the process.
33   bool suppress_java;
34   // Turns off bug reporting entirely (useful for benchmarking).
35   bool report_bugs;
36   // Report thread leaks at exit?
37   bool report_thread_leaks;
38   // Report destruction of a locked mutex?
39   bool report_destroy_locked;
40   // Report incorrect usages of mutexes and mutex annotations?
41   bool report_mutex_bugs;
42   // Report violations of async signal-safety
43   // (e.g. malloc() call from a signal handler).
44   bool report_signal_unsafe;
45   // Report races between atomic and plain memory accesses.
46   bool report_atomic_races;
47   // If set, all atomics are effectively sequentially consistent (seq_cst),
48   // regardless of what user actually specified.
49   bool force_seq_cst_atomics;
50   // Suppressions filename.
51   const char *suppressions;
52   // Print matched suppressions at exit.
53   bool print_suppressions;
54   // Print matched "benign" races at exit.
55   bool print_benign;
56   // Override exit status if something was reported.
57   int exitcode;
58   // Exit after first reported error.
59   bool halt_on_error;
60   // Sleep in main thread before exiting for that many ms
61   // (useful to catch "at exit" races).
62   int atexit_sleep_ms;
63   // If set, periodically write memory profile to that file.
64   const char *profile_memory;
65   // Flush shadow memory every X ms.
66   int flush_memory_ms;
67   // Flush symbolizer caches every X ms.
68   int flush_symbolizer_ms;
69   // Resident memory limit in MB to aim at.
70   // If the process consumes more memory, then TSan will flush shadow memory.
71   int memory_limit_mb;
72   // Stops on start until __tsan_resume() is called (for debugging).
73   bool stop_on_start;
74   // Controls whether RunningOnValgrind() returns true or false.
75   bool running_on_valgrind;
76   // Per-thread history size, controls how many previous memory accesses
77   // are remembered per thread.  Possible values are [0..7].
78   // history_size=0 amounts to 32K memory accesses.  Each next value doubles
79   // the amount of memory accesses, up to history_size=7 that amounts to
80   // 4M memory accesses.  The default value is 2 (128K memory accesses).
81   int history_size;
82   // Controls level of synchronization implied by IO operations.
83   // 0 - no synchronization
84   // 1 - reasonable level of synchronization (write->read)
85   // 2 - global synchronization of all IO operations
86   int io_sync;
87   // Die after multi-threaded fork if the child creates new threads.
88   bool die_after_fork;
89 };
90 
91 Flags *flags();
92 void InitializeFlags(Flags *flags, const char *env);
93 }  // namespace __tsan
94 
95 #endif  // TSAN_FLAGS_H
96