LLVM  14.0.0git
DWARFDebugFrame.h
Go to the documentation of this file.
1 //===- DWARFDebugFrame.h - Parsing of .debug_frame --------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H
10 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H
11 
12 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/SmallString.h"
14 #include "llvm/ADT/Triple.h"
15 #include "llvm/ADT/iterator.h"
18 #include "llvm/Support/Error.h"
19 #include <map>
20 #include <memory>
21 #include <vector>
22 
23 namespace llvm {
24 
25 class raw_ostream;
26 
27 namespace dwarf {
28 
29 constexpr uint32_t InvalidRegisterNumber = UINT32_MAX;
30 
31 /// A class that represents a location for the Call Frame Address (CFA) or a
32 /// register. This is decoded from the DWARF Call Frame Information
33 /// instructions and put into an UnwindRow.
35 public:
36  enum Location {
37  /// Not specified.
39  /// Register is not available and can't be recovered.
41  /// Register value is in the register, nothing needs to be done to unwind
42  /// it:
43  /// reg = reg
45  /// Register is in or at the CFA plus an offset:
46  /// reg = CFA + offset
47  /// reg = defef(CFA + offset)
49  /// Register or CFA is in or at a register plus offset, optionally in
50  /// an address space:
51  /// reg = reg + offset [in addrspace]
52  /// reg = deref(reg + offset [in addrspace])
54  /// Register or CFA value is in or at a value found by evaluating a DWARF
55  /// expression:
56  /// reg = eval(dwarf_expr)
57  /// reg = deref(eval(dwarf_expr))
59  /// Value is a constant value contained in "Offset":
60  /// reg = Offset
62  };
63 
64 private:
65  Location Kind; /// The type of the location that describes how to unwind it.
66  uint32_t RegNum; /// The register number for Kind == RegPlusOffset.
67  int32_t Offset; /// The offset for Kind == CFAPlusOffset or RegPlusOffset.
68  Optional<uint32_t> AddrSpace; /// The address space for Kind == RegPlusOffset
69  /// for CFA.
70  Optional<DWARFExpression> Expr; /// The DWARF expression for Kind ==
71  /// DWARFExpression.
72  bool Dereference; /// If true, the resulting location must be dereferenced
73  /// after the location value is computed.
74 
75  // Constructors are private to force people to use the create static
76  // functions.
78  : Kind(K), RegNum(InvalidRegisterNumber), Offset(0), AddrSpace(None),
79  Dereference(false) {}
80 
81  UnwindLocation(Location K, uint32_t Reg, int32_t Off, Optional<uint32_t> AS,
82  bool Deref)
83  : Kind(K), RegNum(Reg), Offset(Off), AddrSpace(AS), Dereference(Deref) {}
84 
85  UnwindLocation(DWARFExpression E, bool Deref)
86  : Kind(DWARFExpr), RegNum(InvalidRegisterNumber), Offset(0), Expr(E),
87  Dereference(Deref) {}
88 
89 public:
90  /// Create a location whose rule is set to Unspecified. This means the
91  /// register value might be in the same register but it wasn't specified in
92  /// the unwind opcodes.
93  static UnwindLocation createUnspecified();
94  /// Create a location where the value is undefined and not available. This can
95  /// happen when a register is volatile and can't be recovered.
96  static UnwindLocation createUndefined();
97  /// Create a location where the value is known to be in the register itself.
98  static UnwindLocation createSame();
99  /// Create a location that is in (Deref == false) or at (Deref == true) the
100  /// CFA plus an offset. Most registers that are spilled onto the stack use
101  /// this rule. The rule for the register will use this rule and specify a
102  /// unique offset from the CFA with \a Deref set to true. This value will be
103  /// relative to a CFA value which is typically defined using the register
104  /// plus offset location. \see createRegisterPlusOffset(...) for more
105  /// information.
106  static UnwindLocation createIsCFAPlusOffset(int32_t Off);
107  static UnwindLocation createAtCFAPlusOffset(int32_t Off);
108  /// Create a location where the saved value is in (Deref == false) or at
109  /// (Deref == true) a regiser plus an offset and, optionally, in the specified
110  /// address space (used mostly for the CFA).
111  ///
112  /// The CFA is usually defined using this rule by using the stack pointer or
113  /// frame pointer as the register, with an offset that accounts for all
114  /// spilled registers and all local variables in a function, and Deref ==
115  /// false.
116  static UnwindLocation
118  Optional<uint32_t> AddrSpace = None);
119  static UnwindLocation
121  Optional<uint32_t> AddrSpace = None);
122  /// Create a location whose value is the result of evaluating a DWARF
123  /// expression. This allows complex expressions to be evaluated in order to
124  /// unwind a register or CFA value.
125  static UnwindLocation createIsDWARFExpression(DWARFExpression Expr);
126  static UnwindLocation createAtDWARFExpression(DWARFExpression Expr);
127  static UnwindLocation createIsConstant(int32_t Value);
128 
129  Location getLocation() const { return Kind; }
130  uint32_t getRegister() const { return RegNum; }
131  int32_t getOffset() const { return Offset; }
133  assert(Kind == RegPlusOffset && AddrSpace.hasValue());
134  return *AddrSpace;
135  }
136  int32_t getConstant() const { return Offset; }
137  /// Some opcodes will modify the CFA location's register only, so we need
138  /// to be able to modify the CFA register when evaluating DWARF Call Frame
139  /// Information opcodes.
140  void setRegister(uint32_t NewRegNum) { RegNum = NewRegNum; }
141  /// Some opcodes will modify the CFA location's offset only, so we need
142  /// to be able to modify the CFA offset when evaluating DWARF Call Frame
143  /// Information opcodes.
144  void setOffset(int32_t NewOffset) { Offset = NewOffset; }
145  /// Some opcodes modify a constant value and we need to be able to update
146  /// the constant value (DW_CFA_GNU_window_save which is also known as
147  // DW_CFA_AARCH64_negate_ra_state).
148  void setConstant(int32_t Value) { Offset = Value; }
149 
151  /// Dump a location expression as text and use the register information if
152  /// some is provided.
153  ///
154  /// \param OS the stream to use for output.
155  ///
156  /// \param MRI register information that helps emit register names insteead
157  /// of raw register numbers.
158  ///
159  /// \param IsEH true if the DWARF Call Frame Information is from .eh_frame
160  /// instead of from .debug_frame. This is needed for register number
161  /// conversion because some register numbers differ between the two sections
162  /// for certain architectures like x86.
163  void dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH) const;
164 
165  bool operator==(const UnwindLocation &RHS) const;
166 };
167 
168 raw_ostream &operator<<(raw_ostream &OS, const UnwindLocation &R);
169 
170 /// A class that can track all registers with locations in a UnwindRow object.
171 ///
172 /// Register locations use a map where the key is the register number and the
173 /// the value is a UnwindLocation.
174 ///
175 /// The register maps are put into a class so that all register locations can
176 /// be copied when parsing the unwind opcodes DW_CFA_remember_state and
177 /// DW_CFA_restore_state.
179  std::map<uint32_t, UnwindLocation> Locations;
180 
181 public:
182  /// Return the location for the register in \a RegNum if there is a location.
183  ///
184  /// \param RegNum the register number to find a location for.
185  ///
186  /// \returns A location if one is available for \a RegNum, or llvm::None
187  /// otherwise.
189  auto Pos = Locations.find(RegNum);
190  if (Pos == Locations.end())
191  return llvm::None;
192  return Pos->second;
193  }
194 
195  /// Set the location for the register in \a RegNum to \a Location.
196  ///
197  /// \param RegNum the register number to set the location for.
198  ///
199  /// \param Location the UnwindLocation that describes how to unwind the value.
200  void setRegisterLocation(uint32_t RegNum, const UnwindLocation &Location) {
201  Locations.erase(RegNum);
202  Locations.insert(std::make_pair(RegNum, Location));
203  }
204 
205  /// Removes any rule for the register in \a RegNum.
206  ///
207  /// \param RegNum the register number to remove the location for.
208  void removeRegisterLocation(uint32_t RegNum) { Locations.erase(RegNum); }
209 
210  /// Dump all registers + locations that are currently defined in this object.
211  ///
212  /// \param OS the stream to use for output.
213  ///
214  /// \param MRI register information that helps emit register names insteead
215  /// of raw register numbers.
216  ///
217  /// \param IsEH true if the DWARF Call Frame Information is from .eh_frame
218  /// instead of from .debug_frame. This is needed for register number
219  /// conversion because some register numbers differ between the two sections
220  /// for certain architectures like x86.
221  void dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH) const;
222 
223  /// Returns true if we have any register locations in this object.
224  bool hasLocations() const { return !Locations.empty(); }
225 
226  size_t size() const { return Locations.size(); }
227 
228  bool operator==(const RegisterLocations &RHS) const {
229  return Locations == RHS.Locations;
230  }
231 };
232 
233 raw_ostream &operator<<(raw_ostream &OS, const RegisterLocations &RL);
234 
235 /// A class that represents a single row in the unwind table that is decoded by
236 /// parsing the DWARF Call Frame Information opcodes.
237 ///
238 /// The row consists of an optional address, the rule to unwind the CFA and all
239 /// rules to unwind any registers. If the address doesn't have a value, this
240 /// row represents the initial instructions for a CIE. If the address has a
241 /// value the UnwindRow represents a row in the UnwindTable for a FDE. The
242 /// address is the first address for which the CFA location and register rules
243 /// are valid within a function.
244 ///
245 /// UnwindRow objects are created by parsing opcodes in the DWARF Call Frame
246 /// Information and UnwindRow objects are lazily populated and pushed onto a
247 /// stack in the UnwindTable when evaluating this state machine. Accessors are
248 /// needed for the address, CFA value, and register locations as the opcodes
249 /// encode a state machine that produces a sorted array of UnwindRow objects
250 /// \see UnwindTable.
251 class UnwindRow {
252  /// The address will be valid when parsing the instructions in a FDE. If
253  /// invalid, this object represents the initial instructions of a CIE.
254  Optional<uint64_t> Address; ///< Address for row in FDE, invalid for CIE.
255  UnwindLocation CFAValue; ///< How to unwind the Call Frame Address (CFA).
256  RegisterLocations RegLocs; ///< How to unwind all registers in this list.
257 
258 public:
259  UnwindRow() : CFAValue(UnwindLocation::createUnspecified()) {}
260 
261  /// Returns true if the address is valid in this object.
262  bool hasAddress() const { return Address.hasValue(); }
263 
264  /// Get the address for this row.
265  ///
266  /// Clients should only call this function after verifying it has a valid
267  /// address with a call to \see hasAddress().
268  uint64_t getAddress() const { return *Address; }
269 
270  /// Set the address for this UnwindRow.
271  ///
272  /// The address represents the first address for which the CFAValue and
273  /// RegLocs are valid within a function.
275 
276  /// Offset the address for this UnwindRow.
277  ///
278  /// The address represents the first address for which the CFAValue and
279  /// RegLocs are valid within a function. Clients must ensure that this object
280  /// already has an address (\see hasAddress()) prior to calling this
281  /// function.
283  UnwindLocation &getCFAValue() { return CFAValue; }
284  const UnwindLocation &getCFAValue() const { return CFAValue; }
286  const RegisterLocations &getRegisterLocations() const { return RegLocs; }
287 
288  /// Dump the UnwindRow to the stream.
289  ///
290  /// \param OS the stream to use for output.
291  ///
292  /// \param MRI register information that helps emit register names insteead
293  /// of raw register numbers.
294  ///
295  /// \param IsEH true if the DWARF Call Frame Information is from .eh_frame
296  /// instead of from .debug_frame. This is needed for register number
297  /// conversion because some register numbers differ between the two sections
298  /// for certain architectures like x86.
299  ///
300  /// \param IndentLevel specify the indent level as an integer. The UnwindRow
301  /// will be output to the stream preceded by 2 * IndentLevel number of spaces.
302  void dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH,
303  unsigned IndentLevel = 0) const;
304 };
305 
306 raw_ostream &operator<<(raw_ostream &OS, const UnwindRow &Row);
307 
308 class CFIProgram;
309 class CIE;
310 class FDE;
311 
312 /// A class that contains all UnwindRow objects for an FDE or a single unwind
313 /// row for a CIE. To unwind an address the rows, which are sorted by start
314 /// address, can be searched to find the UnwindRow with the lowest starting
315 /// address that is greater than or equal to the address that is being looked
316 /// up.
317 class UnwindTable {
318 public:
319  using RowContainer = std::vector<UnwindRow>;
320  using iterator = RowContainer::iterator;
321  using const_iterator = RowContainer::const_iterator;
322 
323  size_t size() const { return Rows.size(); }
324  iterator begin() { return Rows.begin(); }
325  const_iterator begin() const { return Rows.begin(); }
326  iterator end() { return Rows.end(); }
327  const_iterator end() const { return Rows.end(); }
328  const UnwindRow &operator[](size_t Index) const {
329  assert(Index < size());
330  return Rows[Index];
331  }
332 
333  /// Dump the UnwindTable to the stream.
334  ///
335  /// \param OS the stream to use for output.
336  ///
337  /// \param MRI register information that helps emit register names insteead
338  /// of raw register numbers.
339  ///
340  /// \param IsEH true if the DWARF Call Frame Information is from .eh_frame
341  /// instead of from .debug_frame. This is needed for register number
342  /// conversion because some register numbers differ between the two sections
343  /// for certain architectures like x86.
344  ///
345  /// \param IndentLevel specify the indent level as an integer. The UnwindRow
346  /// will be output to the stream preceded by 2 * IndentLevel number of spaces.
347  void dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH,
348  unsigned IndentLevel = 0) const;
349 
350  /// Create an UnwindTable from a Common Information Entry (CIE).
351  ///
352  /// \param Cie The Common Information Entry to extract the table from. The
353  /// CFIProgram is retrieved from the \a Cie object and used to create the
354  /// UnwindTable.
355  ///
356  /// \returns An error if the DWARF Call Frame Information opcodes have state
357  /// machine errors, or a valid UnwindTable otherwise.
358  static Expected<UnwindTable> create(const CIE *Cie);
359 
360  /// Create an UnwindTable from a Frame Descriptor Entry (FDE).
361  ///
362  /// \param Fde The Frame Descriptor Entry to extract the table from. The
363  /// CFIProgram is retrieved from the \a Fde object and used to create the
364  /// UnwindTable.
365  ///
366  /// \returns An error if the DWARF Call Frame Information opcodes have state
367  /// machine errors, or a valid UnwindTable otherwise.
368  static Expected<UnwindTable> create(const FDE *Fde);
369 
370 private:
371  RowContainer Rows;
372  /// The end address when data is extracted from a FDE. This value will be
373  /// invalid when a UnwindTable is extracted from a CIE.
374  Optional<uint64_t> EndAddress;
375 
376  /// Parse the information in the CFIProgram and update the CurrRow object
377  /// that the state machine describes.
378  ///
379  /// This is an internal implementation that emulates the state machine
380  /// described in the DWARF Call Frame Information opcodes and will push
381  /// CurrRow onto the Rows container when needed.
382  ///
383  /// \param CFIP the CFI program that contains the opcodes from a CIE or FDE.
384  ///
385  /// \param CurrRow the current row to modify while parsing the state machine.
386  ///
387  /// \param InitialLocs If non-NULL, we are parsing a FDE and this contains
388  /// the initial register locations from the CIE. If NULL, then a CIE's
389  /// opcodes are being parsed and this is not needed. This is used for the
390  /// DW_CFA_restore and DW_CFA_restore_extended opcodes.
391  Error parseRows(const CFIProgram &CFIP, UnwindRow &CurrRow,
392  const RegisterLocations *InitialLocs);
393 };
394 
395 raw_ostream &operator<<(raw_ostream &OS, const UnwindTable &Rows);
396 
397 /// Represent a sequence of Call Frame Information instructions that, when read
398 /// in order, construct a table mapping PC to frame state. This can also be
399 /// referred to as "CFI rules" in DWARF literature to avoid confusion with
400 /// computer programs in the broader sense, and in this context each instruction
401 /// would be a rule to establish the mapping. Refer to pg. 172 in the DWARF5
402 /// manual, "6.4.1 Structure of Call Frame Information".
403 class CFIProgram {
404 public:
405  static constexpr size_t MaxOperands = 3;
407 
408  /// An instruction consists of a DWARF CFI opcode and an optional sequence of
409  /// operands. If it refers to an expression, then this expression has its own
410  /// sequence of operations and operands handled separately by DWARFExpression.
411  struct Instruction {
413 
414  uint8_t Opcode;
416  // Associated DWARF expression in case this instruction refers to one
418 
420  uint32_t OperandIdx) const;
421 
423  uint32_t OperandIdx) const;
424  };
425 
426  using InstrList = std::vector<Instruction>;
427  using iterator = InstrList::iterator;
428  using const_iterator = InstrList::const_iterator;
429 
430  iterator begin() { return Instructions.begin(); }
431  const_iterator begin() const { return Instructions.begin(); }
432  iterator end() { return Instructions.end(); }
433  const_iterator end() const { return Instructions.end(); }
434 
435  unsigned size() const { return (unsigned)Instructions.size(); }
436  bool empty() const { return Instructions.empty(); }
437  uint64_t codeAlign() const { return CodeAlignmentFactor; }
438  int64_t dataAlign() const { return DataAlignmentFactor; }
439  Triple::ArchType triple() const { return Arch; }
440 
441  CFIProgram(uint64_t CodeAlignmentFactor, int64_t DataAlignmentFactor,
442  Triple::ArchType Arch)
443  : CodeAlignmentFactor(CodeAlignmentFactor),
444  DataAlignmentFactor(DataAlignmentFactor),
445  Arch(Arch) {}
446 
447  /// Parse and store a sequence of CFI instructions from Data,
448  /// starting at *Offset and ending at EndOffset. *Offset is updated
449  /// to EndOffset upon successful parsing, or indicates the offset
450  /// where a problem occurred in case an error is returned.
452 
453  void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI,
454  bool IsEH, unsigned IndentLevel = 1) const;
455 
456  void addInstruction(const Instruction &I) { Instructions.push_back(I); }
457 
458  /// Get a DWARF CFI call frame string for the given DW_CFA opcode.
459  StringRef callFrameString(unsigned Opcode) const;
460 
461 private:
462  std::vector<Instruction> Instructions;
463  const uint64_t CodeAlignmentFactor;
464  const int64_t DataAlignmentFactor;
465  Triple::ArchType Arch;
466 
467  /// Convenience method to add a new instruction with the given opcode.
468  void addInstruction(uint8_t Opcode) {
469  Instructions.push_back(Instruction(Opcode));
470  }
471 
472  /// Add a new single-operand instruction.
473  void addInstruction(uint8_t Opcode, uint64_t Operand1) {
474  Instructions.push_back(Instruction(Opcode));
475  Instructions.back().Ops.push_back(Operand1);
476  }
477 
478  /// Add a new instruction that has two operands.
479  void addInstruction(uint8_t Opcode, uint64_t Operand1, uint64_t Operand2) {
480  Instructions.push_back(Instruction(Opcode));
481  Instructions.back().Ops.push_back(Operand1);
482  Instructions.back().Ops.push_back(Operand2);
483  }
484 
485  /// Add a new instruction that has three operands.
486  void addInstruction(uint8_t Opcode, uint64_t Operand1, uint64_t Operand2,
487  uint64_t Operand3) {
488  Instructions.push_back(Instruction(Opcode));
489  Instructions.back().Ops.push_back(Operand1);
490  Instructions.back().Ops.push_back(Operand2);
491  Instructions.back().Ops.push_back(Operand3);
492  }
493 
494  /// Types of operands to CFI instructions
495  /// In DWARF, this type is implicitly tied to a CFI instruction opcode and
496  /// thus this type doesn't need to be explictly written to the file (this is
497  /// not a DWARF encoding). The relationship of instrs to operand types can
498  /// be obtained from getOperandTypes() and is only used to simplify
499  /// instruction printing.
500  enum OperandType {
501  OT_Unset,
502  OT_None,
503  OT_Address,
504  OT_Offset,
505  OT_FactoredCodeOffset,
506  OT_SignedFactDataOffset,
507  OT_UnsignedFactDataOffset,
508  OT_Register,
509  OT_AddressSpace,
510  OT_Expression
511  };
512 
513  /// Get the OperandType as a "const char *".
514  static const char *operandTypeString(OperandType OT);
515 
516  /// Retrieve the array describing the types of operands according to the enum
517  /// above. This is indexed by opcode.
518  static ArrayRef<OperandType[MaxOperands]> getOperandTypes();
519 
520  /// Print \p Opcode's operand number \p OperandIdx which has value \p Operand.
521  void printOperand(raw_ostream &OS, DIDumpOptions DumpOpts,
522  const MCRegisterInfo *MRI, bool IsEH,
523  const Instruction &Instr, unsigned OperandIdx,
524  uint64_t Operand) const;
525 };
526 
527 /// An entry in either debug_frame or eh_frame. This entry can be a CIE or an
528 /// FDE.
529 class FrameEntry {
530 public:
532 
534  uint64_t CodeAlign, int64_t DataAlign, Triple::ArchType Arch)
536  CFIs(CodeAlign, DataAlign, Arch) {}
537 
538  virtual ~FrameEntry() {}
539 
540  FrameKind getKind() const { return Kind; }
541  uint64_t getOffset() const { return Offset; }
542  uint64_t getLength() const { return Length; }
543  const CFIProgram &cfis() const { return CFIs; }
544  CFIProgram &cfis() { return CFIs; }
545 
546  /// Dump the instructions in this CFI fragment
547  virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts,
548  const MCRegisterInfo *MRI, bool IsEH) const = 0;
549 
550 protected:
552 
553  const bool IsDWARF64;
554 
555  /// Offset of this entry in the section.
557 
558  /// Entry length as specified in DWARF.
560 
562 };
563 
564 /// DWARF Common Information Entry (CIE)
565 class CIE : public FrameEntry {
566 public:
567  // CIEs (and FDEs) are simply container classes, so the only sensible way to
568  // create them is by providing the full parsed contents in the constructor.
569  CIE(bool IsDWARF64, uint64_t Offset, uint64_t Length, uint8_t Version,
570  SmallString<8> Augmentation, uint8_t AddressSize,
571  uint8_t SegmentDescriptorSize, uint64_t CodeAlignmentFactor,
572  int64_t DataAlignmentFactor, uint64_t ReturnAddressRegister,
573  SmallString<8> AugmentationData, uint32_t FDEPointerEncoding,
574  uint32_t LSDAPointerEncoding, Optional<uint64_t> Personality,
575  Optional<uint32_t> PersonalityEnc, Triple::ArchType Arch)
576  : FrameEntry(FK_CIE, IsDWARF64, Offset, Length, CodeAlignmentFactor,
577  DataAlignmentFactor, Arch),
578  Version(Version), Augmentation(std::move(Augmentation)),
579  AddressSize(AddressSize), SegmentDescriptorSize(SegmentDescriptorSize),
580  CodeAlignmentFactor(CodeAlignmentFactor),
581  DataAlignmentFactor(DataAlignmentFactor),
582  ReturnAddressRegister(ReturnAddressRegister),
583  AugmentationData(std::move(AugmentationData)),
584  FDEPointerEncoding(FDEPointerEncoding),
585  LSDAPointerEncoding(LSDAPointerEncoding), Personality(Personality),
586  PersonalityEnc(PersonalityEnc) {}
587 
588  static bool classof(const FrameEntry *FE) { return FE->getKind() == FK_CIE; }
589 
590  StringRef getAugmentationString() const { return Augmentation; }
591  uint64_t getCodeAlignmentFactor() const { return CodeAlignmentFactor; }
592  int64_t getDataAlignmentFactor() const { return DataAlignmentFactor; }
593  uint8_t getVersion() const { return Version; }
594  uint64_t getReturnAddressRegister() const { return ReturnAddressRegister; }
595  Optional<uint64_t> getPersonalityAddress() const { return Personality; }
596  Optional<uint32_t> getPersonalityEncoding() const { return PersonalityEnc; }
597 
598  uint32_t getFDEPointerEncoding() const { return FDEPointerEncoding; }
599 
600  uint32_t getLSDAPointerEncoding() const { return LSDAPointerEncoding; }
601 
602  void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI,
603  bool IsEH) const override;
604 
605 private:
606  /// The following fields are defined in section 6.4.1 of the DWARF standard v4
607  const uint8_t Version;
608  const SmallString<8> Augmentation;
609  const uint8_t AddressSize;
610  const uint8_t SegmentDescriptorSize;
611  const uint64_t CodeAlignmentFactor;
612  const int64_t DataAlignmentFactor;
613  const uint64_t ReturnAddressRegister;
614 
615  // The following are used when the CIE represents an EH frame entry.
616  const SmallString<8> AugmentationData;
617  const uint32_t FDEPointerEncoding;
618  const uint32_t LSDAPointerEncoding;
619  const Optional<uint64_t> Personality;
620  const Optional<uint32_t> PersonalityEnc;
621 };
622 
623 /// DWARF Frame Description Entry (FDE)
624 class FDE : public FrameEntry {
625 public:
627  uint64_t InitialLocation, uint64_t AddressRange, CIE *Cie,
628  Optional<uint64_t> LSDAAddress, Triple::ArchType Arch)
630  Cie ? Cie->getCodeAlignmentFactor() : 0,
631  Cie ? Cie->getDataAlignmentFactor() : 0,
632  Arch),
633  CIEPointer(CIEPointer), InitialLocation(InitialLocation),
634  AddressRange(AddressRange), LinkedCIE(Cie), LSDAAddress(LSDAAddress) {}
635 
636  ~FDE() override = default;
637 
638  const CIE *getLinkedCIE() const { return LinkedCIE; }
639  uint64_t getInitialLocation() const { return InitialLocation; }
640  uint64_t getAddressRange() const { return AddressRange; }
641  Optional<uint64_t> getLSDAAddress() const { return LSDAAddress; }
642 
643  void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI,
644  bool IsEH) const override;
645 
646  static bool classof(const FrameEntry *FE) { return FE->getKind() == FK_FDE; }
647 
648 private:
649  /// The following fields are defined in section 6.4.1 of the DWARFv3 standard.
650  /// Note that CIE pointers in EH FDEs, unlike DWARF FDEs, contain relative
651  /// offsets to the linked CIEs. See the following link for more info:
652  /// https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html
653  const uint64_t CIEPointer;
654  const uint64_t InitialLocation;
655  const uint64_t AddressRange;
656  const CIE *LinkedCIE;
657  const Optional<uint64_t> LSDAAddress;
658 };
659 
660 } // end namespace dwarf
661 
662 /// A parsed .debug_frame or .eh_frame section
664  const Triple::ArchType Arch;
665  // True if this is parsing an eh_frame section.
666  const bool IsEH;
667  // Not zero for sane pointer values coming out of eh_frame
668  const uint64_t EHFrameAddress;
669 
670  std::vector<std::unique_ptr<dwarf::FrameEntry>> Entries;
671  using iterator = pointee_iterator<decltype(Entries)::const_iterator>;
672 
673  /// Return the entry at the given offset or nullptr.
674  dwarf::FrameEntry *getEntryAtOffset(uint64_t Offset) const;
675 
676 public:
677  // If IsEH is true, assume it is a .eh_frame section. Otherwise,
678  // it is a .debug_frame section. EHFrameAddress should be different
679  // than zero for correct parsing of .eh_frame addresses when they
680  // use a PC-relative encoding.
682  bool IsEH = false, uint64_t EHFrameAddress = 0);
684 
685  /// Dump the section data into the given stream.
686  void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI,
687  Optional<uint64_t> Offset) const;
688 
689  /// Parse the section from raw data. \p Data is assumed to contain the whole
690  /// frame section contents to be parsed.
692 
693  /// Return whether the section has any entries.
694  bool empty() const { return Entries.empty(); }
695 
696  /// DWARF Frame entries accessors
697  iterator begin() const { return Entries.begin(); }
698  iterator end() const { return Entries.end(); }
700  return iterator_range<iterator>(Entries.begin(), Entries.end());
701  }
702 
703  uint64_t getEHFrameAddress() const { return EHFrameAddress; }
704 };
705 
706 } // end namespace llvm
707 
708 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H
llvm::dwarf::UnwindLocation::Undefined
@ Undefined
Register is not available and can't be recovered.
Definition: DWARFDebugFrame.h:40
llvm::dwarf::CFIProgram::iterator
InstrList::iterator iterator
Definition: DWARFDebugFrame.h:427
llvm::dwarf::RegisterLocations::getRegisterLocation
Optional< UnwindLocation > getRegisterLocation(uint32_t RegNum) const
Return the location for the register in RegNum if there is a location.
Definition: DWARFDebugFrame.h:188
llvm::dwarf::CFIProgram::empty
bool empty() const
Definition: DWARFDebugFrame.h:436
llvm::dwarf::CFIProgram::Instruction::Instruction
Instruction(uint8_t Opcode)
Definition: DWARFDebugFrame.h:412
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
llvm::dwarf::FDE
DWARF Frame Description Entry (FDE)
Definition: DWARFDebugFrame.h:624
llvm::dwarf::UnwindRow::hasAddress
bool hasAddress() const
Returns true if the address is valid in this object.
Definition: DWARFDebugFrame.h:262
llvm::dwarf::UnwindRow::getAddress
uint64_t getAddress() const
Get the address for this row.
Definition: DWARFDebugFrame.h:268
llvm::dwarf::UnwindTable::RowContainer
std::vector< UnwindRow > RowContainer
Definition: DWARFDebugFrame.h:319
getDataAlignmentFactor
static int getDataAlignmentFactor(MCStreamer &streamer)
Definition: MCDwarf.cpp:1191
llvm::DWARFDebugFrame::end
iterator end() const
Definition: DWARFDebugFrame.h:698
llvm::dwarf::CFIProgram::Instruction
An instruction consists of a DWARF CFI opcode and an optional sequence of operands.
Definition: DWARFDebugFrame.h:411
llvm::dwarf::FrameEntry::FrameEntry
FrameEntry(FrameKind K, bool IsDWARF64, uint64_t Offset, uint64_t Length, uint64_t CodeAlign, int64_t DataAlign, Triple::ArchType Arch)
Definition: DWARFDebugFrame.h:533
llvm::SmallVector< uint64_t, MaxOperands >
llvm::dwarf::FrameEntry::~FrameEntry
virtual ~FrameEntry()
Definition: DWARFDebugFrame.h:538
llvm::DWARFDebugFrame::begin
iterator begin() const
DWARF Frame entries accessors.
Definition: DWARFDebugFrame.h:697
llvm::DWARFDebugFrame::empty
bool empty() const
Return whether the section has any entries.
Definition: DWARFDebugFrame.h:694
llvm::dwarf::FDE::~FDE
~FDE() override=default
llvm::dwarf::UnwindLocation::Constant
@ Constant
Value is a constant value contained in "Offset": reg = Offset.
Definition: DWARFDebugFrame.h:61
Error.h
llvm::dwarf::UnwindLocation::createAtDWARFExpression
static UnwindLocation createAtDWARFExpression(DWARFExpression Expr)
Definition: DWARFDebugFrame.cpp:78
llvm::dwarf::UnwindLocation::setRegister
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...
Definition: DWARFDebugFrame.h:140
llvm::dwarf::UnwindTable
A class that contains all UnwindRow objects for an FDE or a single unwind row for a CIE.
Definition: DWARFDebugFrame.h:317
Instructions
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
Definition: MSA.txt:11
llvm::dwarf::CFIProgram::Instruction::Opcode
uint8_t Opcode
Definition: DWARFDebugFrame.h:414
llvm::dwarf::CFIProgram::CFIProgram
CFIProgram(uint64_t CodeAlignmentFactor, int64_t DataAlignmentFactor, Triple::ArchType Arch)
Definition: DWARFDebugFrame.h:441
llvm::dwarf::UnwindLocation::getAddressSpace
uint32_t getAddressSpace() const
Definition: DWARFDebugFrame.h:132
llvm::dwarf::UnwindLocation::operator==
bool operator==(const UnwindLocation &RHS) const
Definition: DWARFDebugFrame.cpp:131
llvm::dwarf::UnwindLocation::Same
@ Same
Register value is in the register, nothing needs to be done to unwind it: reg = reg.
Definition: DWARFDebugFrame.h:44
llvm::Optional< uint32_t >
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::dwarf::FrameEntry::FrameKind
FrameKind
Definition: DWARFDebugFrame.h:531
llvm::dwarf::UnwindLocation::createIsCFAPlusOffset
static UnwindLocation createIsCFAPlusOffset(int32_t Off)
Create a location that is in (Deref == false) or at (Deref == true) the CFA plus an offset.
Definition: DWARFDebugFrame.cpp:54
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::dwarf::UnwindLocation::getOffset
int32_t getOffset() const
Definition: DWARFDebugFrame.h:131
llvm::dwarf::CFIProgram::addInstruction
void addInstruction(const Instruction &I)
Definition: DWARFDebugFrame.h:456
llvm::DWARFDataExtractor
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
Definition: DWARFDataExtractor.h:21
llvm::dwarf::CFIProgram::end
const_iterator end() const
Definition: DWARFDebugFrame.h:433
llvm::dwarf::UnwindLocation::createUndefined
static UnwindLocation createUndefined()
Create a location where the value is undefined and not available.
Definition: DWARFDebugFrame.cpp:46
llvm::dwarf::FDE::getLSDAAddress
Optional< uint64_t > getLSDAAddress() const
Definition: DWARFDebugFrame.h:641
llvm::dwarf::UnwindTable::create
static Expected< UnwindTable > create(const CIE *Cie)
Create an UnwindTable from a Common Information Entry (CIE).
Definition: DWARFDebugFrame.cpp:232
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::Optional::hasValue
constexpr bool hasValue() const
Definition: Optional.h:288
llvm::dwarf::CFIProgram::size
unsigned size() const
Definition: DWARFDebugFrame.h:435
llvm::dwarf::FDE::getInitialLocation
uint64_t getInitialLocation() const
Definition: DWARFDebugFrame.h:639
llvm::dwarf::FDE::FDE
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)
Definition: DWARFDebugFrame.h:626
llvm::dwarf::FrameEntry::Offset
const uint64_t Offset
Offset of this entry in the section.
Definition: DWARFDebugFrame.h:556
llvm::Triple::ArchType
ArchType
Definition: Triple.h:47
llvm::dwarf::UnwindRow::getCFAValue
const UnwindLocation & getCFAValue() const
Definition: DWARFDebugFrame.h:284
SmallString.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::dwarf::UnwindLocation::DWARFExpr
@ DWARFExpr
Register or CFA value is in or at a value found by evaluating a DWARF expression: reg = eval(dwarf_ex...
Definition: DWARFDebugFrame.h:58
llvm::dwarf::FDE::classof
static bool classof(const FrameEntry *FE)
Definition: DWARFDebugFrame.h:646
llvm::dwarf::CFIProgram::Instruction::Expression
Optional< DWARFExpression > Expression
Definition: DWARFDebugFrame.h:417
llvm::dwarf::UnwindRow::setAddress
void setAddress(uint64_t Addr)
Set the address for this UnwindRow.
Definition: DWARFDebugFrame.h:274
false
Definition: StackSlotColoring.cpp:142
llvm::dwarf::UnwindRow
A class that represents a single row in the unwind table that is decoded by parsing the DWARF Call Fr...
Definition: DWARFDebugFrame.h:251
llvm::dwarf::Index
Index
Definition: Dwarf.h:467
llvm::dwarf::UnwindLocation::setConstant
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_...
Definition: DWARFDebugFrame.h:148
llvm::dwarf::RegisterLocations::hasLocations
bool hasLocations() const
Returns true if we have any register locations in this object.
Definition: DWARFDebugFrame.h:224
llvm::dwarf::UnwindLocation::createIsDWARFExpression
static UnwindLocation createIsDWARFExpression(DWARFExpression Expr)
Create a location whose value is the result of evaluating a DWARF expression.
Definition: DWARFDebugFrame.cpp:74
llvm::Instruction
Definition: Instruction.h:45
llvm::dwarf::FrameEntry::Kind
const FrameKind Kind
Definition: DWARFDebugFrame.h:551
llvm::dwarf::CFIProgram::codeAlign
uint64_t codeAlign() const
Definition: DWARFDebugFrame.h:437
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::dwarf::CFIProgram::dataAlign
int64_t dataAlign() const
Definition: DWARFDebugFrame.h:438
llvm::dwarf::UnwindTable::iterator
RowContainer::iterator iterator
Definition: DWARFDebugFrame.h:320
llvm::dwarf::CIE::getFDEPointerEncoding
uint32_t getFDEPointerEncoding() const
Definition: DWARFDebugFrame.h:598
llvm::dwarf::UnwindLocation
A class that represents a location for the Call Frame Address (CFA) or a register.
Definition: DWARFDebugFrame.h:34
llvm::DWARFDebugFrame::parse
Error parse(DWARFDataExtractor Data)
Parse the section from raw data.
Definition: DWARFDebugFrame.cpp:1035
llvm::dwarf::FrameEntry::getKind
FrameKind getKind() const
Definition: DWARFDebugFrame.h:540
llvm::None
const NoneType None
Definition: None.h:23
llvm::dwarf::InvalidRegisterNumber
constexpr uint32_t InvalidRegisterNumber
Definition: DWARFDebugFrame.h:29
llvm::dwarf::UnwindLocation::getLocation
Location getLocation() const
Definition: DWARFDebugFrame.h:129
llvm::SmallString< 8 >
llvm::dwarf::UnwindLocation::Unspecified
@ Unspecified
Not specified.
Definition: DWARFDebugFrame.h:38
llvm::dwarf::UnwindRow::getCFAValue
UnwindLocation & getCFAValue()
Definition: DWARFDebugFrame.h:283
llvm::dwarf::CFIProgram::Instruction::Ops
Operands Ops
Definition: DWARFDebugFrame.h:415
llvm::dwarf::CIE::getVersion
uint8_t getVersion() const
Definition: DWARFDebugFrame.h:593
llvm::dwarf::UnwindTable::end
iterator end()
Definition: DWARFDebugFrame.h:326
llvm::dwarf::RegisterLocations
A class that can track all registers with locations in a UnwindRow object.
Definition: DWARFDebugFrame.h:178
llvm::dwarf::CIE::getReturnAddressRegister
uint64_t getReturnAddressRegister() const
Definition: DWARFDebugFrame.h:594
llvm::dwarf::UnwindTable::size
size_t size() const
Definition: DWARFDebugFrame.h:323
llvm::dwarf::RegisterLocations::dump
void dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH) const
Dump all registers + locations that are currently defined in this object.
Definition: DWARFDebugFrame.cpp:152
llvm::dwarf::CIE::CIE
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)
Definition: DWARFDebugFrame.h:569
uint64_t
llvm::dwarf::UnwindLocation::getRegister
uint32_t getRegister() const
Definition: DWARFDebugFrame.h:130
llvm::dwarf::CFIProgram::triple
Triple::ArchType triple() const
Definition: DWARFDebugFrame.h:439
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:80
llvm::dwarf::UnwindTable::const_iterator
RowContainer::const_iterator const_iterator
Definition: DWARFDebugFrame.h:321
llvm::DWARFDebugFrame::entries
iterator_range< iterator > entries() const
Definition: DWARFDebugFrame.h:699
llvm::DWARFDebugFrame
A parsed .debug_frame or .eh_frame section.
Definition: DWARFDebugFrame.h:663
llvm::dwarf::RegisterLocations::setRegisterLocation
void setRegisterLocation(uint32_t RegNum, const UnwindLocation &Location)
Set the location for the register in RegNum to Location.
Definition: DWARFDebugFrame.h:200
llvm::dwarf::UnwindLocation::setOffset
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...
Definition: DWARFDebugFrame.h:144
llvm::dwarf::FrameEntry::FK_FDE
@ FK_FDE
Definition: DWARFDebugFrame.h:531
iterator.h
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::dwarf::UnwindLocation::createAtCFAPlusOffset
static UnwindLocation createAtCFAPlusOffset(int32_t Off)
Definition: DWARFDebugFrame.cpp:58
ArrayRef.h
llvm::dwarf::UnwindLocation::getDWARFExpressionBytes
Optional< DWARFExpression > getDWARFExpressionBytes() const
Definition: DWARFDebugFrame.h:150
llvm::HighlightColor::Address
@ Address
llvm::dwarf::CFIProgram::const_iterator
InstrList::const_iterator const_iterator
Definition: DWARFDebugFrame.h:428
llvm::dwarf::UnwindLocation::getConstant
int32_t getConstant() const
Definition: DWARFDebugFrame.h:136
llvm::dwarf::UnwindLocation::CFAPlusOffset
@ CFAPlusOffset
Register is in or at the CFA plus an offset: reg = CFA + offset reg = defef(CFA + offset)
Definition: DWARFDebugFrame.h:48
llvm::dwarf::CIE::getCodeAlignmentFactor
uint64_t getCodeAlignmentFactor() const
Definition: DWARFDebugFrame.h:591
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1609
llvm::dwarf::UnwindTable::end
const_iterator end() const
Definition: DWARFDebugFrame.h:327
llvm::dwarf::CFIProgram
Represent a sequence of Call Frame Information instructions that, when read in order,...
Definition: DWARFDebugFrame.h:403
llvm::dwarf::UnwindLocation::createSame
static UnwindLocation createSame()
Create a location where the value is known to be in the register itself.
Definition: DWARFDebugFrame.cpp:48
llvm::dwarf::CFIProgram::callFrameString
StringRef callFrameString(unsigned Opcode) const
Get a DWARF CFI call frame string for the given DW_CFA opcode.
Definition: DWARFDebugFrame.cpp:391
llvm::dwarf::CFIProgram::Operands
SmallVector< uint64_t, MaxOperands > Operands
Definition: DWARFDebugFrame.h:406
llvm::dwarf::UnwindRow::getRegisterLocations
RegisterLocations & getRegisterLocations()
Definition: DWARFDebugFrame.h:285
llvm::dwarf::FrameEntry::CFIs
CFIProgram CFIs
Definition: DWARFDebugFrame.h:561
Triple.h
llvm::dwarf::CIE::getLSDAPointerEncoding
uint32_t getLSDAPointerEncoding() const
Definition: DWARFDebugFrame.h:600
llvm::dwarf::UnwindLocation::Location
Location
Definition: DWARFDebugFrame.h:36
llvm::dwarf::FrameEntry::cfis
const CFIProgram & cfis() const
Definition: DWARFDebugFrame.h:543
llvm::dwarf::CIE::dump
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, bool IsEH) const override
Dump the instructions in this CFI fragment.
Definition: DWARFDebugFrame.cpp:941
llvm::dwarf::FrameEntry::dump
virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, bool IsEH) const =0
Dump the instructions in this CFI fragment.
llvm::dwarf::CIE::getDataAlignmentFactor
int64_t getDataAlignmentFactor() const
Definition: DWARFDebugFrame.h:592
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
const_iterator
llvm::dwarf::UnwindLocation::createIsConstant
static UnwindLocation createIsConstant(int32_t Value)
Definition: DWARFDebugFrame.cpp:50
llvm::dwarf::CIE::getPersonalityEncoding
Optional< uint32_t > getPersonalityEncoding() const
Definition: DWARFDebugFrame.h:596
uint32_t
llvm::dwarf::UnwindTable::dump
void dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH, unsigned IndentLevel=0) const
Dump the UnwindTable to the stream.
Definition: DWARFDebugFrame.cpp:191
llvm::DWARFDebugFrame::DWARFDebugFrame
DWARFDebugFrame(Triple::ArchType Arch, bool IsEH=false, uint64_t EHFrameAddress=0)
Definition: DWARFDebugFrame.cpp:1019
llvm::dwarf::CFIProgram::Instruction::getOperandAsUnsigned
Expected< uint64_t > getOperandAsUnsigned(const CFIProgram &CFIP, uint32_t OperandIdx) const
Definition: DWARFDebugFrame.cpp:415
llvm::dwarf::UnwindTable::begin
iterator begin()
Definition: DWARFDebugFrame.h:324
llvm::MCRegisterInfo
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Definition: MCRegisterInfo.h:135
llvm::dwarf::CIE::getAugmentationString
StringRef getAugmentationString() const
Definition: DWARFDebugFrame.h:590
llvm::dwarf::CFIProgram::begin
iterator begin()
Definition: DWARFDebugFrame.h:430
llvm::dwarf::UnwindLocation::createAtRegisterPlusOffset
static UnwindLocation createAtRegisterPlusOffset(uint32_t Reg, int32_t Off, Optional< uint32_t > AddrSpace=None)
Definition: DWARFDebugFrame.cpp:69
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
std
Definition: BitVector.h:838
llvm::dwarf::operator<<
raw_ostream & operator<<(raw_ostream &OS, const UnwindLocation &R)
Definition: DWARFDebugFrame.cpp:125
llvm::dwarf::UnwindLocation::dump
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.
Definition: DWARFDebugFrame.cpp:82
llvm::dwarf::CIE::getPersonalityAddress
Optional< uint64_t > getPersonalityAddress() const
Definition: DWARFDebugFrame.h:595
llvm::dwarf::CFIProgram::InstrList
std::vector< Instruction > InstrList
Definition: DWARFDebugFrame.h:426
llvm::dwarf::UnwindRow::getRegisterLocations
const RegisterLocations & getRegisterLocations() const
Definition: DWARFDebugFrame.h:286
llvm::dwarf::FDE::getLinkedCIE
const CIE * getLinkedCIE() const
Definition: DWARFDebugFrame.h:638
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::DWARFDebugFrame::dump
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, Optional< uint64_t > Offset) const
Dump the section data into the given stream.
Definition: DWARFDebugFrame.cpp:1239
llvm::dwarf::CIE
DWARF Common Information Entry (CIE)
Definition: DWARFDebugFrame.h:565
llvm::dwarf::FDE::dump
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, bool IsEH) const override
Dump the instructions in this CFI fragment.
Definition: DWARFDebugFrame.cpp:990
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
DWARFExpression.h
llvm::dwarf::FrameEntry
An entry in either debug_frame or eh_frame.
Definition: DWARFDebugFrame.h:529
llvm::dwarf::UnwindLocation::createUnspecified
static UnwindLocation createUnspecified()
Create a location whose rule is set to Unspecified.
Definition: DWARFDebugFrame.cpp:44
llvm::dwarf::UnwindRow::dump
void dump(raw_ostream &OS, const MCRegisterInfo *MRI, bool IsEH, unsigned IndentLevel=0) const
Dump the UnwindRow to the stream.
Definition: DWARFDebugFrame.cpp:172
llvm::DWARFDebugFrame::getEHFrameAddress
uint64_t getEHFrameAddress() const
Definition: DWARFDebugFrame.h:703
llvm::dwarf::RegisterLocations::operator==
bool operator==(const RegisterLocations &RHS) const
Definition: DWARFDebugFrame.h:228
llvm::dwarf::UnwindTable::begin
const_iterator begin() const
Definition: DWARFDebugFrame.h:325
llvm::dwarf::UnwindRow::slideAddress
void slideAddress(uint64_t Offset)
Offset the address for this UnwindRow.
Definition: DWARFDebugFrame.h:282
llvm::dwarf::FrameEntry::FK_CIE
@ FK_CIE
Definition: DWARFDebugFrame.h:531
llvm::dwarf::FrameEntry::cfis
CFIProgram & cfis()
Definition: DWARFDebugFrame.h:544
llvm::dwarf::RegisterLocations::size
size_t size() const
Definition: DWARFDebugFrame.h:226
llvm::dwarf::CFIProgram::Instruction::getOperandAsSigned
Expected< int64_t > getOperandAsSigned(const CFIProgram &CFIP, uint32_t OperandIdx) const
Definition: DWARFDebugFrame.cpp:460
llvm::dwarf::CFIProgram::begin
const_iterator begin() const
Definition: DWARFDebugFrame.h:431
llvm::dwarf::UnwindLocation::RegPlusOffset
@ RegPlusOffset
Register or CFA is in or at a register plus offset, optionally in an address space: reg = reg + offse...
Definition: DWARFDebugFrame.h:53
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::dwarf::FrameEntry::Length
const uint64_t Length
Entry length as specified in DWARF.
Definition: DWARFDebugFrame.h:559
llvm::dwarf::CIE::classof
static bool classof(const FrameEntry *FE)
Definition: DWARFDebugFrame.h:588
llvm::dwarf::RegisterLocations::removeRegisterLocation
void removeRegisterLocation(uint32_t RegNum)
Removes any rule for the register in RegNum.
Definition: DWARFDebugFrame.h:208
llvm::dwarf::CFIProgram::dump
void dump(raw_ostream &OS, DIDumpOptions DumpOpts, const MCRegisterInfo *MRI, bool IsEH, unsigned IndentLevel=1) const
Definition: DWARFDebugFrame.cpp:916
llvm::pointee_iterator
An iterator type that allows iterating over the pointees via some other iterator.
Definition: iterator.h:314
llvm::dwarf::FrameEntry::getLength
uint64_t getLength() const
Definition: DWARFDebugFrame.h:542
llvm::DWARFDebugFrame::~DWARFDebugFrame
~DWARFDebugFrame()
llvm::dwarf::UnwindRow::UnwindRow
UnwindRow()
Definition: DWARFDebugFrame.h:259
llvm::dwarf::CFIProgram::MaxOperands
static constexpr size_t MaxOperands
Definition: DWARFDebugFrame.h:405
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::dwarf::FDE::getAddressRange
uint64_t getAddressRange() const
Definition: DWARFDebugFrame.h:640
llvm::dwarf::CFIProgram::end
iterator end()
Definition: DWARFDebugFrame.h:432
llvm::dwarf::UnwindLocation::createIsRegisterPlusOffset
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...
Definition: DWARFDebugFrame.cpp:63
llvm::dwarf::CFIProgram::parse
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...
Definition: DWARFDebugFrame.cpp:253
llvm::dwarf::UnwindTable::operator[]
const UnwindRow & operator[](size_t Index) const
Definition: DWARFDebugFrame.h:328
llvm::dwarf::FrameEntry::getOffset
uint64_t getOffset() const
Definition: DWARFDebugFrame.h:541
llvm::dwarf::FrameEntry::IsDWARF64
const bool IsDWARF64
Definition: DWARFDebugFrame.h:553
DWARFDataExtractor.h
llvm::DIDumpOptions
Container for dump options that control which debug information will be dumped.
Definition: DIContext.h:180