Skip to content

Commit 5ee8e67

Browse files
committed
[lldb/DWARF] Fix DW_AT_rnglists_base handling for dwo files
the value of DW_AT_rnglists_base of the skeleton unit is for that unit alone (e.g. used in DW_AT_ranges of the unit DIE) and should not apply to the split unit. The split unit has a hardcoded range list base value -- we should initialize range list code whenever we detect a nonempty debug_rnglists.dwo section.
1 parent 777d1f7 commit 5ee8e67

File tree

2 files changed

+161
-3
lines changed

2 files changed

+161
-3
lines changed

lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,12 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
358358
else if (gnu_addr_base)
359359
dwo_cu->SetAddrBase(*gnu_addr_base);
360360

361-
if (ranges_base)
362-
dwo_cu->SetRangesBase(*ranges_base);
363-
else if (gnu_ranges_base)
361+
if (GetVersion() <= 4 && gnu_ranges_base)
364362
dwo_cu->SetRangesBase(*gnu_ranges_base);
363+
else if (m_dwo_symbol_file->GetDWARFContext()
364+
.getOrLoadRngListsData()
365+
.GetByteSize() > 0)
366+
dwo_cu->SetRangesBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
365367

366368
for (size_t i = 0; i < m_dwo_symbol_file->DebugInfo()->GetNumUnits(); ++i) {
367369
DWARFUnit *unit = m_dwo_symbol_file->DebugInfo()->GetUnitAtIndex(i);
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# REQUIRES: x86
2+
3+
# RUN: cd %T
4+
# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s >debug_rnglists-dwo.o
5+
# RUN: %lldb debug_rnglists-dwo.o -o "image lookup -v -s lookup_rnglists" \
6+
# RUN: -o exit | FileCheck %s
7+
8+
# CHECK-LABEL: image lookup -v -s lookup_rnglists
9+
# CHECK: Function: id = {0x00000028}, name = "rnglists", range = [0x0000000000000000-0x0000000000000003)
10+
# CHECK: Blocks: id = {0x00000028}, range = [0x00000000-0x00000003)
11+
# CHECK-NEXT: id = {0x00000037}, range = [0x00000001-0x00000002)
12+
13+
.text
14+
rnglists:
15+
nop
16+
.Lblock1_begin:
17+
lookup_rnglists:
18+
nop
19+
.Lblock1_end:
20+
nop
21+
.Lrnglists_end:
22+
23+
.section .debug_abbrev,"",@progbits
24+
.byte 1 # Abbreviation Code
25+
.byte 17 # DW_TAG_compile_unit
26+
.byte 0 # DW_CHILDREN_no
27+
.byte 0x76 # DW_AT_dwo_name
28+
.byte 8 # DW_FORM_string
29+
.byte 115 # DW_AT_addr_base
30+
.byte 23 # DW_FORM_sec_offset
31+
.byte 85 # DW_AT_ranges
32+
.byte 35 # DW_FORM_rnglistx
33+
.byte 116 # DW_AT_rnglists_base
34+
.byte 23 # DW_FORM_sec_offset
35+
.byte 0 # EOM(1)
36+
.byte 0 # EOM(2)
37+
.byte 0 # EOM(3)
38+
39+
.section .debug_info,"",@progbits
40+
.Lcu_begin0:
41+
.long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
42+
.Ldebug_info_start0:
43+
.short 5 # DWARF version number
44+
.byte 4 # DWARF Unit Type
45+
.byte 8 # Address Size (in bytes)
46+
.long .debug_abbrev # Offset Into Abbrev. Section
47+
.quad 0xdeadbeefbaadf00d # DWO id
48+
.byte 1 # Abbrev [1] 0xc:0x5f DW_TAG_compile_unit
49+
.asciz "debug_rnglists-dwo.o" # DW_AT_dwo_name
50+
.long .Laddr_table_base0 # DW_AT_addr_base
51+
.byte 0 # DW_AT_ranges
52+
.long .Lskel_rnglists_table_base # DW_AT_rnglists_base
53+
.Ldebug_info_end0:
54+
55+
.section .debug_addr,"",@progbits
56+
.long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
57+
.Ldebug_addr_start0:
58+
.short 5 # DWARF version number
59+
.byte 8 # Address size
60+
.byte 0 # Segment selector size
61+
.Laddr_table_base0:
62+
.quad rnglists
63+
.quad .Lblock1_begin
64+
.Ldebug_addr_end0:
65+
66+
.section .debug_rnglists,"",@progbits
67+
# A fake rnglists contribution so that range list bases for the skeleton
68+
# and split units differ.
69+
.long .Lfake_rnglist_table_end-.Lfake_rnglist_table_start # Length
70+
.Lfake_rnglist_table_start:
71+
.short 5 # Version
72+
.byte 8 # Address size
73+
.byte 0 # Segment selector size
74+
.long 0 # Offset entry count
75+
.Lfake_rnglists_table_base:
76+
.Lfake_rnglist_table_end:
77+
78+
.long .Lskel_rnglist_table_end-.Lskel_rnglist_table_start # Length
79+
.Lskel_rnglist_table_start:
80+
.short 5 # Version
81+
.byte 8 # Address size
82+
.byte 0 # Segment selector size
83+
.long 1 # Offset entry count
84+
.Lskel_rnglists_table_base:
85+
.long .Lskel_ranges0-.Lskel_rnglists_table_base
86+
.Lskel_ranges0:
87+
.byte 7 # DW_RLE_start_length
88+
.quad rnglists
89+
.uleb128 .Lrnglists_end-rnglists
90+
.byte 0 # DW_RLE_end_of_list
91+
.Lskel_rnglist_table_end:
92+
93+
.section .debug_abbrev.dwo,"e",@progbits
94+
.byte 1 # Abbreviation Code
95+
.byte 17 # DW_TAG_compile_unit
96+
.byte 1 # DW_CHILDREN_yes
97+
.byte 37 # DW_AT_producer
98+
.byte 8 # DW_FORM_string
99+
.byte 0 # EOM(1)
100+
.byte 0 # EOM(2)
101+
.byte 2 # Abbreviation Code
102+
.byte 46 # DW_TAG_subprogram
103+
.byte 1 # DW_CHILDREN_yes
104+
.byte 17 # DW_AT_low_pc
105+
.byte 27 # DW_FORM_addrx
106+
.byte 18 # DW_AT_high_pc
107+
.byte 6 # DW_FORM_data4
108+
.byte 3 # DW_AT_name
109+
.byte 8 # DW_FORM_string
110+
.byte 0 # EOM(1)
111+
.byte 0 # EOM(2)
112+
.byte 5 # Abbreviation Code
113+
.byte 11 # DW_TAG_lexical_block
114+
.byte 0 # DW_CHILDREN_no
115+
.byte 85 # DW_AT_ranges
116+
.byte 35 # DW_FORM_rnglistx
117+
.byte 0 # EOM(1)
118+
.byte 0 # EOM(2)
119+
.byte 0 # EOM(3)
120+
121+
.section .debug_info.dwo,"e",@progbits
122+
.Lcu_begin1:
123+
.long .Ldebug_info_end1-.Ldebug_info_start1 # Length of Unit
124+
.Ldebug_info_start1:
125+
.short 5 # DWARF version number
126+
.byte 5 # DWARF Unit Type
127+
.byte 8 # Address Size (in bytes)
128+
.long .debug_abbrev # Offset Into Abbrev. Section
129+
.quad 0xdeadbeefbaadf00d # DWO id
130+
.byte 1 # Abbrev [1] 0xc:0x5f DW_TAG_compile_unit
131+
.asciz "Hand-written DWARF" # DW_AT_producer
132+
.byte 2 # Abbrev [2] 0x2b:0x37 DW_TAG_subprogram
133+
.byte 0 # DW_AT_low_pc
134+
.long .Lrnglists_end-rnglists # DW_AT_high_pc
135+
.asciz "rnglists" # DW_AT_name
136+
.byte 5 # Abbrev [5] 0x52:0xf DW_TAG_lexical_block
137+
.byte 0 # DW_AT_ranges
138+
.byte 0 # End Of Children Mark
139+
.byte 0 # End Of Children Mark
140+
.Ldebug_info_end1:
141+
142+
.section .debug_rnglists.dwo,"e",@progbits
143+
.long .Ldwo_rnglist_table_end-.Ldwo_rnglist_table_start # Length
144+
.Ldwo_rnglist_table_start:
145+
.short 5 # Version
146+
.byte 8 # Address size
147+
.byte 0 # Segment selector size
148+
.long 1 # Offset entry count
149+
.Ldwo_rnglists_table_base:
150+
.long .Ldwo_ranges-.Ldwo_rnglists_table_base
151+
.Ldwo_ranges:
152+
.byte 3 # DW_RLE_startx_length
153+
.uleb128 1
154+
.uleb128 .Lblock1_end-.Lblock1_begin
155+
.byte 0 # DW_RLE_end_of_list
156+
.Ldwo_rnglist_table_end:

0 commit comments

Comments
 (0)