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