DWARFDebugAbbrev.h revision 360660
1239709Srwatson//===-- DWARFDebugAbbrev.h --------------------------------------*- C++ -*-===// 2239709Srwatson// 3239709Srwatson// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4239709Srwatson// See https://llvm.org/LICENSE.txt for license information. 5239709Srwatson// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6239709Srwatson// 7239709Srwatson//===----------------------------------------------------------------------===// 8239709Srwatson 9239709Srwatson#ifndef SymbolFileDWARF_DWARFDebugAbbrev_h_ 10239709Srwatson#define SymbolFileDWARF_DWARFDebugAbbrev_h_ 11239709Srwatson 12239709Srwatson#include <list> 13239709Srwatson#include <map> 14239709Srwatson 15239709Srwatson#include "lldb/lldb-private.h" 16239709Srwatson 17239709Srwatson#include "DWARFAbbreviationDeclaration.h" 18239709Srwatson#include "DWARFDefines.h" 19239709Srwatson 20239709Srwatsontypedef std::vector<DWARFAbbreviationDeclaration> 21239709Srwatson DWARFAbbreviationDeclarationColl; 22239709Srwatsontypedef DWARFAbbreviationDeclarationColl::iterator 23239709Srwatson DWARFAbbreviationDeclarationCollIter; 24239709Srwatsontypedef DWARFAbbreviationDeclarationColl::const_iterator 25239709Srwatson DWARFAbbreviationDeclarationCollConstIter; 26239709Srwatson 27239709Srwatsonclass DWARFAbbreviationDeclarationSet { 28239709Srwatsonpublic: 29239709Srwatson DWARFAbbreviationDeclarationSet() 30239709Srwatson : m_offset(DW_INVALID_OFFSET), m_idx_offset(0), m_decls() {} 31239709Srwatson 32239709Srwatson DWARFAbbreviationDeclarationSet(dw_offset_t offset, uint32_t idx_offset) 33239709Srwatson : m_offset(offset), m_idx_offset(idx_offset), m_decls() {} 34239709Srwatson 35239709Srwatson void Clear(); 36239709Srwatson dw_offset_t GetOffset() const { return m_offset; } 37239709Srwatson 38239709Srwatson /// Extract all abbrev decls in a set. Returns llvm::ErrorSuccess() on 39239709Srwatson /// success, and an appropriate llvm::Error object otherwise. 40239709Srwatson llvm::Error extract(const lldb_private::DWARFDataExtractor &data, 41239709Srwatson lldb::offset_t *offset_ptr); 42239709Srwatson // void Encode(BinaryStreamBuf& debug_abbrev_buf) const; 43239709Srwatson void GetUnsupportedForms(std::set<dw_form_t> &invalid_forms) const; 44239709Srwatson 45239709Srwatson const DWARFAbbreviationDeclaration * 46239709Srwatson GetAbbreviationDeclaration(dw_uleb128_t abbrCode) const; 47239709Srwatson 48239709Srwatson /// Unit test accessor functions. 49239709Srwatson /// @{ 50239709Srwatson uint32_t GetIndexOffset() const { return m_idx_offset; } 51239709Srwatson /// @} 52239709Srwatsonprivate: 53239709Srwatson dw_offset_t m_offset; 54239709Srwatson uint32_t m_idx_offset; 55239709Srwatson std::vector<DWARFAbbreviationDeclaration> m_decls; 56239709Srwatson}; 57239709Srwatson 58239709Srwatsontypedef std::map<dw_offset_t, DWARFAbbreviationDeclarationSet> 59239709Srwatson DWARFAbbreviationDeclarationCollMap; 60239709Srwatsontypedef DWARFAbbreviationDeclarationCollMap::iterator 61239709Srwatson DWARFAbbreviationDeclarationCollMapIter; 62239709Srwatsontypedef DWARFAbbreviationDeclarationCollMap::const_iterator 63239709Srwatson DWARFAbbreviationDeclarationCollMapConstIter; 64239709Srwatson 65239709Srwatsonclass DWARFDebugAbbrev { 66239709Srwatsonpublic: 67239709Srwatson DWARFDebugAbbrev(); 68239709Srwatson const DWARFAbbreviationDeclarationSet * 69239709Srwatson GetAbbreviationDeclarationSet(dw_offset_t cu_abbr_offset) const; 70239709Srwatson /// Extract all abbreviations for a particular compile unit. Returns 71239709Srwatson /// llvm::ErrorSuccess() on success, and an appropriate llvm::Error object 72239709Srwatson /// otherwise. 73239709Srwatson llvm::Error parse(const lldb_private::DWARFDataExtractor &data); 74239709Srwatson void GetUnsupportedForms(std::set<dw_form_t> &invalid_forms) const; 75239709Srwatson 76239709Srwatsonprotected: 77239709Srwatson DWARFAbbreviationDeclarationCollMap m_abbrevCollMap; 78239709Srwatson mutable DWARFAbbreviationDeclarationCollMapConstIter m_prev_abbr_offset_pos; 79239709Srwatson}; 80239709Srwatson 81239709Srwatson#endif // SymbolFileDWARF_DWARFDebugAbbrev_h_ 82239709Srwatson