From 75673319adf6a9a8e27d6d9da14168b7b04c6baf Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Wed, 14 Sep 2022 10:39:32 +0200 Subject: LibDebug: Break inclusion cycle through many forward-declarations --- Userland/Libraries/LibDebug/Dwarf/CompilationUnit.cpp | 11 ++++++++++- Userland/Libraries/LibDebug/Dwarf/CompilationUnit.h | 6 +++--- Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp | 2 ++ Userland/Libraries/LibDebug/Dwarf/DwarfInfo.h | 5 ++++- Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp | 1 + Userland/Libraries/LibDebug/Dwarf/LineProgram.h | 4 +++- 6 files changed, 23 insertions(+), 6 deletions(-) (limited to 'Userland/Libraries') diff --git a/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.cpp b/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.cpp index 9bef566e5a..7f206ad63a 100644 --- a/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.cpp +++ b/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.cpp @@ -5,8 +5,10 @@ */ #include "CompilationUnit.h" -#include "DIE.h" #include +#include +#include +#include namespace Debug::Dwarf { @@ -20,6 +22,8 @@ CompilationUnit::CompilationUnit(DwarfInfo const& dwarf_info, u32 offset, Compil VERIFY(header.version() < 5 || header.unit_type() == CompilationUnitType::Full); } +CompilationUnit::~CompilationUnit() = default; + DIE CompilationUnit::root_die() const { return DIE(*this, m_offset + m_header.header_size()); @@ -31,6 +35,11 @@ DIE CompilationUnit::get_die_at_offset(u32 die_offset) const return DIE(*this, die_offset); } +LineProgram const& CompilationUnit::line_program() const +{ + return *m_line_program; +} + Optional CompilationUnit::base_address() const { if (m_has_cached_base_address) diff --git a/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.h b/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.h index c67aeb014e..e2157f2517 100644 --- a/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.h +++ b/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.h @@ -7,9 +7,8 @@ #pragma once #include "AbbreviationsMap.h" -#include "DIE.h" -#include "LineProgram.h" #include +#include #include namespace Debug::Dwarf { @@ -24,6 +23,7 @@ class CompilationUnit { public: CompilationUnit(DwarfInfo const& dwarf_info, u32 offset, CompilationUnitHeader const&, NonnullOwnPtr&& line_program); + ~CompilationUnit(); u32 offset() const { return m_offset; } u32 size() const { return m_header.length() + sizeof(u32); } @@ -38,7 +38,7 @@ public: DwarfInfo const& dwarf_info() const { return m_dwarf_info; } AbbreviationsMap const& abbreviations_map() const { return m_abbreviations; } - LineProgram const& line_program() const { return *m_line_program; } + LineProgram const& line_program() const; Optional base_address() const; // DW_AT_addr_base diff --git a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp index 23f7596019..466b824b24 100644 --- a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp +++ b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp @@ -31,6 +31,8 @@ DwarfInfo::DwarfInfo(ELF::Image const& elf) populate_compilation_units(); } +DwarfInfo::~DwarfInfo() = default; + ReadonlyBytes DwarfInfo::section_data(StringView section_name) const { auto section = m_elf.lookup_section(section_name); diff --git a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.h b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.h index ac2ec7e2e5..62b6b890ed 100644 --- a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.h +++ b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.h @@ -7,7 +7,6 @@ #pragma once #include "AttributeValue.h" -#include "CompilationUnit.h" #include "DwarfTypes.h" #include #include @@ -15,16 +14,20 @@ #include #include #include +#include #include namespace Debug::Dwarf { +class CompilationUnit; + class DwarfInfo { AK_MAKE_NONCOPYABLE(DwarfInfo); AK_MAKE_NONMOVABLE(DwarfInfo); public: explicit DwarfInfo(ELF::Image const&); + ~DwarfInfo(); ReadonlyBytes debug_info_data() const { return m_debug_info_data; } ReadonlyBytes abbreviation_data() const { return m_abbreviation_data; } diff --git a/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp b/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp index 09d27bdf7d..29ff19e762 100644 --- a/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp +++ b/Userland/Libraries/LibDebug/Dwarf/LineProgram.cpp @@ -9,6 +9,7 @@ #include #include #include +#include namespace Debug::Dwarf { diff --git a/Userland/Libraries/LibDebug/Dwarf/LineProgram.h b/Userland/Libraries/LibDebug/Dwarf/LineProgram.h index 85e5e3ffdc..037b17f7b2 100644 --- a/Userland/Libraries/LibDebug/Dwarf/LineProgram.h +++ b/Userland/Libraries/LibDebug/Dwarf/LineProgram.h @@ -6,13 +6,15 @@ #pragma once -#include "DwarfInfo.h" #include #include #include +#include namespace Debug::Dwarf { +class DwarfInfo; + struct [[gnu::packed]] LineProgramUnitHeader32Common { u32 length; u16 version; -- cgit v1.2.3