libsanitizer merge from upstream r175733
[official-gcc.git] / libsanitizer / asan / asan_flags.h
blobb880896c7a3ae9e2457209a15e88c2bfa2f2a0c5
1 //===-- asan_flags.h -------------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of AddressSanitizer, an address sanity checker.
9 //
10 // ASan runtime flags.
11 //===----------------------------------------------------------------------===//
13 #ifndef ASAN_FLAGS_H
14 #define ASAN_FLAGS_H
16 #include "sanitizer_common/sanitizer_internal_defs.h"
18 // ASan flag values can be defined in four ways:
19 // 1) initialized with default values at startup.
20 // 2) overriden during compilation of ASan runtime by providing
21 // compile definition ASAN_DEFAULT_OPTIONS.
22 // 3) overriden from string returned by user-specified function
23 // __asan_default_options().
24 // 4) overriden from env variable ASAN_OPTIONS.
26 namespace __asan {
28 struct Flags {
29 // Size (in bytes) of quarantine used to detect use-after-free errors.
30 // Lower value may reduce memory usage but increase the chance of
31 // false negatives.
32 int quarantine_size;
33 // If set, uses in-process symbolizer from common sanitizer runtime.
34 bool symbolize;
35 // Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).
36 int verbosity;
37 // Size (in bytes) of redzones around heap objects.
38 // Requirement: redzone >= 32, is a power of two.
39 int redzone;
40 // If set, prints some debugging information and does additional checks.
41 bool debug;
42 // Controls the way to handle globals (0 - don't detect buffer overflow
43 // on globals, 1 - detect buffer overflow, 2 - print data about registered
44 // globals).
45 int report_globals;
46 // If set, attempts to catch initialization order issues.
47 bool check_initialization_order;
48 // Max number of stack frames kept for each allocation/deallocation.
49 int malloc_context_size;
50 // If set, uses custom wrappers and replacements for libc string functions
51 // to find more errors.
52 bool replace_str;
53 // If set, uses custom wrappers for memset/memcpy/memmove intinsics.
54 bool replace_intrin;
55 // Used on Mac only.
56 bool mac_ignore_invalid_free;
57 // ASan allocator flag. See asan_allocator.cc.
58 bool use_fake_stack;
59 // ASan allocator flag. Sets the maximal size of allocation request
60 // that would return memory filled with zero bytes.
61 int max_malloc_fill_size;
62 // Override exit status if something was reported.
63 int exitcode;
64 // If set, user may manually mark memory regions as poisoned or unpoisoned.
65 bool allow_user_poisoning;
66 // Number of seconds to sleep between printing an error report and
67 // terminating application. Useful for debug purposes (when one needs
68 // to attach gdb, for example).
69 int sleep_before_dying;
70 // If set, registers ASan custom segv handler.
71 bool handle_segv;
72 // If set, uses alternate stack for signal handling.
73 bool use_sigaltstack;
74 // Allow the users to work around the bug in Nvidia drivers prior to 295.*.
75 bool check_malloc_usable_size;
76 // If set, explicitly unmaps (huge) shadow at exit.
77 bool unmap_shadow_on_exit;
78 // If set, calls abort() instead of _exit() after printing an error report.
79 bool abort_on_error;
80 // Print various statistics after printing an error message or if atexit=1.
81 bool print_stats;
82 // Print the legend for the shadow bytes.
83 bool print_legend;
84 // If set, prints ASan exit stats even after program terminates successfully.
85 bool atexit;
86 // By default, disable core dumper on 64-bit - it makes little sense
87 // to dump 16T+ core.
88 bool disable_core;
89 // Allow the tool to re-exec the program. This may interfere badly with the
90 // debugger.
91 bool allow_reexec;
92 // Strips this prefix from file paths in error reports.
93 const char *strip_path_prefix;
94 // If set, prints not only thread creation stacks for threads in error report,
95 // but also thread creation stacks for threads that created those threads,
96 // etc. up to main thread.
97 bool print_full_thread_history;
98 // ASan will write logs to "log_path.pid" instead of stderr.
99 const char *log_path;
100 // Use fast (frame-pointer-based) unwinder on fatal errors (if available).
101 bool fast_unwind_on_fatal;
102 // Use fast (frame-pointer-based) unwinder on malloc/free (if available).
103 bool fast_unwind_on_malloc;
104 // Poison (or not) the heap memory on [de]allocation. Zero value is useful
105 // for benchmarking the allocator or instrumentator.
106 bool poison_heap;
107 // Report errors on malloc/delete, new/free, new/delete[], etc.
108 bool alloc_dealloc_mismatch;
109 // Use stack depot instead of storing stacks in the redzones.
110 bool use_stack_depot;
113 Flags *flags();
114 void InitializeFlags(Flags *f, const char *env);
116 } // namespace __asan
118 #endif // ASAN_FLAGS_H