1061da546Spatrick //===-- DWARFDebugInfo.h ----------------------------------------*- C++ -*-===// 2061da546Spatrick // 3061da546Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4061da546Spatrick // See https://llvm.org/LICENSE.txt for license information. 5061da546Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6061da546Spatrick // 7061da546Spatrick //===----------------------------------------------------------------------===// 8061da546Spatrick 9dda28197Spatrick #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFO_H 10dda28197Spatrick #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFO_H 11061da546Spatrick 12061da546Spatrick #include <map> 13061da546Spatrick #include <vector> 14061da546Spatrick 15061da546Spatrick #include "DWARFDIE.h" 16061da546Spatrick #include "DWARFTypeUnit.h" 17061da546Spatrick #include "DWARFUnit.h" 18061da546Spatrick #include "SymbolFileDWARF.h" 19061da546Spatrick #include "lldb/lldb-private.h" 20061da546Spatrick #include "llvm/Support/Error.h" 21061da546Spatrick 22061da546Spatrick namespace lldb_private { 23061da546Spatrick class DWARFContext; 24061da546Spatrick } 25061da546Spatrick 26061da546Spatrick class DWARFDebugInfo { 27061da546Spatrick public: 28061da546Spatrick typedef dw_offset_t (*Callback)(SymbolFileDWARF *dwarf2Data, 29061da546Spatrick DWARFUnit *cu, 30061da546Spatrick DWARFDebugInfoEntry *die, 31061da546Spatrick const dw_offset_t next_offset, 32061da546Spatrick const uint32_t depth, void *userData); 33061da546Spatrick 34061da546Spatrick explicit DWARFDebugInfo(SymbolFileDWARF &dwarf, 35061da546Spatrick lldb_private::DWARFContext &context); 36061da546Spatrick 37061da546Spatrick size_t GetNumUnits(); 38dda28197Spatrick DWARFUnit *GetUnitAtIndex(size_t idx); 39061da546Spatrick DWARFUnit *GetUnitAtOffset(DIERef::Section section, dw_offset_t cu_offset, 40061da546Spatrick uint32_t *idx_ptr = nullptr); 41061da546Spatrick DWARFUnit *GetUnitContainingDIEOffset(DIERef::Section section, 42061da546Spatrick dw_offset_t die_offset); 43061da546Spatrick DWARFUnit *GetUnit(const DIERef &die_ref); 44061da546Spatrick DWARFTypeUnit *GetTypeUnitForHash(uint64_t hash); 45061da546Spatrick bool ContainsTypeUnits(); 46061da546Spatrick DWARFDIE GetDIE(const DIERef &die_ref); 47061da546Spatrick 48061da546Spatrick enum { 49061da546Spatrick eDumpFlag_Verbose = (1 << 0), // Verbose dumping 50061da546Spatrick eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type 51061da546Spatrick eDumpFlag_ShowAncestors = 52061da546Spatrick (1 << 2) // Show all parent DIEs when dumping single DIEs 53061da546Spatrick }; 54061da546Spatrick 55*be691f3bSpatrick const DWARFDebugAranges &GetCompileUnitAranges(); 56061da546Spatrick 57061da546Spatrick protected: 58061da546Spatrick typedef std::vector<DWARFUnitSP> UnitColl; 59061da546Spatrick 60061da546Spatrick SymbolFileDWARF &m_dwarf; 61061da546Spatrick lldb_private::DWARFContext &m_context; 62dda28197Spatrick 63dda28197Spatrick llvm::once_flag m_units_once_flag; 64061da546Spatrick UnitColl m_units; 65dda28197Spatrick 66061da546Spatrick std::unique_ptr<DWARFDebugAranges> 67061da546Spatrick m_cu_aranges_up; // A quick address to compile unit table 68061da546Spatrick 69061da546Spatrick std::vector<std::pair<uint64_t, uint32_t>> m_type_hash_to_unit_index; 70061da546Spatrick 71061da546Spatrick private: 72061da546Spatrick // All parsing needs to be done partially any managed by this class as 73061da546Spatrick // accessors are called. 74061da546Spatrick void ParseUnitHeadersIfNeeded(); 75061da546Spatrick 76061da546Spatrick void ParseUnitsFor(DIERef::Section section); 77061da546Spatrick 78061da546Spatrick uint32_t FindUnitIndex(DIERef::Section section, dw_offset_t offset); 79061da546Spatrick 80dda28197Spatrick DWARFDebugInfo(const DWARFDebugInfo &) = delete; 81dda28197Spatrick const DWARFDebugInfo &operator=(const DWARFDebugInfo &) = delete; 82061da546Spatrick }; 83061da546Spatrick 84dda28197Spatrick #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFO_H 85