Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 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. |
Alexey Samsonov | 86cdf2d | 2012-06-19 08:57:53 +0000 | [diff] [blame] | 11 | // NOTE: This file may be included into user code. |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef TSAN_FLAGS_H |
| 15 | #define TSAN_FLAGS_H |
| 16 | |
Alexey Samsonov | 86cdf2d | 2012-06-19 08:57:53 +0000 | [diff] [blame] | 17 | // ----------- 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 Vyukov | b48c2b2 | 2013-10-15 12:25:29 +0000 | [diff] [blame^] | 23 | #include "sanitizer_common/sanitizer_flags.h" |
| 24 | |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 25 | namespace __tsan { |
| 26 | |
Dmitry Vyukov | b48c2b2 | 2013-10-15 12:25:29 +0000 | [diff] [blame^] | 27 | struct Flags : CommonFlags { |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 28 | // 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 Vyukov | 543b94a | 2012-11-30 17:45:53 +0000 | [diff] [blame] | 36 | // Suppress weird race reports that can be seen if JVM is embed |
| 37 | // into the process. |
| 38 | bool suppress_java; |
Dmitry Vyukov | 8a32677 | 2012-11-07 16:14:12 +0000 | [diff] [blame] | 39 | // Turns off bug reporting entirely (useful for benchmarking). |
| 40 | bool report_bugs; |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 41 | // Report thread leaks at exit? |
| 42 | bool report_thread_leaks; |
Dmitry Vyukov | fd51390 | 2012-08-16 15:12:35 +0000 | [diff] [blame] | 43 | // Report destruction of a locked mutex? |
| 44 | bool report_destroy_locked; |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 45 | // Report violations of async signal-safety |
| 46 | // (e.g. malloc() call from a signal handler). |
| 47 | bool report_signal_unsafe; |
Dmitry Vyukov | ddbe2be | 2013-02-01 10:06:56 +0000 | [diff] [blame] | 48 | // Report races between atomic and plain memory accesses. |
| 49 | bool report_atomic_races; |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 50 | // If set, all atomics are effectively sequentially consistent (seq_cst), |
| 51 | // regardless of what user actually specified. |
| 52 | bool force_seq_cst_atomics; |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 53 | // Suppressions filename. |
| 54 | const char *suppressions; |
Dmitry Vyukov | f754eb5 | 2013-03-27 17:59:57 +0000 | [diff] [blame] | 55 | // Print matched suppressions at exit. |
| 56 | bool print_suppressions; |
Dmitry Vyukov | 0fd908c | 2013-03-28 16:21:19 +0000 | [diff] [blame] | 57 | // Print matched "benign" races at exit. |
| 58 | bool print_benign; |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 59 | // Override exit status if something was reported. |
| 60 | int exitcode; |
Dmitry Vyukov | dbac0a4 | 2013-08-13 15:33:00 +0000 | [diff] [blame] | 61 | // Exit after first reported error. |
| 62 | bool halt_on_error; |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 63 | // 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 Vyukov | 2612773 | 2012-05-22 11:33:03 +0000 | [diff] [blame] | 68 | // If set, periodically write memory profile to that file. |
| 69 | const char *profile_memory; |
Dmitry Vyukov | adfb650 | 2012-05-22 18:07:45 +0000 | [diff] [blame] | 70 | // Flush shadow memory every X ms. |
| 71 | int flush_memory_ms; |
Dmitry Vyukov | f63dde3 | 2013-03-21 13:01:50 +0000 | [diff] [blame] | 72 | // Flush symbolizer caches every X ms. |
| 73 | int flush_symbolizer_ms; |
Dmitry Vyukov | c78140f | 2013-10-03 14:00:46 +0000 | [diff] [blame] | 74 | // 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 Vyukov | adfb650 | 2012-05-22 18:07:45 +0000 | [diff] [blame] | 77 | // Stops on start until __tsan_resume() is called (for debugging). |
| 78 | bool stop_on_start; |
Dmitry Vyukov | 24567d4 | 2012-05-24 09:24:45 +0000 | [diff] [blame] | 79 | // Controls whether RunningOnValgrind() returns true or false. |
| 80 | bool running_on_valgrind; |
Dmitry Vyukov | d698edc | 2012-11-28 12:19:50 +0000 | [diff] [blame] | 81 | // Per-thread history size, controls how many previous memory accesses |
Dmitry Vyukov | 3fb70e3 | 2012-11-28 13:01:32 +0000 | [diff] [blame] | 82 | // are remembered per thread. Possible values are [0..7]. |
Dmitry Vyukov | d698edc | 2012-11-28 12:19:50 +0000 | [diff] [blame] | 83 | // 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 Vyukov | e3178e8 | 2012-12-18 12:20:55 +0000 | [diff] [blame] | 87 | // 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 Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | Flags *flags(); |
| 95 | void InitializeFlags(Flags *flags, const char *env); |
Alexey Samsonov | ba5e996 | 2013-01-30 07:45:58 +0000 | [diff] [blame] | 96 | } // namespace __tsan |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 97 | |
| 98 | #endif // TSAN_FLAGS_H |