mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:57:34 +00:00
LibDebug: Prefer File::read_until_eof over DeprecatedFile
This commit is contained in:
parent
f9a24eb7eb
commit
9474e0cd94
2 changed files with 18 additions and 10 deletions
|
@ -10,7 +10,6 @@
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
#include <AK/Optional.h>
|
#include <AK/Optional.h>
|
||||||
#include <AK/Platform.h>
|
#include <AK/Platform.h>
|
||||||
#include <LibCore/DeprecatedFile.h>
|
|
||||||
#include <LibFileSystem/FileSystem.h>
|
#include <LibFileSystem/FileSystem.h>
|
||||||
#include <LibRegex/Regex.h>
|
#include <LibRegex/Regex.h>
|
||||||
#include <stdlib.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
|
// 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;
|
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)));
|
auto debug_session = adopt_own(*new DebugSession(pid, source_root, move(on_initialization_progress)));
|
||||||
// At this point, libraries should have been loaded
|
// 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;
|
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 };
|
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));
|
auto file_name = TRY(String::formatted("/proc/{}/vm", m_debuggee_pid));
|
||||||
bool rc = file->open(Core::OpenMode::ReadOnly);
|
auto file = TRY(Core::File::open(file_name, Core::File::OpenMode::Read));
|
||||||
VERIFY(rc);
|
|
||||||
|
|
||||||
auto file_contents = file->read_all();
|
auto file_contents = TRY(file->read_until_eof());
|
||||||
auto json = JsonValue::from_string(file_contents).release_value_but_fixme_should_propagate_errors();
|
auto json = TRY(JsonValue::from_string(file_contents));
|
||||||
|
|
||||||
auto const& vm_entries = json.as_array();
|
auto const& vm_entries = json.as_array();
|
||||||
Regex<PosixExtended> segment_name_re("(.+): ");
|
Regex<PosixExtended> segment_name_re("(.+): ");
|
||||||
|
@ -509,6 +515,8 @@ void DebugSession::update_loaded_libs()
|
||||||
|
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebugSession::stop_debuggee()
|
void DebugSession::stop_debuggee()
|
||||||
|
|
|
@ -137,7 +137,7 @@ private:
|
||||||
// x86 breakpoint instruction "int3"
|
// x86 breakpoint instruction "int3"
|
||||||
static constexpr u8 BREAKPOINT_INSTRUCTION = 0xcc;
|
static constexpr u8 BREAKPOINT_INSTRUCTION = 0xcc;
|
||||||
|
|
||||||
void update_loaded_libs();
|
ErrorOr<void> update_loaded_libs();
|
||||||
|
|
||||||
int m_debuggee_pid { -1 };
|
int m_debuggee_pid { -1 };
|
||||||
DeprecatedString m_source_root;
|
DeprecatedString m_source_root;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue