//===- DWARFDebugFrame.h - Parsing of .debug_frame --------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/iterator.h" #include "llvm/DebugInfo/DWARF/DWARFExpression.h" #include "llvm/Support/Error.h" #include "llvm/TargetParser/Triple.h" #include <map> #include <memory> #include <vector> namespace llvm { class raw_ostream; class DWARFDataExtractor; class MCRegisterInfo; struct DIDumpOptions; namespace dwarf { constexpr uint32_t InvalidRegisterNumber = …; /// A class that represents a location for the Call Frame Address (CFA) or a /// register. This is decoded from the DWARF Call Frame Information /// instructions and put into an UnwindRow. class UnwindLocation { … }; raw_ostream &operator<<(raw_ostream &OS, const UnwindLocation &R); /// A class that can track all registers with locations in a UnwindRow object. /// /// Register locations use a map where the key is the register number and the /// the value is a UnwindLocation. /// /// The register maps are put into a class so that all register locations can /// be copied when parsing the unwind opcodes DW_CFA_remember_state and /// DW_CFA_restore_state. class RegisterLocations { … }; raw_ostream &operator<<(raw_ostream &OS, const RegisterLocations &RL); /// A class that represents a single row in the unwind table that is decoded by /// parsing the DWARF Call Frame Information opcodes. /// /// The row consists of an optional address, the rule to unwind the CFA and all /// rules to unwind any registers. If the address doesn't have a value, this /// row represents the initial instructions for a CIE. If the address has a /// value the UnwindRow represents a row in the UnwindTable for a FDE. The /// address is the first address for which the CFA location and register rules /// are valid within a function. /// /// UnwindRow objects are created by parsing opcodes in the DWARF Call Frame /// Information and UnwindRow objects are lazily populated and pushed onto a /// stack in the UnwindTable when evaluating this state machine. Accessors are /// needed for the address, CFA value, and register locations as the opcodes /// encode a state machine that produces a sorted array of UnwindRow objects /// \see UnwindTable. class UnwindRow { … }; raw_ostream &operator<<(raw_ostream &OS, const UnwindRow &Row); class CFIProgram; class CIE; class FDE; /// A class that contains all UnwindRow objects for an FDE or a single unwind /// row for a CIE. To unwind an address the rows, which are sorted by start /// address, can be searched to find the UnwindRow with the lowest starting /// address that is greater than or equal to the address that is being looked /// up. class UnwindTable { … }; raw_ostream &operator<<(raw_ostream &OS, const UnwindTable &Rows); /// Represent a sequence of Call Frame Information instructions that, when read /// in order, construct a table mapping PC to frame state. This can also be /// referred to as "CFI rules" in DWARF literature to avoid confusion with /// computer programs in the broader sense, and in this context each instruction /// would be a rule to establish the mapping. Refer to pg. 172 in the DWARF5 /// manual, "6.4.1 Structure of Call Frame Information". class CFIProgram { … }; /// An entry in either debug_frame or eh_frame. This entry can be a CIE or an /// FDE. class FrameEntry { … }; /// DWARF Common Information Entry (CIE) class CIE : public FrameEntry { … }; /// DWARF Frame Description Entry (FDE) class FDE : public FrameEntry { … }; } // end namespace dwarf /// A parsed .debug_frame or .eh_frame section class DWARFDebugFrame { … }; } // end namespace llvm #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGFRAME_H