[Lldb-commits] [lldb] r244739 - Improve check for ASAN callbacks

Tamas Berghammer via lldb-commits lldb-commits at lists.llvm.org
Wed Aug 12 04:13:11 PDT 2015


Author: tberghammer
Date: Wed Aug 12 06:13:11 2015
New Revision: 244739

URL: http://llvm.org/viewvc/llvm-project?rev=244739&view=rev
Log:
Improve check for ASAN callbacks

The ASAN callbacks are public symbols so we can search for them
with reading only the symbol table (not the debug info). Whit this
change the attach time for big executables with debug symbols
decreased by a factor of ~4.

Differential revision: http://reviews.llvm.org/D11384

Modified:
    lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
    lldb/trunk/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp

Modified: lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp?rev=244739&r1=244738&r2=244739&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp Wed Aug 12 06:13:11 2015
@@ -78,14 +78,11 @@ AddressSanitizerRuntime::~AddressSanitiz
 
 bool ModuleContainsASanRuntime(Module * module)
 {
-    SymbolContextList sc_list;
-    const bool include_symbols = true;
-    const bool append = true;
-    const bool include_inlines = true;
-    
-    size_t num_matches = module->FindFunctions(ConstString("__asan_get_alloc_stack"), NULL, eFunctionNameTypeAuto, include_symbols, include_inlines, append, sc_list);
-    
-    return num_matches > 0;
+    const Symbol* symbol = module->FindFirstSymbolWithNameAndType(
+            ConstString("__asan_get_alloc_stack"),
+            lldb::eSymbolTypeAny);
+
+    return symbol != nullptr;
 }
 
 void

Modified: lldb/trunk/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp?rev=244739&r1=244738&r2=244739&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp (original)
+++ lldb/trunk/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp Wed Aug 12 06:13:11 2015
@@ -30,36 +30,25 @@ MemoryHistoryASan::CreateInstance (const
 {
     if (!process_sp.get())
         return NULL;
-    
+
     Target & target = process_sp->GetTarget();
-    
-    bool found_asan_runtime = false;
-    
+
     const ModuleList &target_modules = target.GetImages();
     Mutex::Locker modules_locker(target_modules.GetMutex());
     const size_t num_modules = target_modules.GetSize();
     for (size_t i = 0; i < num_modules; ++i)
     {
         Module *module_pointer = target_modules.GetModulePointerAtIndexUnlocked(i);
-        
-        SymbolContextList sc_list;
-        const bool include_symbols = true;
-        const bool append = true;
-        const bool include_inlines = true;
-
-        size_t num_matches = module_pointer->FindFunctions(ConstString("__asan_get_alloc_stack"), NULL, eFunctionNameTypeAuto, include_symbols, include_inlines, append, sc_list);
-        
-        if (num_matches)
-        {
-            found_asan_runtime = true;
-            break;
-        }
+
+        const Symbol* symbol = module_pointer->FindFirstSymbolWithNameAndType(
+                ConstString("__asan_get_alloc_stack"),
+                lldb::eSymbolTypeAny);
+
+        if (symbol != nullptr)
+            return MemoryHistorySP(new MemoryHistoryASan(process_sp));        
     }
-    
-    if (! found_asan_runtime)
-        return MemoryHistorySP();
 
-    return MemoryHistorySP(new MemoryHistoryASan(process_sp));
+    return MemoryHistorySP();
 }
 
 void




More information about the lldb-commits mailing list