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 //===----------------------------------------------------------------------===//
14 #error "Define COMMON_FLAG prior to including this file!"
17 // COMMON_FLAG(Type, Name, DefaultValue, Description)
18 // Supported types: bool, const char *, int, uptr.
19 // Default value must be a compile-time constant.
20 // Description must be a string literal.
23 bool, symbolize, true,
24 "If set, use the online symbolizer from common sanitizer runtime to turn "
25 "virtual addresses to file/line locations.")
27 const char *, external_symbolizer_path, 0,
28 "Path to external symbolizer. If empty, the tool will search $PATH for "
31 bool, allow_addr2line, false,
32 "If set, allows online symbolizer to run addr2line binary to symbolize "
33 "stack traces (addr2line will only be used if llvm-symbolizer binary is "
35 COMMON_FLAG(const char *, strip_path_prefix, "",
36 "Strips this prefix from file paths in error reports.")
37 COMMON_FLAG(bool, fast_unwind_on_check, false,
38 "If available, use the fast frame-pointer-based unwinder on "
39 "internal CHECK failures.")
40 COMMON_FLAG(bool, fast_unwind_on_fatal, false,
41 "If available, use the fast frame-pointer-based unwinder on fatal "
43 COMMON_FLAG(bool, fast_unwind_on_malloc, true,
44 "If available, use the fast frame-pointer-based unwinder on "
46 COMMON_FLAG(bool, handle_ioctl, false, "Intercept and handle ioctl requests.")
47 COMMON_FLAG(int, malloc_context_size, 1,
48 "Max number of stack frames kept for each allocation/deallocation.")
50 const char *, log_path, "stderr",
51 "Write logs to \"log_path.pid\". The special values are \"stdout\" and "
52 "\"stderr\". The default is \"stderr\".")
54 bool, log_exe_name, false,
55 "Mention name of executable when reporting error and "
56 "append executable name to logs (as in \"log_path.exe_name.pid\").")
59 "Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).")
60 COMMON_FLAG(bool, detect_leaks, true, "Enable memory leak detection.")
62 bool, leak_check_at_exit, true,
63 "Invoke leak checking in an atexit handler. Has no effect if "
64 "detect_leaks=false, or if __lsan_do_leak_check() is called before the "
65 "handler has a chance to run.")
66 COMMON_FLAG(bool, allocator_may_return_null, false,
67 "If false, the allocator will crash instead of returning 0 on "
69 COMMON_FLAG(bool, print_summary, true,
70 "If false, disable printing error summaries in addition to error "
72 COMMON_FLAG(bool, check_printf, true, "Check printf arguments.")
73 COMMON_FLAG(bool, handle_segv, SANITIZER_NEEDS_SEGV,
74 "If set, registers the tool's custom SIGSEGV/SIGBUS handler.")
75 COMMON_FLAG(bool, handle_abort, false,
76 "If set, registers the tool's custom SIGABRT handler.")
77 COMMON_FLAG(bool, allow_user_segv_handler, false,
78 "If set, allows user to register a SEGV handler even if the tool "
80 COMMON_FLAG(bool, use_sigaltstack, true,
81 "If set, uses alternate stack for signal handling.")
82 COMMON_FLAG(bool, detect_deadlocks, false,
83 "If set, deadlock detection is enabled.")
85 uptr, clear_shadow_mmap_threshold, 64 * 1024,
86 "Large shadow regions are zero-filled using mmap(NORESERVE) instead of "
87 "memset(). This is the threshold size in bytes.")
88 COMMON_FLAG(const char *, color, "auto",
89 "Colorize reports: (always|never|auto).")
91 bool, legacy_pthread_cond, false,
92 "Enables support for dynamic libraries linked with libpthread 2.2.5.")
93 COMMON_FLAG(bool, intercept_tls_get_addr, false, "Intercept __tls_get_addr.")
94 COMMON_FLAG(bool, help, false, "Print the flag descriptions.")
95 COMMON_FLAG(uptr, mmap_limit_mb, 0,
96 "Limit the amount of mmap-ed memory (excluding shadow) in Mb; "
97 "not a user-facing flag, used mosly for testing the tools")
98 COMMON_FLAG(uptr, hard_rss_limit_mb, 0,
99 "Hard RSS limit in Mb."
100 " If non-zero, a background thread is spawned at startup"
101 " which periodically reads RSS and aborts the process if the"
103 COMMON_FLAG(uptr, soft_rss_limit_mb, 0,
104 "Soft RSS limit in Mb."
105 " If non-zero, a background thread is spawned at startup"
106 " which periodically reads RSS. If the limit is reached"
107 " all subsequent malloc/new calls will fail or return NULL"
108 " (depending on the value of allocator_may_return_null)"
109 " until the RSS goes below the soft limit."
110 " This limit does not affect memory allocations other than"
112 COMMON_FLAG(bool, can_use_proc_maps_statm, true,
113 "If false, do not attempt to read /proc/maps/statm."
114 " Mostly useful for testing sanitizers.")
116 bool, coverage, false,
117 "If set, coverage information will be dumped at program shutdown (if the "
118 "coverage instrumentation was enabled at compile time).")
119 COMMON_FLAG(bool, coverage_pcs, true,
120 "If set (and if 'coverage' is set too), the coverage information "
121 "will be dumped as a set of PC offsets for every module.")
122 COMMON_FLAG(bool, coverage_order_pcs, false,
123 "If true, the PCs will be dumped in the order they've"
124 " appeared during the execution.")
125 COMMON_FLAG(bool, coverage_bitset, false,
126 "If set (and if 'coverage' is set too), the coverage information "
127 "will also be dumped as a bitset to a separate file.")
128 COMMON_FLAG(bool, coverage_counters, false,
129 "If set (and if 'coverage' is set too), the bitmap that corresponds"
130 " to coverage counters will be dumped.")
131 COMMON_FLAG(bool, coverage_direct, SANITIZER_ANDROID,
132 "If set, coverage information will be dumped directly to a memory "
133 "mapped file. This way data is not lost even if the process is "
135 COMMON_FLAG(const char *, coverage_dir, ".",
136 "Target directory for coverage dumps. Defaults to the current "
138 COMMON_FLAG(bool, full_address_space, false,
139 "Sanitize complete address space; "
140 "by default kernel area on 32-bit platforms will not be sanitized")
141 COMMON_FLAG(bool, print_suppressions, true,
142 "Print matched suppressions at exit.")
144 bool, disable_coredump, (SANITIZER_WORDSIZE == 64),
145 "Disable core dumping. By default, disable_core=1 on 64-bit to avoid "
146 "dumping a 16T+ core file. Ignored on OSes that don't dump core by"
147 "default and for sanitizers that don't reserve lots of virtual memory.")
148 COMMON_FLAG(bool, use_madv_dontdump, true,
149 "If set, instructs kernel to not store the (huge) shadow "
151 COMMON_FLAG(bool, symbolize_inline_frames, true,
152 "Print inlined frames in stacktraces. Defaults to true.")
153 COMMON_FLAG(bool, symbolize_vs_style, false,
154 "Print file locations in Visual Studio style (e.g: "
156 COMMON_FLAG(const char *, stack_trace_format, "DEFAULT",
157 "Format string used to render stack frames. "
158 "See sanitizer_stacktrace_printer.h for the format description. "
159 "Use DEFAULT to get default format.")
160 COMMON_FLAG(bool, no_huge_pages_for_shadow, true,
161 "If true, the shadow is not allowed to use huge pages. ")
162 COMMON_FLAG(bool, strict_string_checks, false,
163 "If set check that string arguments are properly null-terminated")
164 COMMON_FLAG(bool, intercept_strstr, true,
165 "If set, uses custom wrappers for strstr and strcasestr functions "
166 "to find more errors.")
167 COMMON_FLAG(bool, intercept_strspn, true,
168 "If set, uses custom wrappers for strspn and strcspn function "
169 "to find more errors.")
170 COMMON_FLAG(bool, intercept_strpbrk, true,
171 "If set, uses custom wrappers for strpbrk function "
172 "to find more errors.")
173 COMMON_FLAG(bool, decorate_proc_maps, false, "If set, decorate sanitizer "
174 "mappings in /proc/self/maps with "
175 "user-readable names")