asan_flags.h revision 71b42c9740e6f73da607aaa539affb5c4807231c
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//===-- asan_flags.h -------------------------------------------*- C++ -*-===//
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//                     The LLVM Compiler Infrastructure
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This file is distributed under the University of Illinois Open Source
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// License. See LICENSE.TXT for details.
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//===----------------------------------------------------------------------===//
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This file is a part of AddressSanitizer, an address sanity checker.
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// ASan runtime flags.
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//===----------------------------------------------------------------------===//
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef ASAN_FLAGS_H
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define ASAN_FLAGS_H
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "sanitizer/common_interface_defs.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// ASan flag values can be defined in three ways:
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 1) initialized with default values at startup.
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 2) overriden from string returned by user-specified function
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//    __asan_default_options().
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// 3) overriden from env variable ASAN_OPTIONS.
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace __asan {
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct Flags {
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Size (in bytes) of quarantine used to detect use-after-free errors.
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Lower value may reduce memory usage but increase the chance of
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // false negatives.
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int  quarantine_size;
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If set, uses in-process symbolizer from common sanitizer runtime.
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool symbolize;
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int  verbosity;
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Size (in bytes) of redzones around heap objects.
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Requirement: redzone >= 32, is a power of two.
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int  redzone;
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If set, prints some debugging information and does additional checks.
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool debug;
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Controls the way to handle globals (0 - don't detect buffer overflow
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // on globals, 1 - detect buffer overflow, 2 - print data about registered
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // 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.
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. See comments in asan_mac.cc and asan_malloc_mac.cc.
56  bool replace_cfallocator;
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  // 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};
97
98Flags *flags();
99void InitializeFlags(Flags *f, const char *env);
100
101}  // namespace __asan
102
103#endif  // ASAN_FLAGS_H
104