DIE.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2020-2021, Itamar S. <itamar8910@gmail.com>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include "AttributeValue.h"
  8. #include "DwarfTypes.h"
  9. #include <AK/Function.h>
  10. #include <AK/NonnullOwnPtr.h>
  11. #include <AK/Optional.h>
  12. #include <AK/Types.h>
  13. namespace Debug::Dwarf {
  14. class CompilationUnit;
  15. // DIE = Debugging Information Entry
  16. class DIE {
  17. public:
  18. DIE(CompilationUnit const&, u32 offset, Optional<u32> parent_offset = {});
  19. u32 offset() const { return m_offset; }
  20. u32 size() const { return m_size; }
  21. bool has_children() const { return m_has_children; }
  22. EntryTag tag() const { return m_tag; }
  23. ErrorOr<Optional<AttributeValue>> get_attribute(Attribute const&) const;
  24. ErrorOr<void> for_each_child(Function<ErrorOr<void>(DIE const& child)> callback) const;
  25. bool is_null() const { return m_tag == EntryTag::None; }
  26. CompilationUnit const& compilation_unit() const { return m_compilation_unit; }
  27. Optional<u32> parent_offset() const { return m_parent_offset; }
  28. private:
  29. ErrorOr<void> rehydrate_from(u32 offset, Optional<u32> parent_offset);
  30. CompilationUnit const& m_compilation_unit;
  31. u32 m_offset { 0 };
  32. u32 m_data_offset { 0 };
  33. size_t m_abbreviation_code { 0 };
  34. EntryTag m_tag { EntryTag::None };
  35. bool m_has_children { false };
  36. u32 m_size { 0 };
  37. Optional<u32> m_parent_offset;
  38. };
  39. }