[llvm] a93b77b - [DebugInfo] Fix reading location tables headers of v5 units in DWP.

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 6 00:04:44 PDT 2020


Author: Igor Kudrin
Date: 2020-04-06T13:28:06+07:00
New Revision: a93b77b97f105db911316d896056dc8718a850e3

URL: https://github.com/llvm/llvm-project/commit/a93b77b97f105db911316d896056dc8718a850e3
DIFF: https://github.com/llvm/llvm-project/commit/a93b77b97f105db911316d896056dc8718a850e3.diff

LOG: [DebugInfo] Fix reading location tables headers of v5 units in DWP.

This fixes the reading of location lists headers for compilation units
in package files by adjusting the reading offset according to the
corresponding record in the unit index. This is required for
DW_FORM_loclistx to work.

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

Added: 
    

Modified: 
    llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
    llvm/test/DebugInfo/X86/dwp-v5-loclists.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 43fc8f787cc5..356bed5e4403 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -538,6 +538,9 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
                                  " list table with base = 0x%" PRIx64 "\n",
                                  Offset);
       Offset -= HeaderSize;
+      if (auto *IndexEntry = Header.getIndexEntry())
+        if (const auto *Contrib = IndexEntry->getContribution(DW_SECT_LOCLISTS))
+          Offset += Contrib->Offset;
       if (Error E = LoclistTableHeader->extract(Data, &Offset))
         return createStringError(errc::invalid_argument,
                                  "parsing a loclist table: " +

diff  --git a/llvm/test/DebugInfo/X86/dwp-v5-loclists.s b/llvm/test/DebugInfo/X86/dwp-v5-loclists.s
index 27b9a3bc87f7..9bc66397fe30 100644
--- a/llvm/test/DebugInfo/X86/dwp-v5-loclists.s
+++ b/llvm/test/DebugInfo/X86/dwp-v5-loclists.s
@@ -12,12 +12,19 @@
 # CHECK-NEXT:   DW_AT_name ("a")
 # CHECK-NEXT:   DW_AT_location (0x{{[0-9a-f]+}}:
 # CHECK-NEXT:     DW_LLE_startx_length (0x0000000000000001, 0x0000000000000010): DW_OP_reg5 RDI)
+# CHECK:      DW_TAG_variable
+# CHECK-NEXT:   DW_AT_name ("b")
+# CHECK-NEXT:   DW_AT_location (indexed (0x1) loclist = 0x{{[0-9a-f]+}}:
+# CHECK-NEXT:     DW_LLE_startx_length (0x0000000000000005, 0x0000000000000020): DW_OP_regx RDI)
 
 # CHECK:      .debug_loclists.dwo contents:
 # CHECK:      locations list header:
 # CHECK:      locations list header:
+# CHECK:      offsets:
 # CHECK:      0x{{[0-9a-f]+}}:
 # CHECK-NEXT:   DW_LLE_startx_length (0x0000000000000001, 0x0000000000000010): DW_OP_reg5 RDI
+# CHECK:      0x{{[0-9a-f]+}}:
+# CHECK-NEXT:   DW_LLE_startx_length (0x0000000000000005, 0x0000000000000020): DW_OP_regx RDI
 
 .section .debug_abbrev.dwo, "e", @progbits
 .LAbbrevBegin:
@@ -35,6 +42,15 @@
     .uleb128 23                         # DW_FORM_sec_offset
     .byte 0                             # EOM(1)
     .byte 0                             # EOM(2)
+    .uleb128 3                          # Abbreviation Code
+    .uleb128 52                         # DW_TAG_variable
+    .byte 0                             # DW_CHILDREN_no
+    .uleb128 3                          # DW_AT_name
+    .uleb128 8                          # DW_FORM_string
+    .uleb128 2                          # DW_AT_location
+    .uleb128 34                         # DW_FORM_loclistx
+    .byte 0                             # EOM(1)
+    .byte 0                             # EOM(2)
     .byte 0                             # EOM(3)
 .LAbbrevEnd:
 
@@ -50,7 +66,10 @@
     .uleb128 1                          # Abbrev [1] DW_TAG_compile_unit
     .uleb128 2                          # Abbrev [2] DW_TAG_variable
     .asciz "a"                          # DW_AT_name
-    .long .LLL0-.LLLBegin               # DW_AT_location
+    .long .LLL0-.LLLBegin               # DW_AT_location (DW_FORM_sec_offset)
+    .uleb128 3                          # Abbrev [3] DW_TAG_variable
+    .asciz "b"                          # DW_AT_name
+    .uleb128 1                          # DW_AT_location (DW_FORM_loclistx)
     .byte 0                             # End Of Children Mark
 .LCUEnd:
 
@@ -72,7 +91,10 @@
     .short 5                            # Version
     .byte 8                             # Address size
     .byte 0                             # Segment selector size
-    .long 0                             # Offset entry count
+    .long 2                             # Offset entry count
+.LLLBase:
+    .long .LLL0-.LLLBase
+    .long .LLL1-.LLLBase
 .LLL0:
     .byte 3                             # DW_LLE_startx_length
     .uleb128 1                          # Index
@@ -80,6 +102,14 @@
     .uleb128 1                          # Loc expr size
     .byte 85                            # DW_OP_reg5
     .byte 0                             # DW_LLE_end_of_list
+.LLL1:
+    .byte 3                             # DW_LLE_startx_length
+    .uleb128 5                          # Index
+    .uleb128 0x20                       # Length
+    .uleb128 2                          # Loc expr size
+    .byte 144                           # DW_OP_regx
+    .uleb128 5                          # RDI
+    .byte 0                             # DW_LLE_end_of_list
 .LLLEnd:
 
     .section .debug_cu_index, "", @progbits


        


More information about the llvm-commits mailing list