1 //===-- tsan_flags.cc -----------------------------------------------------===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of ThreadSanitizer (TSan), a race detector.
10 //===----------------------------------------------------------------------===//
12 #include "sanitizer_common/sanitizer_flags.h"
13 #include "sanitizer_common/sanitizer_libc.h"
14 #include "tsan_flags.h"
16 #include "tsan_mman.h"
24 // Can be overriden in frontend.
25 #ifdef TSAN_EXTERNAL_HOOKS
26 void OverrideFlags(Flags
*f
);
28 SANITIZER_INTERFACE_ATTRIBUTE
29 void WEAK
OverrideFlags(Flags
*f
) {
34 void InitializeFlags(Flags
*f
, const char *env
) {
35 internal_memset(f
, 0, sizeof(*f
));
38 f
->enable_annotations
= true;
39 f
->suppress_equal_stacks
= true;
40 f
->suppress_equal_addresses
= true;
41 f
->suppress_java
= false;
42 f
->report_bugs
= true;
43 f
->report_thread_leaks
= true;
44 f
->report_destroy_locked
= true;
45 f
->report_signal_unsafe
= true;
46 f
->report_atomic_races
= true;
47 f
->force_seq_cst_atomics
= false;
48 f
->strip_path_prefix
= "";
51 f
->log_path
= "stderr";
52 f
->atexit_sleep_ms
= 1000;
54 f
->profile_memory
= "";
55 f
->flush_memory_ms
= 0;
56 f
->stop_on_start
= false;
57 f
->running_on_valgrind
= false;
58 f
->external_symbolizer_path
= "";
59 f
->history_size
= kGoMode
? 1 : 2; // There are a lot of goroutines in Go.
62 // Let a frontend override.
65 // Override from command line.
66 ParseFlag(env
, &f
->enable_annotations
, "enable_annotations");
67 ParseFlag(env
, &f
->suppress_equal_stacks
, "suppress_equal_stacks");
68 ParseFlag(env
, &f
->suppress_equal_addresses
, "suppress_equal_addresses");
69 ParseFlag(env
, &f
->suppress_java
, "suppress_java");
70 ParseFlag(env
, &f
->report_bugs
, "report_bugs");
71 ParseFlag(env
, &f
->report_thread_leaks
, "report_thread_leaks");
72 ParseFlag(env
, &f
->report_destroy_locked
, "report_destroy_locked");
73 ParseFlag(env
, &f
->report_signal_unsafe
, "report_signal_unsafe");
74 ParseFlag(env
, &f
->report_atomic_races
, "report_atomic_races");
75 ParseFlag(env
, &f
->force_seq_cst_atomics
, "force_seq_cst_atomics");
76 ParseFlag(env
, &f
->strip_path_prefix
, "strip_path_prefix");
77 ParseFlag(env
, &f
->suppressions
, "suppressions");
78 ParseFlag(env
, &f
->exitcode
, "exitcode");
79 ParseFlag(env
, &f
->log_path
, "log_path");
80 ParseFlag(env
, &f
->atexit_sleep_ms
, "atexit_sleep_ms");
81 ParseFlag(env
, &f
->verbosity
, "verbosity");
82 ParseFlag(env
, &f
->profile_memory
, "profile_memory");
83 ParseFlag(env
, &f
->flush_memory_ms
, "flush_memory_ms");
84 ParseFlag(env
, &f
->stop_on_start
, "stop_on_start");
85 ParseFlag(env
, &f
->external_symbolizer_path
, "external_symbolizer_path");
86 ParseFlag(env
, &f
->history_size
, "history_size");
87 ParseFlag(env
, &f
->io_sync
, "io_sync");
89 if (!f
->report_bugs
) {
90 f
->report_thread_leaks
= false;
91 f
->report_destroy_locked
= false;
92 f
->report_signal_unsafe
= false;
95 if (f
->history_size
< 0 || f
->history_size
> 7) {
96 Printf("ThreadSanitizer: incorrect value for history_size"
97 " (must be [0..7])\n");
101 if (f
->io_sync
< 0 || f
->io_sync
> 2) {
102 Printf("ThreadSanitizer: incorrect value for io_sync"
103 " (must be [0..2])\n");
108 } // namespace __tsan