[Lldb-commits] [lldb] 512c03b - [DebugInfo] Add a DWARFDataExtractor constructor that takes ArrayRef<uint8_t>
Fangrui Song via lldb-commits
lldb-commits at lists.llvm.org
Sun Feb 9 17:48:37 PST 2020
Author: Fangrui Song
Date: 2020-02-09T17:45:32-08:00
New Revision: 512c03bac449d8d40c5fc8d0ff1719f887c7fdc3
URL: https://github.com/llvm/llvm-project/commit/512c03bac449d8d40c5fc8d0ff1719f887c7fdc3
DIFF: https://github.com/llvm/llvm-project/commit/512c03bac449d8d40c5fc8d0ff1719f887c7fdc3.diff
LOG: [DebugInfo] Add a DWARFDataExtractor constructor that takes ArrayRef<uint8_t>
Similar to D67797 (DataExtractor).
Added:
Modified:
lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h
Removed:
################################################################################
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
index 4eea18e0f237..cf483286a66d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
@@ -23,8 +23,7 @@ DWARFDataExtractor::GetDWARFOffset(lldb::offset_t *offset_ptr) const {
llvm::DWARFDataExtractor DWARFDataExtractor::GetAsLLVM() const {
return llvm::DWARFDataExtractor(
- llvm::StringRef(reinterpret_cast<const char *>(GetDataStart()),
- GetByteSize()),
+ llvm::makeArrayRef(GetDataStart(), GetByteSize()),
GetByteOrder() == lldb::eByteOrderLittle, GetAddressByteSize());
}
} // namespace lldb_private
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 8944078d7fff..e4a89160969e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -468,8 +468,8 @@ void DWARFUnit::SetLoclistsBase(dw_addr_t loclists_base) {
std::unique_ptr<llvm::DWARFLocationTable>
DWARFUnit::GetLocationTable(const DataExtractor &data) const {
llvm::DWARFDataExtractor llvm_data(
- toStringRef(data.GetData()),
- data.GetByteOrder() == lldb::eByteOrderLittle, data.GetAddressByteSize());
+ data.GetData(), data.GetByteOrder() == lldb::eByteOrderLittle,
+ data.GetAddressByteSize());
if (m_is_dwo || GetVersion() >= 5)
return std::make_unique<llvm::DWARFDebugLoclists>(llvm_data, GetVersion());
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
index 6f7ddb2ef421..c4ba982ce808 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h
@@ -32,6 +32,11 @@ class DWARFDataExtractor : public DataExtractor {
/// Constructor for cases when there are no relocations.
DWARFDataExtractor(StringRef Data, bool IsLittleEndian, uint8_t AddressSize)
: DataExtractor(Data, IsLittleEndian, AddressSize) {}
+ DWARFDataExtractor(ArrayRef<uint8_t> Data, bool IsLittleEndian,
+ uint8_t AddressSize)
+ : DataExtractor(
+ StringRef(reinterpret_cast<const char *>(Data.data()), Data.size()),
+ IsLittleEndian, AddressSize) {}
/// Extracts a value and applies a relocation to the result if
/// one exists for the given offset.
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
index 131017e749d6..8f047bb872e5 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
@@ -109,7 +109,7 @@ DWARFLocationInterpreter::Interpret(const DWARFLocationEntry &E) {
static void dumpExpression(raw_ostream &OS, ArrayRef<uint8_t> Data,
bool IsLittleEndian, unsigned AddressSize,
const MCRegisterInfo *MRI, DWARFUnit *U) {
- DWARFDataExtractor Extractor(toStringRef(Data), IsLittleEndian, AddressSize);
+ DWARFDataExtractor Extractor(Data, IsLittleEndian, AddressSize);
DWARFExpression(Extractor, AddressSize).print(OS, MRI, U);
}
diff --git a/llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h b/llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h
index 0a365d4fe72a..3d0b75f93771 100644
--- a/llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h
+++ b/llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h
@@ -186,12 +186,9 @@ void PrinterContext<ELFT>::printEHFrame(
if (Error E = Result.takeError())
reportError(std::move(E), ObjF->getFileName());
- auto Contents = Result.get();
- DWARFDataExtractor DE(
- StringRef(reinterpret_cast<const char *>(Contents.data()),
- Contents.size()),
- ELFT::TargetEndianness == support::endianness::little,
- ELFT::Is64Bits ? 8 : 4);
+ DWARFDataExtractor DE(*Result,
+ ELFT::TargetEndianness == support::endianness::little,
+ ELFT::Is64Bits ? 8 : 4);
DWARFDebugFrame EHFrame(Triple::ArchType(ObjF->getArch()), /*IsEH=*/true,
/*EHFrameAddress=*/Address);
EHFrame.parse(DE);
More information about the lldb-commits
mailing list