1 //===-- sanitizer_flags.h ---------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes common flags available in all sanitizers.
12 //===----------------------------------------------------------------------===//
14 #error "Define COMMON_FLAG prior to including this file!"
17 // COMMON_FLAG(Type, Name, DefaultValue, Description)
18 // Supported types: bool, const char *, int, uptr.
19 // Default value must be a compile-time constant.
20 // Description must be a string literal.
23 bool, symbolize, true,
24 "If set, use the online symbolizer from common sanitizer runtime to turn "
25 "virtual addresses to file/line locations.")
27 const char *, external_symbolizer_path, 0,
28 "Path to external symbolizer. If empty, the tool will search $PATH for "
31 bool, allow_addr2line, false,
32 "If set, allows online symbolizer to run addr2line binary to symbolize "
33 "stack traces (addr2line will only be used if llvm-symbolizer binary is "
35 COMMON_FLAG(const char *, strip_path_prefix, "",
36 "Strips this prefix from file paths in error reports.")
37 COMMON_FLAG(bool, fast_unwind_on_check, false,
38 "If available, use the fast frame-pointer-based unwinder on "
39 "internal CHECK failures.")
40 COMMON_FLAG(bool, fast_unwind_on_fatal, false,
41 "If available, use the fast frame-pointer-based unwinder on fatal "
43 COMMON_FLAG(bool, fast_unwind_on_malloc, true,
44 "If available, use the fast frame-pointer-based unwinder on "
46 COMMON_FLAG(bool, handle_ioctl, false, "Intercept and handle ioctl requests.")
47 COMMON_FLAG(int, malloc_context_size, 1,
48 "Max number of stack frames kept for each allocation/deallocation.")
50 const char *, log_path, "stderr",
51 "Write logs to \"log_path.pid\". The special values are \"stdout\" and "
52 "\"stderr\". The default is \"stderr\".")
55 "Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).")
56 COMMON_FLAG(bool, detect_leaks, true, "Enable memory leak detection.")
58 bool, leak_check_at_exit, true,
59 "Invoke leak checking in an atexit handler. Has no effect if "
60 "detect_leaks=false, or if __lsan_do_leak_check() is called before the "
61 "handler has a chance to run.")
62 COMMON_FLAG(bool, allocator_may_return_null, false,
63 "If false, the allocator will crash instead of returning 0 on "
65 COMMON_FLAG(bool, print_summary, true,
66 "If false, disable printing error summaries in addition to error "
68 COMMON_FLAG(bool, check_printf, true, "Check printf arguments.")
69 COMMON_FLAG(bool, handle_segv, SANITIZER_NEEDS_SEGV,
70 "If set, registers the tool's custom SEGV handler (both SIGBUS and "
72 COMMON_FLAG(bool, allow_user_segv_handler, false,
73 "If set, allows user to register a SEGV handler even if the tool "
75 COMMON_FLAG(bool, use_sigaltstack, true,
76 "If set, uses alternate stack for signal handling.")
77 COMMON_FLAG(bool, detect_deadlocks, false,
78 "If set, deadlock detection is enabled.")
80 uptr, clear_shadow_mmap_threshold, 64 * 1024,
81 "Large shadow regions are zero-filled using mmap(NORESERVE) instead of "
82 "memset(). This is the threshold size in bytes.")
83 COMMON_FLAG(const char *, color, "auto",
84 "Colorize reports: (always|never|auto).")
86 bool, legacy_pthread_cond, false,
87 "Enables support for dynamic libraries linked with libpthread 2.2.5.")
88 COMMON_FLAG(bool, intercept_tls_get_addr, false, "Intercept __tls_get_addr.")
89 COMMON_FLAG(bool, help, false, "Print the flag descriptions.")
90 COMMON_FLAG(uptr, mmap_limit_mb, 0,
91 "Limit the amount of mmap-ed memory (excluding shadow) in Mb; "
92 "not a user-facing flag, used mosly for testing the tools")
93 COMMON_FLAG(uptr, hard_rss_limit_mb, 0,
94 "Hard RSS limit in Mb."
95 " If non-zero, a background thread is spawned at startup"
96 " which periodically reads RSS and aborts the process if the"
98 COMMON_FLAG(uptr, soft_rss_limit_mb, 0,
99 "Soft RSS limit in Mb."
100 " If non-zero, a background thread is spawned at startup"
101 " which periodically reads RSS. If the limit is reached"
102 " all subsequent malloc/new calls will fail or return NULL"
103 " (depending on the value of allocator_may_return_null)"
104 " until the RSS goes below the soft limit."
105 " This limit does not affect memory allocations other than"
107 COMMON_FLAG(bool, can_use_proc_maps_statm, true,
108 "If false, do not attempt to read /proc/maps/statm."
109 " Mostly useful for testing sanitizers.")
111 bool, coverage, false,
112 "If set, coverage information will be dumped at program shutdown (if the "
113 "coverage instrumentation was enabled at compile time).")
114 // On by default, but works only if coverage == true.
115 COMMON_FLAG(bool, coverage_pcs, true,
116 "If set (and if 'coverage' is set too), the coverage information "
117 "will be dumped as a set of PC offsets for every module.")
118 COMMON_FLAG(bool, coverage_bitset, false,
119 "If set (and if 'coverage' is set too), the coverage information "
120 "will also be dumped as a bitset to a separate file.")
121 COMMON_FLAG(bool, coverage_direct, SANITIZER_ANDROID,
122 "If set, coverage information will be dumped directly to a memory "
123 "mapped file. This way data is not lost even if the process is "
125 COMMON_FLAG(const char *, coverage_dir, ".",
126 "Target directory for coverage dumps. Defaults to the current "
128 COMMON_FLAG(bool, full_address_space, false,
129 "Sanitize complete address space; "
130 "by default kernel area on 32-bit platforms will not be sanitized")
131 COMMON_FLAG(bool, print_suppressions, true,
132 "Print matched suppressions at exit.")
134 bool, disable_coredump, (SANITIZER_WORDSIZE == 64),
135 "Disable core dumping. By default, disable_core=1 on 64-bit to avoid "
136 "dumping a 16T+ core file. Ignored on OSes that don't dump core by"
137 "default and for sanitizers that don't reserve lots of virtual memory.")
138 COMMON_FLAG(bool, use_madv_dontdump, true,
139 "If set, instructs kernel to not store the (huge) shadow "
141 COMMON_FLAG(bool, symbolize_inline_frames, true,
142 "Print inlined frames in stacktraces. Defaults to true.")
143 COMMON_FLAG(const char *, stack_trace_format, "DEFAULT",
144 "Format string used to render stack frames. "
145 "See sanitizer_stacktrace_printer.h for the format description. "
146 "Use DEFAULT to get default format.")
147 COMMON_FLAG(bool, no_huge_pages_for_shadow, true,
148 "If true, the shadow is not allowed to use huge pages. ")