asan_flags.h revision c6b8716d9acd202d311a7d9095eeed440bba1ce5
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_interface_defs.h" 19 20// ASan flag values can be defined in three ways: 21// 1) initialized with default values at startup. 22// 2) overriden from string returned by user-specified function 23// __asan_default_options(). 24// 3) overriden from env variable ASAN_OPTIONS. 25 26extern "C" { 27// Can be overriden by user. 28const char *__asan_default_options() 29 SANITIZER_WEAK_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE; 30} // extern "C" 31 32namespace __asan { 33 34struct Flags { 35 // Size (in bytes) of quarantine used to detect use-after-free errors. 36 // Lower value may reduce memory usage but increase the chance of 37 // false negatives. 38 int quarantine_size; 39 // If set, uses in-process symbolizer from common sanitizer runtime. 40 bool symbolize; 41 // Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output). 42 int verbosity; 43 // Size (in bytes) of redzones around heap objects. 44 // Requirement: redzone >= 32, is a power of two. 45 int redzone; 46 // If set, prints some debugging information and does additional checks. 47 bool debug; 48 // Controls the way to handle globals (0 - don't detect buffer overflow 49 // on globals, 1 - detect buffer overflow, 2 - print data about registered 50 // globals). 51 int report_globals; 52 // Max number of stack frames kept for each allocation. 53 int malloc_context_size; 54 // If set, uses custom wrappers and replacements for libc string functions 55 // to find more errors. 56 bool replace_str; 57 // If set, uses custom wrappers for memset/memcpy/memmove intinsics. 58 bool replace_intrin; 59 // Used on Mac only. See comments in asan_mac.cc and asan_malloc_mac.cc. 60 bool replace_cfallocator; 61 // Used on Mac only. 62 bool mac_ignore_invalid_free; 63 // ASan allocator flag. See asan_allocator.cc. 64 bool use_fake_stack; 65 // ASan allocator flag. Sets the maximal size of allocation request 66 // that would return memory filled with zero bytes. 67 int max_malloc_fill_size; 68 // Override exit status if something was reported. 69 int exitcode; 70 // If set, user may manually mark memory regions as poisoned or unpoisoned. 71 bool allow_user_poisoning; 72 // Number of seconds to sleep between printing an error report and 73 // terminating application. Useful for debug purposes (when one needs 74 // to attach gdb, for example). 75 int sleep_before_dying; 76 // If set, registers ASan custom segv handler. 77 bool handle_segv; 78 // If set, uses alternate stack for signal handling. 79 bool use_sigaltstack; 80 // Allow the users to work around the bug in Nvidia drivers prior to 295.*. 81 bool check_malloc_usable_size; 82 // If set, explicitly unmaps (huge) shadow at exit. 83 bool unmap_shadow_on_exit; 84 // If set, calls abort() instead of _exit() after printing an error report. 85 bool abort_on_error; 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 // Strips this prefix from file paths in error reports. 92 const char *strip_path_prefix; 93}; 94 95Flags *flags(); 96void InitializeFlags(Flags *f, const char *env); 97 98} // namespace __asan 99 100#endif // ASAN_FLAGS_H 101