]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/asan/asan_flags.inc
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r306956, and update
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / asan / asan_flags.inc
1 //===-- asan_flags.inc ------------------------------------------*- 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 // ASan runtime flags.
11 //
12 //===----------------------------------------------------------------------===//
13 #ifndef ASAN_FLAG
14 # error "Define ASAN_FLAG prior to including this file!"
15 #endif
16
17 // ASAN_FLAG(Type, Name, DefaultValue, Description)
18 // See COMMON_FLAG in sanitizer_flags.inc for more details.
19
20 ASAN_FLAG(int, quarantine_size, -1,
21             "Deprecated, please use quarantine_size_mb.")
22 ASAN_FLAG(int, quarantine_size_mb, -1,
23           "Size (in Mb) of quarantine used to detect use-after-free "
24           "errors. Lower value may reduce memory usage but increase the "
25           "chance of false negatives.")
26 ASAN_FLAG(int, thread_local_quarantine_size_kb, -1,
27           "Size (in Kb) of thread local quarantine used to detect "
28           "use-after-free errors. Lower value may reduce memory usage but "
29           "increase the chance of false negatives. It is not advised to go "
30           "lower than 64Kb, otherwise frequent transfers to global quarantine "
31           "might affect performance.")
32 ASAN_FLAG(int, redzone, 16,
33           "Minimal size (in bytes) of redzones around heap objects. "
34           "Requirement: redzone >= 16, is a power of two.")
35 ASAN_FLAG(int, max_redzone, 2048,
36           "Maximal size (in bytes) of redzones around heap objects.")
37 ASAN_FLAG(
38     bool, debug, false,
39     "If set, prints some debugging information and does additional checks.")
40 ASAN_FLAG(
41     int, report_globals, 1,
42     "Controls the way to handle globals (0 - don't detect buffer overflow on "
43     "globals, 1 - detect buffer overflow, 2 - print data about registered "
44     "globals).")
45 ASAN_FLAG(bool, check_initialization_order, false,
46           "If set, attempts to catch initialization order issues.")
47 ASAN_FLAG(
48     bool, replace_str, true,
49     "If set, uses custom wrappers and replacements for libc string functions "
50     "to find more errors.")
51 ASAN_FLAG(bool, replace_intrin, true,
52           "If set, uses custom wrappers for memset/memcpy/memmove intrinsics.")
53 ASAN_FLAG(bool, detect_stack_use_after_return, false,
54           "Enables stack-use-after-return checking at run-time.")
55 ASAN_FLAG(int, min_uar_stack_size_log, 16, // We can't do smaller anyway.
56           "Minimum fake stack size log.")
57 ASAN_FLAG(int, max_uar_stack_size_log,
58           20, // 1Mb per size class, i.e. ~11Mb per thread
59           "Maximum fake stack size log.")
60 ASAN_FLAG(bool, uar_noreserve, false,
61           "Use mmap with 'noreserve' flag to allocate fake stack.")
62 ASAN_FLAG(
63     int, max_malloc_fill_size, 0x1000,  // By default, fill only the first 4K.
64     "ASan allocator flag. max_malloc_fill_size is the maximal amount of "
65     "bytes that will be filled with malloc_fill_byte on malloc.")
66 ASAN_FLAG(
67     int, max_free_fill_size, 0,
68     "ASan allocator flag. max_free_fill_size is the maximal amount of "
69     "bytes that will be filled with free_fill_byte during free.")
70 ASAN_FLAG(int, malloc_fill_byte, 0xbe,
71           "Value used to fill the newly allocated memory.")
72 ASAN_FLAG(int, free_fill_byte, 0x55,
73           "Value used to fill deallocated memory.")
74 ASAN_FLAG(bool, allow_user_poisoning, true,
75           "If set, user may manually mark memory regions as poisoned or "
76           "unpoisoned.")
77 ASAN_FLAG(
78     int, sleep_before_dying, 0,
79     "Number of seconds to sleep between printing an error report and "
80     "terminating the program. Useful for debugging purposes (e.g. when one "
81     "needs to attach gdb).")
82 ASAN_FLAG(bool, check_malloc_usable_size, true,
83           "Allows the users to work around the bug in Nvidia drivers prior to "
84           "295.*.")
85 ASAN_FLAG(bool, unmap_shadow_on_exit, false,
86           "If set, explicitly unmaps the (huge) shadow at exit.")
87 ASAN_FLAG(bool, protect_shadow_gap, true, "If set, mprotect the shadow gap")
88 ASAN_FLAG(bool, print_stats, false,
89           "Print various statistics after printing an error message or if "
90           "atexit=1.")
91 ASAN_FLAG(bool, print_legend, true, "Print the legend for the shadow bytes.")
92 ASAN_FLAG(bool, print_scariness, false,
93           "Print the scariness score. Experimental.")
94 ASAN_FLAG(bool, atexit, false,
95           "If set, prints ASan exit stats even after program terminates "
96           "successfully.")
97 ASAN_FLAG(
98     bool, print_full_thread_history, true,
99     "If set, prints thread creation stacks for the threads involved in the "
100     "report and their ancestors up to the main thread.")
101 ASAN_FLAG(
102     bool, poison_heap, true,
103     "Poison (or not) the heap memory on [de]allocation. Zero value is useful "
104     "for benchmarking the allocator or instrumentator.")
105 ASAN_FLAG(bool, poison_partial, true,
106           "If true, poison partially addressable 8-byte aligned words "
107           "(default=true). This flag affects heap and global buffers, but not "
108           "stack buffers.")
109 ASAN_FLAG(bool, poison_array_cookie, true,
110           "Poison (or not) the array cookie after operator new[].")
111
112 // Turn off alloc/dealloc mismatch checker on Mac and Windows for now.
113 // https://github.com/google/sanitizers/issues/131
114 // https://github.com/google/sanitizers/issues/309
115 // TODO(glider,timurrrr): Fix known issues and enable this back.
116 ASAN_FLAG(bool, alloc_dealloc_mismatch,
117           !SANITIZER_MAC && !SANITIZER_WINDOWS && !SANITIZER_ANDROID,
118           "Report errors on malloc/delete, new/free, new/delete[], etc.")
119
120 ASAN_FLAG(bool, new_delete_type_mismatch, true,
121           "Report errors on mismatch between size of new and delete.")
122 ASAN_FLAG(
123     bool, strict_init_order, false,
124     "If true, assume that dynamic initializers can never access globals from "
125     "other modules, even if the latter are already initialized.")
126 ASAN_FLAG(
127     bool, start_deactivated, false,
128     "If true, ASan tweaks a bunch of other flags (quarantine, redzone, heap "
129     "poisoning) to reduce memory consumption as much as possible, and "
130     "restores them to original values when the first instrumented module is "
131     "loaded into the process. This is mainly intended to be used on "
132     "Android. ")
133 ASAN_FLAG(
134     int, detect_invalid_pointer_pairs, 0,
135     "If non-zero, try to detect operations like <, <=, >, >= and - on "
136     "invalid pointer pairs (e.g. when pointers belong to different objects). "
137     "The bigger the value the harder we try.")
138 ASAN_FLAG(
139     bool, detect_container_overflow, true,
140     "If true, honor the container overflow annotations. See "
141     "https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow")
142 ASAN_FLAG(int, detect_odr_violation, 2,
143           "If >=2, detect violation of One-Definition-Rule (ODR); "
144           "If ==1, detect ODR-violation only if the two variables "
145           "have different sizes")
146 ASAN_FLAG(bool, dump_instruction_bytes, false,
147           "If true, dump 16 bytes starting at the instruction that caused SEGV")
148 ASAN_FLAG(bool, dump_registers, true,
149           "If true, dump values of CPU registers when SEGV happens. Only "
150           "available on OS X for now.")
151 ASAN_FLAG(const char *, suppressions, "", "Suppressions file name.")
152 ASAN_FLAG(bool, halt_on_error, true,
153           "Crash the program after printing the first error report "
154           "(WARNING: USE AT YOUR OWN RISK!)")
155 ASAN_FLAG(bool, use_odr_indicator, false,
156           "Use special ODR indicator symbol for ODR violation detection")
157 ASAN_FLAG(bool, allocator_frees_and_returns_null_on_realloc_zero, true,
158           "realloc(p, 0) is equivalent to free(p) by default (Same as the "
159           "POSIX standard). If set to false, realloc(p, 0) will return a "
160           "pointer to an allocated space which can not be used.")
161 ASAN_FLAG(bool, verify_asan_link_order, true,
162           "Check position of ASan runtime in library list (needs to be disabled"
163           " when other library has to be preloaded system-wide)")