mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-07 13:09:52 +00:00
[DWARF parser] DWARFDebugFrame: Make FrameEntry struct smaller.
FrameEntry doesn't need to hold a reference to the section it is located in. Instead, pass DataExtractor as an argument of parsing function. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207461 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4fc8298f17
commit
07c3167c2b
@ -26,8 +26,8 @@ using namespace dwarf;
|
|||||||
class llvm::FrameEntry {
|
class llvm::FrameEntry {
|
||||||
public:
|
public:
|
||||||
enum FrameKind {FK_CIE, FK_FDE};
|
enum FrameKind {FK_CIE, FK_FDE};
|
||||||
FrameEntry(FrameKind K, DataExtractor D, uint64_t Offset, uint64_t Length)
|
FrameEntry(FrameKind K, uint64_t Offset, uint64_t Length)
|
||||||
: Kind(K), Data(D), Offset(Offset), Length(Length) {}
|
: Kind(K), Offset(Offset), Length(Length) {}
|
||||||
|
|
||||||
virtual ~FrameEntry() {
|
virtual ~FrameEntry() {
|
||||||
}
|
}
|
||||||
@ -35,11 +35,12 @@ public:
|
|||||||
FrameKind getKind() const { return Kind; }
|
FrameKind getKind() const { return Kind; }
|
||||||
virtual uint64_t getOffset() const { return Offset; }
|
virtual uint64_t getOffset() const { return Offset; }
|
||||||
|
|
||||||
/// \brief Parse and store a sequence of CFI instructions from our data
|
/// \brief Parse and store a sequence of CFI instructions from Data,
|
||||||
/// stream, starting at *Offset and ending at EndOffset. If everything
|
/// starting at *Offset and ending at EndOffset. If everything
|
||||||
/// goes well, *Offset should be equal to EndOffset when this method
|
/// goes well, *Offset should be equal to EndOffset when this method
|
||||||
/// returns. Otherwise, an error occurred.
|
/// returns. Otherwise, an error occurred.
|
||||||
virtual void parseInstructions(uint32_t *Offset, uint32_t EndOffset);
|
virtual void parseInstructions(DataExtractor Data, uint32_t *Offset,
|
||||||
|
uint32_t EndOffset);
|
||||||
|
|
||||||
/// \brief Dump the entry header to the given output stream.
|
/// \brief Dump the entry header to the given output stream.
|
||||||
virtual void dumpHeader(raw_ostream &OS) const = 0;
|
virtual void dumpHeader(raw_ostream &OS) const = 0;
|
||||||
@ -50,10 +51,6 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
const FrameKind Kind;
|
const FrameKind Kind;
|
||||||
|
|
||||||
/// \brief The data stream holding the section from which the entry was
|
|
||||||
/// parsed.
|
|
||||||
DataExtractor Data;
|
|
||||||
|
|
||||||
/// \brief Offset of this entry in the section.
|
/// \brief Offset of this entry in the section.
|
||||||
uint64_t Offset;
|
uint64_t Offset;
|
||||||
|
|
||||||
@ -97,8 +94,8 @@ protected:
|
|||||||
const uint8_t DWARF_CFI_PRIMARY_OPCODE_MASK = 0xc0;
|
const uint8_t DWARF_CFI_PRIMARY_OPCODE_MASK = 0xc0;
|
||||||
const uint8_t DWARF_CFI_PRIMARY_OPERAND_MASK = 0x3f;
|
const uint8_t DWARF_CFI_PRIMARY_OPERAND_MASK = 0x3f;
|
||||||
|
|
||||||
|
void FrameEntry::parseInstructions(DataExtractor Data, uint32_t *Offset,
|
||||||
void FrameEntry::parseInstructions(uint32_t *Offset, uint32_t EndOffset) {
|
uint32_t EndOffset) {
|
||||||
while (*Offset < EndOffset) {
|
while (*Offset < EndOffset) {
|
||||||
uint8_t Opcode = Data.getU8(Offset);
|
uint8_t Opcode = Data.getU8(Offset);
|
||||||
// Some instructions have a primary opcode encoded in the top bits.
|
// Some instructions have a primary opcode encoded in the top bits.
|
||||||
@ -201,13 +198,13 @@ class CIE : public FrameEntry {
|
|||||||
public:
|
public:
|
||||||
// CIEs (and FDEs) are simply container classes, so the only sensible way to
|
// CIEs (and FDEs) are simply container classes, so the only sensible way to
|
||||||
// create them is by providing the full parsed contents in the constructor.
|
// create them is by providing the full parsed contents in the constructor.
|
||||||
CIE(DataExtractor D, uint64_t Offset, uint64_t Length, uint8_t Version,
|
CIE(uint64_t Offset, uint64_t Length, uint8_t Version,
|
||||||
SmallString<8> Augmentation, uint64_t CodeAlignmentFactor,
|
SmallString<8> Augmentation, uint64_t CodeAlignmentFactor,
|
||||||
int64_t DataAlignmentFactor, uint64_t ReturnAddressRegister)
|
int64_t DataAlignmentFactor, uint64_t ReturnAddressRegister)
|
||||||
: FrameEntry(FK_CIE, D, Offset, Length), Version(Version),
|
: FrameEntry(FK_CIE, Offset, Length), Version(Version),
|
||||||
Augmentation(Augmentation), CodeAlignmentFactor(CodeAlignmentFactor),
|
Augmentation(Augmentation), CodeAlignmentFactor(CodeAlignmentFactor),
|
||||||
DataAlignmentFactor(DataAlignmentFactor),
|
DataAlignmentFactor(DataAlignmentFactor),
|
||||||
ReturnAddressRegister(ReturnAddressRegister) {}
|
ReturnAddressRegister(ReturnAddressRegister) {}
|
||||||
|
|
||||||
~CIE() {
|
~CIE() {
|
||||||
}
|
}
|
||||||
@ -229,7 +226,7 @@ public:
|
|||||||
|
|
||||||
static bool classof(const FrameEntry *FE) {
|
static bool classof(const FrameEntry *FE) {
|
||||||
return FE->getKind() == FK_CIE;
|
return FE->getKind() == FK_CIE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// The following fields are defined in section 6.4.1 of the DWARF standard v3
|
/// The following fields are defined in section 6.4.1 of the DWARF standard v3
|
||||||
@ -247,11 +244,11 @@ public:
|
|||||||
// Each FDE has a CIE it's "linked to". Our FDE contains is constructed with
|
// Each FDE has a CIE it's "linked to". Our FDE contains is constructed with
|
||||||
// an offset to the CIE (provided by parsing the FDE header). The CIE itself
|
// an offset to the CIE (provided by parsing the FDE header). The CIE itself
|
||||||
// is obtained lazily once it's actually required.
|
// is obtained lazily once it's actually required.
|
||||||
FDE(DataExtractor D, uint64_t Offset, uint64_t Length,
|
FDE(uint64_t Offset, uint64_t Length, int64_t LinkedCIEOffset,
|
||||||
int64_t LinkedCIEOffset, uint64_t InitialLocation, uint64_t AddressRange)
|
uint64_t InitialLocation, uint64_t AddressRange)
|
||||||
: FrameEntry(FK_FDE, D, Offset, Length), LinkedCIEOffset(LinkedCIEOffset),
|
: FrameEntry(FK_FDE, Offset, Length), LinkedCIEOffset(LinkedCIEOffset),
|
||||||
InitialLocation(InitialLocation), AddressRange(AddressRange),
|
InitialLocation(InitialLocation), AddressRange(AddressRange),
|
||||||
LinkedCIE(nullptr) {}
|
LinkedCIE(nullptr) {}
|
||||||
|
|
||||||
~FDE() {
|
~FDE() {
|
||||||
}
|
}
|
||||||
@ -270,9 +267,9 @@ public:
|
|||||||
|
|
||||||
static bool classof(const FrameEntry *FE) {
|
static bool classof(const FrameEntry *FE) {
|
||||||
return FE->getKind() == FK_FDE;
|
return FE->getKind() == FK_FDE;
|
||||||
}
|
}
|
||||||
private:
|
|
||||||
|
|
||||||
|
private:
|
||||||
/// The following fields are defined in section 6.4.1 of the DWARF standard v3
|
/// The following fields are defined in section 6.4.1 of the DWARF standard v3
|
||||||
uint64_t LinkedCIEOffset;
|
uint64_t LinkedCIEOffset;
|
||||||
uint64_t InitialLocation;
|
uint64_t InitialLocation;
|
||||||
@ -340,7 +337,7 @@ void DWARFDebugFrame::parse(DataExtractor Data) {
|
|||||||
int64_t DataAlignmentFactor = Data.getSLEB128(&Offset);
|
int64_t DataAlignmentFactor = Data.getSLEB128(&Offset);
|
||||||
uint64_t ReturnAddressRegister = Data.getULEB128(&Offset);
|
uint64_t ReturnAddressRegister = Data.getULEB128(&Offset);
|
||||||
|
|
||||||
Entries.emplace_back(new CIE(Data, StartOffset, Length, Version,
|
Entries.emplace_back(new CIE(StartOffset, Length, Version,
|
||||||
StringRef(Augmentation), CodeAlignmentFactor,
|
StringRef(Augmentation), CodeAlignmentFactor,
|
||||||
DataAlignmentFactor, ReturnAddressRegister));
|
DataAlignmentFactor, ReturnAddressRegister));
|
||||||
} else {
|
} else {
|
||||||
@ -349,11 +346,11 @@ void DWARFDebugFrame::parse(DataExtractor Data) {
|
|||||||
uint64_t InitialLocation = Data.getAddress(&Offset);
|
uint64_t InitialLocation = Data.getAddress(&Offset);
|
||||||
uint64_t AddressRange = Data.getAddress(&Offset);
|
uint64_t AddressRange = Data.getAddress(&Offset);
|
||||||
|
|
||||||
Entries.emplace_back(new FDE(Data, StartOffset, Length, CIEPointer,
|
Entries.emplace_back(new FDE(StartOffset, Length, CIEPointer,
|
||||||
InitialLocation, AddressRange));
|
InitialLocation, AddressRange));
|
||||||
}
|
}
|
||||||
|
|
||||||
Entries.back()->parseInstructions(&Offset, EndStructureOffset);
|
Entries.back()->parseInstructions(Data, &Offset, EndStructureOffset);
|
||||||
|
|
||||||
if (Offset != EndStructureOffset) {
|
if (Offset != EndStructureOffset) {
|
||||||
std::string Str;
|
std::string Str;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user