blob: b240fdce4a20785b8c94ff0c47e568db82c063b2 [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
Dmitry Vyukovb48c2b22013-10-15 12:25:29 +000023#include "sanitizer_common/sanitizer_flags.h"
24
Kostya Serebryany7ac41482012-05-10 13:48:04 +000025namespace __tsan {
26
Dmitry Vyukovb48c2b22013-10-15 12:25:29 +000027struct Flags : CommonFlags {
Kostya Serebryany7ac41482012-05-10 13:48:04 +000028 // 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;
Dmitry Vyukov543b94a2012-11-30 17:45:53 +000036 // Suppress weird race reports that can be seen if JVM is embed
37 // into the process.
38 bool suppress_java;
Dmitry Vyukov8a326772012-11-07 16:14:12 +000039 // Turns off bug reporting entirely (useful for benchmarking).
40 bool report_bugs;
Kostya Serebryany7ac41482012-05-10 13:48:04 +000041 // Report thread leaks at exit?
42 bool report_thread_leaks;
Dmitry Vyukovfd513902012-08-16 15:12:35 +000043 // Report destruction of a locked mutex?
44 bool report_destroy_locked;
Kostya Serebryany7ac41482012-05-10 13:48:04 +000045 // Report violations of async signal-safety
46 // (e.g. malloc() call from a signal handler).
47 bool report_signal_unsafe;
Dmitry Vyukovddbe2be2013-02-01 10:06:56 +000048 // Report races between atomic and plain memory accesses.
49 bool report_atomic_races;
Kostya Serebryany7ac41482012-05-10 13:48:04 +000050 // If set, all atomics are effectively sequentially consistent (seq_cst),
51 // regardless of what user actually specified.
52 bool force_seq_cst_atomics;
Kostya Serebryany7ac41482012-05-10 13:48:04 +000053 // Suppressions filename.
54 const char *suppressions;
Dmitry Vyukovf754eb52013-03-27 17:59:57 +000055 // Print matched suppressions at exit.
56 bool print_suppressions;
Dmitry Vyukov0fd908c2013-03-28 16:21:19 +000057 // Print matched "benign" races at exit.
58 bool print_benign;
Kostya Serebryany7ac41482012-05-10 13:48:04 +000059 // Override exit status if something was reported.
60 int exitcode;
Dmitry Vyukovdbac0a42013-08-13 15:33:00 +000061 // Exit after first reported error.
62 bool halt_on_error;
Kostya Serebryany7ac41482012-05-10 13:48:04 +000063 // Sleep in main thread before exiting for that many ms
64 // (useful to catch "at exit" races).
65 int atexit_sleep_ms;
66 // Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).
67 int verbosity;
Dmitry Vyukov26127732012-05-22 11:33:03 +000068 // If set, periodically write memory profile to that file.
69 const char *profile_memory;
Dmitry Vyukovadfb6502012-05-22 18:07:45 +000070 // Flush shadow memory every X ms.
71 int flush_memory_ms;
Dmitry Vyukovf63dde32013-03-21 13:01:50 +000072 // Flush symbolizer caches every X ms.
73 int flush_symbolizer_ms;
Dmitry Vyukovc78140f2013-10-03 14:00:46 +000074 // Resident memory limit in MB to aim at.
75 // If the process consumes more memory, then TSan will flush shadow memory.
76 int memory_limit_mb;
Dmitry Vyukovadfb6502012-05-22 18:07:45 +000077 // Stops on start until __tsan_resume() is called (for debugging).
78 bool stop_on_start;
Dmitry Vyukov24567d42012-05-24 09:24:45 +000079 // Controls whether RunningOnValgrind() returns true or false.
80 bool running_on_valgrind;
Dmitry Vyukovd698edc2012-11-28 12:19:50 +000081 // Per-thread history size, controls how many previous memory accesses
Dmitry Vyukov3fb70e32012-11-28 13:01:32 +000082 // are remembered per thread. Possible values are [0..7].
Dmitry Vyukovd698edc2012-11-28 12:19:50 +000083 // history_size=0 amounts to 32K memory accesses. Each next value doubles
84 // the amount of memory accesses, up to history_size=7 that amounts to
85 // 4M memory accesses. The default value is 2 (128K memory accesses).
86 int history_size;
Dmitry Vyukove3178e82012-12-18 12:20:55 +000087 // Controls level of synchronization implied by IO operations.
88 // 0 - no synchronization
89 // 1 - reasonable level of synchronization (write->read)
90 // 2 - global synchronization of all IO operations
91 int io_sync;
Kostya Serebryany7ac41482012-05-10 13:48:04 +000092};
93
94Flags *flags();
95void InitializeFlags(Flags *flags, const char *env);
Alexey Samsonovba5e9962013-01-30 07:45:58 +000096} // namespace __tsan
Kostya Serebryany7ac41482012-05-10 13:48:04 +000097
98#endif // TSAN_FLAGS_H