blob: 77891bb3087d33d8f6a770ae7beed21c686b46ba [file] [log] [blame]
Kostya Serebryany7ac41482012-05-10 13:48:04 +00001//===-- 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.
Alexey Samsonov86cdf2d2012-06-19 08:57:53 +000011// NOTE: This file may be included into user code.
Kostya Serebryany7ac41482012-05-10 13:48:04 +000012//===----------------------------------------------------------------------===//
13
14#ifndef TSAN_FLAGS_H
15#define TSAN_FLAGS_H
16
Alexey Samsonov86cdf2d2012-06-19 08:57:53 +000017// ----------- 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
Kostya Serebryany7ac41482012-05-10 13:48:04 +000023namespace __tsan {
24
25struct Flags {
26 // Enable dynamic annotations, otherwise they are no-ops.
27 bool enable_annotations;
28 // Supress a race report if we've already output another race report
29 // with the same stack.
30 bool suppress_equal_stacks;
31 // Supress a race report if we've already output another race report
32 // on the same address.
33 bool suppress_equal_addresses;
Dmitry Vyukov543b94a2012-11-30 17:45:53 +000034 // Suppress weird race reports that can be seen if JVM is embed
35 // into the process.
36 bool suppress_java;
Dmitry Vyukov8a326772012-11-07 16:14:12 +000037 // Turns off bug reporting entirely (useful for benchmarking).
38 bool report_bugs;
Kostya Serebryany7ac41482012-05-10 13:48:04 +000039 // Report thread leaks at exit?
40 bool report_thread_leaks;
Dmitry Vyukovfd513902012-08-16 15:12:35 +000041 // Report destruction of a locked mutex?
42 bool report_destroy_locked;
Kostya Serebryany7ac41482012-05-10 13:48:04 +000043 // Report violations of async signal-safety
44 // (e.g. malloc() call from a signal handler).
45 bool report_signal_unsafe;
46 // If set, all atomics are effectively sequentially consistent (seq_cst),
47 // regardless of what user actually specified.
48 bool force_seq_cst_atomics;
49 // Strip that prefix from file paths in reports.
50 const char *strip_path_prefix;
51 // Suppressions filename.
52 const char *suppressions;
53 // Override exit status if something was reported.
54 int exitcode;
Dmitry Vyukovcec60682012-11-28 12:56:52 +000055 // Write logs to "log_path.pid".
56 // The special values are "stdout" and "stderr".
57 // The default is "stderr".
Dmitry Vyukov92733f92012-11-30 06:50:15 +000058 const char *log_path;
Kostya Serebryany7ac41482012-05-10 13:48:04 +000059 // Sleep in main thread before exiting for that many ms
60 // (useful to catch "at exit" races).
61 int atexit_sleep_ms;
62 // Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).
63 int verbosity;
Dmitry Vyukov26127732012-05-22 11:33:03 +000064 // If set, periodically write memory profile to that file.
65 const char *profile_memory;
Dmitry Vyukovadfb6502012-05-22 18:07:45 +000066 // Flush shadow memory every X ms.
67 int flush_memory_ms;
68 // Stops on start until __tsan_resume() is called (for debugging).
69 bool stop_on_start;
Dmitry Vyukov24567d42012-05-24 09:24:45 +000070 // Controls whether RunningOnValgrind() returns true or false.
71 bool running_on_valgrind;
Alexey Samsonov8cc1f812012-09-06 08:48:43 +000072 // Path to external symbolizer.
73 const char *external_symbolizer_path;
Dmitry Vyukovd698edc2012-11-28 12:19:50 +000074 // Per-thread history size, controls how many previous memory accesses
Dmitry Vyukov3fb70e32012-11-28 13:01:32 +000075 // are remembered per thread. Possible values are [0..7].
Dmitry Vyukovd698edc2012-11-28 12:19:50 +000076 // history_size=0 amounts to 32K memory accesses. Each next value doubles
77 // the amount of memory accesses, up to history_size=7 that amounts to
78 // 4M memory accesses. The default value is 2 (128K memory accesses).
79 int history_size;
Dmitry Vyukove3178e82012-12-18 12:20:55 +000080 // Controls level of synchronization implied by IO operations.
81 // 0 - no synchronization
82 // 1 - reasonable level of synchronization (write->read)
83 // 2 - global synchronization of all IO operations
84 int io_sync;
Kostya Serebryany7ac41482012-05-10 13:48:04 +000085};
86
87Flags *flags();
88void InitializeFlags(Flags *flags, const char *env);
Alexey Samsonovba5e9962013-01-30 07:45:58 +000089} // namespace __tsan
Kostya Serebryany7ac41482012-05-10 13:48:04 +000090
91#endif // TSAN_FLAGS_H