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