diff --git a/Userland/Libraries/LibCoreDump/Backtrace.cpp b/Userland/Libraries/LibCoreDump/Backtrace.cpp index 2c0b46af8d..52378e33d0 100644 --- a/Userland/Libraries/LibCoreDump/Backtrace.cpp +++ b/Userland/Libraries/LibCoreDump/Backtrace.cpp @@ -42,7 +42,7 @@ static const ELFObjectInfo* object_info_for_region(const ELF::Core::MemoryRegion return nullptr; auto image = make(file_or_error.value()->bytes()); - auto info = make(file_or_error.release_value(), Debug::DebugInfo { move(image) }); + auto info = make(file_or_error.release_value(), make(move(image))); auto* info_ptr = info.ptr(); s_debug_info_cache.set(path, move(info)); return info_ptr; diff --git a/Userland/Libraries/LibCoreDump/Backtrace.h b/Userland/Libraries/LibCoreDump/Backtrace.h index 82bdc4492e..32b32d0c28 100644 --- a/Userland/Libraries/LibCoreDump/Backtrace.h +++ b/Userland/Libraries/LibCoreDump/Backtrace.h @@ -14,14 +14,14 @@ namespace CoreDump { struct ELFObjectInfo { - ELFObjectInfo(NonnullRefPtr file, Debug::DebugInfo&& debug_info) + ELFObjectInfo(NonnullRefPtr file, NonnullOwnPtr&& debug_info) : file(move(file)) , debug_info(move(debug_info)) { } NonnullRefPtr file; - Debug::DebugInfo debug_info; + NonnullOwnPtr debug_info; }; class Backtrace { diff --git a/Userland/Libraries/LibDebug/DebugInfo.h b/Userland/Libraries/LibDebug/DebugInfo.h index be93e03ea8..3922729b4a 100644 --- a/Userland/Libraries/LibDebug/DebugInfo.h +++ b/Userland/Libraries/LibDebug/DebugInfo.h @@ -20,6 +20,9 @@ namespace Debug { class DebugInfo { + AK_MAKE_NONCOPYABLE(DebugInfo); + AK_MAKE_NONMOVABLE(DebugInfo); + public: explicit DebugInfo(NonnullOwnPtr, String source_root = {}, FlatPtr base_address = 0); diff --git a/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.h b/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.h index 9d54dc20c6..4cda34d9b7 100644 --- a/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.h +++ b/Userland/Libraries/LibDebug/Dwarf/CompilationUnit.h @@ -7,6 +7,7 @@ #pragma once #include "AbbreviationsMap.h" +#include #include namespace Debug::Dwarf { @@ -15,6 +16,9 @@ class DwarfInfo; class DIE; class CompilationUnit { + AK_MAKE_NONCOPYABLE(CompilationUnit); + AK_MAKE_NONMOVABLE(CompilationUnit); + public: CompilationUnit(const DwarfInfo& dwarf_info, u32 offset, const CompilationUnitHeader&); diff --git a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp index fa238c88fa..3c2781211c 100644 --- a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp +++ b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.cpp @@ -44,7 +44,7 @@ void DwarfInfo::populate_compilation_units() VERIFY(compilation_unit_header.address_size() == sizeof(u32)); u32 length_after_header = compilation_unit_header.length() - (compilation_unit_header.header_size() - offsetof(CompilationUnitHeader, common.version)); - m_compilation_units.empend(*this, unit_offset, compilation_unit_header); + m_compilation_units.append(make(*this, unit_offset, compilation_unit_header)); stream.discard_or_error(length_after_header); } } diff --git a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.h b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.h index 5942a2acad..477fed0471 100644 --- a/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.h +++ b/Userland/Libraries/LibDebug/Dwarf/DwarfInfo.h @@ -19,6 +19,9 @@ namespace Debug::Dwarf { class DwarfInfo { + AK_MAKE_NONCOPYABLE(DwarfInfo); + AK_MAKE_NONMOVABLE(DwarfInfo); + public: explicit DwarfInfo(const ELF::Image&); @@ -44,7 +47,7 @@ private: ReadonlyBytes m_debug_strings_data; ReadonlyBytes m_debug_line_strings_data; - Vector m_compilation_units; + NonnullOwnPtrVector m_compilation_units; }; template diff --git a/Userland/Libraries/LibSymbolication/Symbolication.cpp b/Userland/Libraries/LibSymbolication/Symbolication.cpp index c9676ca536..9964684364 100644 --- a/Userland/Libraries/LibSymbolication/Symbolication.cpp +++ b/Userland/Libraries/LibSymbolication/Symbolication.cpp @@ -16,7 +16,7 @@ namespace Symbolication { struct CachedELF { NonnullRefPtr mapped_file; - Debug::DebugInfo debug_info; + NonnullOwnPtr debug_info; }; static HashMap> s_cache; @@ -36,8 +36,7 @@ Optional symbolicate(String const& path, u32 address) s_cache.set(path, {}); {}; } - Debug::DebugInfo debug_info(move(elf)); - auto cached_elf = make(mapped_file.release_value(), move(debug_info)); + auto cached_elf = make(mapped_file.release_value(), make(move(elf))); s_cache.set(path, move(cached_elf)); } @@ -49,8 +48,8 @@ Optional symbolicate(String const& path, u32 address) return {}; u32 offset = 0; - auto symbol = cached_elf->debug_info.elf().symbolicate(address, &offset); - auto source_position = cached_elf->debug_info.get_source_position(address); + auto symbol = cached_elf->debug_info->elf().symbolicate(address, &offset); + auto source_position = cached_elf->debug_info->get_source_position(address); String filename; u32 line_number = 0; if (source_position.has_value()) {