2012-07-10 15:41:27 +08:00
|
|
|
//===-- asan_flags.h -------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of AddressSanitizer, an address sanity checker.
|
|
|
|
//
|
|
|
|
// ASan runtime flags.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef ASAN_FLAGS_H
|
|
|
|
#define ASAN_FLAGS_H
|
|
|
|
|
2013-01-30 21:12:08 +08:00
|
|
|
#include "sanitizer_common/sanitizer_internal_defs.h"
|
2012-07-10 15:41:27 +08:00
|
|
|
|
2013-02-19 21:14:48 +08:00
|
|
|
// ASan flag values can be defined in four ways:
|
2012-07-10 15:41:27 +08:00
|
|
|
// 1) initialized with default values at startup.
|
2013-02-19 21:14:48 +08:00
|
|
|
// 2) overriden during compilation of ASan runtime by providing
|
|
|
|
// compile definition ASAN_DEFAULT_OPTIONS.
|
|
|
|
// 3) overriden from string returned by user-specified function
|
2012-07-25 18:40:57 +08:00
|
|
|
// __asan_default_options().
|
2013-02-19 21:14:48 +08:00
|
|
|
// 4) overriden from env variable ASAN_OPTIONS.
|
2012-07-10 15:41:27 +08:00
|
|
|
|
|
|
|
namespace __asan {
|
|
|
|
|
|
|
|
struct Flags {
|
|
|
|
// Size (in bytes) of quarantine used to detect use-after-free errors.
|
|
|
|
// Lower value may reduce memory usage but increase the chance of
|
|
|
|
// false negatives.
|
|
|
|
int quarantine_size;
|
2014-01-09 22:41:03 +08:00
|
|
|
// Minimal size (in bytes) of redzones around heap objects.
|
|
|
|
// Requirement: redzone >= 16, is a power of two.
|
2012-07-10 15:41:27 +08:00
|
|
|
int redzone;
|
2014-01-09 22:41:03 +08:00
|
|
|
// Maximal size (in bytes) of redzones around heap objects.
|
|
|
|
int max_redzone;
|
2012-07-10 15:41:27 +08:00
|
|
|
// If set, prints some debugging information and does additional checks.
|
|
|
|
bool debug;
|
|
|
|
// Controls the way to handle globals (0 - don't detect buffer overflow
|
|
|
|
// on globals, 1 - detect buffer overflow, 2 - print data about registered
|
|
|
|
// globals).
|
|
|
|
int report_globals;
|
2012-08-21 22:10:25 +08:00
|
|
|
// If set, attempts to catch initialization order issues.
|
|
|
|
bool check_initialization_order;
|
2012-07-10 15:41:27 +08:00
|
|
|
// If set, uses custom wrappers and replacements for libc string functions
|
|
|
|
// to find more errors.
|
|
|
|
bool replace_str;
|
|
|
|
// If set, uses custom wrappers for memset/memcpy/memmove intinsics.
|
|
|
|
bool replace_intrin;
|
|
|
|
// Used on Mac only.
|
|
|
|
bool mac_ignore_invalid_free;
|
2013-09-18 18:35:12 +08:00
|
|
|
// Enables stack-use-after-return checking at run-time.
|
|
|
|
bool detect_stack_use_after_return;
|
2013-12-16 16:42:08 +08:00
|
|
|
// The minimal and the maximal fake stack size log.
|
|
|
|
int min_uar_stack_size_log;
|
|
|
|
int max_uar_stack_size_log;
|
2013-12-13 23:03:49 +08:00
|
|
|
// Use mmap with 'norserve' flag to allocate fake stack.
|
|
|
|
bool uar_noreserve;
|
2013-04-04 19:17:14 +08:00
|
|
|
// ASan allocator flag. max_malloc_fill_size is the maximal amount of bytes
|
|
|
|
// that will be filled with malloc_fill_byte on malloc.
|
|
|
|
int max_malloc_fill_size, malloc_fill_byte;
|
2012-07-10 15:41:27 +08:00
|
|
|
// Override exit status if something was reported.
|
|
|
|
int exitcode;
|
|
|
|
// If set, user may manually mark memory regions as poisoned or unpoisoned.
|
|
|
|
bool allow_user_poisoning;
|
|
|
|
// Number of seconds to sleep between printing an error report and
|
|
|
|
// terminating application. Useful for debug purposes (when one needs
|
|
|
|
// to attach gdb, for example).
|
|
|
|
int sleep_before_dying;
|
|
|
|
// Allow the users to work around the bug in Nvidia drivers prior to 295.*.
|
|
|
|
bool check_malloc_usable_size;
|
|
|
|
// If set, explicitly unmaps (huge) shadow at exit.
|
|
|
|
bool unmap_shadow_on_exit;
|
|
|
|
// If set, calls abort() instead of _exit() after printing an error report.
|
|
|
|
bool abort_on_error;
|
2013-01-28 15:34:22 +08:00
|
|
|
// Print various statistics after printing an error message or if atexit=1.
|
|
|
|
bool print_stats;
|
|
|
|
// Print the legend for the shadow bytes.
|
|
|
|
bool print_legend;
|
2012-07-10 15:41:27 +08:00
|
|
|
// If set, prints ASan exit stats even after program terminates successfully.
|
|
|
|
bool atexit;
|
2013-11-15 15:18:15 +08:00
|
|
|
// If set, coverage information will be dumped at shutdown time if the
|
|
|
|
// appropriate instrumentation was enabled.
|
|
|
|
bool coverage;
|
2012-07-10 15:41:27 +08:00
|
|
|
// By default, disable core dumper on 64-bit - it makes little sense
|
|
|
|
// to dump 16T+ core.
|
|
|
|
bool disable_core;
|
2012-08-24 17:22:05 +08:00
|
|
|
// Allow the tool to re-exec the program. This may interfere badly with the
|
|
|
|
// debugger.
|
|
|
|
bool allow_reexec;
|
2012-09-05 15:37:15 +08:00
|
|
|
// If set, prints not only thread creation stacks for threads in error report,
|
|
|
|
// but also thread creation stacks for threads that created those threads,
|
|
|
|
// etc. up to main thread.
|
|
|
|
bool print_full_thread_history;
|
2012-12-20 19:54:21 +08:00
|
|
|
// Poison (or not) the heap memory on [de]allocation. Zero value is useful
|
|
|
|
// for benchmarking the allocator or instrumentator.
|
|
|
|
bool poison_heap;
|
2013-10-16 21:49:01 +08:00
|
|
|
// If true, poison partially addressable 8-byte aligned words (default=true).
|
|
|
|
// This flag affects heap and global buffers, but not stack buffers.
|
|
|
|
bool poison_partial;
|
2012-12-21 16:53:59 +08:00
|
|
|
// Report errors on malloc/delete, new/free, new/delete[], etc.
|
|
|
|
bool alloc_dealloc_mismatch;
|
2013-02-28 22:09:30 +08:00
|
|
|
// If true, assume that memcmp(p1, p2, n) always reads n bytes before
|
|
|
|
// comparing p1 and p2.
|
|
|
|
bool strict_memcmp;
|
2013-04-19 16:35:16 +08:00
|
|
|
// If true, assume that dynamic initializers can never access globals from
|
|
|
|
// other modules, even if the latter are already initialized.
|
|
|
|
bool strict_init_order;
|
2014-01-16 20:31:50 +08:00
|
|
|
// If true, ASan tweaks a bunch of other flags (quarantine, redzone, heap
|
|
|
|
// poisoning) to reduce memory consumption as much as possible, and restores
|
|
|
|
// them to original values when the first instrumented module is loaded into
|
|
|
|
// the process. This is mainly intended to be used on Android.
|
|
|
|
bool start_deactivated;
|
2014-02-27 20:45:36 +08:00
|
|
|
// If non-zero, try to detect operations like <, <=, >, >= and - on invalid
|
|
|
|
// pointer pairs (e.g. when pointers belong to different objects).
|
|
|
|
// The bigger the value the harder we try.
|
|
|
|
int detect_invalid_pointer_pairs;
|
2012-07-10 15:41:27 +08:00
|
|
|
};
|
2012-07-25 17:18:43 +08:00
|
|
|
|
2013-04-12 02:36:04 +08:00
|
|
|
extern Flags asan_flags_dont_use_directly;
|
|
|
|
inline Flags *flags() {
|
|
|
|
return &asan_flags_dont_use_directly;
|
|
|
|
}
|
2012-07-10 15:41:27 +08:00
|
|
|
void InitializeFlags(Flags *f, const char *env);
|
|
|
|
|
|
|
|
} // namespace __asan
|
|
|
|
|
|
|
|
#endif // ASAN_FLAGS_H
|