1 //===-- sanitizer_flags.h ---------------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file describes common flags available in all sanitizers.
10 //===----------------------------------------------------------------------===//
13 #error "Define COMMON_FLAG prior to including this file!"
16 // COMMON_FLAG(Type, Name, DefaultValue, Description)
17 // Supported types: bool, const char *, int, uptr.
18 // Default value must be a compile-time constant.
19 // Description must be a string literal.
22 bool, symbolize, true,
23 "If set, use the online symbolizer from common sanitizer runtime to turn "
24 "virtual addresses to file/line locations.")
26 const char *, external_symbolizer_path, nullptr,
27 "Path to external symbolizer. If empty, the tool will search $PATH for "
30 bool, allow_addr2line, false,
31 "If set, allows online symbolizer to run addr2line binary to symbolize "
32 "stack traces (addr2line will only be used if llvm-symbolizer binary is "
34 COMMON_FLAG(const char *, strip_path_prefix, "",
35 "Strips this prefix from file paths in error reports.")
36 COMMON_FLAG(bool, fast_unwind_on_check, false,
37 "If available, use the fast frame-pointer-based unwinder on "
38 "internal CHECK failures.")
39 COMMON_FLAG(bool, fast_unwind_on_fatal, false,
40 "If available, use the fast frame-pointer-based unwinder on fatal "
42 COMMON_FLAG(bool, fast_unwind_on_malloc, true,
43 "If available, use the fast frame-pointer-based unwinder on "
45 COMMON_FLAG(bool, handle_ioctl, false, "Intercept and handle ioctl requests.")
46 COMMON_FLAG(int, malloc_context_size, 1,
47 "Max number of stack frames kept for each allocation/deallocation.")
49 const char *, log_path, "stderr",
50 "Write logs to \"log_path.pid\". The special values are \"stdout\" and "
51 "\"stderr\". The default is \"stderr\".")
53 bool, log_exe_name, false,
54 "Mention name of executable when reporting error and "
55 "append executable name to logs (as in \"log_path.exe_name.pid\").")
57 bool, log_to_syslog, SANITIZER_ANDROID || SANITIZER_MAC,
58 "Write all sanitizer output to syslog in addition to other means of "
62 "Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).")
63 COMMON_FLAG(bool, detect_leaks, (SANITIZER_WORDSIZE == 64),
64 "Enable memory leak detection.")
66 bool, leak_check_at_exit, true,
67 "Invoke leak checking in an atexit handler. Has no effect if "
68 "detect_leaks=false, or if __lsan_do_leak_check() is called before the "
69 "handler has a chance to run.")
70 COMMON_FLAG(uptr, leak_check_interval_s, 0,
71 "Experimental. If set, creates background thread that performs "
72 "recoverable leak checking every leak_check_interval_s seconds. "
73 "Disabled if zero or detect_leaks=false.\n")
74 COMMON_FLAG(bool, allocator_may_return_null, false,
75 "If false, the allocator will crash instead of returning 0 on "
77 COMMON_FLAG(bool, print_summary, true,
78 "If false, disable printing error summaries in addition to error "
80 COMMON_FLAG(bool, check_printf, true, "Check printf arguments.")
81 COMMON_FLAG(bool, handle_segv, true,
82 "If set, registers the tool's custom SIGSEGV/SIGBUS handler.")
83 COMMON_FLAG(bool, handle_abort, false,
84 "If set, registers the tool's custom SIGABRT handler.")
85 COMMON_FLAG(bool, handle_sigill, false,
86 "If set, registers the tool's custom SIGILL handler.")
87 COMMON_FLAG(bool, handle_sigfpe, true,
88 "If set, registers the tool's custom SIGFPE handler.")
89 COMMON_FLAG(bool, allow_user_segv_handler, false,
90 "If set, allows user to register a SEGV handler even if the tool "
92 COMMON_FLAG(bool, use_sigaltstack, true,
93 "If set, uses alternate stack for signal handling.")
94 COMMON_FLAG(bool, detect_deadlocks, false,
95 "If set, deadlock detection is enabled.")
97 uptr, clear_shadow_mmap_threshold, 64 * 1024,
98 "Large shadow regions are zero-filled using mmap(NORESERVE) instead of "
99 "memset(). This is the threshold size in bytes.")
100 COMMON_FLAG(const char *, color, "auto",
101 "Colorize reports: (always|never|auto).")
103 bool, legacy_pthread_cond, false,
104 "Enables support for dynamic libraries linked with libpthread 2.2.5.")
105 COMMON_FLAG(bool, intercept_tls_get_addr, false, "Intercept __tls_get_addr.")
106 COMMON_FLAG(bool, help, false, "Print the flag descriptions.")
107 COMMON_FLAG(uptr, mmap_limit_mb, 0,
108 "Limit the amount of mmap-ed memory (excluding shadow) in Mb; "
109 "not a user-facing flag, used mosly for testing the tools")
110 COMMON_FLAG(uptr, hard_rss_limit_mb, 0,
111 "Hard RSS limit in Mb."
112 " If non-zero, a background thread is spawned at startup"
113 " which periodically reads RSS and aborts the process if the"
115 COMMON_FLAG(uptr, soft_rss_limit_mb, 0,
116 "Soft RSS limit in Mb."
117 " If non-zero, a background thread is spawned at startup"
118 " which periodically reads RSS. If the limit is reached"
119 " all subsequent malloc/new calls will fail or return NULL"
120 " (depending on the value of allocator_may_return_null)"
121 " until the RSS goes below the soft limit."
122 " This limit does not affect memory allocations other than"
124 COMMON_FLAG(int, bgthread_min_sleep_ms, 2,
125 "Lower bound for background thread sleeping interval.")
126 COMMON_FLAG(int, bgthread_max_sleep_ms, 100,
127 "Upper bound for background thread sleeping interval.")
128 COMMON_FLAG(bool, heap_profile, false,
129 "Experimental. Enables heap profiler (asan-only).")
130 COMMON_FLAG(bool, heap_profile_timestamp, false,
131 "If set, prints timestamps along with heap profiler data.")
132 COMMON_FLAG(int, heap_profile_out_full_lim, 10,
133 "Threshold value (in percentages) of RSS growth which"
134 " triggers printing memory usage by heap profiler.")
135 COMMON_FLAG(bool, heap_profile_out_decrease, false,
136 "If set, prints memory profile on memory usage decrease.")
137 COMMON_FLAG(uptr, heap_profile_full_out_time, 0,
138 "If non-zero, sets timeout (in milliseconds) for unconditional"
139 " printing of memory usage data by heap profiler; otherwise"
140 " there's no timeout.")
141 COMMON_FLAG(uptr, heap_profile_short_out_time, 0,
142 "If non-zero, sets timeout (in milliseconds) for unconditional"
143 " printing of short memory usage data by heap profiler;"
144 " otherwise there's no timeout. This should be less than"
145 " heap_profile_full_out_time or no short output will be produced,"
146 " as printing full memory profile has higher precedence.")
147 COMMON_FLAG(int, heap_profile_top_percent, 90,
148 "Sets threshold (in percentages) for memory allocations to be"
149 " shown, from largest to smallest.")
150 COMMON_FLAG(bool, heap_profile_rss_mb, true,
151 "If true, prints RSS memory usage in MBs instead of bytes.")
152 COMMON_FLAG(const char *, heap_profile_log_path, "",
153 "If set, uses separate file to write heap profile reports.")
154 COMMON_FLAG(s32, allocator_release_to_os_interval_ms, kReleaseToOSIntervalNever,
155 "Experimental. Only affects a 64-bit allocator. If set, tries to "
156 "release unused memory to the OS, but not more often than this "
157 "interval (in milliseconds). Negative values mean do not attempt "
158 "to release memory to the OS.\n")
159 COMMON_FLAG(bool, can_use_proc_maps_statm, true,
160 "If false, do not attempt to read /proc/maps/statm."
161 " Mostly useful for testing sanitizers.")
163 bool, coverage, false,
164 "If set, coverage information will be dumped at program shutdown (if the "
165 "coverage instrumentation was enabled at compile time).")
166 COMMON_FLAG(bool, coverage_pcs, true,
167 "If set (and if 'coverage' is set too), the coverage information "
168 "will be dumped as a set of PC offsets for every module.")
169 COMMON_FLAG(bool, coverage_order_pcs, false,
170 "If true, the PCs will be dumped in the order they've"
171 " appeared during the execution.")
172 COMMON_FLAG(bool, coverage_bitset, false,
173 "If set (and if 'coverage' is set too), the coverage information "
174 "will also be dumped as a bitset to a separate file.")
175 COMMON_FLAG(bool, coverage_counters, false,
176 "If set (and if 'coverage' is set too), the bitmap that corresponds"
177 " to coverage counters will be dumped.")
178 COMMON_FLAG(bool, coverage_direct, SANITIZER_ANDROID,
179 "If set, coverage information will be dumped directly to a memory "
180 "mapped file. This way data is not lost even if the process is "
182 COMMON_FLAG(const char *, coverage_dir, ".",
183 "Target directory for coverage dumps. Defaults to the current "
185 COMMON_FLAG(bool, full_address_space, false,
186 "Sanitize complete address space; "
187 "by default kernel area on 32-bit platforms will not be sanitized")
188 COMMON_FLAG(bool, print_suppressions, true,
189 "Print matched suppressions at exit.")
191 bool, disable_coredump, (SANITIZER_WORDSIZE == 64) && !SANITIZER_GO,
192 "Disable core dumping. By default, disable_coredump=1 on 64-bit to avoid"
193 " dumping a 16T+ core file. Ignored on OSes that don't dump core by"
194 " default and for sanitizers that don't reserve lots of virtual memory.")
195 COMMON_FLAG(bool, use_madv_dontdump, true,
196 "If set, instructs kernel to not store the (huge) shadow "
198 COMMON_FLAG(bool, symbolize_inline_frames, true,
199 "Print inlined frames in stacktraces. Defaults to true.")
200 COMMON_FLAG(bool, symbolize_vs_style, false,
201 "Print file locations in Visual Studio style (e.g: "
203 COMMON_FLAG(int, dedup_token_length, 0,
204 "If positive, after printing a stack trace also print a short "
205 "string token based on this number of frames that will simplify "
206 "deduplication of the reports. "
207 "Example: 'DEDUP_TOKEN: foo-bar-main'. Default is 0.")
208 COMMON_FLAG(const char *, stack_trace_format, "DEFAULT",
209 "Format string used to render stack frames. "
210 "See sanitizer_stacktrace_printer.h for the format description. "
211 "Use DEFAULT to get default format.")
212 COMMON_FLAG(bool, no_huge_pages_for_shadow, true,
213 "If true, the shadow is not allowed to use huge pages. ")
214 COMMON_FLAG(bool, strict_string_checks, false,
215 "If set check that string arguments are properly null-terminated")
216 COMMON_FLAG(bool, intercept_strstr, true,
217 "If set, uses custom wrappers for strstr and strcasestr functions "
218 "to find more errors.")
219 COMMON_FLAG(bool, intercept_strspn, true,
220 "If set, uses custom wrappers for strspn and strcspn function "
221 "to find more errors.")
222 COMMON_FLAG(bool, intercept_strpbrk, true,
223 "If set, uses custom wrappers for strpbrk function "
224 "to find more errors.")
225 COMMON_FLAG(bool, intercept_strlen, true,
226 "If set, uses custom wrappers for strlen and strnlen functions "
227 "to find more errors.")
228 COMMON_FLAG(bool, intercept_strchr, true,
229 "If set, uses custom wrappers for strchr, strchrnul, and strrchr "
230 "functions to find more errors.")
231 COMMON_FLAG(bool, intercept_memcmp, true,
232 "If set, uses custom wrappers for memcmp function "
233 "to find more errors.")
234 COMMON_FLAG(bool, strict_memcmp, true,
235 "If true, assume that memcmp(p1, p2, n) always reads n bytes before "
236 "comparing p1 and p2.")
237 COMMON_FLAG(bool, intercept_memmem, true,
238 "If set, uses a wrapper for memmem() to find more errors.")
239 COMMON_FLAG(bool, intercept_intrin, true,
240 "If set, uses custom wrappers for memset/memcpy/memmove "
241 "intrinsics to find more errors.")
242 COMMON_FLAG(bool, intercept_stat, true,
243 "If set, uses custom wrappers for *stat functions "
244 "to find more errors.")
245 COMMON_FLAG(bool, intercept_send, true,
246 "If set, uses custom wrappers for send* functions "
247 "to find more errors.")
248 COMMON_FLAG(bool, decorate_proc_maps, false, "If set, decorate sanitizer "
249 "mappings in /proc/self/maps with "
250 "user-readable names")
251 COMMON_FLAG(int, exitcode, 1, "Override the program exit status if the tool "
254 bool, abort_on_error, SANITIZER_ANDROID || SANITIZER_MAC,
255 "If set, the tool calls abort() instead of _exit() after printing the "
257 COMMON_FLAG(bool, suppress_equal_pcs, true,
258 "Deduplicate multiple reports for single source location in "
259 "halt_on_error=false mode (asan only).")
260 COMMON_FLAG(bool, print_cmdline, false, "Print command line on crash "
261 "(asan, ubsan and lsan only).")
262 COMMON_FLAG(bool, html_cov_report, false, "Generate html coverage report.")
263 COMMON_FLAG(const char *, sancov_path, "sancov", "Sancov tool location.")