From fea9bb8c517ef28fc9a3daffa408398c6636f590 Mon Sep 17 00:00:00 2001 From: Itamar Date: Sat, 12 Jun 2021 10:29:33 +0300 Subject: LibDebug: Move get_die_at_offset to Dwarf::CompilationUnit --- Userland/Libraries/LibDebug/DebugInfo.cpp | 2 +- Userland/Libraries/LibDebug/Dwarf/CompilationUnit.cpp | 6 ++++++ Userland/Libraries/LibDebug/Dwarf/CompilationUnit.h | 1 + Userland/Libraries/LibDebug/Dwarf/DIE.cpp | 6 ------ Userland/Libraries/LibDebug/Dwarf/DIE.h | 3 +-- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'Userland') diff --git a/Userland/Libraries/LibDebug/DebugInfo.cpp b/Userland/Libraries/LibDebug/DebugInfo.cpp index 9d378ed66a..7c1da1996a 100644 --- a/Userland/Libraries/LibDebug/DebugInfo.cpp +++ b/Userland/Libraries/LibDebug/DebugInfo.cpp @@ -194,7 +194,7 @@ static Optional parse_variable_type_die(const Dwarf::DIE& variable_d VERIFY(type_die_offset.value().type == Dwarf::AttributeValue::Type::DieReference); - auto type_die = variable_die.get_die_at_offset(type_die_offset.value().data.as_u32); + auto type_die = variable_die.compilation_unit().get_die_at_offset(type_die_offset.value().data.as_u32); auto type_name = type_die.get_attribute(Dwarf::Attribute::Name); if (type_name.has_value()) { variable_info.type_name = type_name.value().data.as_string; diff --git a/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.cpp b/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.cpp index 7b0af95f20..ee16f22c12 100644 --- a/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.cpp +++ b/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.cpp @@ -23,4 +23,10 @@ DIE CompilationUnit::root_die() const return DIE(*this, m_offset + m_header.header_size()); } +DIE CompilationUnit::get_die_at_offset(u32 die_offset) const +{ + VERIFY(die_offset >= offset() && die_offset < offset() + size()); + return DIE(*this, die_offset); +} + } diff --git a/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.h b/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.h index d48c781b67..9d54dc20c6 100644 --- a/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.h +++ b/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.h @@ -22,6 +22,7 @@ public: u32 size() const { return m_header.length() + sizeof(u32); } DIE root_die() const; + DIE get_die_at_offset(u32 offset) const; const DwarfInfo& dwarf_info() const { return m_dwarf_info; } const AbbreviationsMap& abbreviations_map() const { return m_abbreviations; } diff --git a/Userland/Libraries/LibDebug/Dwarf/DIE.cpp b/Userland/Libraries/LibDebug/Dwarf/DIE.cpp index a2eef74d94..65c5353a53 100644 --- a/Userland/Libraries/LibDebug/Dwarf/DIE.cpp +++ b/Userland/Libraries/LibDebug/Dwarf/DIE.cpp @@ -88,10 +88,4 @@ void DIE::for_each_child(Function callback) const } } -DIE DIE::get_die_at_offset(u32 offset) const -{ - VERIFY(offset >= m_compilation_unit.offset() && offset < m_compilation_unit.offset() + m_compilation_unit.size()); - return DIE(m_compilation_unit, offset); -} - } diff --git a/Userland/Libraries/LibDebug/Dwarf/DIE.h b/Userland/Libraries/LibDebug/Dwarf/DIE.h index 880d47058a..c234e94fee 100644 --- a/Userland/Libraries/LibDebug/Dwarf/DIE.h +++ b/Userland/Libraries/LibDebug/Dwarf/DIE.h @@ -33,8 +33,7 @@ public: void for_each_child(Function callback) const; bool is_null() const { return m_tag == EntryTag::None; } - - DIE get_die_at_offset(u32 offset) const; + const CompilationUnit& compilation_unit() const { return m_compilation_unit; } private: const CompilationUnit& m_compilation_unit; -- cgit v1.2.3