LLDB  mainline
DWARFDebugInfo.h
Go to the documentation of this file.
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 SymbolFileDWARF_DWARFDebugInfo_h_
10 #define SymbolFileDWARF_DWARFDebugInfo_h_
11 
12 #include <map>
13 #include <vector>
14 
15 #include "DWARFDIE.h"
16 #include "DWARFUnit.h"
17 #include "SymbolFileDWARF.h"
18 #include "lldb/Core/STLUtils.h"
19 #include "lldb/lldb-private.h"
20 #include "llvm/Support/Error.h"
21 
22 namespace lldb_private {
23 class DWARFContext;
24 }
25 
26 typedef std::multimap<const char *, dw_offset_t, CStringCompareFunctionObject>
28 typedef CStringToDIEMap::iterator CStringToDIEMapIter;
29 typedef CStringToDIEMap::const_iterator CStringToDIEMapConstIter;
30 
32 public:
33  typedef dw_offset_t (*Callback)(SymbolFileDWARF *dwarf2Data,
34  DWARFUnit *cu,
36  const dw_offset_t next_offset,
37  const uint32_t depth, void *userData);
38 
39  explicit DWARFDebugInfo(lldb_private::DWARFContext &context);
40  void SetDwarfData(SymbolFileDWARF *dwarf2Data);
41 
42  size_t GetNumCompileUnits();
43  DWARFUnit *GetCompileUnitAtIndex(lldb::user_id_t idx);
44  DWARFUnit *GetCompileUnitAtOffset(dw_offset_t cu_offset,
45  uint32_t *idx_ptr = NULL);
46  DWARFUnit *GetCompileUnitContainingDIEOffset(dw_offset_t die_offset);
47  DWARFUnit *GetCompileUnit(const DIERef &die_ref);
48  DWARFDIE GetDIEForDIEOffset(dw_offset_t die_offset);
49  DWARFDIE GetDIE(const DIERef &die_ref);
50 
51  enum {
52  eDumpFlag_Verbose = (1 << 0), // Verbose dumping
53  eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type
54  eDumpFlag_ShowAncestors =
55  (1 << 2) // Show all parent DIEs when dumping single DIEs
56  };
57 
58  llvm::Expected<DWARFDebugAranges &> GetCompileUnitAranges();
59 
60 protected:
61  static bool OffsetLessThanCompileUnitOffset(dw_offset_t offset,
62  const DWARFUnitSP &cu_sp);
63 
64  typedef std::vector<DWARFUnitSP> CompileUnitColl;
65 
66  // Member variables
69  CompileUnitColl m_compile_units;
70  std::unique_ptr<DWARFDebugAranges>
71  m_cu_aranges_up; // A quick address to compile unit table
72 
73 private:
74  // All parsing needs to be done partially any managed by this class as
75  // accessors are called.
76  void ParseCompileUnitHeadersIfNeeded();
77 
78  uint32_t FindCompileUnitIndex(dw_offset_t offset);
79 
80  DISALLOW_COPY_AND_ASSIGN(DWARFDebugInfo);
81 };
82 
83 #endif // SymbolFileDWARF_DWARFDebugInfo_h_
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
uint32_t dw_offset_t
Definition: dwarf.h:30
CompileUnitColl m_compile_units
std::multimap< const char *, dw_offset_t, CStringCompareFunctionObject > CStringToDIEMap
Definition: DIERef.h:18
CStringToDIEMap::iterator CStringToDIEMapIter
uint64_t user_id_t
Definition: lldb-types.h:84
std::unique_ptr< DWARFDebugAranges > m_cu_aranges_up
lldb_private::DWARFContext & m_context
std::vector< DWARFUnitSP > CompileUnitColl
std::shared_ptr< DWARFUnit > DWARFUnitSP
Definition: DWARFUnit.h:22
SymbolFileDWARF * m_dwarf2Data
CStringToDIEMap::const_iterator CStringToDIEMapConstIter