]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r307894, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / DebugInfo / DWARF / DWARFAcceleratorTable.h
1 //===- DWARFAcceleratorTable.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_DWARFACCELERATORTABLE_H
11 #define LLVM_DEBUGINFO_DWARFACCELERATORTABLE_H
12
13 #include "llvm/ADT/SmallVector.h"
14 #include "llvm/BinaryFormat/Dwarf.h"
15 #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
16 #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
17 #include <cstdint>
18 #include <utility>
19
20 namespace llvm {
21
22 class raw_ostream;
23
24 class DWARFAcceleratorTable {
25   struct Header {
26     uint32_t Magic;
27     uint16_t Version;
28     uint16_t HashFunction;
29     uint32_t NumBuckets;
30     uint32_t NumHashes;
31     uint32_t HeaderDataLength;
32   };
33
34   struct HeaderData {
35     using AtomType = uint16_t;
36     using Form = dwarf::Form;
37
38     uint32_t DIEOffsetBase;
39     SmallVector<std::pair<AtomType, Form>, 3> Atoms;
40   };
41
42   struct Header Hdr;
43   struct HeaderData HdrData;
44   DWARFDataExtractor AccelSection;
45   DataExtractor StringSection;
46
47 public:
48   DWARFAcceleratorTable(const DWARFDataExtractor &AccelSection,
49                         DataExtractor StringSection)
50       : AccelSection(AccelSection), StringSection(StringSection) {}
51
52   bool extract();
53   uint32_t getNumBuckets();
54   uint32_t getNumHashes();
55   uint32_t getSizeHdr();
56   uint32_t getHeaderDataLength();
57   ArrayRef<std::pair<HeaderData::AtomType, HeaderData::Form>> getAtomsDesc();
58   bool validateForms();
59
60   /// Return information related to the DWARF DIE we're looking for when
61   /// performing a lookup by name.
62   ///
63   /// \param HashDataOffset an offset into the hash data table
64   /// \returns DIEOffset the offset into the .debug_info section for the DIE
65   /// related to the input hash data offset. Currently this function returns
66   /// only the DIEOffset but it can be modified to return more data regarding
67   /// the DIE
68   uint32_t readAtoms(uint32_t &HashDataOffset);
69   void dump(raw_ostream &OS) const;
70 };
71
72 } // end namespace llvm
73
74 #endif // LLVM_DEBUGINFO_DWARFACCELERATORTABLE_H