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