1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:07:34 +00:00

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.
This commit is contained in:
Itamar 2021-06-18 14:31:03 +03:00 committed by Andreas Kling
parent edd79ddd00
commit e9e4358a93
7 changed files with 19 additions and 10 deletions

View file

@ -42,7 +42,7 @@ static const ELFObjectInfo* object_info_for_region(const ELF::Core::MemoryRegion
return nullptr;
auto image = make<ELF::Image>(file_or_error.value()->bytes());
auto info = make<ELFObjectInfo>(file_or_error.release_value(), Debug::DebugInfo { move(image) });
auto info = make<ELFObjectInfo>(file_or_error.release_value(), make<Debug::DebugInfo>(move(image)));
auto* info_ptr = info.ptr();
s_debug_info_cache.set(path, move(info));
return info_ptr;

View file

@ -14,14 +14,14 @@
namespace CoreDump {
struct ELFObjectInfo {
ELFObjectInfo(NonnullRefPtr<MappedFile> file, Debug::DebugInfo&& debug_info)
ELFObjectInfo(NonnullRefPtr<MappedFile> file, NonnullOwnPtr<Debug::DebugInfo>&& debug_info)
: file(move(file))
, debug_info(move(debug_info))
{
}
NonnullRefPtr<MappedFile> file;
Debug::DebugInfo debug_info;
NonnullOwnPtr<Debug::DebugInfo> debug_info;
};
class Backtrace {