blob: c89273117a5e9b66287e691fd8269f93856446b2 [file] [log] [blame]
Stephen Hines86277eb2015-03-23 12:06:32 -07001//===-- sanitizer_flags.h ---------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file describes common flags available in all sanitizers.
11//
12//===----------------------------------------------------------------------===//
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080013
Stephen Hines86277eb2015-03-23 12:06:32 -070014#ifndef COMMON_FLAG
15#error "Define COMMON_FLAG prior to including this file!"
16#endif
17
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.
22
23COMMON_FLAG(
24 bool, symbolize, true,
25 "If set, use the online symbolizer from common sanitizer runtime to turn "
26 "virtual addresses to file/line locations.")
27COMMON_FLAG(
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080028 const char *, external_symbolizer_path, nullptr,
Stephen Hines86277eb2015-03-23 12:06:32 -070029 "Path to external symbolizer. If empty, the tool will search $PATH for "
30 "the symbolizer.")
31COMMON_FLAG(
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 "
35 "unavailable.")
36COMMON_FLAG(const char *, strip_path_prefix, "",
37 "Strips this prefix from file paths in error reports.")
38COMMON_FLAG(bool, fast_unwind_on_check, false,
39 "If available, use the fast frame-pointer-based unwinder on "
40 "internal CHECK failures.")
41COMMON_FLAG(bool, fast_unwind_on_fatal, false,
42 "If available, use the fast frame-pointer-based unwinder on fatal "
43 "errors.")
44COMMON_FLAG(bool, fast_unwind_on_malloc, true,
45 "If available, use the fast frame-pointer-based unwinder on "
46 "malloc/free.")
47COMMON_FLAG(bool, handle_ioctl, false, "Intercept and handle ioctl requests.")
48COMMON_FLAG(int, malloc_context_size, 1,
49 "Max number of stack frames kept for each allocation/deallocation.")
50COMMON_FLAG(
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\".")
54COMMON_FLAG(
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -070055 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\").")
58COMMON_FLAG(
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080059 bool, log_to_syslog, SANITIZER_ANDROID || SANITIZER_MAC,
60 "Write all sanitizer output to syslog in addition to other means of "
61 "logging.")
62COMMON_FLAG(
Stephen Hines86277eb2015-03-23 12:06:32 -070063 int, verbosity, 0,
64 "Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).")
65COMMON_FLAG(bool, detect_leaks, true, "Enable memory leak detection.")
66COMMON_FLAG(
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.")
71COMMON_FLAG(bool, allocator_may_return_null, false,
72 "If false, the allocator will crash instead of returning 0 on "
73 "out-of-memory.")
74COMMON_FLAG(bool, print_summary, true,
75 "If false, disable printing error summaries in addition to error "
76 "reports.")
77COMMON_FLAG(bool, check_printf, true, "Check printf arguments.")
78COMMON_FLAG(bool, handle_segv, SANITIZER_NEEDS_SEGV,
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -070079 "If set, registers the tool's custom SIGSEGV/SIGBUS handler.")
80COMMON_FLAG(bool, handle_abort, false,
81 "If set, registers the tool's custom SIGABRT handler.")
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080082COMMON_FLAG(bool, handle_sigill, false,
83 "If set, registers the tool's custom SIGILL handler.")
84COMMON_FLAG(bool, handle_sigfpe, true,
85 "If set, registers the tool's custom SIGFPE handler.")
Stephen Hines86277eb2015-03-23 12:06:32 -070086COMMON_FLAG(bool, allow_user_segv_handler, false,
87 "If set, allows user to register a SEGV handler even if the tool "
88 "registers one.")
89COMMON_FLAG(bool, use_sigaltstack, true,
90 "If set, uses alternate stack for signal handling.")
91COMMON_FLAG(bool, detect_deadlocks, false,
92 "If set, deadlock detection is enabled.")
93COMMON_FLAG(
94 uptr, clear_shadow_mmap_threshold, 64 * 1024,
95 "Large shadow regions are zero-filled using mmap(NORESERVE) instead of "
96 "memset(). This is the threshold size in bytes.")
97COMMON_FLAG(const char *, color, "auto",
98 "Colorize reports: (always|never|auto).")
99COMMON_FLAG(
100 bool, legacy_pthread_cond, false,
101 "Enables support for dynamic libraries linked with libpthread 2.2.5.")
102COMMON_FLAG(bool, intercept_tls_get_addr, false, "Intercept __tls_get_addr.")
103COMMON_FLAG(bool, help, false, "Print the flag descriptions.")
104COMMON_FLAG(uptr, mmap_limit_mb, 0,
105 "Limit the amount of mmap-ed memory (excluding shadow) in Mb; "
106 "not a user-facing flag, used mosly for testing the tools")
107COMMON_FLAG(uptr, hard_rss_limit_mb, 0,
108 "Hard RSS limit in Mb."
109 " If non-zero, a background thread is spawned at startup"
110 " which periodically reads RSS and aborts the process if the"
111 " limit is reached")
112COMMON_FLAG(uptr, soft_rss_limit_mb, 0,
113 "Soft RSS limit in Mb."
114 " If non-zero, a background thread is spawned at startup"
115 " which periodically reads RSS. If the limit is reached"
116 " all subsequent malloc/new calls will fail or return NULL"
117 " (depending on the value of allocator_may_return_null)"
118 " until the RSS goes below the soft limit."
119 " This limit does not affect memory allocations other than"
120 " malloc/new.")
121COMMON_FLAG(bool, can_use_proc_maps_statm, true,
122 "If false, do not attempt to read /proc/maps/statm."
123 " Mostly useful for testing sanitizers.")
124COMMON_FLAG(
125 bool, coverage, false,
126 "If set, coverage information will be dumped at program shutdown (if the "
127 "coverage instrumentation was enabled at compile time).")
Stephen Hines86277eb2015-03-23 12:06:32 -0700128COMMON_FLAG(bool, coverage_pcs, true,
129 "If set (and if 'coverage' is set too), the coverage information "
130 "will be dumped as a set of PC offsets for every module.")
Pirama Arumuga Nainar7c915052015-04-08 08:58:29 -0700131COMMON_FLAG(bool, coverage_order_pcs, false,
132 "If true, the PCs will be dumped in the order they've"
133 " appeared during the execution.")
Stephen Hines86277eb2015-03-23 12:06:32 -0700134COMMON_FLAG(bool, coverage_bitset, false,
135 "If set (and if 'coverage' is set too), the coverage information "
136 "will also be dumped as a bitset to a separate file.")
Pirama Arumuga Nainar7c915052015-04-08 08:58:29 -0700137COMMON_FLAG(bool, coverage_counters, false,
138 "If set (and if 'coverage' is set too), the bitmap that corresponds"
139 " to coverage counters will be dumped.")
Stephen Hines86277eb2015-03-23 12:06:32 -0700140COMMON_FLAG(bool, coverage_direct, SANITIZER_ANDROID,
141 "If set, coverage information will be dumped directly to a memory "
142 "mapped file. This way data is not lost even if the process is "
143 "suddenly killed.")
144COMMON_FLAG(const char *, coverage_dir, ".",
145 "Target directory for coverage dumps. Defaults to the current "
146 "directory.")
147COMMON_FLAG(bool, full_address_space, false,
148 "Sanitize complete address space; "
149 "by default kernel area on 32-bit platforms will not be sanitized")
150COMMON_FLAG(bool, print_suppressions, true,
151 "Print matched suppressions at exit.")
152COMMON_FLAG(
153 bool, disable_coredump, (SANITIZER_WORDSIZE == 64),
154 "Disable core dumping. By default, disable_core=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.")
157COMMON_FLAG(bool, use_madv_dontdump, true,
158 "If set, instructs kernel to not store the (huge) shadow "
159 "in core file.")
160COMMON_FLAG(bool, symbolize_inline_frames, true,
161 "Print inlined frames in stacktraces. Defaults to true.")
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -0700162COMMON_FLAG(bool, symbolize_vs_style, false,
163 "Print file locations in Visual Studio style (e.g: "
164 " file(10,42): ...")
Stephen Hines86277eb2015-03-23 12:06:32 -0700165COMMON_FLAG(const char *, stack_trace_format, "DEFAULT",
166 "Format string used to render stack frames. "
167 "See sanitizer_stacktrace_printer.h for the format description. "
168 "Use DEFAULT to get default format.")
169COMMON_FLAG(bool, no_huge_pages_for_shadow, true,
170 "If true, the shadow is not allowed to use huge pages. ")
Pirama Arumuga Nainar259f7062015-05-06 11:49:53 -0700171COMMON_FLAG(bool, strict_string_checks, false,
172 "If set check that string arguments are properly null-terminated")
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -0700173COMMON_FLAG(bool, intercept_strstr, true,
174 "If set, uses custom wrappers for strstr and strcasestr functions "
175 "to find more errors.")
176COMMON_FLAG(bool, intercept_strspn, true,
177 "If set, uses custom wrappers for strspn and strcspn function "
178 "to find more errors.")
179COMMON_FLAG(bool, intercept_strpbrk, true,
180 "If set, uses custom wrappers for strpbrk function "
181 "to find more errors.")
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -0800182COMMON_FLAG(bool, intercept_memcmp, true,
183 "If set, uses custom wrappers for memcmp function "
184 "to find more errors.")
185COMMON_FLAG(bool, strict_memcmp, true,
186 "If true, assume that memcmp(p1, p2, n) always reads n bytes before "
187 "comparing p1 and p2.")
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -0700188COMMON_FLAG(bool, decorate_proc_maps, false, "If set, decorate sanitizer "
189 "mappings in /proc/self/maps with "
190 "user-readable names")
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -0800191COMMON_FLAG(int, exitcode, 1, "Override the program exit status if the tool "
192 "found an error")
193COMMON_FLAG(
194 bool, abort_on_error, SANITIZER_MAC,
195 "If set, the tool calls abort() instead of _exit() after printing the "
196 "error report.")
197COMMON_FLAG(bool, suppress_equal_pcs, true,
198 "Deduplicate multiple reports for single source location in "
199 "halt_on_error=false mode (asan only).")