1254721Semaste//===-- DWARFDebugAbbrev.h --------------------------------------*- C++ -*-===//
2254721Semaste//
3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4353358Sdim// See https://llvm.org/LICENSE.txt for license information.
5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6254721Semaste//
7254721Semaste//===----------------------------------------------------------------------===//
8254721Semaste
9254721Semaste#ifndef SymbolFileDWARF_DWARFDebugAbbrev_h_
10254721Semaste#define SymbolFileDWARF_DWARFDebugAbbrev_h_
11254721Semaste
12254721Semaste#include <list>
13254721Semaste#include <map>
14254721Semaste
15254721Semaste#include "lldb/lldb-private.h"
16254721Semaste
17314564Sdim#include "DWARFAbbreviationDeclaration.h"
18254721Semaste#include "DWARFDefines.h"
19254721Semaste
20314564Sdimtypedef std::vector<DWARFAbbreviationDeclaration>
21314564Sdim    DWARFAbbreviationDeclarationColl;
22314564Sdimtypedef DWARFAbbreviationDeclarationColl::iterator
23314564Sdim    DWARFAbbreviationDeclarationCollIter;
24314564Sdimtypedef DWARFAbbreviationDeclarationColl::const_iterator
25314564Sdim    DWARFAbbreviationDeclarationCollConstIter;
26254721Semaste
27314564Sdimclass DWARFAbbreviationDeclarationSet {
28254721Semastepublic:
29314564Sdim  DWARFAbbreviationDeclarationSet()
30314564Sdim      : m_offset(DW_INVALID_OFFSET), m_idx_offset(0), m_decls() {}
31254721Semaste
32314564Sdim  DWARFAbbreviationDeclarationSet(dw_offset_t offset, uint32_t idx_offset)
33314564Sdim      : m_offset(offset), m_idx_offset(idx_offset), m_decls() {}
34254721Semaste
35314564Sdim  void Clear();
36314564Sdim  dw_offset_t GetOffset() const { return m_offset; }
37353358Sdim
38353358Sdim  /// Extract all abbrev decls in a set.  Returns llvm::ErrorSuccess() on
39353358Sdim  /// success, and an appropriate llvm::Error object otherwise.
40353358Sdim  llvm::Error extract(const lldb_private::DWARFDataExtractor &data,
41353358Sdim                      lldb::offset_t *offset_ptr);
42314564Sdim  // void Encode(BinaryStreamBuf& debug_abbrev_buf) const;
43327952Sdim  void GetUnsupportedForms(std::set<dw_form_t> &invalid_forms) const;
44254721Semaste
45314564Sdim  const DWARFAbbreviationDeclaration *
46314564Sdim  GetAbbreviationDeclaration(dw_uleb128_t abbrCode) const;
47314564Sdim
48353358Sdim  /// Unit test accessor functions.
49353358Sdim  /// @{
50353358Sdim  uint32_t GetIndexOffset() const { return m_idx_offset; }
51353358Sdim  /// @}
52254721Semasteprivate:
53314564Sdim  dw_offset_t m_offset;
54314564Sdim  uint32_t m_idx_offset;
55314564Sdim  std::vector<DWARFAbbreviationDeclaration> m_decls;
56254721Semaste};
57254721Semaste
58314564Sdimtypedef std::map<dw_offset_t, DWARFAbbreviationDeclarationSet>
59314564Sdim    DWARFAbbreviationDeclarationCollMap;
60314564Sdimtypedef DWARFAbbreviationDeclarationCollMap::iterator
61314564Sdim    DWARFAbbreviationDeclarationCollMapIter;
62314564Sdimtypedef DWARFAbbreviationDeclarationCollMap::const_iterator
63314564Sdim    DWARFAbbreviationDeclarationCollMapConstIter;
64254721Semaste
65314564Sdimclass DWARFDebugAbbrev {
66314564Sdimpublic:
67314564Sdim  DWARFDebugAbbrev();
68314564Sdim  const DWARFAbbreviationDeclarationSet *
69314564Sdim  GetAbbreviationDeclarationSet(dw_offset_t cu_abbr_offset) const;
70353358Sdim  /// Extract all abbreviations for a particular compile unit.  Returns
71353358Sdim  /// llvm::ErrorSuccess() on success, and an appropriate llvm::Error object
72353358Sdim  /// otherwise.
73353358Sdim  llvm::Error parse(const lldb_private::DWARFDataExtractor &data);
74327952Sdim  void GetUnsupportedForms(std::set<dw_form_t> &invalid_forms) const;
75254721Semaste
76254721Semasteprotected:
77314564Sdim  DWARFAbbreviationDeclarationCollMap m_abbrevCollMap;
78314564Sdim  mutable DWARFAbbreviationDeclarationCollMapConstIter m_prev_abbr_offset_pos;
79254721Semaste};
80254721Semaste
81314564Sdim#endif // SymbolFileDWARF_DWARFDebugAbbrev_h_
82