mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
HackStudio: Add progress bar to Debugger initialization
During Debugger initialization, most of the time is spent creating DebugInfo objects for the libraries that the program has loaded.
This commit is contained in:
parent
0896c03744
commit
6e5b1f5819
5 changed files with 39 additions and 16 deletions
|
@ -17,10 +17,10 @@
|
|||
|
||||
namespace Debug {
|
||||
|
||||
DebugSession::DebugSession(pid_t pid, DeprecatedString source_root)
|
||||
DebugSession::DebugSession(pid_t pid, DeprecatedString source_root, Function<void(float)> on_initialization_progress)
|
||||
: m_debuggee_pid(pid)
|
||||
, m_source_root(source_root)
|
||||
|
||||
, m_on_initialization_progress(move(on_initialization_progress))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,8 @@ void DebugSession::for_each_loaded_library(Function<IterationDecision(LoadedLibr
|
|||
|
||||
OwnPtr<DebugSession> DebugSession::exec_and_attach(DeprecatedString const& command,
|
||||
DeprecatedString source_root,
|
||||
Function<ErrorOr<void>()> setup_child)
|
||||
Function<ErrorOr<void>()> setup_child,
|
||||
Function<void(float)> on_initialization_progress)
|
||||
{
|
||||
auto pid = fork();
|
||||
|
||||
|
@ -114,7 +115,7 @@ OwnPtr<DebugSession> DebugSession::exec_and_attach(DeprecatedString const& comma
|
|||
return {};
|
||||
}
|
||||
|
||||
auto debug_session = adopt_own(*new DebugSession(pid, source_root));
|
||||
auto debug_session = adopt_own(*new DebugSession(pid, source_root, move(on_initialization_progress)));
|
||||
|
||||
// Continue until breakpoint before entry point of main program
|
||||
int wstatus = debug_session->continue_debuggee_and_wait();
|
||||
|
@ -129,7 +130,7 @@ OwnPtr<DebugSession> DebugSession::exec_and_attach(DeprecatedString const& comma
|
|||
return debug_session;
|
||||
}
|
||||
|
||||
OwnPtr<DebugSession> DebugSession::attach(pid_t pid, DeprecatedString source_root)
|
||||
OwnPtr<DebugSession> DebugSession::attach(pid_t pid, DeprecatedString source_root, Function<void(float)> on_initialization_progress)
|
||||
{
|
||||
if (ptrace(PT_ATTACH, pid, 0, 0) < 0) {
|
||||
perror("PT_ATTACH");
|
||||
|
@ -142,7 +143,7 @@ OwnPtr<DebugSession> DebugSession::attach(pid_t pid, DeprecatedString source_roo
|
|||
return {};
|
||||
}
|
||||
|
||||
auto debug_session = adopt_own(*new DebugSession(pid, source_root));
|
||||
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();
|
||||
|
||||
|
@ -467,7 +468,17 @@ void DebugSession::update_loaded_libs()
|
|||
return DeprecatedString::formatted("/usr/lib/{}", lib_name);
|
||||
};
|
||||
|
||||
ScopeGuard progress_guard([this]() {
|
||||
m_on_initialization_progress(0);
|
||||
});
|
||||
|
||||
size_t vm_entry_index = 0;
|
||||
|
||||
vm_entries.for_each([&](auto& entry) {
|
||||
++vm_entry_index;
|
||||
if (m_on_initialization_progress)
|
||||
m_on_initialization_progress(vm_entry_index / static_cast<float>(vm_entries.size()));
|
||||
|
||||
// TODO: check that region is executable
|
||||
auto vm_name = entry.as_object().get_deprecated_string("name"sv).value();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue