1 //===-- DWARFDebugAbbrev.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_DWARFDEBUGABBREV_H 10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGABBREV_H 11 12 #include <list> 13 #include <map> 14 15 #include "lldb/lldb-private.h" 16 17 #include "DWARFAbbreviationDeclaration.h" 18 #include "DWARFDefines.h" 19 20 typedef std::vector<DWARFAbbreviationDeclaration> 21 DWARFAbbreviationDeclarationColl; 22 typedef DWARFAbbreviationDeclarationColl::iterator 23 DWARFAbbreviationDeclarationCollIter; 24 typedef DWARFAbbreviationDeclarationColl::const_iterator 25 DWARFAbbreviationDeclarationCollConstIter; 26 27 class DWARFAbbreviationDeclarationSet { 28 public: DWARFAbbreviationDeclarationSet()29 DWARFAbbreviationDeclarationSet() 30 : m_offset(DW_INVALID_OFFSET), m_idx_offset(0), m_decls() {} 31 DWARFAbbreviationDeclarationSet(dw_offset_t offset,uint32_t idx_offset)32 DWARFAbbreviationDeclarationSet(dw_offset_t offset, uint32_t idx_offset) 33 : m_offset(offset), m_idx_offset(idx_offset), m_decls() {} 34 35 void Clear(); GetOffset()36 dw_offset_t GetOffset() const { return m_offset; } 37 38 /// Extract all abbrev decls in a set. Returns llvm::ErrorSuccess() on 39 /// success, and an appropriate llvm::Error object otherwise. 40 llvm::Error extract(const lldb_private::DWARFDataExtractor &data, 41 lldb::offset_t *offset_ptr); 42 // void Encode(BinaryStreamBuf& debug_abbrev_buf) const; 43 void GetUnsupportedForms(std::set<dw_form_t> &invalid_forms) const; 44 45 const DWARFAbbreviationDeclaration * 46 GetAbbreviationDeclaration(dw_uleb128_t abbrCode) const; 47 48 /// Unit test accessor functions. 49 /// @{ GetIndexOffset()50 uint32_t GetIndexOffset() const { return m_idx_offset; } 51 /// @} 52 private: 53 dw_offset_t m_offset; 54 uint32_t m_idx_offset; 55 std::vector<DWARFAbbreviationDeclaration> m_decls; 56 }; 57 58 typedef std::map<dw_offset_t, DWARFAbbreviationDeclarationSet> 59 DWARFAbbreviationDeclarationCollMap; 60 typedef DWARFAbbreviationDeclarationCollMap::iterator 61 DWARFAbbreviationDeclarationCollMapIter; 62 typedef DWARFAbbreviationDeclarationCollMap::const_iterator 63 DWARFAbbreviationDeclarationCollMapConstIter; 64 65 class DWARFDebugAbbrev { 66 public: 67 DWARFDebugAbbrev(); 68 const DWARFAbbreviationDeclarationSet * 69 GetAbbreviationDeclarationSet(dw_offset_t cu_abbr_offset) const; 70 /// Extract all abbreviations for a particular compile unit. Returns 71 /// llvm::ErrorSuccess() on success, and an appropriate llvm::Error object 72 /// otherwise. 73 llvm::Error parse(const lldb_private::DWARFDataExtractor &data); 74 void GetUnsupportedForms(std::set<dw_form_t> &invalid_forms) const; 75 76 protected: 77 DWARFAbbreviationDeclarationCollMap m_abbrevCollMap; 78 mutable DWARFAbbreviationDeclarationCollMapConstIter m_prev_abbr_offset_pos; 79 }; 80 81 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGABBREV_H 82