[llvm-commits] [compiler-rt] r159985 - in /compiler-rt/trunk/lib/asan: asan_flags.h asan_interface.h asan_internal.h asan_rtl.cc
Alexey Samsonov
samsonov at google.com
Tue Jul 10 00:41:27 PDT 2012
Author: samsonov
Date: Tue Jul 10 02:41:27 2012
New Revision: 159985
URL: http://llvm.org/viewvc/llvm-project?rev=159985&view=rev
Log:
[ASan] move flags description to separate header, add comments about them.
Added:
compiler-rt/trunk/lib/asan/asan_flags.h
Modified:
compiler-rt/trunk/lib/asan/asan_interface.h
compiler-rt/trunk/lib/asan/asan_internal.h
compiler-rt/trunk/lib/asan/asan_rtl.cc
Added: compiler-rt/trunk/lib/asan/asan_flags.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_flags.h?rev=159985&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_flags.h (added)
+++ compiler-rt/trunk/lib/asan/asan_flags.h Tue Jul 10 02:41:27 2012
@@ -0,0 +1,97 @@
+//===-- 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
+
+#include "sanitizer_common/sanitizer_interface_defs.h"
+
+// ASan flag values can be defined in three ways:
+// 1) initialized with default values at startup.
+// 2) overriden from user-specified string __asan_default_options.
+// 3) overriden from env variable ASAN_OPTIONS.
+
+extern "C" {
+#if !defined(_WIN32)
+ // We do not need to redefine the defaults right now on Windows.
+ char *__asan_default_options SANITIZER_WEAK_ATTRIBUTE;
+#endif
+}
+
+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;
+ // If set, uses in-process symbolizer from common sanitizer runtime.
+ bool symbolize;
+ // Verbosity level (0 - silent, 1 - a bit of output, 2+ - more output).
+ int verbosity;
+ // Size (in bytes) of redzones around heap objects.
+ // Requirement: redzone >= 32, is a power of two.
+ int redzone;
+ // 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;
+ // Max number of stack frames kept for each allocation.
+ int malloc_context_size;
+ // 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. See comments in asan_mac.cc and asan_malloc_mac.cc.
+ bool replace_cfallocator;
+ // Used on Mac only.
+ bool mac_ignore_invalid_free;
+ // ASan allocator flag. See asan_allocator.cc.
+ bool use_fake_stack;
+ // ASan allocator flag. Sets the maximal size of allocation request
+ // that would return memory filled with zero bytes.
+ int max_malloc_fill_size;
+ // 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;
+ // If set, registers ASan custom segv handler.
+ bool handle_segv;
+ // If set, uses alternate stack for signal handling.
+ bool use_sigaltstack;
+ // 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;
+ // If set, prints ASan exit stats even after program terminates successfully.
+ bool atexit;
+ // By default, disable core dumper on 64-bit - it makes little sense
+ // to dump 16T+ core.
+ bool disable_core;
+};
+Flags *flags();
+void InitializeFlags(Flags *f, const char *env);
+
+} // namespace __asan
+
+#endif // ASAN_FLAGS_H
Modified: compiler-rt/trunk/lib/asan/asan_interface.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interface.h?rev=159985&r1=159984&r2=159985&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interface.h (original)
+++ compiler-rt/trunk/lib/asan/asan_interface.h Tue Jul 10 02:41:27 2012
@@ -154,10 +154,6 @@
// Prints accumulated stats to stderr. Used for debugging.
void __asan_print_accumulated_stats()
SANITIZER_INTERFACE_ATTRIBUTE;
-#if !defined(_WIN32)
- // We do not need to redefine the defaults right now on Windows.
- char *__asan_default_options SANITIZER_WEAK_ATTRIBUTE;
-#endif
} // namespace
#endif // ASAN_INTERFACE_H
Modified: compiler-rt/trunk/lib/asan/asan_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_internal.h?rev=159985&r1=159984&r2=159985&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_internal.h Tue Jul 10 02:41:27 2012
@@ -14,6 +14,7 @@
#ifndef ASAN_INTERNAL_H
#define ASAN_INTERNAL_H
+#include "asan_flags.h"
#include "sanitizer_common/sanitizer_common.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "sanitizer_common/sanitizer_libc.h"
@@ -136,34 +137,6 @@
# define PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE true
#endif // __APPLE__
-struct Flags {
- int quarantine_size;
- bool symbolize;
- int verbosity;
- int redzone;
- int debug;
- int report_globals;
- int malloc_context_size;
- bool replace_str;
- bool replace_intrin;
- bool replace_cfallocator;
- bool mac_ignore_invalid_free;
- bool use_fake_stack;
- int max_malloc_fill_size;
- int exitcode;
- bool allow_user_poisoning;
- int sleep_before_dying;
- bool handle_segv;
- bool use_sigaltstack;
- bool check_malloc_usable_size;
- bool unmap_shadow_on_exit;
- bool abort_on_error;
- bool atexit;
- bool disable_core;
-};
-Flags *flags();
-void InitializeFlags(Flags *f, const char *env);
-
extern int asan_inited;
// Used to avoid infinite recursion in __asan_init().
extern bool asan_init_is_running;
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=159985&r1=159984&r2=159985&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Tue Jul 10 02:41:27 2012
@@ -67,11 +67,6 @@
return &asan_flags;
}
-// Can be overriden in frontend.
-void WEAK OverrideFlags(Flags *f) {
- (void)f;
-}
-
static void ParseFlagsFromString(Flags *f, const char *str) {
ParseFlag(str, &f->quarantine_size, "quarantine_size");
ParseFlag(str, &f->symbolize, "symbolize");
@@ -96,13 +91,10 @@
ParseFlag(str, &f->sleep_before_dying, "sleep_before_dying");
ParseFlag(str, &f->handle_segv, "handle_segv");
ParseFlag(str, &f->use_sigaltstack, "use_sigaltstack");
- // Allow the users to work around the bug in Nvidia drivers prior to 295.*.
ParseFlag(str, &f->check_malloc_usable_size, "check_malloc_usable_size");
ParseFlag(str, &f->unmap_shadow_on_exit, "unmap_shadow_on_exit");
ParseFlag(str, &f->abort_on_error, "abort_on_error");
ParseFlag(str, &f->atexit, "atexit");
- // By default, disable core dumper on 64-bit --
- // it makes little sense to dump 16T+ core.
ParseFlag(str, &f->disable_core, "disable_core");
}
@@ -112,14 +104,14 @@
f->quarantine_size = (ASAN_LOW_MEMORY) ? 1UL << 24 : 1UL << 28;
f->symbolize = false;
f->verbosity = 0;
- f->redzone = (ASAN_LOW_MEMORY) ? 64 : 128; // power of two, >= 32.
- f->debug = 0;
+ f->redzone = (ASAN_LOW_MEMORY) ? 64 : 128;
+ f->debug = false;
f->report_globals = 1;
f->malloc_context_size = kMallocContextSize;
f->replace_str = true;
f->replace_intrin = true;
- f->replace_cfallocator = true; // Used on Mac only.
- f->mac_ignore_invalid_free = false; // Used on Mac only.
+ f->replace_cfallocator = true;
+ f->mac_ignore_invalid_free = false;
f->use_fake_stack = true;
f->max_malloc_fill_size = 0;
f->exitcode = ASAN_DEFAULT_FAILURE_EXITCODE;
@@ -133,9 +125,6 @@
f->atexit = false;
f->disable_core = (__WORDSIZE == 64);
- // Let a frontend override.
- OverrideFlags(f);
-
// Override from user-specified string.
#if !defined(_WIN32)
if (__asan_default_options) {
More information about the llvm-commits
mailing list