asan_flags.h revision 73bad81febb2a872627c03e579beea1da4b49294
1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)//===-- asan_flags.h -------------------------------------------*- C++ -*-===// 2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// 3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// The LLVM Compiler Infrastructure 4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// 5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// This file is distributed under the University of Illinois Open Source 6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// License. See LICENSE.TXT for details. 7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// 8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)//===----------------------------------------------------------------------===// 9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// 10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// This file is a part of AddressSanitizer, an address sanity checker. 11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// ASan runtime flags. 13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)//===----------------------------------------------------------------------===// 14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#ifndef ASAN_FLAGS_H 16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#define ASAN_FLAGS_H 17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "sanitizer/common_interface_defs.h" 19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// ASan flag values can be defined in three ways: 21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// 1) initialized with default values at startup. 22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// 2) overriden from string returned by user-specified function 23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// __asan_default_options(). 24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// 3) overriden from env variable ASAN_OPTIONS. 25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace __asan { 27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)struct Flags { 29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Size (in bytes) of quarantine used to detect use-after-free errors. 30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Lower value may reduce memory usage but increase the chance of 31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // false negatives. 32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int quarantine_size; 33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // If set, uses in-process symbolizer from common sanitizer runtime. 34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool symbolize; 35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output). 36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int verbosity; 37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Size (in bytes) of redzones around heap objects. 38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Requirement: redzone >= 32, is a power of two. 39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int redzone; 40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // If set, prints some debugging information and does additional checks. 41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool debug; 42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Controls the way to handle globals (0 - don't detect buffer overflow 43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // on globals, 1 - detect buffer overflow, 2 - print data about registered 44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // globals). 45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int report_globals; 46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // If set, attempts to catch initialization order issues. 47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool check_initialization_order; 48868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Max number of stack frames kept for each allocation/deallocation. 49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int malloc_context_size; 50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // If set, uses custom wrappers and replacements for libc string functions 51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // to find more errors. 52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool replace_str; 53868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // If set, uses custom wrappers for memset/memcpy/memmove intinsics. 54868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool replace_intrin; 55868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Used on Mac only. See comments in asan_mac.cc and asan_malloc_mac.cc. 56868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool replace_cfallocator; 57868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Used on Mac only. 58868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool mac_ignore_invalid_free; 59868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // ASan allocator flag. See asan_allocator.cc. 60868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool use_fake_stack; 61868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // ASan allocator flag. Sets the maximal size of allocation request 62868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // that would return memory filled with zero bytes. 63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int max_malloc_fill_size; 64868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Override exit status if something was reported. 65868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int exitcode; 66868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // If set, user may manually mark memory regions as poisoned or unpoisoned. 67868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool allow_user_poisoning; 68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Number of seconds to sleep between printing an error report and 69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // terminating application. Useful for debug purposes (when one needs 70868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // to attach gdb, for example). 71868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) int sleep_before_dying; 72868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // If set, registers ASan custom segv handler. 73868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool handle_segv; 74868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // If set, uses alternate stack for signal handling. 75868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool use_sigaltstack; 76868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Allow the users to work around the bug in Nvidia drivers prior to 295.*. 77868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool check_malloc_usable_size; 78868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // If set, explicitly unmaps (huge) shadow at exit. 79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool unmap_shadow_on_exit; 80 // If set, calls abort() instead of _exit() after printing an error report. 81 bool abort_on_error; 82 // If set, prints ASan exit stats even after program terminates successfully. 83 bool atexit; 84 // By default, disable core dumper on 64-bit - it makes little sense 85 // to dump 16T+ core. 86 bool disable_core; 87 // Allow the tool to re-exec the program. This may interfere badly with the 88 // debugger. 89 bool allow_reexec; 90 // Strips this prefix from file paths in error reports. 91 const char *strip_path_prefix; 92 // If set, prints not only thread creation stacks for threads in error report, 93 // but also thread creation stacks for threads that created those threads, 94 // etc. up to main thread. 95 bool print_full_thread_history; 96 // ASan will write logs to "log_path.pid" instead of stderr. 97 const char *log_path; 98 // Use fast (frame-pointer-based) unwinder on fatal errors (if available). 99 bool fast_unwind_on_fatal; 100 // Use fast (frame-pointer-based) unwinder on malloc/free (if available). 101 bool fast_unwind_on_malloc; 102 // Poison (or not) the heap memory on [de]allocation. Zero value is useful 103 // for benchmarking the allocator or instrumentator. 104 bool poison_heap; 105}; 106 107Flags *flags(); 108void InitializeFlags(Flags *f, const char *env); 109 110} // namespace __asan 111 112#endif // ASAN_FLAGS_H 113