tsan_flags.h 3.3 KB

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