[Lldb-commits] [PATCH] D18975: Fix unwind failures when PC points beyond the end of a function

Ulrich Weigand via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 15 14:42:56 PDT 2016


uweigand added reviewers: clayborg, tberghammer.
uweigand updated this revision to Diff 53951.
uweigand added a comment.

Add fix for a related problem that still caused unwind failures on SystemZ.

The ResolveSymbolContextForAddress sometimes returns a "symbol" with empty
name.  This turns out to be an ELF section symbol.  Now, usually those get type
eSymbolTypeInvalid.  However, there is code in ObjectFileELF::ParseSymbols
that tries to change the type of invalid symbols to eSymbolTypeCode or
eSymbolTypeData if the symbol lies within the code or data section.

Unfortunately, this check also hits the symbol for the code section
itself, which is then marked as eSymbolTypeCode.  While the size of
the section symbol is 0 according to the ELF file, LLDB considers
this size invalid and attempts to figure out the "correct" size.
Depending on how this goes, we may end up with a symbol that overlays
part of the code section, even outside areas covered by real function
symbols.

Therefore, if we call ResolveSymbolContextForAddress with PC pointing
beyond the end of a function, we may get this bogus section symbol.
This again means InitializeNonZerothFrame thinks we have a valid PC,
but then we don't find any unwind info for it.

The fix for this problem seems to me to simply always leave ELF section
symbols as type eSymbolTypeInvalid.


http://reviews.llvm.org/D18975

Files:
  source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  source/Plugins/Process/Utility/RegisterContextLLDB.cpp

Index: source/Plugins/Process/Utility/RegisterContextLLDB.cpp
===================================================================
--- source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -470,11 +470,13 @@
         return;
     }
 
-    bool resolve_tail_call_address = true; // m_current_pc can be one past the address range of the function...
-                                           // This will handle the case where the saved pc does not point to 
-                                           // a function/symbol because it is beyond the bounds of the correct
-                                           // function and there's no symbol there.  ResolveSymbolContextForAddress
-                                           // will fail to find a symbol, back up the pc by 1 and re-search.
+    bool resolve_tail_call_address = false; // m_current_pc can be one past the address range of the function...
+                                            // If the saved pc does not point to a function/symbol because it is
+                                            // beyond the bounds of the correct function and there's no symbol there,
+                                            // we do *not* want ResolveSymbolContextForAddress to back up the pc by 1,
+                                            // because then we might not find the correct unwind information later.
+                                            // Instead, let ResolveSymbolContextForAddress fail, and handle the case
+                                            // via decr_pc_and_recompute_addr_range below.
     const uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol;
     uint32_t resolved_scope = pc_module_sp->ResolveSymbolContextForAddress (m_current_pc,
                                                                             resolve_scope,
Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
===================================================================
--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2148,7 +2148,7 @@
             }
         }
 
-        if (symbol_type == eSymbolTypeInvalid)
+        if (symbol_type == eSymbolTypeInvalid && symbol.getType() != STT_SECTION)
         {
             if (symbol_section_sp)
             {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18975.53951.patch
Type: text/x-patch
Size: 2389 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160415/f6437e25/attachment.bin>


More information about the lldb-commits mailing list