[Lldb-commits] [lldb] r309554 - Add support for base address entries in the .debug_ranges section

Tamas Berghammer via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 31 03:26:19 PDT 2017


Author: tberghammer
Date: Mon Jul 31 03:26:19 2017
New Revision: 309554

URL: http://llvm.org/viewvc/llvm-project?rev=309554&view=rev
Log:
Add support for base address entries in the .debug_ranges section

Summary:
Clang recently started to emit base address entries into the
.debug_ranges section to reduce the number of relocations needed. Lets
make sure LLDB can read them.

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

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp?rev=309554&r1=309553&r2=309554&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp Mon Jul 31 03:26:19 2017
@@ -15,6 +15,18 @@
 using namespace lldb_private;
 using namespace std;
 
+static dw_addr_t GetBaseAddressMarker(uint32_t addr_size) {
+  switch(addr_size) {
+    case 2:
+      return 0xffff;
+    case 4:
+      return 0xffffffff;
+    case 8:
+      return 0xffffffffffffffff;
+  }
+  llvm_unreachable("GetBaseAddressMarker unsupported address size.");
+}
+
 DWARFDebugRanges::DWARFDebugRanges() : m_range_map() {}
 
 DWARFDebugRanges::~DWARFDebugRanges() {}
@@ -39,38 +51,27 @@ bool DWARFDebugRanges::Extract(SymbolFil
   const DWARFDataExtractor &debug_ranges_data =
       dwarf2Data->get_debug_ranges_data();
   uint32_t addr_size = debug_ranges_data.GetAddressByteSize();
+  dw_addr_t base_addr = 0;
+  dw_addr_t base_addr_marker = GetBaseAddressMarker(addr_size);
 
   while (
       debug_ranges_data.ValidOffsetForDataOfSize(*offset_ptr, 2 * addr_size)) {
     dw_addr_t begin = debug_ranges_data.GetMaxU64(offset_ptr, addr_size);
     dw_addr_t end = debug_ranges_data.GetMaxU64(offset_ptr, addr_size);
+
     if (!begin && !end) {
       // End of range list
       break;
     }
-    // Extend 4 byte addresses that consists of 32 bits of 1's to be 64 bits
-    // of ones
-    switch (addr_size) {
-    case 2:
-      if (begin == 0xFFFFull)
-        begin = LLDB_INVALID_ADDRESS;
-      break;
-
-    case 4:
-      if (begin == 0xFFFFFFFFull)
-        begin = LLDB_INVALID_ADDRESS;
-      break;
-
-    case 8:
-      break;
 
-    default:
-      llvm_unreachable("DWARFRangeList::Extract() unsupported address size.");
+    if (begin == base_addr_marker) {
+      base_addr = end;
+      continue;
     }
 
     // Filter out empty ranges
     if (begin < end)
-      range_list.Append(DWARFRangeList::Entry(begin, end - begin));
+      range_list.Append(DWARFRangeList::Entry(begin + base_addr, end - begin));
   }
 
   // Make sure we consumed at least something




More information about the lldb-commits mailing list