LLVM  15.0.0git
DWARFDebugInfoEntry.h
Go to the documentation of this file.
1 //===- DWARFDebugInfoEntry.h ------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGINFOENTRY_H
10 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGINFOENTRY_H
11 
14 #include <cstdint>
15 
16 namespace llvm {
17 
18 class DWARFUnit;
19 class DWARFDataExtractor;
20 
21 /// DWARFDebugInfoEntry - A DIE with only the minimum required data.
23  /// Offset within the .debug_info of the start of this entry.
24  uint64_t Offset = 0;
25 
26  /// Index of the parent die. UINT32_MAX if there is no parent.
27  uint32_t ParentIdx = UINT32_MAX;
28 
29  /// Index of the sibling die. Zero if there is no sibling.
30  uint32_t SiblingIdx = 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  /// High performance extraction should use this call.
41  bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr,
42  const DWARFDataExtractor &DebugInfoData, uint64_t UEndOffset,
43  uint32_t ParentIdx);
44 
45  uint64_t getOffset() const { return Offset; }
46 
47  /// Returns index of the parent die.
49  if (ParentIdx == UINT32_MAX)
50  return None;
51 
52  return ParentIdx;
53  }
54 
55  /// Returns index of the sibling die.
57  if (SiblingIdx == 0)
58  return None;
59 
60  return SiblingIdx;
61  }
62 
63  /// Set index of sibling.
64  void setSiblingIdx(uint32_t Idx) { SiblingIdx = Idx; }
65 
66  dwarf::Tag getTag() const {
67  return AbbrevDecl ? AbbrevDecl->getTag() : dwarf::DW_TAG_null;
68  }
69 
70  bool hasChildren() const { return AbbrevDecl && AbbrevDecl->hasChildren(); }
71 
73  return AbbrevDecl;
74  }
75 };
76 
77 } // end namespace llvm
78 
79 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGINFOENTRY_H
llvm::DWARFAbbreviationDeclaration::getTag
dwarf::Tag getTag() const
Definition: DWARFAbbreviationDeclaration.h:90
llvm::DWARFDebugInfoEntry::extractFast
bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr, const DWARFDataExtractor &DebugInfoData, uint64_t UEndOffset, uint32_t ParentIdx)
Extracts a debug info entry, which is a child of a given unit, starting at a given offset.
Definition: DWARFDebugInfoEntry.cpp:23
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::DWARFDebugInfoEntry::getTag
dwarf::Tag getTag() const
Definition: DWARFDebugInfoEntry.h:66
llvm::Optional< uint32_t >
llvm::DWARFAbbreviationDeclaration::hasChildren
bool hasChildren() const
Definition: DWARFAbbreviationDeclaration.h:91
llvm::DWARFDebugInfoEntry::getAbbreviationDeclarationPtr
const DWARFAbbreviationDeclaration * getAbbreviationDeclarationPtr() const
Definition: DWARFDebugInfoEntry.h:72
llvm::DWARFDebugInfoEntry
DWARFDebugInfoEntry - A DIE with only the minimum required data.
Definition: DWARFDebugInfoEntry.h:22
llvm::DWARFDataExtractor
A DataExtractor (typically for an in-memory copy of an object-file section) plus a relocation map for...
Definition: DWARFDataExtractor.h:21
llvm::dwarf::Tag
Tag
Definition: Dwarf.h:105
llvm::None
const NoneType None
Definition: None.h:24
llvm::DWARFDebugInfoEntry::setSiblingIdx
void setSiblingIdx(uint32_t Idx)
Set index of sibling.
Definition: DWARFDebugInfoEntry.h:64
uint64_t
llvm::DWARFDebugInfoEntry::getOffset
uint64_t getOffset() const
Definition: DWARFDebugInfoEntry.h:45
DWARFAbbreviationDeclaration.h
llvm::DWARFDebugInfoEntry::getParentIdx
Optional< uint32_t > getParentIdx() const
Returns index of the parent die.
Definition: DWARFDebugInfoEntry.h:48
Dwarf.h
uint32_t
llvm::DWARFDebugInfoEntry::getSiblingIdx
Optional< uint32_t > getSiblingIdx() const
Returns index of the sibling die.
Definition: DWARFDebugInfoEntry.h:56
llvm::DWARFAbbreviationDeclaration
Definition: DWARFAbbreviationDeclaration.h:27
llvm::DWARFUnit
Definition: DWARFUnit.h:207
llvm::DWARFDebugInfoEntry::DWARFDebugInfoEntry
DWARFDebugInfoEntry()=default
llvm::DWARFDebugInfoEntry::hasChildren
bool hasChildren() const
Definition: DWARFDebugInfoEntry.h:70