[Lldb-commits] [PATCH] D11384: Improve check for ASAN callbacks

Tamas Berghammer tberghammer at google.com
Tue Jul 21 03:07:35 PDT 2015


tberghammer created this revision.
tberghammer added a reviewer: kubabrecka.
tberghammer added a subscriber: lldb-commits.

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 a big executable with debug symbols
decreased by a factor of ~4 on Linux.

http://reviews.llvm.org/D11384

Files:
  source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
  source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp

Index: source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
===================================================================
--- source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
+++ source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
@@ -30,36 +30,25 @@
 {
     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
Index: source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
===================================================================
--- source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
+++ source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
@@ -78,14 +78,11 @@
 
 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11384.30239.patch
Type: text/x-patch
Size: 2654 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150721/d131754b/attachment.bin>


More information about the lldb-commits mailing list