1 //===-- DWARFDebugInfo.h ----------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef SymbolFileDWARF_DWARFDebugInfo_h_ 11 #define SymbolFileDWARF_DWARFDebugInfo_h_ 12 13 #include <map> 14 #include <vector> 15 16 #include "DWARFUnit.h" 17 #include "DWARFDIE.h" 18 #include "SymbolFileDWARF.h" 19 #include "lldb/Core/STLUtils.h" 20 #include "lldb/lldb-private.h" 21 22 typedef std::multimap<const char *, dw_offset_t, CStringCompareFunctionObject> 23 CStringToDIEMap; 24 typedef CStringToDIEMap::iterator CStringToDIEMapIter; 25 typedef CStringToDIEMap::const_iterator CStringToDIEMapConstIter; 26 27 class DWARFDebugInfo { 28 public: 29 typedef dw_offset_t (*Callback)(SymbolFileDWARF *dwarf2Data, 30 DWARFUnit *cu, 31 DWARFDebugInfoEntry *die, 32 const dw_offset_t next_offset, 33 const uint32_t depth, void *userData); 34 35 DWARFDebugInfo(); 36 void SetDwarfData(SymbolFileDWARF *dwarf2Data); 37 38 size_t GetNumCompileUnits(); 39 bool ContainsCompileUnit(const DWARFUnit *cu) const; 40 DWARFUnit *GetCompileUnitAtIndex(uint32_t idx); 41 DWARFUnit *GetCompileUnit(dw_offset_t cu_offset, uint32_t *idx_ptr = NULL); 42 DWARFUnit *GetCompileUnitContainingDIEOffset(dw_offset_t die_offset); 43 DWARFUnit *GetCompileUnit(const DIERef &die_ref); 44 DWARFDIE GetDIEForDIEOffset(dw_offset_t die_offset); 45 DWARFDIE GetDIE(const DIERef &die_ref); 46 47 enum { 48 eDumpFlag_Verbose = (1 << 0), // Verbose dumping 49 eDumpFlag_ShowForm = (1 << 1), // Show the DW_form type 50 eDumpFlag_ShowAncestors = 51 (1 << 2) // Show all parent DIEs when dumping single DIEs 52 }; 53 54 DWARFDebugAranges &GetCompileUnitAranges(); 55 56 protected: 57 static bool OffsetLessThanCompileUnitOffset(dw_offset_t offset, 58 const DWARFUnitSP &cu_sp); 59 60 typedef std::vector<DWARFUnitSP> CompileUnitColl; 61 62 //---------------------------------------------------------------------- 63 // Member variables 64 //---------------------------------------------------------------------- 65 SymbolFileDWARF *m_dwarf2Data; 66 CompileUnitColl m_compile_units; 67 std::unique_ptr<DWARFDebugAranges> 68 m_cu_aranges_ap; // A quick address to compile unit table 69 70 private: 71 // All parsing needs to be done partially any managed by this class as 72 // accessors are called. 73 void ParseCompileUnitHeadersIfNeeded(); 74 75 DISALLOW_COPY_AND_ASSIGN(DWARFDebugInfo); 76 }; 77 78 #endif // SymbolFileDWARF_DWARFDebugInfo_h_ 79