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

LibCore: Make MappedFile OwnPtr-based

Since it will become a stream in a little bit, it should behave like all
non-trivial stream classes, who are not primarily intended to have
shared ownership to make closing behavior more predictable. Across all
uses of MappedFile, there is only one use case of shared mapped files in
LibVideo, which now uses the thin SharedMappedFile wrapper.
This commit is contained in:
kleines Filmröllchen 2023-09-26 00:54:34 +02:00 committed by Tim Schumacher
parent 5b2496e522
commit 062e0db46c
32 changed files with 80 additions and 64 deletions

View file

@ -15,14 +15,14 @@
namespace Coredump {
struct ELFObjectInfo {
ELFObjectInfo(NonnullRefPtr<Core::MappedFile> file, NonnullOwnPtr<Debug::DebugInfo>&& debug_info, NonnullOwnPtr<ELF::Image> image)
ELFObjectInfo(NonnullOwnPtr<Core::MappedFile> file, NonnullOwnPtr<Debug::DebugInfo>&& debug_info, NonnullOwnPtr<ELF::Image> image)
: file(move(file))
, debug_info(move(debug_info))
, image(move(image))
{
}
NonnullRefPtr<Core::MappedFile> file;
NonnullOwnPtr<Core::MappedFile> file;
NonnullOwnPtr<Debug::DebugInfo> debug_info;
NonnullOwnPtr<ELF::Image> image;
};

View file

@ -47,7 +47,7 @@ void Inspector::parse_loaded_libraries(Function<void(float)> on_progress)
auto image = make<ELF::Image>(file_or_error.value()->bytes());
auto debug_info = make<Debug::DebugInfo>(*image, DeprecatedString {}, library.base_address);
m_loaded_libraries.append(make<Debug::LoadedLibrary>(library.name, file_or_error.value(), move(image), move(debug_info), library.base_address));
m_loaded_libraries.append(make<Debug::LoadedLibrary>(library.name, file_or_error.release_value(), move(image), move(debug_info), library.base_address));
});
}

View file

@ -43,7 +43,7 @@ Reader::Reader(ByteBuffer buffer)
m_coredump_buffer = move(buffer);
}
Reader::Reader(NonnullRefPtr<Core::MappedFile> file)
Reader::Reader(NonnullOwnPtr<Core::MappedFile> file)
: Reader(file->bytes())
{
m_mapped_file = move(file);

View file

@ -66,7 +66,7 @@ public:
struct LibraryData {
DeprecatedString name;
FlatPtr base_address { 0 };
NonnullRefPtr<Core::MappedFile> file;
NonnullOwnPtr<Core::MappedFile> file;
ELF::Image lib_elf;
};
LibraryData const* library_containing(FlatPtr address) const;
@ -83,7 +83,7 @@ public:
private:
explicit Reader(ReadonlyBytes);
explicit Reader(ByteBuffer);
explicit Reader(NonnullRefPtr<Core::MappedFile>);
explicit Reader(NonnullOwnPtr<Core::MappedFile>);
static Optional<ByteBuffer> decompress_coredump(ReadonlyBytes);
@ -108,7 +108,7 @@ private:
const JsonObject process_info() const;
// For uncompressed coredumps, we keep the MappedFile
RefPtr<Core::MappedFile> m_mapped_file;
OwnPtr<Core::MappedFile> m_mapped_file;
// For compressed coredumps, we decompress them into a ByteBuffer
ByteBuffer m_coredump_buffer;