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