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,
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, true, "Enable memory leak detection.")
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 "
72 COMMON_FLAG(bool, print_summary, true,
73 "If false, disable printing error summaries in addition to error "
75 COMMON_FLAG(bool, check_printf, true, "Check printf arguments.")
76 COMMON_FLAG(bool, handle_segv, SANITIZER_NEEDS_SEGV,
77 "If set, registers the tool's custom SIGSEGV/SIGBUS handler.")
78 COMMON_FLAG(bool, handle_abort, false,
79 "If set, registers the tool's custom SIGABRT handler.")
80 COMMON_FLAG(bool, handle_sigfpe, true,
81 "If set, registers the tool's custom SIGFPE handler.")
82 COMMON_FLAG(bool, allow_user_segv_handler, false,
83 "If set, allows user to register a SEGV handler even if the tool "
85 COMMON_FLAG(bool, use_sigaltstack, true,
86 "If set, uses alternate stack for signal handling.")
87 COMMON_FLAG(bool, detect_deadlocks, false,
88 "If set, deadlock detection is enabled.")
90 uptr, clear_shadow_mmap_threshold, 64 * 1024,
91 "Large shadow regions are zero-filled using mmap(NORESERVE) instead of "
92 "memset(). This is the threshold size in bytes.")
93 COMMON_FLAG(const char *, color, "auto",
94 "Colorize reports: (always|never|auto).")
96 bool, legacy_pthread_cond, false,
97 "Enables support for dynamic libraries linked with libpthread 2.2.5.")
98 COMMON_FLAG(bool, intercept_tls_get_addr, false, "Intercept __tls_get_addr.")
99 COMMON_FLAG(bool, help, false, "Print the flag descriptions.")
100 COMMON_FLAG(uptr, mmap_limit_mb, 0,
101 "Limit the amount of mmap-ed memory (excluding shadow) in Mb; "
102 "not a user-facing flag, used mosly for testing the tools")
103 COMMON_FLAG(uptr, hard_rss_limit_mb, 0,
104 "Hard RSS limit in Mb."
105 " If non-zero, a background thread is spawned at startup"
106 " which periodically reads RSS and aborts the process if the"
108 COMMON_FLAG(uptr, soft_rss_limit_mb, 0,
109 "Soft RSS limit in Mb."
110 " If non-zero, a background thread is spawned at startup"
111 " which periodically reads RSS. If the limit is reached"
112 " all subsequent malloc/new calls will fail or return NULL"
113 " (depending on the value of allocator_may_return_null)"
114 " until the RSS goes below the soft limit."
115 " This limit does not affect memory allocations other than"
117 COMMON_FLAG(bool, can_use_proc_maps_statm, true,
118 "If false, do not attempt to read /proc/maps/statm."
119 " Mostly useful for testing sanitizers.")
121 bool, coverage, false,
122 "If set, coverage information will be dumped at program shutdown (if the "
123 "coverage instrumentation was enabled at compile time).")
124 COMMON_FLAG(bool, coverage_pcs, true,
125 "If set (and if 'coverage' is set too), the coverage information "
126 "will be dumped as a set of PC offsets for every module.")
127 COMMON_FLAG(bool, coverage_order_pcs, false,
128 "If true, the PCs will be dumped in the order they've"
129 " appeared during the execution.")
130 COMMON_FLAG(bool, coverage_bitset, false,
131 "If set (and if 'coverage' is set too), the coverage information "
132 "will also be dumped as a bitset to a separate file.")
133 COMMON_FLAG(bool, coverage_counters, false,
134 "If set (and if 'coverage' is set too), the bitmap that corresponds"
135 " to coverage counters will be dumped.")
136 COMMON_FLAG(bool, coverage_direct, SANITIZER_ANDROID,
137 "If set, coverage information will be dumped directly to a memory "
138 "mapped file. This way data is not lost even if the process is "
140 COMMON_FLAG(const char *, coverage_dir, ".",
141 "Target directory for coverage dumps. Defaults to the current "
143 COMMON_FLAG(bool, full_address_space, false,
144 "Sanitize complete address space; "
145 "by default kernel area on 32-bit platforms will not be sanitized")
146 COMMON_FLAG(bool, print_suppressions, true,
147 "Print matched suppressions at exit.")
149 bool, disable_coredump, (SANITIZER_WORDSIZE == 64),
150 "Disable core dumping. By default, disable_core=1 on 64-bit to avoid "
151 "dumping a 16T+ core file. Ignored on OSes that don't dump core by"
152 "default and for sanitizers that don't reserve lots of virtual memory.")
153 COMMON_FLAG(bool, use_madv_dontdump, true,
154 "If set, instructs kernel to not store the (huge) shadow "
156 COMMON_FLAG(bool, symbolize_inline_frames, true,
157 "Print inlined frames in stacktraces. Defaults to true.")
158 COMMON_FLAG(bool, symbolize_vs_style, false,
159 "Print file locations in Visual Studio style (e.g: "
161 COMMON_FLAG(const char *, stack_trace_format, "DEFAULT",
162 "Format string used to render stack frames. "
163 "See sanitizer_stacktrace_printer.h for the format description. "
164 "Use DEFAULT to get default format.")
165 COMMON_FLAG(bool, no_huge_pages_for_shadow, true,
166 "If true, the shadow is not allowed to use huge pages. ")
167 COMMON_FLAG(bool, strict_string_checks, false,
168 "If set check that string arguments are properly null-terminated")
169 COMMON_FLAG(bool, intercept_strstr, true,
170 "If set, uses custom wrappers for strstr and strcasestr functions "
171 "to find more errors.")
172 COMMON_FLAG(bool, intercept_strspn, true,
173 "If set, uses custom wrappers for strspn and strcspn function "
174 "to find more errors.")
175 COMMON_FLAG(bool, intercept_strpbrk, true,
176 "If set, uses custom wrappers for strpbrk function "
177 "to find more errors.")
178 COMMON_FLAG(bool, intercept_memcmp, true,
179 "If set, uses custom wrappers for memcmp function "
180 "to find more errors.")
181 COMMON_FLAG(bool, strict_memcmp, true,
182 "If true, assume that memcmp(p1, p2, n) always reads n bytes before "
183 "comparing p1 and p2.")
184 COMMON_FLAG(bool, decorate_proc_maps, false, "If set, decorate sanitizer "
185 "mappings in /proc/self/maps with "
186 "user-readable names")
187 COMMON_FLAG(int, exitcode, 1, "Override the program exit status if the tool "
190 bool, abort_on_error, SANITIZER_MAC,
191 "If set, the tool calls abort() instead of _exit() after printing the "