DWARFDebugInfoEntry.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- DWARFDebugInfoEntry.h ------------------------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_DEBUGINFO_DWARFDEBUGINFOENTRY_H
  14. #define LLVM_DEBUGINFO_DWARFDEBUGINFOENTRY_H
  15. #include "llvm/BinaryFormat/Dwarf.h"
  16. #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
  17. #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
  18. #include <cstdint>
  19. namespace llvm {
  20. class DataExtractor;
  21. class DWARFUnit;
  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.
  25. uint64_t Offset = 0;
  26. /// The integer depth of this DIE within the compile unit DIEs where the
  27. /// compile/type unit DIE has a depth of zero.
  28. uint32_t Depth = 0;
  29. const DWARFAbbreviationDeclaration *AbbrevDecl = nullptr;
  30. public:
  31. DWARFDebugInfoEntry() = default;
  32. /// Extracts a debug info entry, which is a child of a given unit,
  33. /// starting at a given offset. If DIE can't be extracted, returns false and
  34. /// doesn't change OffsetPtr.
  35. bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr);
  36. /// High performance extraction should use this call.
  37. bool extractFast(const DWARFUnit &U, uint64_t *OffsetPtr,
  38. const DWARFDataExtractor &DebugInfoData, uint64_t UEndOffset,
  39. uint32_t Depth);
  40. uint64_t getOffset() const { return Offset; }
  41. uint32_t getDepth() const { return Depth; }
  42. dwarf::Tag getTag() const {
  43. return AbbrevDecl ? AbbrevDecl->getTag() : dwarf::DW_TAG_null;
  44. }
  45. bool hasChildren() const { return AbbrevDecl && AbbrevDecl->hasChildren(); }
  46. const DWARFAbbreviationDeclaration *getAbbreviationDeclarationPtr() const {
  47. return AbbrevDecl;
  48. }
  49. };
  50. } // end namespace llvm
  51. #endif // LLVM_DEBUGINFO_DWARFDEBUGINFOENTRY_H
  52. #ifdef __GNUC__
  53. #pragma GCC diagnostic pop
  54. #endif