[Lldb-commits] [lldb] r119017 - in /lldb/trunk: include/lldb/Symbol/Block.h lldb.xcodeproj/project.pbxproj source/Breakpoint/BreakpointResolverName.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/Block.cpp

Greg Clayton gclayton at apple.com
Sat Nov 13 16:22:48 PST 2010


Author: gclayton
Date: Sat Nov 13 18:22:48 2010
New Revision: 119017

URL: http://llvm.org/viewvc/llvm-project?rev=119017&view=rev
Log:
Fixed a crasher (an assert was firing in the DWARF parser) when setting
breakpoints on inlined functions by name. This involved fixing the DWARF parser
to correctly back up and parse the concrete function when we find inlined
functions by name, then grabbing any appropriate inlined blocks and returning
symbol contexts with the block filled in. After this was fixed, the breakpoint
by name resolver needed to correctly deal with symbol contexts that had the
inlined block filled in in the symbol contexts.


Modified:
    lldb/trunk/include/lldb/Symbol/Block.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Symbol/Block.cpp

Modified: lldb/trunk/include/lldb/Symbol/Block.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=119017&r1=119016&r2=119017&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Block.h (original)
+++ lldb/trunk/include/lldb/Symbol/Block.h Sat Nov 13 18:22:48 2010
@@ -420,6 +420,8 @@
     bool
     GetRangeContainingAddress (const Address& addr, AddressRange &range);
 
+    bool
+    GetStartAddress (Address &addr);
     
 protected:
     typedef std::vector<lldb::BlockSP> collection;

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=119017&r1=119016&r2=119017&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sat Nov 13 18:22:48 2010
@@ -2941,6 +2941,7 @@
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
+				ONLY_ACTIVE_ARCH = YES;
 				PREBINDING = NO;
 				VALID_ARCHS = "x86_64 i386";
 			};

Modified: lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp?rev=119017&r1=119016&r2=119017&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp Sat Nov 13 18:22:48 2010
@@ -191,8 +191,21 @@
                     remove = true;
                 else if (sc.function == NULL)
                     remove = true;
-                else if (::strstr (sc.function->GetName().AsCString(), basename_filter) == NULL)
-                    remove = true;
+                else
+                {
+                    const InlineFunctionInfo* inlined_info = NULL;
+                    
+                    if (sc.block)
+                        inlined_info = sc.block->GetInlinedFunctionInfo();
+
+                    if (inlined_info)
+                    {
+                        if (::strstr (inlined_info->GetName().AsCString(), basename_filter) == NULL)
+                            remove = true;
+                    }
+                    else if (::strstr (sc.function->GetName().AsCString(), basename_filter) == NULL)
+                        remove = true;
+                }
 
                 if (remove)
                 {
@@ -259,16 +272,27 @@
         {
             if (func_list.GetContextAtIndex(i, sc))
             {
-                if (sc.function)
+                if (sc.block && sc.block->GetInlinedFunctionInfo())
+                {
+                    if (!sc.block->GetStartAddress(break_addr))
+                        break_addr.Clear();
+                }
+                else if (sc.function)
                 {
                     break_addr = sc.function->GetAddressRange().GetBaseAddress();
                     if (skip_prologue)
                     {
-                        const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
-                        if (prologue_byte_size)
-                            break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
+                        if (break_addr.IsValid())
+                        {
+                            const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize();
+                            if (prologue_byte_size)
+                                break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size);
+                        }
                     }
-                    
+                }
+                
+                if (break_addr.IsValid())
+                {
                     if (filter.AddressPasses(break_addr))
                     {
                         BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(break_addr, &new_location));

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=119017&r1=119016&r2=119017&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Sat Nov 13 18:22:48 2010
@@ -659,7 +659,9 @@
             FunctionSP func_sp;
             std::auto_ptr<Declaration> decl_ap;
             if (decl_file != 0 || decl_line != 0 || decl_column != 0)
-                decl_ap.reset(new Declaration(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line, decl_column));
+                decl_ap.reset(new Declaration (sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), 
+                                               decl_line, 
+                                               decl_column));
 
             Type *func_type = m_die_to_type.lookup (die);
 
@@ -1932,7 +1934,7 @@
     DWARFCompileUnit* prev_cu = NULL;
     const DWARFDebugInfoEntry* die = NULL;
     std::vector<NameToDIE::Info> die_info_array;
-    const size_t num_matches = name_to_die.Find(name, die_info_array);
+    const size_t num_matches = name_to_die.Find (name, die_info_array);
     for (size_t i=0; i<num_matches; ++i, prev_cu = curr_cu)
     {
         curr_cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx);
@@ -1941,20 +1943,52 @@
             curr_cu->ExtractDIEsIfNeeded (false);
 
         die = curr_cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx);
+        
+        const DWARFDebugInfoEntry* inlined_die = NULL;
+        if (die->Tag() == DW_TAG_inlined_subroutine)
+        {
+            inlined_die = die;
+            
+            while ((die = die->GetParent()) != NULL)
+            {
+                if (die->Tag() == DW_TAG_subprogram)
+                    break;
+            }
+        }
+        assert (die->Tag() == DW_TAG_subprogram);
         if (GetFunction (curr_cu, die, sc))
         {
-            // We found the function, so we should find the line table
-            // and line table entry as well
-            LineTable *line_table = sc.comp_unit->GetLineTable();
-            if (line_table == NULL)
+            Address addr;
+            // Parse all blocks if needed
+            if (inlined_die)
             {
-                if (ParseCompileUnitLineTable(sc))
-                    line_table = sc.comp_unit->GetLineTable();
+                sc.block = sc.function->GetBlock (true).FindBlockByID (inlined_die->GetOffset());
+                assert (sc.block != NULL);
+                if (sc.block->GetStartAddress (addr) == false)
+                    addr.Clear();
+            }
+            else 
+            {
+                sc.block = NULL;
+                addr = sc.function->GetAddressRange().GetBaseAddress();
             }
-            if (line_table != NULL)
-                line_table->FindLineEntryByAddress (sc.function->GetAddressRange().GetBaseAddress(), sc.line_entry);
 
-            sc_list.Append(sc);
+            if (addr.IsValid())
+            {
+            
+                // We found the function, so we should find the line table
+                // and line table entry as well
+                LineTable *line_table = sc.comp_unit->GetLineTable();
+                if (line_table == NULL)
+                {
+                    if (ParseCompileUnitLineTable(sc))
+                        line_table = sc.comp_unit->GetLineTable();
+                }
+                if (line_table != NULL)
+                    line_table->FindLineEntryByAddress (addr, sc.line_entry);
+
+                sc_list.Append(sc);
+            }
         }
     }
 }

Modified: lldb/trunk/source/Symbol/Block.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=119017&r1=119016&r2=119017&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Block.cpp (original)
+++ lldb/trunk/source/Symbol/Block.cpp Sat Nov 13 18:22:48 2010
@@ -358,6 +358,24 @@
     return false;
 }
 
+
+bool
+Block::GetStartAddress (Address &addr)
+{
+    if (m_ranges.empty())
+        return false;
+
+    SymbolContext sc;
+    CalculateSymbolContext(&sc);
+    if (sc.function)
+    {
+        addr = sc.function->GetAddressRange().GetBaseAddress();
+        addr.Slide(m_ranges.front().GetBaseAddress ());
+        return true;
+    }
+    return false;
+}
+
 void
 Block::AddRange(addr_t start_offset, addr_t end_offset)
 {





More information about the lldb-commits mailing list