mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-02 04:27:12 +02:00
HackStudio+LibDebug: Support stopping a debugged process
In LibDebug this required implementing the Kill debug action, and in HackStudio this required making the toolbar's stop action stop the debugger if active.
This commit is contained in:
Notes:
sideshowbarker
2024-07-18 19:18:44 +09:00
Author: https://github.com/FalseHonesty Commit: https://github.com/SerenityOS/serenity/commit/58d6781cbbe Pull-request: https://github.com/SerenityOS/serenity/pull/6299 Issue: https://github.com/SerenityOS/serenity/issues/4393 Reviewed-by: https://github.com/itamar8910 ✅
@@ -626,6 +626,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_debug_action()
|
||||
Debugger::the().set_executable_path(get_project_executable_path());
|
||||
m_debugger_thread = LibThread::Thread::construct(Debugger::start_static);
|
||||
m_debugger_thread->start();
|
||||
m_stop_action->set_enabled(true);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -662,16 +663,19 @@ void HackStudioWidget::initialize_debugger()
|
||||
[this]() {
|
||||
Core::EventLoop::main().post_event(*window(), make<Core::DeferredInvocationEvent>([this](auto&) {
|
||||
m_debug_info_widget->set_debug_actions_enabled(false);
|
||||
if (m_current_editor_in_execution) {
|
||||
if (m_current_editor_in_execution)
|
||||
m_current_editor_in_execution->editor().clear_execution_position();
|
||||
}
|
||||
}));
|
||||
Core::EventLoop::wake();
|
||||
},
|
||||
[this]() {
|
||||
Core::EventLoop::main().post_event(*window(), make<Core::DeferredInvocationEvent>([this](auto&) {
|
||||
m_debug_info_widget->set_debug_actions_enabled(false);
|
||||
if (m_current_editor_in_execution)
|
||||
m_current_editor_in_execution->editor().clear_execution_position();
|
||||
m_debug_info_widget->program_stopped();
|
||||
m_disassembly_widget->program_stopped();
|
||||
m_stop_action->set_enabled(false);
|
||||
HackStudioWidget::hide_action_tabs();
|
||||
GUI::MessageBox::show(window(), "Program Exited", "Debugger", GUI::MessageBox::Type::Information);
|
||||
}));
|
||||
@@ -1060,7 +1064,12 @@ void HackStudioWidget::create_help_menubar(GUI::Menubar& menubar)
|
||||
NonnullRefPtr<GUI::Action> HackStudioWidget::create_stop_action()
|
||||
{
|
||||
auto action = GUI::Action::create("&Stop", Gfx::Bitmap::load_from_file("/res/icons/16x16/program-stop.png"), [this](auto&) {
|
||||
m_terminal_wrapper->kill_running_command();
|
||||
if (!Debugger::the().session()) {
|
||||
m_terminal_wrapper->kill_running_command();
|
||||
return;
|
||||
}
|
||||
|
||||
Debugger::the().stop();
|
||||
});
|
||||
|
||||
action->set_enabled(false);
|
||||
@@ -1089,7 +1098,7 @@ void HackStudioWidget::initialize_menubar(GUI::Menubar& menubar)
|
||||
HackStudioWidget::~HackStudioWidget()
|
||||
{
|
||||
if (!m_debugger_thread.is_null()) {
|
||||
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::Exit);
|
||||
Debugger::the().stop();
|
||||
dbgln("Waiting for debugger thread to terminate");
|
||||
auto rc = m_debugger_thread->join();
|
||||
if (rc.is_error()) {
|
||||
|
||||
Reference in New Issue
Block a user