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

LibCore+AK: Move MappedFile from AK to LibCore

MappedFile is strictly a userspace thing, so it doesn't belong in AK
(which is supposed to be user/kernel agnostic.)
This commit is contained in:
Andreas Kling 2021-11-23 11:32:25 +01:00
parent c1c9da6c35
commit 58fb3ebf66
48 changed files with 101 additions and 103 deletions

View file

@ -5,11 +5,11 @@
*/
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h>
#include <AK/Platform.h>
#include <AK/StringBuilder.h>
#include <AK/Types.h>
#include <LibCore/File.h>
#include <LibCore/MappedFile.h>
#include <LibCoredump/Backtrace.h>
#include <LibCoredump/Reader.h>
#include <LibELF/Core.h>
@ -30,7 +30,7 @@ ELFObjectInfo const* Backtrace::object_info_for_region(ELF::Core::MemoryRegionIn
if (!Core::File::exists(path))
return nullptr;
auto file_or_error = MappedFile::map(path);
auto file_or_error = Core::MappedFile::map(path);
if (file_or_error.is_error())
return nullptr;

View file

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

View file

@ -41,7 +41,7 @@ void Inspector::parse_loaded_libraries(Function<void(float)> on_progress)
if (on_progress)
on_progress(library_index / (float)number_of_libraries);
auto file_or_error = MappedFile::map(library.path);
auto file_or_error = Core::MappedFile::map(library.path);
if (file_or_error.is_error())
return;

View file

@ -17,7 +17,7 @@ namespace Coredump {
OwnPtr<Reader> Reader::create(StringView path)
{
auto file_or_error = MappedFile::map(path);
auto file_or_error = Core::MappedFile::map(path);
if (file_or_error.is_error())
return {};
@ -38,7 +38,7 @@ Reader::Reader(ByteBuffer buffer)
m_coredump_buffer = move(buffer);
}
Reader::Reader(NonnullRefPtr<MappedFile> file)
Reader::Reader(NonnullRefPtr<Core::MappedFile> file)
: Reader(file->bytes())
{
m_mapped_file = move(file);
@ -261,7 +261,6 @@ HashMap<String, String> Reader::metadata() const
struct LibraryData {
String name;
OwnPtr<MappedFile> file;
ELF::Image lib_elf;
};
@ -282,7 +281,7 @@ const Reader::LibraryData* Reader::library_containing(FlatPtr address) const
}
if (!cached_libs.contains(path)) {
auto file_or_error = MappedFile::map(path);
auto file_or_error = Core::MappedFile::map(path);
if (file_or_error.is_error())
return {};
auto image = ELF::Image(file_or_error.value()->bytes());

View file

@ -7,9 +7,9 @@
#pragma once
#include <AK/HashMap.h>
#include <AK/MappedFile.h>
#include <AK/Noncopyable.h>
#include <AK/OwnPtr.h>
#include <LibCore/MappedFile.h>
#include <LibELF/Core.h>
#include <LibELF/Image.h>
@ -46,7 +46,7 @@ public:
struct LibraryData {
String name;
FlatPtr base_address { 0 };
NonnullRefPtr<MappedFile> file;
NonnullRefPtr<Core::MappedFile> file;
ELF::Image lib_elf;
};
const LibraryData* library_containing(FlatPtr address) const;
@ -61,7 +61,7 @@ public:
private:
explicit Reader(ReadonlyBytes);
explicit Reader(ByteBuffer);
explicit Reader(NonnullRefPtr<MappedFile>);
explicit Reader(NonnullRefPtr<Core::MappedFile>);
static Optional<ByteBuffer> decompress_coredump(ReadonlyBytes);
@ -86,7 +86,7 @@ private:
const JsonObject process_info() const;
// For uncompressed coredumps, we keep the MappedFile
RefPtr<MappedFile> m_mapped_file;
RefPtr<Core::MappedFile> m_mapped_file;
// For compressed coredumps, we decompress them into a ByteBuffer
ByteBuffer m_coredump_buffer;