#ifndef LLVM_DEBUGINFO_DWARF_DWARFDATAEXTRACTOR_H
#define LLVM_DEBUGINFO_DWARF_DWARFDATAEXTRACTOR_H
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/DebugInfo/DWARF/DWARFSection.h"
#include "llvm/Support/DataExtractor.h"
namespace llvm {
class DWARFObject;
class DWARFDataExtractor : public DataExtractor {
const DWARFObject *Obj = nullptr;
const DWARFSection *Section = nullptr;
public:
DWARFDataExtractor(const DWARFObject &Obj, const DWARFSection &Section,
bool IsLittleEndian, uint8_t AddressSize)
: DataExtractor(Section.Data, IsLittleEndian, AddressSize), Obj(&Obj),
Section(&Section) {}
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) {}
DWARFDataExtractor(const DWARFDataExtractor &Other, size_t Length)
: DataExtractor(Other.getData().substr(0, Length), Other.isLittleEndian(),
Other.getAddressSize()),
Obj(Other.Obj), Section(Other.Section) {}
std::pair<uint64_t, dwarf::DwarfFormat>
getInitialLength(uint64_t *Off, Error *Err = nullptr) const;
std::pair<uint64_t, dwarf::DwarfFormat> getInitialLength(Cursor &C) const {
return getInitialLength(&getOffset(C), &getError(C));
}
uint64_t getRelocatedValue(uint32_t Size, uint64_t *Off,
uint64_t *SectionIndex = nullptr,
Error *Err = nullptr) const;
uint64_t getRelocatedValue(Cursor &C, uint32_t Size,
uint64_t *SectionIndex = nullptr) const {
return getRelocatedValue(Size, &getOffset(C), SectionIndex, &getError(C));
}
uint64_t getRelocatedAddress(uint64_t *Off, uint64_t *SecIx = nullptr) const {
return getRelocatedValue(getAddressSize(), Off, SecIx);
}
uint64_t getRelocatedAddress(Cursor &C, uint64_t *SecIx = nullptr) const {
return getRelocatedValue(getAddressSize(), &getOffset(C), SecIx,
&getError(C));
}
Optional<uint64_t> getEncodedPointer(uint64_t *Offset, uint8_t Encoding,
uint64_t AbsPosOffset = 0) const;
};
}
#endif