mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-19 17:27:51 +03:00
LibDebug: Prefer File::read_until_eof over DeprecatedFile
This commit is contained in:
parent
f9a24eb7eb
commit
9474e0cd94
Notes:
sideshowbarker
2024-07-17 02:39:10 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/9474e0cd94 Pull-request: https://github.com/SerenityOS/serenity/pull/18844 Reviewed-by: https://github.com/LucasChollet Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/gmta ✅ Reviewed-by: https://github.com/krkk
@ -10,7 +10,6 @@
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/Platform.h>
|
||||
#include <LibCore/DeprecatedFile.h>
|
||||
#include <LibFileSystem/FileSystem.h>
|
||||
#include <LibRegex/Regex.h>
|
||||
#include <stdlib.h>
|
||||
@ -126,7 +125,11 @@ OwnPtr<DebugSession> DebugSession::exec_and_attach(DeprecatedString const& comma
|
||||
}
|
||||
|
||||
// At this point, libraries should have been loaded
|
||||
debug_session->update_loaded_libs();
|
||||
auto update_or_error = debug_session->update_loaded_libs();
|
||||
if (update_or_error.is_error()) {
|
||||
dbgln("update failed: {}", update_or_error.error());
|
||||
return {};
|
||||
}
|
||||
|
||||
return debug_session;
|
||||
}
|
||||
@ -146,7 +149,11 @@ OwnPtr<DebugSession> DebugSession::attach(pid_t pid, DeprecatedString source_roo
|
||||
|
||||
auto debug_session = adopt_own(*new DebugSession(pid, source_root, move(on_initialization_progress)));
|
||||
// At this point, libraries should have been loaded
|
||||
debug_session->update_loaded_libs();
|
||||
auto update_or_error = debug_session->update_loaded_libs();
|
||||
if (update_or_error.is_error()) {
|
||||
dbgln("update failed: {}", update_or_error.error());
|
||||
return {};
|
||||
}
|
||||
|
||||
return debug_session;
|
||||
}
|
||||
@ -444,14 +451,13 @@ Optional<DebugSession::InsertBreakpointAtSourcePositionResult> DebugSession::ins
|
||||
return InsertBreakpointAtSourcePositionResult { lib->name, address_and_source_position.value().file, address_and_source_position.value().line, address };
|
||||
}
|
||||
|
||||
void DebugSession::update_loaded_libs()
|
||||
ErrorOr<void> DebugSession::update_loaded_libs()
|
||||
{
|
||||
auto file = Core::DeprecatedFile::construct(DeprecatedString::formatted("/proc/{}/vm", m_debuggee_pid));
|
||||
bool rc = file->open(Core::OpenMode::ReadOnly);
|
||||
VERIFY(rc);
|
||||
auto file_name = TRY(String::formatted("/proc/{}/vm", m_debuggee_pid));
|
||||
auto file = TRY(Core::File::open(file_name, Core::File::OpenMode::Read));
|
||||
|
||||
auto file_contents = file->read_all();
|
||||
auto json = JsonValue::from_string(file_contents).release_value_but_fixme_should_propagate_errors();
|
||||
auto file_contents = TRY(file->read_until_eof());
|
||||
auto json = TRY(JsonValue::from_string(file_contents));
|
||||
|
||||
auto const& vm_entries = json.as_array();
|
||||
Regex<PosixExtended> segment_name_re("(.+): ");
|
||||
@ -509,6 +515,8 @@ void DebugSession::update_loaded_libs()
|
||||
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void DebugSession::stop_debuggee()
|
||||
|
@ -137,7 +137,7 @@ private:
|
||||
// x86 breakpoint instruction "int3"
|
||||
static constexpr u8 BREAKPOINT_INSTRUCTION = 0xcc;
|
||||
|
||||
void update_loaded_libs();
|
||||
ErrorOr<void> update_loaded_libs();
|
||||
|
||||
int m_debuggee_pid { -1 };
|
||||
DeprecatedString m_source_root;
|
||||
|
Loading…
Reference in New Issue
Block a user