Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:41

0001 //===- DWARFDebugInfoEntry.h ------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGINFOENTRY_H
0010 #define LLVM_DEBUGINFO_DWARF_DWARFDEBUGINFOENTRY_H
0011 
0012 #include "llvm/BinaryFormat/Dwarf.h"
0013 #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
0014 #include <cstdint>
0015 
0016 namespace llvm {
0017 
0018 class DWARFUnit;
0019 class DWARFDataExtractor;
0020 
0021 /// DWARFDebugInfoEntry - A DIE with only the minimum required data.
0022 class DWARFDebugInfoEntry {
0023   /// Offset within the .debug_info of the start of this entry.
0024   uint64_t Offset = 0;
0025 
0026   /// Index of the parent die. UINT32_MAX if there is no parent.
0027   uint32_t ParentIdx = UINT32_MAX;
0028 
0029   /// Index of the sibling die. Zero if there is no sibling.
0030   uint32_t SiblingIdx = 0;
0031 
0032   const DWARFAbbreviationDeclaration *AbbrevDecl = nullptr;
0033 
0034 public:
0035   DWARFDebugInfoEntry() = default;
0036 
0037   /// Extracts a debug info entry, which is a child of a given unit,
0038   /// starting at a given offset. If DIE can't be extracted, returns false and
0039   /// doesn't change OffsetPtr.
0040   /// High performance extraction should use this call.
0041   bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr,
0042                    const DWARFDataExtractor &DebugInfoData, uint64_t UEndOffset,
0043                    uint32_t ParentIdx);
0044 
0045   uint64_t getOffset() const { return Offset; }
0046 
0047   /// Returns index of the parent die.
0048   std::optional<uint32_t> getParentIdx() const {
0049     if (ParentIdx == UINT32_MAX)
0050       return std::nullopt;
0051 
0052     return ParentIdx;
0053   }
0054 
0055   /// Returns index of the sibling die.
0056   std::optional<uint32_t> getSiblingIdx() const {
0057     if (SiblingIdx == 0)
0058       return std::nullopt;
0059 
0060     return SiblingIdx;
0061   }
0062 
0063   /// Set index of sibling.
0064   void setSiblingIdx(uint32_t Idx) { SiblingIdx = Idx; }
0065 
0066   dwarf::Tag getTag() const {
0067     return AbbrevDecl ? AbbrevDecl->getTag() : dwarf::DW_TAG_null;
0068   }
0069 
0070   bool hasChildren() const { return AbbrevDecl && AbbrevDecl->hasChildren(); }
0071 
0072   const DWARFAbbreviationDeclaration *getAbbreviationDeclarationPtr() const {
0073     return AbbrevDecl;
0074   }
0075 };
0076 
0077 } // end namespace llvm
0078 
0079 #endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGINFOENTRY_H