1 //===- DWARFDebugInfoEntry.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_DWARFDEBUGINFOENTRY_H
11 #define LLVM_DEBUGINFO_DWARFDEBUGINFOENTRY_H
12 
13 #include "llvm/BinaryFormat/Dwarf.h"
14 #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
15 #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
16 #include <cstdint>
17 
18 namespace llvm {
19 
20 class DataExtractor;
21 class DWARFUnit;
22 
23 /// DWARFDebugInfoEntry - A DIE with only the minimum required data.
24 class DWARFDebugInfoEntry {
25   /// Offset within the .debug_info of the start of this entry.
26   uint32_t Offset = 0;
27 
28   /// The integer depth of this DIE within the compile unit DIEs where the
29   /// compile/type unit DIE has a depth of zero.
30   uint32_t Depth = 0;
31 
32   const DWARFAbbreviationDeclaration *AbbrevDecl = nullptr;
33 
34 public:
35   DWARFDebugInfoEntry() = default;
36 
37   /// Extracts a debug info entry, which is a child of a given unit,
38   /// starting at a given offset. If DIE can't be extracted, returns false and
39   /// doesn't change OffsetPtr.
40   bool extractFast(const DWARFUnit &U, uint32_t *OffsetPtr);
41 
42   /// High performance extraction should use this call.
43   bool extractFast(const DWARFUnit &U, uint32_t *OffsetPtr,
44                    const DWARFDataExtractor &DebugInfoData, uint32_t UEndOffset,
45                    uint32_t Depth);
46 
getOffset()47   uint32_t getOffset() const { return Offset; }
getDepth()48   uint32_t getDepth() const { return Depth; }
49 
getTag()50   dwarf::Tag getTag() const {
51     return AbbrevDecl ? AbbrevDecl->getTag() : dwarf::DW_TAG_null;
52   }
53 
hasChildren()54   bool hasChildren() const { return AbbrevDecl && AbbrevDecl->hasChildren(); }
55 
getAbbreviationDeclarationPtr()56   const DWARFAbbreviationDeclaration *getAbbreviationDeclarationPtr() const {
57     return AbbrevDecl;
58   }
59 };
60 
61 } // end namespace llvm
62 
63 #endif // LLVM_DEBUGINFO_DWARFDEBUGINFOENTRY_H
64