[compiler-rt] r215479 - [Sanitizer] Make disable_coredump a common flag and use it in TSan

Alexey Samsonov vonosmas at gmail.com
Tue Aug 12 15:07:49 PDT 2014


Author: samsonov
Date: Tue Aug 12 17:07:48 2014
New Revision: 215479

URL: http://llvm.org/viewvc/llvm-project?rev=215479&view=rev
Log:
[Sanitizer] Make disable_coredump a common flag and use it in TSan

Modified:
    compiler-rt/trunk/lib/asan/asan_flags.h
    compiler-rt/trunk/lib/asan/asan_rtl.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h
    compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc

Modified: compiler-rt/trunk/lib/asan/asan_flags.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_flags.h?rev=215479&r1=215478&r2=215479&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_flags.h (original)
+++ compiler-rt/trunk/lib/asan/asan_flags.h Tue Aug 12 17:07:48 2014
@@ -52,7 +52,6 @@ struct Flags {
   bool print_stats;
   bool print_legend;
   bool atexit;
-  bool disable_core;
   bool allow_reexec;
   bool print_full_thread_history;
   bool poison_heap;

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=215479&r1=215478&r2=215479&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Tue Aug 12 17:07:48 2014
@@ -173,11 +173,6 @@ static void ParseFlagsFromString(Flags *
       "If set, prints ASan exit stats even after program terminates "
       "successfully.");
 
-  ParseFlag(str, &f->disable_core, "disable_core",
-      "Disable core dumping. By default, disable_core=1 on 64-bit to avoid "
-      "dumping a 16T+ core file. "
-      "Ignored on OSes that don't dump core by default.");
-
   ParseFlag(str, &f->allow_reexec, "allow_reexec",
       "Allow the tool to re-exec the program. This may interfere badly with "
       "the debugger.");
@@ -271,7 +266,6 @@ void InitializeFlags(Flags *f, const cha
   f->print_stats = false;
   f->print_legend = true;
   f->atexit = false;
-  f->disable_core = (SANITIZER_WORDSIZE == 64);
   f->allow_reexec = true;
   f->print_full_thread_history = true;
   f->poison_heap = true;
@@ -617,7 +611,7 @@ static void AsanInitInternal() {
   if (common_flags()->verbosity)
     PrintAddressSpaceLayout();
 
-  if (flags()->disable_core) {
+  if (common_flags()->disable_coredump) {
     DisableCoreDumper();
   }
 

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc?rev=215479&r1=215478&r2=215479&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.cc Tue Aug 12 17:07:48 2014
@@ -65,6 +65,7 @@ void SetCommonFlagsDefaults(CommonFlags
   f->full_address_space = false;
   f->suppressions = "";
   f->print_suppressions = true;
+  f->disable_coredump = (SANITIZER_WORDSIZE == 64);
 }
 
 void ParseCommonFlagsFromString(CommonFlags *f, const char *str) {
@@ -149,6 +150,10 @@ void ParseCommonFlagsFromString(CommonFl
   ParseFlag(str, &f->suppressions, "suppressions", "Suppressions file name.");
   ParseFlag(str, &f->print_suppressions, "print_suppressions",
             "Print matched suppressions at exit.");
+  ParseFlag(str, &f->disable_coredump, "disable_coredump",
+      "Disable core dumping. By default, disable_core=1 on 64-bit to avoid "
+      "dumping a 16T+ core file. Ignored on OSes that don't dump core by"
+      "default and for sanitizers that don't reserve lots of virtual memory.");
 
   // Do a sanity check for certain flags.
   if (f->malloc_context_size < 1)

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h?rev=215479&r1=215478&r2=215479&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_flags.h Tue Aug 12 17:07:48 2014
@@ -59,6 +59,7 @@ struct CommonFlags {
   bool full_address_space;
   const char *suppressions;
   bool print_suppressions;
+  bool disable_coredump;
 };
 
 inline CommonFlags *common_flags() {

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc?rev=215479&r1=215478&r2=215479&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc Tue Aug 12 17:07:48 2014
@@ -347,8 +347,7 @@ static void setlim(int res, rlim_t lim)
 }
 
 const char *InitializePlatform() {
-  void *p = 0;
-  if (sizeof(p) == 8) {
+  if (common_flags()->disable_coredump) {
     // Disable core dumps, dumping of 16TB usually takes a bit long.
     setlim(RLIMIT_CORE, 0);
   }





More information about the llvm-commits mailing list