[Lldb-commits] [lldb] r111322 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp

Greg Clayton gclayton at apple.com
Tue Aug 17 16:16:15 PDT 2010


Author: gclayton
Date: Tue Aug 17 18:16:15 2010
New Revision: 111322

URL: http://llvm.org/viewvc/llvm-project?rev=111322&view=rev
Log:
Fixed an issue where we would return matches for DWARF in the .o files when
the resulting function from the .o file DWARF didn't make it into the final
executable. I recently changed the way FindFunctions() worked in the DWARF
with debug map case that caused regressions in our test suite for dead 
stripped functions. The previous changes allowed us to leverage the powerful 
searching added to the DWARF parser (search by full name, basename, selector, 
or method name), without having to chop up the symbol names from the symbol
table and do any special parsing of the names to extract the basename, 
selector or method. Previously we would look through the symbol table for 
matches first, then try and find the .o file with DWARF for that symbol and
only search those .o files. Now we let the DWARF for the .o file search using
the new search styles, and filter out any functions that didn't make it.



Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=111322&r1=111321&r2=111322&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Tue Aug 17 18:16:15 2010
@@ -762,6 +762,33 @@
     return comp_unit_info;
 }
 
+static void
+RemoveFunctionsWithModuleNotEqualTo (Module *module, SymbolContextList &sc_list, uint32_t start_idx)
+{
+    // We found functions in .o files. Not all functions in the .o files
+    // will have made it into the final output file. The ones that did
+    // make it into the final output file will have a section whose module
+    // matches the module from the ObjectFile for this SymbolFile. When
+    // the modules don't match, then we have something that was in a
+    // .o file, but doesn't map to anything in the final executable.
+    uint32_t i=start_idx;
+    while (i < sc_list.GetSize())
+    {
+        SymbolContext sc;
+        sc_list.GetContextAtIndex(i, sc);
+        if (sc.function)
+        {
+            const Section *section = sc.function->GetAddressRange().GetBaseAddress().GetSection();
+            if (section->GetModule() != module)
+            {
+                sc_list.RemoveContextAtIndex(i);
+                continue;
+            }
+        }
+        ++i;
+    }
+}
+
 uint32_t
 SymbolFileDWARFDebugMap::FindFunctions(const ConstString &name, uint32_t name_type_mask, bool append, SymbolContextList& sc_list)
 {
@@ -779,7 +806,11 @@
     SymbolFileDWARF *oso_dwarf;
     while ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx++)) != NULL)
     {
-        oso_dwarf->FindFunctions(name, name_type_mask, true, sc_list);
+        uint32_t sc_idx = sc_list.GetSize();
+        if (oso_dwarf->FindFunctions(name, name_type_mask, true, sc_list))
+        {
+            RemoveFunctionsWithModuleNotEqualTo (m_obj_file->GetModule(), sc_list, sc_idx);
+        }
     }
 
     return sc_list.GetSize() - initial_size;
@@ -803,12 +834,15 @@
     SymbolFileDWARF *oso_dwarf;
     while ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx++)) != NULL)
     {
-        oso_dwarf->FindFunctions(regex, true, sc_list);
+        uint32_t sc_idx = sc_list.GetSize();
+        
+        if (oso_dwarf->FindFunctions(regex, true, sc_list))
+        {
+            RemoveFunctionsWithModuleNotEqualTo (m_obj_file->GetModule(), sc_list, sc_idx);
+        }
     }
 
     return sc_list.GetSize() - initial_size;
-
-    return 0;
 }
 
 





More information about the lldb-commits mailing list