mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 18:47:41 +00:00
HackStudio: Move debugger actions to a toolbar in the debug widget
This commit is contained in:
parent
dd9d5d6c72
commit
f5aa0988f5
3 changed files with 58 additions and 28 deletions
|
@ -32,6 +32,7 @@
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/BoxLayout.h>
|
#include <LibGUI/BoxLayout.h>
|
||||||
#include <LibGUI/InputBox.h>
|
#include <LibGUI/InputBox.h>
|
||||||
|
#include <LibGUI/Layout.h>
|
||||||
#include <LibGUI/ListView.h>
|
#include <LibGUI/ListView.h>
|
||||||
#include <LibGUI/Menu.h>
|
#include <LibGUI/Menu.h>
|
||||||
#include <LibGUI/Model.h>
|
#include <LibGUI/Model.h>
|
||||||
|
@ -40,10 +41,38 @@
|
||||||
|
|
||||||
namespace HackStudio {
|
namespace HackStudio {
|
||||||
|
|
||||||
|
void DebugInfoWidget::init_toolbar()
|
||||||
|
{
|
||||||
|
m_continue_action = GUI::Action::create("Continue", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-continue.png"), [&](auto&) {
|
||||||
|
pthread_mutex_lock(Debugger::the().continue_mutex());
|
||||||
|
Debugger::the().set_continue_type(Debugger::ContinueType::Continue);
|
||||||
|
pthread_cond_signal(Debugger::the().continue_cond());
|
||||||
|
pthread_mutex_unlock(Debugger::the().continue_mutex());
|
||||||
|
});
|
||||||
|
|
||||||
|
m_singlestep_action = GUI::Action::create("Single Step", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-single-step.png"), [&](auto&) {
|
||||||
|
pthread_mutex_lock(Debugger::the().continue_mutex());
|
||||||
|
Debugger::the().set_continue_type(Debugger::ContinueType::SourceSingleStep);
|
||||||
|
pthread_cond_signal(Debugger::the().continue_cond());
|
||||||
|
pthread_mutex_unlock(Debugger::the().continue_mutex());
|
||||||
|
});
|
||||||
|
m_continue_action->set_enabled(false);
|
||||||
|
m_singlestep_action->set_enabled(false);
|
||||||
|
|
||||||
|
m_toolbar->add_action(*m_continue_action);
|
||||||
|
m_toolbar->add_action(*m_singlestep_action);
|
||||||
|
}
|
||||||
|
|
||||||
DebugInfoWidget::DebugInfoWidget()
|
DebugInfoWidget::DebugInfoWidget()
|
||||||
{
|
{
|
||||||
set_layout<GUI::HorizontalBoxLayout>();
|
set_layout<GUI::VerticalBoxLayout>();
|
||||||
auto& splitter = add<GUI::HorizontalSplitter>();
|
auto& toolbar_container = add<GUI::ToolBarContainer>();
|
||||||
|
m_toolbar = toolbar_container.add<GUI::ToolBar>();
|
||||||
|
init_toolbar();
|
||||||
|
auto& bottom_box = add<GUI::Widget>();
|
||||||
|
bottom_box.set_layout<GUI::HorizontalBoxLayout>();
|
||||||
|
|
||||||
|
auto& splitter = bottom_box.add<GUI::HorizontalSplitter>();
|
||||||
m_backtrace_view = splitter.add<GUI::ListView>();
|
m_backtrace_view = splitter.add<GUI::ListView>();
|
||||||
m_variables_view = splitter.add<GUI::TreeView>();
|
m_variables_view = splitter.add<GUI::TreeView>();
|
||||||
|
|
||||||
|
@ -111,4 +140,16 @@ void DebugInfoWidget::program_stopped()
|
||||||
m_variables_view->set_model({});
|
m_variables_view->set_model({});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GUI::Action& DebugInfoWidget::continue_action()
|
||||||
|
{
|
||||||
|
ASSERT(m_continue_action);
|
||||||
|
return *m_continue_action;
|
||||||
|
}
|
||||||
|
|
||||||
|
GUI::Action& DebugInfoWidget::singlestep_action()
|
||||||
|
{
|
||||||
|
ASSERT(m_singlestep_action);
|
||||||
|
return *m_singlestep_action;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,11 @@
|
||||||
|
|
||||||
#include "Debugger.h"
|
#include "Debugger.h"
|
||||||
#include <AK/NonnullOwnPtr.h>
|
#include <AK/NonnullOwnPtr.h>
|
||||||
|
#include <LibGUI/Action.h>
|
||||||
#include <LibGUI/ListView.h>
|
#include <LibGUI/ListView.h>
|
||||||
#include <LibGUI/Model.h>
|
#include <LibGUI/Model.h>
|
||||||
|
#include <LibGUI/ToolBar.h>
|
||||||
|
#include <LibGUI/ToolBarContainer.h>
|
||||||
#include <LibGUI/Widget.h>
|
#include <LibGUI/Widget.h>
|
||||||
#include <sys/arch/i386/regs.h>
|
#include <sys/arch/i386/regs.h>
|
||||||
|
|
||||||
|
@ -38,17 +41,24 @@ namespace HackStudio {
|
||||||
class DebugInfoWidget final : public GUI::Widget {
|
class DebugInfoWidget final : public GUI::Widget {
|
||||||
C_OBJECT(DebugInfoWidget)
|
C_OBJECT(DebugInfoWidget)
|
||||||
public:
|
public:
|
||||||
virtual ~DebugInfoWidget() override { }
|
virtual ~DebugInfoWidget() override {}
|
||||||
|
|
||||||
void update_state(const DebugSession&, const PtraceRegisters&);
|
void update_state(const DebugSession&, const PtraceRegisters&);
|
||||||
void program_stopped();
|
void program_stopped();
|
||||||
|
|
||||||
|
GUI::Action& continue_action();
|
||||||
|
GUI::Action& singlestep_action();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit DebugInfoWidget();
|
explicit DebugInfoWidget();
|
||||||
|
void init_toolbar();
|
||||||
|
|
||||||
RefPtr<GUI::TreeView> m_variables_view;
|
RefPtr<GUI::TreeView> m_variables_view;
|
||||||
RefPtr<GUI::ListView> m_backtrace_view;
|
RefPtr<GUI::ListView> m_backtrace_view;
|
||||||
RefPtr<GUI::Menu> m_variable_context_menu;
|
RefPtr<GUI::Menu> m_variable_context_menu;
|
||||||
|
RefPtr<GUI::ToolBar> m_toolbar;
|
||||||
|
RefPtr<GUI::Action> m_continue_action;
|
||||||
|
RefPtr<GUI::Action> m_singlestep_action;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -608,29 +608,8 @@ int main_impl(int argc, char** argv)
|
||||||
debugger_thread->start();
|
debugger_thread->start();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto continue_action = GUI::Action::create("Continue", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-continue.png"), [&](auto&) {
|
|
||||||
pthread_mutex_lock(Debugger::the().continue_mutex());
|
|
||||||
Debugger::the().set_continue_type(Debugger::ContinueType::Continue);
|
|
||||||
pthread_cond_signal(Debugger::the().continue_cond());
|
|
||||||
pthread_mutex_unlock(Debugger::the().continue_mutex());
|
|
||||||
});
|
|
||||||
|
|
||||||
auto single_step_action = GUI::Action::create("Single Step", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-single-step.png"), [&](auto&) {
|
|
||||||
pthread_mutex_lock(Debugger::the().continue_mutex());
|
|
||||||
Debugger::the().set_continue_type(Debugger::ContinueType::SourceSingleStep);
|
|
||||||
pthread_cond_signal(Debugger::the().continue_cond());
|
|
||||||
pthread_mutex_unlock(Debugger::the().continue_mutex());
|
|
||||||
});
|
|
||||||
continue_action->set_enabled(false);
|
|
||||||
single_step_action->set_enabled(false);
|
|
||||||
|
|
||||||
toolbar.add_action(run_action);
|
|
||||||
toolbar.add_action(stop_action);
|
|
||||||
|
|
||||||
toolbar.add_separator();
|
toolbar.add_separator();
|
||||||
toolbar.add_action(debug_action);
|
toolbar.add_action(debug_action);
|
||||||
toolbar.add_action(continue_action);
|
|
||||||
toolbar.add_action(single_step_action);
|
|
||||||
|
|
||||||
RefPtr<EditorWrapper> current_editor_in_execution;
|
RefPtr<EditorWrapper> current_editor_in_execution;
|
||||||
Debugger::initialize(
|
Debugger::initialize(
|
||||||
|
@ -652,8 +631,8 @@ int main_impl(int argc, char** argv)
|
||||||
current_editor_in_execution = get_editor_of_file(source_position.value().file_path);
|
current_editor_in_execution = get_editor_of_file(source_position.value().file_path);
|
||||||
current_editor_in_execution->editor().set_execution_position(source_position.value().line_number - 1);
|
current_editor_in_execution->editor().set_execution_position(source_position.value().line_number - 1);
|
||||||
debug_info_widget.update_state(*Debugger::the().session(), regs);
|
debug_info_widget.update_state(*Debugger::the().session(), regs);
|
||||||
continue_action->set_enabled(true);
|
debug_info_widget.continue_action().set_enabled(true);
|
||||||
single_step_action->set_enabled(true);
|
debug_info_widget.singlestep_action().set_enabled(true);
|
||||||
reveal_action_tab(debug_info_widget);
|
reveal_action_tab(debug_info_widget);
|
||||||
}));
|
}));
|
||||||
Core::EventLoop::wake();
|
Core::EventLoop::wake();
|
||||||
|
@ -663,8 +642,8 @@ int main_impl(int argc, char** argv)
|
||||||
[&]() {
|
[&]() {
|
||||||
dbg() << "Program continued";
|
dbg() << "Program continued";
|
||||||
Core::EventLoop::main().post_event(*g_window, make<Core::DeferredInvocationEvent>([&](auto&) {
|
Core::EventLoop::main().post_event(*g_window, make<Core::DeferredInvocationEvent>([&](auto&) {
|
||||||
continue_action->set_enabled(false);
|
debug_info_widget.continue_action().set_enabled(false);
|
||||||
single_step_action->set_enabled(false);
|
debug_info_widget.singlestep_action().set_enabled(false);
|
||||||
if (current_editor_in_execution) {
|
if (current_editor_in_execution) {
|
||||||
current_editor_in_execution->editor().clear_execution_position();
|
current_editor_in_execution->editor().clear_execution_position();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue