Skip to content

Commit 512c03b

Browse files
committed
[DebugInfo] Add a DWARFDataExtractor constructor that takes ArrayRef<uint8_t>
Similar to D67797 (DataExtractor).
1 parent 312a9d1 commit 512c03b

File tree

5 files changed

+12
-11
lines changed

5 files changed

+12
-11
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ DWARFDataExtractor::GetDWARFOffset(lldb::offset_t *offset_ptr) const {
2323

2424
llvm::DWARFDataExtractor DWARFDataExtractor::GetAsLLVM() const {
2525
return llvm::DWARFDataExtractor(
26-
llvm::StringRef(reinterpret_cast<const char *>(GetDataStart()),
27-
GetByteSize()),
26+
llvm::makeArrayRef(GetDataStart(), GetByteSize()),
2827
GetByteOrder() == lldb::eByteOrderLittle, GetAddressByteSize());
2928
}
3029
} // namespace lldb_private

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ void DWARFUnit::SetLoclistsBase(dw_addr_t loclists_base) {
468468
std::unique_ptr<llvm::DWARFLocationTable>
469469
DWARFUnit::GetLocationTable(const DataExtractor &data) const {
470470
llvm::DWARFDataExtractor llvm_data(
471-
toStringRef(data.GetData()),
472-
data.GetByteOrder() == lldb::eByteOrderLittle, data.GetAddressByteSize());
471+
data.GetData(), data.GetByteOrder() == lldb::eByteOrderLittle,
472+
data.GetAddressByteSize());
473473

474474
if (m_is_dwo || GetVersion() >= 5)
475475
return std::make_unique<llvm::DWARFDebugLoclists>(llvm_data, GetVersion());

llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class DWARFDataExtractor : public DataExtractor {
3232
/// Constructor for cases when there are no relocations.
3333
DWARFDataExtractor(StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
3434
: DataExtractor(Data, IsLittleEndian, AddressSize) {}
35+
DWARFDataExtractor(ArrayRef<uint8_t> Data, bool IsLittleEndian,
36+
uint8_t AddressSize)
37+
: DataExtractor(
38+
StringRef(reinterpret_cast<const char *>(Data.data()), Data.size()),
39+
IsLittleEndian, AddressSize) {}
3540

3641
/// Extracts a value and applies a relocation to the result if
3742
/// one exists for the given offset.

llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ DWARFLocationInterpreter::Interpret(const DWARFLocationEntry &E) {
109109
static void dumpExpression(raw_ostream &OS, ArrayRef<uint8_t> Data,
110110
bool IsLittleEndian, unsigned AddressSize,
111111
const MCRegisterInfo *MRI, DWARFUnit *U) {
112-
DWARFDataExtractor Extractor(toStringRef(Data), IsLittleEndian, AddressSize);
112+
DWARFDataExtractor Extractor(Data, IsLittleEndian, AddressSize);
113113
DWARFExpression(Extractor, AddressSize).print(OS, MRI, U);
114114
}
115115

llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,9 @@ void PrinterContext<ELFT>::printEHFrame(
186186
if (Error E = Result.takeError())
187187
reportError(std::move(E), ObjF->getFileName());
188188

189-
auto Contents = Result.get();
190-
DWARFDataExtractor DE(
191-
StringRef(reinterpret_cast<const char *>(Contents.data()),
192-
Contents.size()),
193-
ELFT::TargetEndianness == support::endianness::little,
194-
ELFT::Is64Bits ? 8 : 4);
189+
DWARFDataExtractor DE(*Result,
190+
ELFT::TargetEndianness == support::endianness::little,
191+
ELFT::Is64Bits ? 8 : 4);
195192
DWARFDebugFrame EHFrame(Triple::ArchType(ObjF->getArch()), /*IsEH=*/true,
196193
/*EHFrameAddress=*/Address);
197194
EHFrame.parse(DE);

0 commit comments

Comments
 (0)