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