summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSymbolication
diff options
context:
space:
mode:
authorItamar <itamar8910@gmail.com>2021-06-18 14:31:03 +0300
committerAndreas Kling <kling@serenityos.org>2021-06-19 14:51:18 +0200
commite9e4358a935596e8d2ee77ce14952fcd502df935 (patch)
tree7b5e7f9e24180af08f8b50a92ab5e8acf51f772a /Userland/Libraries/LibSymbolication
parentedd79ddd00836fa48fb128dc7e5affd58de85090 (diff)
downloadserenity-e9e4358a935596e8d2ee77ce14952fcd502df935.zip
LibDebug: Store LibDebug objects on the heap & make them non-copyable
This fixes an issue were some LibDebug objects (for example, Dwarf::CompilationUnit) held a reference to their parent Dwarf::DwarfInfo object, which was constructed on the stack and later moved to the heap.
Diffstat (limited to 'Userland/Libraries/LibSymbolication')
-rw-r--r--Userland/Libraries/LibSymbolication/Symbolication.cpp9
1 files changed, 4 insertions, 5 deletions
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<MappedFile> mapped_file;
- Debug::DebugInfo debug_info;
+ NonnullOwnPtr<Debug::DebugInfo> debug_info;
};
static HashMap<String, OwnPtr<CachedELF>> s_cache;
@@ -36,8 +36,7 @@ Optional<Symbol> symbolicate(String const& path, u32 address)
s_cache.set(path, {});
{};
}
- Debug::DebugInfo debug_info(move(elf));
- auto cached_elf = make<CachedELF>(mapped_file.release_value(), move(debug_info));
+ auto cached_elf = make<CachedELF>(mapped_file.release_value(), make<Debug::DebugInfo>(move(elf)));
s_cache.set(path, move(cached_elf));
}
@@ -49,8 +48,8 @@ Optional<Symbol> 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()) {