DWARFDebugAbbrev.h revision 314564
1//===-- DWARFDebugAbbrev.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_DWARFDebugAbbrev_h_
11#define SymbolFileDWARF_DWARFDebugAbbrev_h_
12
13#include <list>
14#include <map>
15
16#include "lldb/lldb-private.h"
17
18#include "DWARFAbbreviationDeclaration.h"
19#include "DWARFDefines.h"
20
21typedef std::vector<DWARFAbbreviationDeclaration>
22    DWARFAbbreviationDeclarationColl;
23typedef DWARFAbbreviationDeclarationColl::iterator
24    DWARFAbbreviationDeclarationCollIter;
25typedef DWARFAbbreviationDeclarationColl::const_iterator
26    DWARFAbbreviationDeclarationCollConstIter;
27
28class DWARFAbbreviationDeclarationSet {
29public:
30  DWARFAbbreviationDeclarationSet()
31      : m_offset(DW_INVALID_OFFSET), m_idx_offset(0), m_decls() {}
32
33  DWARFAbbreviationDeclarationSet(dw_offset_t offset, uint32_t idx_offset)
34      : m_offset(offset), m_idx_offset(idx_offset), m_decls() {}
35
36  void Clear();
37  dw_offset_t GetOffset() const { return m_offset; }
38  void Dump(lldb_private::Stream *s) const;
39  bool Extract(const lldb_private::DWARFDataExtractor &data,
40               lldb::offset_t *offset_ptr);
41  // void Encode(BinaryStreamBuf& debug_abbrev_buf) const;
42  dw_uleb128_t
43  AppendAbbrevDeclSequential(const DWARFAbbreviationDeclaration &abbrevDecl);
44
45  const DWARFAbbreviationDeclaration *
46  GetAbbreviationDeclaration(dw_uleb128_t abbrCode) const;
47
48private:
49  dw_offset_t m_offset;
50  uint32_t m_idx_offset;
51  std::vector<DWARFAbbreviationDeclaration> m_decls;
52};
53
54typedef std::map<dw_offset_t, DWARFAbbreviationDeclarationSet>
55    DWARFAbbreviationDeclarationCollMap;
56typedef DWARFAbbreviationDeclarationCollMap::iterator
57    DWARFAbbreviationDeclarationCollMapIter;
58typedef DWARFAbbreviationDeclarationCollMap::const_iterator
59    DWARFAbbreviationDeclarationCollMapConstIter;
60
61class DWARFDebugAbbrev {
62public:
63  DWARFDebugAbbrev();
64  const DWARFAbbreviationDeclarationSet *
65  GetAbbreviationDeclarationSet(dw_offset_t cu_abbr_offset) const;
66  void Dump(lldb_private::Stream *s) const;
67  void Parse(const lldb_private::DWARFDataExtractor &data);
68
69protected:
70  DWARFAbbreviationDeclarationCollMap m_abbrevCollMap;
71  mutable DWARFAbbreviationDeclarationCollMapConstIter m_prev_abbr_offset_pos;
72};
73
74#endif // SymbolFileDWARF_DWARFDebugAbbrev_h_
75