[Sanitizer] Replace Symbolizer::IsAvailable and Symbolizer::IsExternalAvailable with...
authorAlexey Samsonov <samsonov@google.com>
Wed, 25 Dec 2013 07:09:44 +0000 (07:09 +0000)
committerAlexey Samsonov <samsonov@google.com>
Wed, 25 Dec 2013 07:09:44 +0000 (07:09 +0000)
Remove now redundant checks in symbolizer initialization in TSan and MSan.

llvm-svn: 198000

compiler-rt/lib/msan/msan.cc
compiler-rt/lib/sanitizer_common/sanitizer_common.cc
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cc
compiler-rt/lib/tsan/rtl/tsan_rtl.cc
compiler-rt/lib/tsan/rtl/tsan_symbolize.cc

index a1a37b6..46f37cb 100644 (file)
@@ -300,12 +300,7 @@ void __msan_init() {
     Die();
   }
 
-  const char *external_symbolizer = common_flags()->external_symbolizer_path;
-  bool external_symbolizer_started =
-      Symbolizer::Init(external_symbolizer)->IsExternalAvailable();
-  if (external_symbolizer && external_symbolizer[0]) {
-    CHECK(external_symbolizer_started);
-  }
+  Symbolizer::Init(common_flags()->external_symbolizer_path);
   Symbolizer::Get()->AddHooks(EnterSymbolizer, ExitSymbolizer);
 
   GetThreadStackAndTls(/* main */ true, &msan_stack_bounds.stack_addr,
index 77ffda3..5e68c95 100644 (file)
@@ -202,7 +202,7 @@ void ReportErrorSummary(const char *error_type, StackTrace *stack) {
     return;
   AddressInfo ai;
 #if !SANITIZER_GO
-  if (stack->size > 0 && Symbolizer::Get()->IsAvailable()) {
+  if (stack->size > 0 && Symbolizer::Get()->CanReturnFileLineInfo()) {
     // Currently, we include the first stack frame into the report summary.
     // Maybe sometimes we need to choose another frame (e.g. skip memcpy/etc).
     uptr pc = StackTrace::GetPreviousInstructionPc(stack->trace[0]);
index 776cdeb..5edc30b 100644 (file)
@@ -95,10 +95,7 @@ class Symbolizer {
   virtual bool SymbolizeData(uptr address, DataInfo *info) {
     return false;
   }
-  virtual bool IsAvailable() {
-    return false;
-  }
-  virtual bool IsExternalAvailable() {
+  virtual bool CanReturnFileLineInfo() {
     return false;
   }
   // Release internal caches (if any).
index f2840f6..0190e2d 100644 (file)
@@ -473,14 +473,10 @@ class POSIXSymbolizer : public Symbolizer {
     return true;
   }
 
-  bool IsAvailable() {
+  bool CanReturnFileLineInfo() {
     return internal_symbolizer_ != 0 || external_symbolizer_ != 0;
   }
 
-  bool IsExternalAvailable() {
-    return external_symbolizer_ != 0;
-  }
-
   void Flush() {
     BlockingMutexLock l(&mu_);
     if (internal_symbolizer_ != 0) {
index 0a5f9f2..3a175ce 100644 (file)
@@ -74,7 +74,7 @@ class WinSymbolizer : public Symbolizer {
     return 1;
   }
 
-  bool IsAvailable() {
+  bool CanReturnFileLineInfo() {
     return true;
   }
 
index 5a7a57e..aaab64f 100644 (file)
@@ -241,16 +241,7 @@ void Initialize(ThreadState *thr) {
   InitializeSuppressions();
 #ifndef TSAN_GO
   InitializeLibIgnore();
-  // Initialize external symbolizer before internal threads are started.
-  const char *external_symbolizer = flags()->external_symbolizer_path;
-  bool external_symbolizer_started =
-      Symbolizer::Init(external_symbolizer)->IsExternalAvailable();
-  if (external_symbolizer != 0 && external_symbolizer[0] != '\0' &&
-      !external_symbolizer_started) {
-    Printf("Failed to start external symbolizer: '%s'\n",
-           external_symbolizer);
-    Die();
-  }
+  Symbolizer::Init(common_flags()->external_symbolizer_path);
   Symbolizer::Get()->AddHooks(EnterSymbolizer, ExitSymbolizer);
 #endif
   internal_start_thread(&BackgroundThread, 0);
index 97163da..a2fd7a1 100644 (file)
@@ -105,7 +105,7 @@ ReportStack *SymbolizeCode(uptr addr) {
     ent->col = col;
     return ent;
   }
-  if (!Symbolizer::Get()->IsAvailable())
+  if (!Symbolizer::Get()->CanReturnFileLineInfo())
     return SymbolizeCodeAddr2Line(addr);
   static const uptr kMaxAddrFrames = 16;
   InternalScopedBuffer<AddressInfo> addr_frames(kMaxAddrFrames);
@@ -131,8 +131,6 @@ ReportStack *SymbolizeCode(uptr addr) {
 }
 
 ReportLocation *SymbolizeData(uptr addr) {
-  if (!Symbolizer::Get()->IsAvailable())
-    return 0;
   DataInfo info;
   if (!Symbolizer::Get()->SymbolizeData(addr, &info))
     return 0;
@@ -150,8 +148,6 @@ ReportLocation *SymbolizeData(uptr addr) {
 }
 
 void SymbolizeFlush() {
-  if (!Symbolizer::Get()->IsAvailable())
-    return;
   Symbolizer::Get()->Flush();
 }