annotate libsanitizer/sanitizer_common/sanitizer_flags.inc @ 138:fc828634a951

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