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