@@ -66,23 +66,24 @@ DWARFLocationInterpreter::Interpret(const DWARFLocationEntry &E) {
66
66
LowPC->SectionIndex },
67
67
E.Loc };
68
68
}
69
- case dwarf::DW_LLE_offset_pair:
69
+ case dwarf::DW_LLE_offset_pair: {
70
70
if (!Base) {
71
71
return createStringError (
72
72
inconvertibleErrorCode (),
73
73
" Unable to resolve DW_LLE_offset_pair: base address unknown" );
74
74
}
75
- return DWARFLocationExpression{DWARFAddressRange{Base->Address + E.Value0 ,
76
- Base->Address + E.Value1 ,
77
- Base->SectionIndex },
78
- E.Loc };
75
+ DWARFAddressRange Range{Base->Address + E.Value0 , Base->Address + E.Value1 ,
76
+ Base->SectionIndex };
77
+ if (Range.SectionIndex == SectionedAddress::UndefSection)
78
+ Range.SectionIndex = E.SectionIndex ;
79
+ return DWARFLocationExpression{Range, E.Loc };
80
+ }
79
81
case dwarf::DW_LLE_base_address:
80
- Base = SectionedAddress{E.Value0 , SectionedAddress::UndefSection };
82
+ Base = SectionedAddress{E.Value0 , E. SectionIndex };
81
83
return None;
82
84
case dwarf::DW_LLE_start_length:
83
85
return DWARFLocationExpression{
84
- DWARFAddressRange{E.Value0 , E.Value0 + E.Value1 ,
85
- SectionedAddress::UndefSection},
86
+ DWARFAddressRange{E.Value0 , E.Value0 + E.Value1 , E.SectionIndex },
86
87
E.Loc };
87
88
default :
88
89
llvm_unreachable (" unreachable locations list kind" );
@@ -104,7 +105,8 @@ static void dumpExpression(raw_ostream &OS, ArrayRef<uint8_t> Data,
104
105
bool DWARFLocationTable::dumpLocationList (uint64_t *Offset, raw_ostream &OS,
105
106
Optional<SectionedAddress> BaseAddr,
106
107
const MCRegisterInfo *MRI,
107
- DWARFUnit *U, DIDumpOptions DumpOpts,
108
+ const DWARFObject &Obj, DWARFUnit *U,
109
+ DIDumpOptions DumpOpts,
108
110
unsigned Indent) const {
109
111
DWARFLocationInterpreter Interp (
110
112
BaseAddr, [U](uint32_t Index) -> Optional<SectionedAddress> {
@@ -116,7 +118,7 @@ bool DWARFLocationTable::dumpLocationList(uint64_t *Offset, raw_ostream &OS,
116
118
Error E = visitLocationList (Offset, [&](const DWARFLocationEntry &E) {
117
119
Expected<Optional<DWARFLocationExpression>> Loc = Interp.Interpret (E);
118
120
if (!Loc || DumpOpts.DisplayRawContents )
119
- dumpRawEntry (E, OS, Indent);
121
+ dumpRawEntry (E, OS, Indent, DumpOpts, Obj );
120
122
if (Loc && *Loc) {
121
123
OS << " \n " ;
122
124
OS.indent (Indent);
@@ -125,10 +127,7 @@ bool DWARFLocationTable::dumpLocationList(uint64_t *Offset, raw_ostream &OS,
125
127
126
128
DIDumpOptions RangeDumpOpts (DumpOpts);
127
129
RangeDumpOpts.DisplayRawContents = false ;
128
- const DWARFObject *Obj = nullptr ;
129
- if (U)
130
- Obj = &U->getContext ().getDWARFObj ();
131
- Loc.get ()->Range ->dump (OS, Data.getAddressSize (), RangeDumpOpts, Obj);
130
+ Loc.get ()->Range ->dump (OS, Data.getAddressSize (), RangeDumpOpts, &Obj);
132
131
}
133
132
if (!Loc)
134
133
consumeError (Loc.takeError ());
@@ -167,12 +166,12 @@ Error DWARFLocationTable::visitAbsoluteLocationList(
167
166
}
168
167
169
168
void DWARFDebugLoc::dump (raw_ostream &OS, const MCRegisterInfo *MRI,
170
- DIDumpOptions DumpOpts,
169
+ const DWARFObject &Obj, DIDumpOptions DumpOpts,
171
170
Optional<uint64_t > DumpOffset) const {
172
171
auto BaseAddr = None;
173
172
unsigned Indent = 12 ;
174
173
if (DumpOffset) {
175
- dumpLocationList (&*DumpOffset, OS, BaseAddr, MRI, nullptr , DumpOpts,
174
+ dumpLocationList (&*DumpOffset, OS, BaseAddr, MRI, Obj, nullptr , DumpOpts,
176
175
Indent);
177
176
} else {
178
177
uint64_t Offset = 0 ;
@@ -182,7 +181,7 @@ void DWARFDebugLoc::dump(raw_ostream &OS, const MCRegisterInfo *MRI,
182
181
OS << Separator;
183
182
Separator = " \n " ;
184
183
185
- CanContinue = dumpLocationList (&Offset, OS, BaseAddr, MRI, nullptr ,
184
+ CanContinue = dumpLocationList (&Offset, OS, BaseAddr, MRI, Obj, nullptr ,
186
185
DumpOpts, Indent);
187
186
OS << ' \n ' ;
188
187
}
@@ -194,8 +193,9 @@ Error DWARFDebugLoc::visitLocationList(
194
193
function_ref<bool (const DWARFLocationEntry &)> Callback) const {
195
194
DataExtractor::Cursor C (*Offset);
196
195
while (true ) {
196
+ uint64_t SectionIndex;
197
197
uint64_t Value0 = Data.getRelocatedAddress (C);
198
- uint64_t Value1 = Data.getRelocatedAddress (C);
198
+ uint64_t Value1 = Data.getRelocatedAddress (C, &SectionIndex );
199
199
200
200
DWARFLocationEntry E;
201
201
@@ -208,10 +208,12 @@ Error DWARFDebugLoc::visitLocationList(
208
208
} else if (Value0 == (Data.getAddressSize () == 4 ? -1U : -1ULL )) {
209
209
E.Kind = dwarf::DW_LLE_base_address;
210
210
E.Value0 = Value1;
211
+ E.SectionIndex = SectionIndex;
211
212
} else {
212
213
E.Kind = dwarf::DW_LLE_offset_pair;
213
214
E.Value0 = Value0;
214
215
E.Value1 = Value1;
216
+ E.SectionIndex = SectionIndex;
215
217
unsigned Bytes = Data.getU16 (C);
216
218
// A single location description describing the location of the object...
217
219
Data.getU8 (C, E.Loc , Bytes);
@@ -227,7 +229,9 @@ Error DWARFDebugLoc::visitLocationList(
227
229
}
228
230
229
231
void DWARFDebugLoc::dumpRawEntry (const DWARFLocationEntry &Entry,
230
- raw_ostream &OS, unsigned Indent) const {
232
+ raw_ostream &OS, unsigned Indent,
233
+ DIDumpOptions DumpOpts,
234
+ const DWARFObject &Obj) const {
231
235
uint64_t Value0, Value1;
232
236
switch (Entry.Kind ) {
233
237
case dwarf::DW_LLE_base_address:
@@ -248,6 +252,7 @@ void DWARFDebugLoc::dumpRawEntry(const DWARFLocationEntry &Entry,
248
252
OS.indent (Indent);
249
253
OS << ' (' << format_hex (Value0, 2 + Data.getAddressSize () * 2 ) << " , "
250
254
<< format_hex (Value1, 2 + Data.getAddressSize () * 2 ) << ' )' ;
255
+ DWARFFormValue::dumpAddressSection (Obj, OS, DumpOpts, Entry.SectionIndex );
251
256
}
252
257
253
258
Error DWARFDebugLoclists::visitLocationList (
@@ -276,12 +281,13 @@ Error DWARFDebugLoclists::visitLocationList(
276
281
case dwarf::DW_LLE_offset_pair:
277
282
E.Value0 = Data.getULEB128 (C);
278
283
E.Value1 = Data.getULEB128 (C);
284
+ E.SectionIndex = SectionedAddress::UndefSection;
279
285
break ;
280
286
case dwarf::DW_LLE_base_address:
281
- E.Value0 = Data.getRelocatedAddress (C);
287
+ E.Value0 = Data.getRelocatedAddress (C, &E. SectionIndex );
282
288
break ;
283
289
case dwarf::DW_LLE_start_length:
284
- E.Value0 = Data.getRelocatedAddress (C);
290
+ E.Value0 = Data.getRelocatedAddress (C, &E. SectionIndex );
285
291
E.Value1 = Data.getULEB128 (C);
286
292
break ;
287
293
case dwarf::DW_LLE_startx_endx:
@@ -310,7 +316,9 @@ Error DWARFDebugLoclists::visitLocationList(
310
316
}
311
317
312
318
void DWARFDebugLoclists::dumpRawEntry (const DWARFLocationEntry &Entry,
313
- raw_ostream &OS, unsigned Indent) const {
319
+ raw_ostream &OS, unsigned Indent,
320
+ DIDumpOptions DumpOpts,
321
+ const DWARFObject &Obj) const {
314
322
size_t MaxEncodingStringLength = 0 ;
315
323
#define HANDLE_DW_LLE (ID, NAME ) \
316
324
MaxEncodingStringLength = std::max (MaxEncodingStringLength, \
@@ -339,10 +347,19 @@ void DWARFDebugLoclists::dumpRawEntry(const DWARFLocationEntry &Entry,
339
347
break ;
340
348
}
341
349
OS << ' )' ;
350
+ switch (Entry.Kind ) {
351
+ case dwarf::DW_LLE_start_length:
352
+ case dwarf::DW_LLE_base_address:
353
+ DWARFFormValue::dumpAddressSection (Obj, OS, DumpOpts, Entry.SectionIndex );
354
+ break ;
355
+ default :
356
+ break ;
357
+ }
342
358
}
343
359
344
360
void DWARFDebugLoclists::dumpRange (uint64_t StartOffset, uint64_t Size,
345
361
raw_ostream &OS, const MCRegisterInfo *MRI,
362
+ const DWARFObject &Obj,
346
363
DIDumpOptions DumpOpts) {
347
364
if (!Data.isValidOffsetForDataOfSize (StartOffset, Size)) {
348
365
OS << " Invalid dump range\n " ;
@@ -355,8 +372,8 @@ void DWARFDebugLoclists::dumpRange(uint64_t StartOffset, uint64_t Size,
355
372
OS << Separator;
356
373
Separator = " \n " ;
357
374
358
- CanContinue = dumpLocationList (&Offset, OS, /* BaseAddr=*/ None, MRI, nullptr ,
359
- DumpOpts, /* Indent=*/ 12 );
375
+ CanContinue = dumpLocationList (&Offset, OS, /* BaseAddr=*/ None, MRI, Obj ,
376
+ nullptr , DumpOpts, /* Indent=*/ 12 );
360
377
OS << ' \n ' ;
361
378
}
362
379
}
0 commit comments