blob: bbb39c73e2d0d071b062509618cfd8f2c8f85dfd [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//===----------------------------------------------------------------------===//
13#ifndef COMMON_FLAG
14#error "Define COMMON_FLAG prior to including this file!"
15#endif
16
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.
21
22COMMON_FLAG(
23 bool, symbolize, true,
24 "If set, use the online symbolizer from common sanitizer runtime to turn "
25 "virtual addresses to file/line locations.")
26COMMON_FLAG(
27 const char *, external_symbolizer_path, 0,
28 "Path to external symbolizer. If empty, the tool will search $PATH for "
29 "the symbolizer.")
30COMMON_FLAG(
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 "
34 "unavailable.")
35COMMON_FLAG(const char *, strip_path_prefix, "",
36 "Strips this prefix from file paths in error reports.")
37COMMON_FLAG(bool, fast_unwind_on_check, false,
38 "If available, use the fast frame-pointer-based unwinder on "
39 "internal CHECK failures.")
40COMMON_FLAG(bool, fast_unwind_on_fatal, false,
41 "If available, use the fast frame-pointer-based unwinder on fatal "
42 "errors.")
43COMMON_FLAG(bool, fast_unwind_on_malloc, true,
44 "If available, use the fast frame-pointer-based unwinder on "
45 "malloc/free.")
46COMMON_FLAG(bool, handle_ioctl, false, "Intercept and handle ioctl requests.")
47COMMON_FLAG(int, malloc_context_size, 1,
48 "Max number of stack frames kept for each allocation/deallocation.")
49COMMON_FLAG(
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\".")
53COMMON_FLAG(
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -070054 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\").")
57COMMON_FLAG(
Stephen Hines86277eb2015-03-23 12:06:32 -070058 int, verbosity, 0,
59 "Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).")
60COMMON_FLAG(bool, detect_leaks, true, "Enable memory leak detection.")
61COMMON_FLAG(
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.")
66COMMON_FLAG(bool, allocator_may_return_null, false,
67 "If false, the allocator will crash instead of returning 0 on "
68 "out-of-memory.")
69COMMON_FLAG(bool, print_summary, true,
70 "If false, disable printing error summaries in addition to error "
71 "reports.")
72COMMON_FLAG(bool, check_printf, true, "Check printf arguments.")
73COMMON_FLAG(bool, handle_segv, SANITIZER_NEEDS_SEGV,
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -070074 "If set, registers the tool's custom SIGSEGV/SIGBUS handler.")
75COMMON_FLAG(bool, handle_abort, false,
76 "If set, registers the tool's custom SIGABRT handler.")
Stephen Hines86277eb2015-03-23 12:06:32 -070077COMMON_FLAG(bool, allow_user_segv_handler, false,
78 "If set, allows user to register a SEGV handler even if the tool "
79 "registers one.")
80COMMON_FLAG(bool, use_sigaltstack, true,
81 "If set, uses alternate stack for signal handling.")
82COMMON_FLAG(bool, detect_deadlocks, false,
83 "If set, deadlock detection is enabled.")
84COMMON_FLAG(
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.")
88COMMON_FLAG(const char *, color, "auto",
89 "Colorize reports: (always|never|auto).")
90COMMON_FLAG(
91 bool, legacy_pthread_cond, false,
92 "Enables support for dynamic libraries linked with libpthread 2.2.5.")
93COMMON_FLAG(bool, intercept_tls_get_addr, false, "Intercept __tls_get_addr.")
94COMMON_FLAG(bool, help, false, "Print the flag descriptions.")
95COMMON_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")
98COMMON_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"
102 " limit is reached")
103COMMON_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"
111 " malloc/new.")
112COMMON_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.")
115COMMON_FLAG(
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).")
Stephen Hines86277eb2015-03-23 12:06:32 -0700119COMMON_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.")
Pirama Arumuga Nainar7c915052015-04-08 08:58:29 -0700122COMMON_FLAG(bool, coverage_order_pcs, false,
123 "If true, the PCs will be dumped in the order they've"
124 " appeared during the execution.")
Stephen Hines86277eb2015-03-23 12:06:32 -0700125COMMON_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.")
Pirama Arumuga Nainar7c915052015-04-08 08:58:29 -0700128COMMON_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.")
Stephen Hines86277eb2015-03-23 12:06:32 -0700131COMMON_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 "
134 "suddenly killed.")
135COMMON_FLAG(const char *, coverage_dir, ".",
136 "Target directory for coverage dumps. Defaults to the current "
137 "directory.")
138COMMON_FLAG(bool, full_address_space, false,
139 "Sanitize complete address space; "
140 "by default kernel area on 32-bit platforms will not be sanitized")
141COMMON_FLAG(bool, print_suppressions, true,
142 "Print matched suppressions at exit.")
143COMMON_FLAG(
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.")
148COMMON_FLAG(bool, use_madv_dontdump, true,
149 "If set, instructs kernel to not store the (huge) shadow "
150 "in core file.")
151COMMON_FLAG(bool, symbolize_inline_frames, true,
152 "Print inlined frames in stacktraces. Defaults to true.")
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -0700153COMMON_FLAG(bool, symbolize_vs_style, false,
154 "Print file locations in Visual Studio style (e.g: "
155 " file(10,42): ...")
Stephen Hines86277eb2015-03-23 12:06:32 -0700156COMMON_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.")
160COMMON_FLAG(bool, no_huge_pages_for_shadow, true,
161 "If true, the shadow is not allowed to use huge pages. ")
Pirama Arumuga Nainar259f7062015-05-06 11:49:53 -0700162COMMON_FLAG(bool, strict_string_checks, false,
163 "If set check that string arguments are properly null-terminated")
Pirama Arumuga Nainarcdce50b2015-07-01 12:26:56 -0700164COMMON_FLAG(bool, intercept_strstr, true,
165 "If set, uses custom wrappers for strstr and strcasestr functions "
166 "to find more errors.")
167COMMON_FLAG(bool, intercept_strspn, true,
168 "If set, uses custom wrappers for strspn and strcspn function "
169 "to find more errors.")
170COMMON_FLAG(bool, intercept_strpbrk, true,
171 "If set, uses custom wrappers for strpbrk function "
172 "to find more errors.")
173COMMON_FLAG(bool, decorate_proc_maps, false, "If set, decorate sanitizer "
174 "mappings in /proc/self/maps with "
175 "user-readable names")