[Lldb-commits] [lldb] r345249 - [LLDB] - Parse the DW_LLE_startx_length correctly for DWARF v5 case.

George Rimar via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 25 02:22:27 PDT 2018

Author: grimar
Date: Thu Oct 25 02:22:26 2018
New Revision: 345249

URL: http://llvm.org/viewvc/llvm-project?rev=345249&view=rev
[LLDB] - Parse the DW_LLE_startx_length correctly for DWARF v5 case.

Currently, we always parse the length field of DW_LLE_startx_length entry as U32.
That is correct for pre-standard definition:

https://gcc.gnu.org/wiki/DebugFission - "A start/length entry contains one unsigned LEB128 number
and a 4-byte unsigned value (as would be represented by the form code DW_FORM_const4u). The first
number is an index into the .debug_addr section that selects the beginning offset, and the second
number is the length of the range. ")

But DWARF v5 says: "This is a form of bounded location description that has two unsigned ULEB operands.
The first value is an address index (into the .debug_addr section) that indicates the beginning of the address
range over which the location is valid. The second value is the length of the range."

Fortunately, we can easily handle the difference. No test case because it seems impossible to test
until we will be ready to use DWARF v5 in tests that need to run the executables.

Differential revision: https://reviews.llvm.org/D53646


Modified: lldb/trunk/include/lldb/Expression/DWARFExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/DWARFExpression.h?rev=345249&r1=345248&r2=345249&view=diff
--- lldb/trunk/include/lldb/Expression/DWARFExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/DWARFExpression.h Thu Oct 25 02:22:26 2018
@@ -40,8 +40,10 @@ public:
   enum LocationListFormat : uint8_t {
     NonLocationList,     // Not a location list
     RegularLocationList, // Location list format used in non-split dwarf files
-    SplitDwarfLocationList, // Location list format used in split dwarf files
-    LocLists,               // Location list format used in DWARF v5 (.debug_loclists).
+    SplitDwarfLocationList, // Location list format used in pre-DWARF v5 split
+                            // dwarf files (.debug_loc.dwo)
+    LocLists,               // Location list format used in DWARF v5
+                            // (.debug_loclists/.debug_loclists.dwo).
@@ -153,7 +155,7 @@ public:
   lldb::addr_t GetLocation_DW_OP_addr(uint32_t op_addr_idx, bool &error) const;
   bool Update_DW_OP_addr(lldb::addr_t file_addr);
   void SetModule(const lldb::ModuleSP &module) { m_module_wp = module; }
   bool ContainsThreadLocalStorage() const;

Modified: lldb/trunk/source/Expression/DWARFExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=345249&r1=345248&r2=345249&view=diff
--- lldb/trunk/source/Expression/DWARFExpression.cpp (original)
+++ lldb/trunk/source/Expression/DWARFExpression.cpp Thu Oct 25 02:22:26 2018
@@ -3029,7 +3029,9 @@ bool DWARFExpression::AddressRangeForLoc
   if (!debug_loc_data.ValidOffset(*offset_ptr))
     return false;
-  switch (dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat()) {
+  DWARFExpression::LocationListFormat format =
+      dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat();
+  switch (format) {
   case NonLocationList:
     return false;
   case RegularLocationList:
@@ -3051,7 +3053,9 @@ bool DWARFExpression::AddressRangeForLoc
     case DW_LLE_startx_length: {
       uint64_t index = debug_loc_data.GetULEB128(offset_ptr);
       low_pc = ReadAddressFromDebugAddrSection(dwarf_cu, index);
-      uint32_t length = debug_loc_data.GetU32(offset_ptr);
+      uint64_t length = (format == LocLists)
+                            ? debug_loc_data.GetULEB128(offset_ptr)
+                            : debug_loc_data.GetU32(offset_ptr);
       high_pc = low_pc + length;
       return true;

More information about the lldb-commits mailing list