1 //===-- DWARFDebugInfo.h ----------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef SymbolFileDWARF_DWARFDebugInfo_h_
10 #define SymbolFileDWARF_DWARFDebugInfo_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"
22 namespace lldb_private {
26 class DWARFDebugInfo {
28 typedef dw_offset_t (*Callback)(SymbolFileDWARF *dwarf2Data,
30 DWARFDebugInfoEntry *die,
31 const dw_offset_t next_offset,
32 const uint32_t depth, void *userData);
34 explicit DWARFDebugInfo(SymbolFileDWARF &dwarf,
35 lldb_private::DWARFContext &context);
38 DWARFUnit *GetUnitAtIndex(lldb::user_id_t idx);
39 DWARFUnit *GetUnitAtOffset(DIERef::Section section, dw_offset_t cu_offset,
40 uint32_t *idx_ptr = nullptr);
41 DWARFUnit *GetUnitContainingDIEOffset(DIERef::Section section,
42 dw_offset_t die_offset);
43 DWARFUnit *GetUnit(const DIERef &die_ref);
44 DWARFTypeUnit *GetTypeUnitForHash(uint64_t hash);
45 bool ContainsTypeUnits();
46 DWARFDIE GetDIEForDIEOffset(DIERef::Section section,
47 dw_offset_t die_offset);
48 DWARFDIE GetDIE(const DIERef &die_ref);
51 eDumpFlag_Verbose = (1 << 0), // Verbose dumping
52 eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type
53 eDumpFlag_ShowAncestors =
54 (1 << 2) // Show all parent DIEs when dumping single DIEs
57 llvm::Expected<DWARFDebugAranges &> GetCompileUnitAranges();
60 typedef std::vector<DWARFUnitSP> UnitColl;
62 SymbolFileDWARF &m_dwarf;
63 lldb_private::DWARFContext &m_context;
65 std::unique_ptr<DWARFDebugAranges>
66 m_cu_aranges_up; // A quick address to compile unit table
68 std::vector<std::pair<uint64_t, uint32_t>> m_type_hash_to_unit_index;
71 // All parsing needs to be done partially any managed by this class as
72 // accessors are called.
73 void ParseUnitHeadersIfNeeded();
75 void ParseUnitsFor(DIERef::Section section);
77 uint32_t FindUnitIndex(DIERef::Section section, dw_offset_t offset);
79 DISALLOW_COPY_AND_ASSIGN(DWARFDebugInfo);
82 #endif // SymbolFileDWARF_DWARFDebugInfo_h_