Go to the documentation of this file.
9 #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H
10 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H
25 class DWARFDataExtractor;
85 : Kind(K), RegNum(
Reg), Offset(Off), AddrSpace(AS), Dereference(Deref) {}
87 UnwindLocation(DWARFExpression
E,
bool Deref)
118 static UnwindLocation
120 Optional<uint32_t> AddrSpace = None);
121 static UnwindLocation
123 Optional<uint32_t> AddrSpace = None);
146 void setOffset(int32_t NewOffset) { Offset = NewOffset; }
181 std::map<uint32_t, UnwindLocation> Locations;
191 auto Pos = Locations.find(RegNum);
192 if (Pos == Locations.end())
203 Locations.erase(RegNum);
204 Locations.insert(std::make_pair(RegNum, Location));
228 size_t size()
const {
return Locations.size(); }
231 return Locations ==
RHS.Locations;
305 unsigned IndentLevel = 0)
const;
325 size_t size()
const {
return Rows.size(); }
350 unsigned IndentLevel = 0)
const;
437 unsigned size()
const {
return (
unsigned)Instructions.size(); }
438 bool empty()
const {
return Instructions.empty(); }
440 int64_t
dataAlign()
const {
return DataAlignmentFactor; }
445 : CodeAlignmentFactor(CodeAlignmentFactor),
446 DataAlignmentFactor(DataAlignmentFactor),
456 bool IsEH,
unsigned IndentLevel = 1)
const;
464 std::vector<Instruction> Instructions;
466 const int64_t DataAlignmentFactor;
507 OT_FactoredCodeOffset,
508 OT_SignedFactDataOffset,
509 OT_UnsignedFactDataOffset,
516 static const char *operandTypeString(OperandType OT);
520 static ArrayRef<OperandType[MaxOperands]> getOperandTypes();
523 void printOperand(raw_ostream &OS, DIDumpOptions DumpOpts,
524 const MCRegisterInfo *
MRI,
bool IsEH,
525 const Instruction &Instr,
unsigned OperandIdx,
538 CFIs(CodeAlign, DataAlign, Arch) {}
573 uint8_t SegmentDescriptorSize,
uint64_t CodeAlignmentFactor,
574 int64_t DataAlignmentFactor,
uint64_t ReturnAddressRegister,
579 DataAlignmentFactor, Arch),
580 Version(Version), Augmentation(
std::
move(Augmentation)),
581 AddressSize(AddressSize), SegmentDescriptorSize(SegmentDescriptorSize),
582 CodeAlignmentFactor(CodeAlignmentFactor),
583 DataAlignmentFactor(DataAlignmentFactor),
584 ReturnAddressRegister(ReturnAddressRegister),
585 AugmentationData(
std::
move(AugmentationData)),
586 FDEPointerEncoding(FDEPointerEncoding),
587 LSDAPointerEncoding(LSDAPointerEncoding), Personality(Personality),
588 PersonalityEnc(PersonalityEnc) {}
605 bool IsEH)
const override;
609 const uint8_t Version;
611 const uint8_t AddressSize;
612 const uint8_t SegmentDescriptorSize;
614 const int64_t DataAlignmentFactor;
615 const uint64_t ReturnAddressRegister;
632 Cie ? Cie->getCodeAlignmentFactor() : 0,
635 CIEPointer(CIEPointer), InitialLocation(InitialLocation),
638 ~FDE()
override =
default;
646 bool IsEH)
const override;
658 const CIE *LinkedCIE;
672 std::vector<std::unique_ptr<dwarf::FrameEntry>> Entries;
684 bool IsEH =
false,
uint64_t EHFrameAddress = 0);
696 bool empty()
const {
return Entries.empty(); }
710 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H
@ Undefined
Register is not available and can't be recovered.
InstrList::iterator iterator
Optional< UnwindLocation > getRegisterLocation(uint32_t RegNum) const
Return the location for the register in RegNum if there is a location.
Instruction(uint8_t Opcode)
This is an optimization pass for GlobalISel generic memory operations.
DWARF Frame Description Entry (FDE)
bool hasAddress() const
Returns true if the address is valid in this object.
uint64_t getAddress() const
Get the address for this row.
std::vector< UnwindRow > RowContainer
static int getDataAlignmentFactor(MCStreamer &streamer)
An instruction consists of a DWARF CFI opcode and an optional sequence of operands.
FrameEntry(FrameKind K, bool IsDWARF64, uint64_t Offset, uint64_t Length, uint64_t CodeAlign, int64_t DataAlign, Triple::ArchType Arch)
Reg
All possible values of the reg field in the ModR/M byte.
iterator begin() const
DWARF Frame entries accessors.
bool empty() const
Return whether the section has any entries.
@ Constant
Value is a constant value contained in "Offset": reg = Offset.
static UnwindLocation createAtDWARFExpression(DWARFExpression Expr)
void setRegister(uint32_t NewRegNum)
Some opcodes will modify the CFA location's register only, so we need to be able to modify the CFA re...
A class that contains all UnwindRow objects for an FDE or a single unwind row for a CIE.
Code Generation Notes for reduce the size of the ISel and reduce repetition in the implementation In a small number of this can cause even when no optimisation has taken place Instructions
CFIProgram(uint64_t CodeAlignmentFactor, int64_t DataAlignmentFactor, Triple::ArchType Arch)
uint32_t getAddressSpace() const
bool operator==(const UnwindLocation &RHS) const
@ Same
Register value is in the register, nothing needs to be done to unwind it: reg = reg.
static UnwindLocation createIsCFAPlusOffset(int32_t Off)
Create a location that is in (Deref == false) or at (Deref == true) the CFA plus an offset.
Tagged union holding either a T or a Error.
int32_t getOffset() const
void addInstruction(const Instruction &I)
const_iterator end() const
static UnwindLocation createUndefined()
Create a location where the value is undefined and not available.
Optional< uint64_t > getLSDAAddress() const
static Expected< UnwindTable > create(const CIE *Cie)
Create an UnwindTable from a Common Information Entry (CIE).
constexpr bool hasValue() const
uint64_t getInitialLocation() const
FDE(bool IsDWARF64, uint64_t Offset, uint64_t Length, uint64_t CIEPointer, uint64_t InitialLocation, uint64_t AddressRange, CIE *Cie, Optional< uint64_t > LSDAAddress, Triple::ArchType Arch)
const uint64_t Offset
Offset of this entry in the section.
const UnwindLocation & getCFAValue() const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
@ DWARFExpr
Register or CFA value is in or at a value found by evaluating a DWARF expression: reg = eval(dwarf_ex...
static bool classof(const FrameEntry *FE)
Optional< DWARFExpression > Expression
void setAddress(uint64_t Addr)
Set the address for this UnwindRow.
A class that represents a single row in the unwind table that is decoded by parsing the DWARF Call Fr...
void setConstant(int32_t Value)
Some opcodes modify a constant value and we need to be able to update the constant value (DW_CFA_GNU_...
bool hasLocations() const
Returns true if we have any register locations in this object.
static UnwindLocation createIsDWARFExpression(DWARFExpression Expr)
Create a location whose value is the result of evaluating a DWARF expression.
uint64_t codeAlign() const
This class implements an extremely fast bulk output stream that can only output to a stream.
int64_t dataAlign() const
RowContainer::iterator iterator
uint32_t getFDEPointerEncoding() const
A class that represents a location for the Call Frame Address (CFA) or a register.
Error parse(DWARFDataExtractor Data)
Parse the section from raw data.
FrameKind getKind() const
constexpr uint32_t InvalidRegisterNumber
Location getLocation() const
@ Unspecified
Not specified.
UnwindLocation & getCFAValue()
uint8_t getVersion() const
A class that represents an address range.
A class that can track all registers with locations in a UnwindRow object.
uint64_t getReturnAddressRegister() const
void dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH) const
Dump all registers + locations that are currently defined in this object.
CIE(bool IsDWARF64, uint64_t Offset, uint64_t Length, uint8_t Version, SmallString< 8 > Augmentation, uint8_t AddressSize, uint8_t SegmentDescriptorSize, uint64_t CodeAlignmentFactor, int64_t DataAlignmentFactor, uint64_t ReturnAddressRegister, SmallString< 8 > AugmentationData, uint32_t FDEPointerEncoding, uint32_t LSDAPointerEncoding, Optional< uint64_t > Personality, Optional< uint32_t > PersonalityEnc, Triple::ArchType Arch)
uint32_t getRegister() const
Triple::ArchType triple() const
RowContainer::const_iterator const_iterator
iterator_range< iterator > entries() const
A parsed .debug_frame or .eh_frame section.
void setRegisterLocation(uint32_t RegNum, const UnwindLocation &Location)
Set the location for the register in RegNum to Location.
void setOffset(int32_t NewOffset)
Some opcodes will modify the CFA location's offset only, so we need to be able to modify the CFA offs...
static UnwindLocation createAtCFAPlusOffset(int32_t Off)
Optional< DWARFExpression > getDWARFExpressionBytes() const
InstrList::const_iterator const_iterator
int32_t getConstant() const
@ CFAPlusOffset
Register is in or at the CFA plus an offset: reg = CFA + offset reg = defef(CFA + offset)
uint64_t getCodeAlignmentFactor() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
virtual ~FrameEntry()=default
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
const_iterator end() const
Represent a sequence of Call Frame Information instructions that, when read in order,...
static UnwindLocation createSame()
Create a location where the value is known to be in the register itself.
StringRef callFrameString(unsigned Opcode) const
Get a DWARF CFI call frame string for the given DW_CFA opcode.
SmallVector< uint64_t, MaxOperands > Operands
RegisterLocations & getRegisterLocations()
uint32_t getLSDAPointerEncoding() const
const CFIProgram & cfis() const
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, bool IsEH) const override
Dump the instructions in this CFI fragment.
virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, bool IsEH) const =0
Dump the instructions in this CFI fragment.
int64_t getDataAlignmentFactor() const
StringRef - Represent a constant reference to a string, i.e.
static UnwindLocation createIsConstant(int32_t Value)
Optional< uint32_t > getPersonalityEncoding() const
void dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH, unsigned IndentLevel=0) const
Dump the UnwindTable to the stream.
DWARFDebugFrame(Triple::ArchType Arch, bool IsEH=false, uint64_t EHFrameAddress=0)
Expected< uint64_t > getOperandAsUnsigned(const CFIProgram &CFIP, uint32_t OperandIdx) const
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
StringRef getAugmentationString() const
static UnwindLocation createAtRegisterPlusOffset(uint32_t Reg, int32_t Off, Optional< uint32_t > AddrSpace=None)
unsigned const MachineRegisterInfo * MRI
raw_ostream & operator<<(raw_ostream &OS, const UnwindLocation &R)
void dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH) const
Dump a location expression as text and use the register information if some is provided.
Optional< uint64_t > getPersonalityAddress() const
std::vector< Instruction > InstrList
const RegisterLocations & getRegisterLocations() const
const CIE * getLinkedCIE() const
Lightweight error class with error context and mandatory checking.
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, Optional< uint64_t > Offset) const
Dump the section data into the given stream.
DWARF Common Information Entry (CIE)
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, bool IsEH) const override
Dump the instructions in this CFI fragment.
An entry in either debug_frame or eh_frame.
static UnwindLocation createUnspecified()
Create a location whose rule is set to Unspecified.
void dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH, unsigned IndentLevel=0) const
Dump the UnwindRow to the stream.
uint64_t getEHFrameAddress() const
bool operator==(const RegisterLocations &RHS) const
const_iterator begin() const
void slideAddress(uint64_t Offset)
Offset the address for this UnwindRow.
Expected< int64_t > getOperandAsSigned(const CFIProgram &CFIP, uint32_t OperandIdx) const
const_iterator begin() const
@ RegPlusOffset
Register or CFA is in or at a register plus offset, optionally in an address space: reg = reg + offse...
A range adaptor for a pair of iterators.
const uint64_t Length
Entry length as specified in DWARF.
static bool classof(const FrameEntry *FE)
void removeRegisterLocation(uint32_t RegNum)
Removes any rule for the register in RegNum.
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, bool IsEH, unsigned IndentLevel=1) const
An iterator type that allows iterating over the pointees via some other iterator.
uint64_t getLength() const
static constexpr size_t MaxOperands
LLVM Value Representation.
uint64_t getAddressRange() const
static UnwindLocation createIsRegisterPlusOffset(uint32_t Reg, int32_t Off, Optional< uint32_t > AddrSpace=None)
Create a location where the saved value is in (Deref == false) or at (Deref == true) a regiser plus a...
Error parse(DWARFDataExtractor Data, uint64_t *Offset, uint64_t EndOffset)
Parse and store a sequence of CFI instructions from Data, starting at *Offset and ending at EndOffset...
const UnwindRow & operator[](size_t Index) const
uint64_t getOffset() const
Container for dump options that control which debug information will be dumped.