| 1 | //===-- DWARFDebugInfo.h ----------------------------------------*- 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 LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFO_H |
| 10 | #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFO_H |
| 11 | |
| 12 | #include <map> |
| 13 | #include <vector> |
| 14 | |
| 15 | #include "DWARFDIE.h" |
| 16 | #include "DWARFTypeUnit.h" |
| 17 | #include "DWARFUnit.h" |
| 18 | #include "SymbolFileDWARF.h" |
| 19 | #include "lldb/lldb-private.h" |
| 20 | #include "llvm/Support/Error.h" |
| 21 | |
| 22 | namespace lldb_private::plugin { |
| 23 | namespace dwarf { |
| 24 | class DWARFContext; |
| 25 | |
| 26 | class DWARFDebugInfo { |
| 27 | public: |
| 28 | typedef dw_offset_t (*Callback)(SymbolFileDWARF *dwarf2Data, DWARFUnit *cu, |
| 29 | DWARFDebugInfoEntry *die, |
| 30 | const dw_offset_t next_offset, |
| 31 | const uint32_t depth, void *userData); |
| 32 | |
| 33 | explicit DWARFDebugInfo(SymbolFileDWARF &dwarf, DWARFContext &context); |
| 34 | |
| 35 | size_t GetNumUnits(); |
| 36 | DWARFUnit *GetUnitAtIndex(size_t idx); |
| 37 | DWARFUnit *GetUnitAtOffset(DIERef::Section section, dw_offset_t cu_offset, |
| 38 | uint32_t *idx_ptr = nullptr); |
| 39 | DWARFUnit *GetUnitContainingDIEOffset(DIERef::Section section, |
| 40 | dw_offset_t die_offset); |
| 41 | DWARFUnit *GetSkeletonUnit(DWARFUnit *dwo_unit); |
| 42 | DWARFTypeUnit *GetTypeUnitForHash(uint64_t hash); |
| 43 | bool ContainsTypeUnits(); |
| 44 | DWARFDIE GetDIE(DIERef::Section section, dw_offset_t die_offset); |
| 45 | |
| 46 | enum { |
| 47 | eDumpFlag_Verbose = (1 << 0), // Verbose dumping |
| 48 | eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type |
| 49 | eDumpFlag_ShowAncestors = |
| 50 | (1 << 2) // Show all parent DIEs when dumping single DIEs |
| 51 | }; |
| 52 | |
| 53 | const DWARFDebugAranges &GetCompileUnitAranges(); |
| 54 | |
| 55 | const std::shared_ptr<SymbolFileDWARFDwo> &GetDwpSymbolFile(); |
| 56 | |
| 57 | protected: |
| 58 | typedef std::vector<DWARFUnitSP> UnitColl; |
| 59 | |
| 60 | SymbolFileDWARF &m_dwarf; |
| 61 | DWARFContext &m_context; |
| 62 | |
| 63 | llvm::once_flag m_units_once_flag; |
| 64 | UnitColl m_units; |
| 65 | |
| 66 | std::unique_ptr<DWARFDebugAranges> |
| 67 | m_cu_aranges_up; // A quick address to compile unit table |
| 68 | |
| 69 | std::vector<std::pair<uint64_t, uint32_t>> m_type_hash_to_unit_index; |
| 70 | llvm::DenseMap<uint64_t, DWARFUnit *> m_dwarf5_dwo_id_to_skeleton_unit; |
| 71 | llvm::DenseMap<uint64_t, DWARFUnit *> m_dwarf4_dwo_id_to_skeleton_unit; |
| 72 | llvm::once_flag m_dwarf4_dwo_id_to_skeleton_unit_once_flag; |
| 73 | |
| 74 | private: |
| 75 | // All parsing needs to be done partially any managed by this class as |
| 76 | // accessors are called. |
| 77 | void (); |
| 78 | |
| 79 | void ParseUnitsFor(DIERef::Section section); |
| 80 | |
| 81 | uint32_t FindUnitIndex(DIERef::Section section, dw_offset_t offset); |
| 82 | |
| 83 | DWARFDebugInfo(const DWARFDebugInfo &) = delete; |
| 84 | const DWARFDebugInfo &operator=(const DWARFDebugInfo &) = delete; |
| 85 | }; |
| 86 | } // namespace dwarf |
| 87 | } // namespace lldb_private::plugin |
| 88 | |
| 89 | #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFO_H |
| 90 | |