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 //===----------------------------------------------------------------------===//
15 #error "Define COMMON_FLAG prior to including this file!"
18 // COMMON_FLAG(Type, Name, DefaultValue, Description)
19 // Supported types: bool, const char *, int, uptr.
20 // Default value must be a compile-time constant.
21 // Description must be a string literal.
24 bool, symbolize, true,
25 "If set, use the online symbolizer from common sanitizer runtime to turn "
26 "virtual addresses to file/line locations.")
28 const char *, external_symbolizer_path, nullptr,
29 "Path to external symbolizer. If empty, the tool will search $PATH for "
32 bool, allow_addr2line, false,
33 "If set, allows online symbolizer to run addr2line binary to symbolize "
34 "stack traces (addr2line will only be used if llvm-symbolizer binary is "
36 COMMON_FLAG(const char *, strip_path_prefix, "",
37 "Strips this prefix from file paths in error reports.")
38 COMMON_FLAG(bool, fast_unwind_on_check, false,
39 "If available, use the fast frame-pointer-based unwinder on "
40 "internal CHECK failures.")
41 COMMON_FLAG(bool, fast_unwind_on_fatal, false,
42 "If available, use the fast frame-pointer-based unwinder on fatal "
44 COMMON_FLAG(bool, fast_unwind_on_malloc, true,
45 "If available, use the fast frame-pointer-based unwinder on "
47 COMMON_FLAG(bool, handle_ioctl, false, "Intercept and handle ioctl requests.")
48 COMMON_FLAG(int, malloc_context_size, 1,
49 "Max number of stack frames kept for each allocation/deallocation.")
51 const char *, log_path, "stderr",
52 "Write logs to \"log_path.pid\". The special values are \"stdout\" and "
53 "\"stderr\". The default is \"stderr\".")
55 bool, log_exe_name, false,
56 "Mention name of executable when reporting error and "
57 "append executable name to logs (as in \"log_path.exe_name.pid\").")
59 bool, log_to_syslog, SANITIZER_ANDROID || SANITIZER_MAC,
60 "Write all sanitizer output to syslog in addition to other means of "
64 "Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).")
65 COMMON_FLAG(bool, detect_leaks, !SANITIZER_MAC, "Enable memory leak detection.")
67 bool, leak_check_at_exit, true,
68 "Invoke leak checking in an atexit handler. Has no effect if "
69 "detect_leaks=false, or if __lsan_do_leak_check() is called before the "
70 "handler has a chance to run.")
71 COMMON_FLAG(bool, allocator_may_return_null, false,
72 "If false, the allocator will crash instead of returning 0 on "
74 COMMON_FLAG(bool, print_summary, true,
75 "If false, disable printing error summaries in addition to error "
77 COMMON_FLAG(int, print_module_map, 0,
78 "OS X only (0 - don't print, 1 - print only once before process "
79 "exits, 2 - print after each report).")
80 COMMON_FLAG(bool, check_printf, true, "Check printf arguments.")
81 #define COMMON_FLAG_HANDLE_SIGNAL_HELP(signal) \
82 "Controls custom tool's " #signal " handler (0 - do not registers the " \
83 "handler, 1 - register the handler and allow user to set own, " \
84 "2 - registers the handler and block user from changing it). "
85 COMMON_FLAG(HandleSignalMode, handle_segv, kHandleSignalYes,
86 COMMON_FLAG_HANDLE_SIGNAL_HELP(SIGSEGV))
87 COMMON_FLAG(HandleSignalMode, handle_sigbus, kHandleSignalYes,
88 COMMON_FLAG_HANDLE_SIGNAL_HELP(SIGBUS))
89 COMMON_FLAG(HandleSignalMode, handle_abort, kHandleSignalNo,
90 COMMON_FLAG_HANDLE_SIGNAL_HELP(SIGABRT))
91 COMMON_FLAG(HandleSignalMode, handle_sigill, kHandleSignalNo,
92 COMMON_FLAG_HANDLE_SIGNAL_HELP(SIGILL))
93 COMMON_FLAG(HandleSignalMode, handle_sigfpe, kHandleSignalYes,
94 COMMON_FLAG_HANDLE_SIGNAL_HELP(SIGFPE))
95 #undef COMMON_FLAG_HANDLE_SIGNAL_HELP
96 COMMON_FLAG(bool, allow_user_segv_handler, true,
97 "Deprecated. True has no effect, use handle_sigbus=1. If false, "
98 "handle_*=1 will be upgraded to handle_*=2.")
99 COMMON_FLAG(bool, use_sigaltstack, true,
100 "If set, uses alternate stack for signal handling.")
101 COMMON_FLAG(bool, detect_deadlocks, false,
102 "If set, deadlock detection is enabled.")
104 uptr, clear_shadow_mmap_threshold, 64 * 1024,
105 "Large shadow regions are zero-filled using mmap(NORESERVE) instead of "
106 "memset(). This is the threshold size in bytes.")
107 COMMON_FLAG(const char *, color, "auto",
108 "Colorize reports: (always|never|auto).")
110 bool, legacy_pthread_cond, false,
111 "Enables support for dynamic libraries linked with libpthread 2.2.5.")
112 COMMON_FLAG(bool, intercept_tls_get_addr, false, "Intercept __tls_get_addr.")
113 COMMON_FLAG(bool, help, false, "Print the flag descriptions.")
114 COMMON_FLAG(uptr, mmap_limit_mb, 0,
115 "Limit the amount of mmap-ed memory (excluding shadow) in Mb; "
116 "not a user-facing flag, used mosly for testing the tools")
117 COMMON_FLAG(uptr, hard_rss_limit_mb, 0,
118 "Hard RSS limit in Mb."
119 " If non-zero, a background thread is spawned at startup"
120 " which periodically reads RSS and aborts the process if the"
122 COMMON_FLAG(uptr, soft_rss_limit_mb, 0,
123 "Soft RSS limit in Mb."
124 " If non-zero, a background thread is spawned at startup"
125 " which periodically reads RSS. If the limit is reached"
126 " all subsequent malloc/new calls will fail or return NULL"
127 " (depending on the value of allocator_may_return_null)"
128 " until the RSS goes below the soft limit."
129 " This limit does not affect memory allocations other than"
131 COMMON_FLAG(bool, heap_profile, false, "Experimental heap profiler, asan-only")
132 COMMON_FLAG(s32, allocator_release_to_os_interval_ms, kReleaseToOSIntervalNever,
133 "Experimental. Only affects a 64-bit allocator. If set, tries to "
134 "release unused memory to the OS, but not more often than this "
135 "interval (in milliseconds). Negative values mean do not attempt "
136 "to release memory to the OS.\n")
137 COMMON_FLAG(bool, can_use_proc_maps_statm, true,
138 "If false, do not attempt to read /proc/maps/statm."
139 " Mostly useful for testing sanitizers.")
141 bool, coverage, false,
142 "If set, coverage information will be dumped at program shutdown (if the "
143 "coverage instrumentation was enabled at compile time).")
144 COMMON_FLAG(const char *, coverage_dir, ".",
145 "Target directory for coverage dumps. Defaults to the current "
147 COMMON_FLAG(bool, full_address_space, false,
148 "Sanitize complete address space; "
149 "by default kernel area on 32-bit platforms will not be sanitized")
150 COMMON_FLAG(bool, print_suppressions, true,
151 "Print matched suppressions at exit.")
153 bool, disable_coredump, (SANITIZER_WORDSIZE == 64) && !SANITIZER_GO,
154 "Disable core dumping. By default, disable_coredump=1 on 64-bit to avoid"
155 " dumping a 16T+ core file. Ignored on OSes that don't dump core by"
156 " default and for sanitizers that don't reserve lots of virtual memory.")
157 COMMON_FLAG(bool, use_madv_dontdump, true,
158 "If set, instructs kernel to not store the (huge) shadow "
160 COMMON_FLAG(bool, symbolize_inline_frames, true,
161 "Print inlined frames in stacktraces. Defaults to true.")
162 COMMON_FLAG(bool, symbolize_vs_style, false,
163 "Print file locations in Visual Studio style (e.g: "
165 COMMON_FLAG(int, dedup_token_length, 0,
166 "If positive, after printing a stack trace also print a short "
167 "string token based on this number of frames that will simplify "
168 "deduplication of the reports. "
169 "Example: 'DEDUP_TOKEN: foo-bar-main'. Default is 0.")
170 COMMON_FLAG(const char *, stack_trace_format, "DEFAULT",
171 "Format string used to render stack frames. "
172 "See sanitizer_stacktrace_printer.h for the format description. "
173 "Use DEFAULT to get default format.")
174 COMMON_FLAG(bool, no_huge_pages_for_shadow, true,
175 "If true, the shadow is not allowed to use huge pages. ")
176 COMMON_FLAG(bool, strict_string_checks, false,
177 "If set check that string arguments are properly null-terminated")
178 COMMON_FLAG(bool, intercept_strstr, true,
179 "If set, uses custom wrappers for strstr and strcasestr functions "
180 "to find more errors.")
181 COMMON_FLAG(bool, intercept_strspn, true,
182 "If set, uses custom wrappers for strspn and strcspn function "
183 "to find more errors.")
184 COMMON_FLAG(bool, intercept_strtok, true,
185 "If set, uses a custom wrapper for the strtok function "
186 "to find more errors.")
187 COMMON_FLAG(bool, intercept_strpbrk, true,
188 "If set, uses custom wrappers for strpbrk function "
189 "to find more errors.")
190 COMMON_FLAG(bool, intercept_strlen, true,
191 "If set, uses custom wrappers for strlen and strnlen functions "
192 "to find more errors.")
193 COMMON_FLAG(bool, intercept_strndup, true,
194 "If set, uses custom wrappers for strndup functions "
195 "to find more errors.")
196 COMMON_FLAG(bool, intercept_strchr, true,
197 "If set, uses custom wrappers for strchr, strchrnul, and strrchr "
198 "functions to find more errors.")
199 COMMON_FLAG(bool, intercept_memcmp, true,
200 "If set, uses custom wrappers for memcmp function "
201 "to find more errors.")
202 COMMON_FLAG(bool, strict_memcmp, true,
203 "If true, assume that memcmp(p1, p2, n) always reads n bytes before "
204 "comparing p1 and p2.")
205 COMMON_FLAG(bool, intercept_memmem, true,
206 "If set, uses a wrapper for memmem() to find more errors.")
207 COMMON_FLAG(bool, intercept_intrin, true,
208 "If set, uses custom wrappers for memset/memcpy/memmove "
209 "intrinsics to find more errors.")
210 COMMON_FLAG(bool, intercept_stat, true,
211 "If set, uses custom wrappers for *stat functions "
212 "to find more errors.")
213 COMMON_FLAG(bool, intercept_send, true,
214 "If set, uses custom wrappers for send* functions "
215 "to find more errors.")
216 COMMON_FLAG(bool, decorate_proc_maps, false, "If set, decorate sanitizer "
217 "mappings in /proc/self/maps with "
218 "user-readable names")
219 COMMON_FLAG(int, exitcode, 1, "Override the program exit status if the tool "
222 bool, abort_on_error, SANITIZER_ANDROID || SANITIZER_MAC,
223 "If set, the tool calls abort() instead of _exit() after printing the "
225 COMMON_FLAG(bool, suppress_equal_pcs, true,
226 "Deduplicate multiple reports for single source location in "
227 "halt_on_error=false mode (asan only).")
228 COMMON_FLAG(bool, print_cmdline, false, "Print command line on crash "
230 COMMON_FLAG(bool, html_cov_report, false, "Generate html coverage report.")
231 COMMON_FLAG(const char *, sancov_path, "sancov", "Sancov tool location.")