DWARFGdbIndex.h revision 344779
1//===- DWARFGdbIndex.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 LLVM_DEBUGINFO_DWARF_DWARFGDBINDEX_H
11#define LLVM_DEBUGINFO_DWARF_DWARFGDBINDEX_H
12
13#include "llvm/ADT/SmallVector.h"
14#include "llvm/ADT/StringRef.h"
15#include "llvm/Support/DataExtractor.h"
16#include <cstdint>
17#include <utility>
18
19namespace llvm {
20
21class raw_ostream;
22
23class DWARFGdbIndex {
24  uint32_t Version;
25
26  uint32_t CuListOffset;
27  uint32_t TuListOffset;
28  uint32_t AddressAreaOffset;
29  uint32_t SymbolTableOffset;
30  uint32_t ConstantPoolOffset;
31
32  struct CompUnitEntry {
33    uint64_t Offset; /// Offset of a CU in the .debug_info section.
34    uint64_t Length; /// Length of that CU.
35  };
36  SmallVector<CompUnitEntry, 0> CuList;
37
38  struct TypeUnitEntry {
39    uint64_t Offset;
40    uint64_t TypeOffset;
41    uint64_t TypeSignature;
42  };
43  SmallVector<TypeUnitEntry, 0> TuList;
44
45  struct AddressEntry {
46    uint64_t LowAddress;  /// The low address.
47    uint64_t HighAddress; /// The high address.
48    uint32_t CuIndex;     /// The CU index.
49  };
50  SmallVector<AddressEntry, 0> AddressArea;
51
52  struct SymTableEntry {
53    uint32_t NameOffset; /// Offset of the symbol's name in the constant pool.
54    uint32_t VecOffset;  /// Offset of the CU vector in the constant pool.
55  };
56  SmallVector<SymTableEntry, 0> SymbolTable;
57
58  /// Each value is CU index + attributes.
59  SmallVector<std::pair<uint32_t, SmallVector<uint32_t, 0>>, 0>
60      ConstantPoolVectors;
61
62  StringRef ConstantPoolStrings;
63  uint32_t StringPoolOffset;
64
65  void dumpCUList(raw_ostream &OS) const;
66  void dumpTUList(raw_ostream &OS) const;
67  void dumpAddressArea(raw_ostream &OS) const;
68  void dumpSymbolTable(raw_ostream &OS) const;
69  void dumpConstantPool(raw_ostream &OS) const;
70
71  bool parseImpl(DataExtractor Data);
72
73public:
74  void dump(raw_ostream &OS);
75  void parse(DataExtractor Data);
76
77  bool HasContent = false;
78  bool HasError = false;
79};
80
81} // end namespace llvm
82
83#endif // LLVM_DEBUGINFO_DWARF_DWARFGDBINDEX_H
84