clayborg created this revision.
clayborg added reviewers: labath, JDevlieghere, aprantl.
Herald added a project: All.
clayborg requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Debugging some DWARF5 binaries was causing errors to appear when 
DWARFExpression::Evaluate was called:

  error: GetDIE for DIE 0x31 is outside of its CU 0x123450

The issue is in the DWARF expression evaluator. Fixed with this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133623

Files:
  lldb/source/Expression/DWARFExpression.cpp


Index: lldb/source/Expression/DWARFExpression.cpp
===================================================================
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -2354,7 +2354,7 @@
               "Expression stack needs at least 1 item for DW_OP_convert.");
         return false;
       }
-      const uint64_t die_offset = opcodes.GetULEB128(&offset);
+      uint64_t die_offset = opcodes.GetULEB128(&offset);
       uint64_t bit_size;
       bool sign;
       if (die_offset == 0) {
@@ -2374,7 +2374,9 @@
           return false;
         }
       } else {
-        // Retrieve the type DIE that the value is being converted to.
+        // Retrieve the type DIE that the value is being converted to. This
+        // offset is compile unit relative so we need to fix it up.
+        die_offset += dwarf_cu->GetOffset();
         // FIXME: the constness has annoying ripple effects.
         DWARFDIE die = const_cast<DWARFUnit *>(dwarf_cu)->GetDIE(die_offset);
         if (!die) {


Index: lldb/source/Expression/DWARFExpression.cpp
===================================================================
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -2354,7 +2354,7 @@
               "Expression stack needs at least 1 item for DW_OP_convert.");
         return false;
       }
-      const uint64_t die_offset = opcodes.GetULEB128(&offset);
+      uint64_t die_offset = opcodes.GetULEB128(&offset);
       uint64_t bit_size;
       bool sign;
       if (die_offset == 0) {
@@ -2374,7 +2374,9 @@
           return false;
         }
       } else {
-        // Retrieve the type DIE that the value is being converted to.
+        // Retrieve the type DIE that the value is being converted to. This
+        // offset is compile unit relative so we need to fix it up.
+        die_offset += dwarf_cu->GetOffset();
         // FIXME: the constness has annoying ripple effects.
         DWARFDIE die = const_cast<DWARFUnit *>(dwarf_cu)->GetDIE(die_offset);
         if (!die) {
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to