diff options
author | Lucas CHOLLET <lucas.chollet@free.fr> | 2023-04-26 22:22:35 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-04-27 07:27:14 +0200 |
commit | 309a15e2aa218b53948e6acce329e9ba1d61402f (patch) | |
tree | 0b6cf60c7d6dc2267b7485c80deee70232c1515b /Userland/Libraries/LibSymbolication | |
parent | c50b0728522539a3db6dfdfabfa65be578102167 (diff) | |
download | serenity-309a15e2aa218b53948e6acce329e9ba1d61402f.zip |
LibSymbolication: Use `Core::File` instead of `Core::DeprecatedFile`
Diffstat (limited to 'Userland/Libraries/LibSymbolication')
-rw-r--r-- | Userland/Libraries/LibSymbolication/Symbolication.cpp | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/Userland/Libraries/LibSymbolication/Symbolication.cpp b/Userland/Libraries/LibSymbolication/Symbolication.cpp index 274c75aca6..f299ba1738 100644 --- a/Userland/Libraries/LibSymbolication/Symbolication.cpp +++ b/Userland/Libraries/LibSymbolication/Symbolication.cpp @@ -10,7 +10,7 @@ #include <AK/JsonObject.h> #include <AK/JsonValue.h> #include <AK/LexicalPath.h> -#include <LibCore/DeprecatedFile.h> +#include <LibCore/File.h> #include <LibCore/MappedFile.h> #include <LibDebug/DebugInfo.h> #include <LibFileSystem/FileSystem.h> @@ -38,12 +38,19 @@ static KernelBaseState s_kernel_base_state = KernelBaseState::Uninitialized; Optional<FlatPtr> kernel_base() { if (s_kernel_base_state == KernelBaseState::Uninitialized) { - auto file = Core::DeprecatedFile::open("/sys/kernel/constants/load_base", Core::OpenMode::ReadOnly); + auto file = Core::File::open("/sys/kernel/constants/load_base"sv, Core::File::OpenMode::Read); if (file.is_error()) { s_kernel_base_state = KernelBaseState::Invalid; return {}; } - auto kernel_base_str = DeprecatedString { file.value()->read_all(), NoChomp }; + + auto file_content = file.value()->read_until_eof(); + if (file_content.is_error()) { + s_kernel_base_state = KernelBaseState::Invalid; + return {}; + } + + auto kernel_base_str = DeprecatedString { file_content.value(), NoChomp }; using AddressType = u64; auto maybe_kernel_base = kernel_base_str.to_uint<AddressType>(); if (!maybe_kernel_base.has_value()) { @@ -148,13 +155,19 @@ Vector<Symbol> symbolicate_thread(pid_t pid, pid_t tid, IncludeSourcePosition in { auto stack_path = DeprecatedString::formatted("/proc/{}/stacks/{}", pid, tid); - auto file_or_error = Core::DeprecatedFile::open(stack_path, Core::OpenMode::ReadOnly); + auto file_or_error = Core::File::open(stack_path, Core::File::OpenMode::Read); if (file_or_error.is_error()) { warnln("Could not open {}: {}", stack_path, file_or_error.error()); return {}; } - auto json = JsonValue::from_string(file_or_error.value()->read_all()); + auto file_content = file_or_error.value()->read_until_eof(); + if (file_content.is_error()) { + warnln("Could not read {}: {}", stack_path, file_or_error.error()); + return {}; + } + + auto json = JsonValue::from_string(file_content.value()); if (json.is_error() || !json.value().is_array()) { warnln("Invalid contents in {}", stack_path); return {}; @@ -168,13 +181,19 @@ Vector<Symbol> symbolicate_thread(pid_t pid, pid_t tid, IncludeSourcePosition in { auto vm_path = DeprecatedString::formatted("/proc/{}/vm", pid); - auto file_or_error = Core::DeprecatedFile::open(vm_path, Core::OpenMode::ReadOnly); + auto file_or_error = Core::File::open(vm_path, Core::File::OpenMode::Read); if (file_or_error.is_error()) { warnln("Could not open {}: {}", vm_path, file_or_error.error()); return {}; } - auto json = JsonValue::from_string(file_or_error.value()->read_all()); + auto file_content = file_or_error.value()->read_until_eof(); + if (file_content.is_error()) { + warnln("Could not read {}: {}", vm_path, file_or_error.error()); + return {}; + } + + auto json = JsonValue::from_string(file_content.value()); if (json.is_error() || !json.value().is_array()) { warnln("Invalid contents in {}", vm_path); return {}; |