aboutsummaryrefslogtreecommitdiffstats
path: root/lib/DebugInfo/DWARFDebugAbbrev.h
blob: c7c0436866c402c6b180914aaa9067e2cdfbf7dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//===-- DWARFDebugAbbrev.h --------------------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_DEBUGINFO_DWARFDEBUGABBREV_H
#define LLVM_DEBUGINFO_DWARFDEBUGABBREV_H

#include "DWARFAbbreviationDeclaration.h"
#include <list>
#include <map>
#include <vector>

namespace llvm {

typedef std::vector<DWARFAbbreviationDeclaration>
  DWARFAbbreviationDeclarationColl;
typedef DWARFAbbreviationDeclarationColl::iterator
  DWARFAbbreviationDeclarationCollIter;
typedef DWARFAbbreviationDeclarationColl::const_iterator
  DWARFAbbreviationDeclarationCollConstIter;

class DWARFAbbreviationDeclarationSet {
  uint32_t Offset;
  uint32_t IdxOffset;
  std::vector<DWARFAbbreviationDeclaration> Decls;
  public:
  DWARFAbbreviationDeclarationSet()
    : Offset(0), IdxOffset(0) {}

  DWARFAbbreviationDeclarationSet(uint32_t offset, uint32_t idxOffset)
    : Offset(offset), IdxOffset(idxOffset) {}

  void clear() {
    IdxOffset = 0;
    Decls.clear();
  }
  uint32_t getOffset() const { return Offset; }
  void dump(raw_ostream &OS) const;
  bool extract(DataExtractor data, uint32_t* offset_ptr);

  const DWARFAbbreviationDeclaration *
    getAbbreviationDeclaration(uint32_t abbrCode) const;
};

class DWARFDebugAbbrev {
public:
  typedef std::map<uint64_t, DWARFAbbreviationDeclarationSet>
    DWARFAbbreviationDeclarationCollMap;
  typedef DWARFAbbreviationDeclarationCollMap::iterator
    DWARFAbbreviationDeclarationCollMapIter;
  typedef DWARFAbbreviationDeclarationCollMap::const_iterator
    DWARFAbbreviationDeclarationCollMapConstIter;

private:
  DWARFAbbreviationDeclarationCollMap AbbrevCollMap;
  mutable DWARFAbbreviationDeclarationCollMapConstIter PrevAbbrOffsetPos;

public:
  DWARFDebugAbbrev();
  const DWARFAbbreviationDeclarationSet *
    getAbbreviationDeclarationSet(uint64_t cu_abbr_offset) const;
  void dump(raw_ostream &OS) const;
  void parse(DataExtractor data);
};

}

#endif