diff options
-rw-r--r-- | DevTools/HackStudio/Debugger/DebugInfoWidget.cpp | 13 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/DisassemblyWidget.cpp | 1 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/RegistersModel.cpp | 29 | ||||
-rw-r--r-- | DevTools/HackStudio/Debugger/RegistersModel.h | 10 |
4 files changed, 49 insertions, 4 deletions
diff --git a/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp b/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp index 15b3288512..60131f10bb 100644 --- a/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp +++ b/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp @@ -52,21 +52,21 @@ void DebugInfoWidget::init_toolbar() pthread_mutex_unlock(Debugger::the().continue_mutex()); }); - m_singlestep_action = GUI::Action::create("Step Over", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-step-over.png"), [&](auto&) { + m_singlestep_action = GUI::Action::create("Step Over", { Mod_None, Key_F10 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-step-over.png"), [&](auto&) { pthread_mutex_lock(Debugger::the().continue_mutex()); Debugger::the().set_continue_type(Debugger::ContinueType::SourceStepOver); pthread_cond_signal(Debugger::the().continue_cond()); pthread_mutex_unlock(Debugger::the().continue_mutex()); }); - m_step_in_action = GUI::Action::create("Step In", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-step-in.png"), [&](auto&) { + m_step_in_action = GUI::Action::create("Step In", { Mod_None, Key_F11 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-step-in.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_step_out_action = GUI::Action::create("Step Out", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-step-out.png"), [&](auto&) { + m_step_out_action = GUI::Action::create("Step Out", { Mod_Shift, Key_F11 },Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-step-out.png"), [&](auto&) { pthread_mutex_lock(Debugger::the().continue_mutex()); Debugger::the().set_continue_type(Debugger::ContinueType::SourceStepOut); pthread_cond_signal(Debugger::the().continue_cond()); @@ -168,7 +168,12 @@ void DebugInfoWidget::update_state(const Debug::DebugSession& debug_session, con { m_variables_view->set_model(VariablesModel::create(regs)); m_backtrace_view->set_model(BacktraceModel::create(debug_session, regs)); - m_registers_view->set_model(RegistersModel::create(regs)); + if (m_registers_view->model()) { + auto& previous_registers = static_cast<RegistersModel*>(m_registers_view->model())->raw_registers(); + m_registers_view->set_model(RegistersModel::create(regs, previous_registers)); + } else { + m_registers_view->set_model(RegistersModel::create(regs)); + } auto selected_index = m_backtrace_view->model()->index(0); if (!selected_index.is_valid()) { dbg() << "Warning: DebugInfoWidget: backtrace selected index is invalid"; diff --git a/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp b/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp index eec5aaefd5..69395a5c10 100644 --- a/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp +++ b/DevTools/HackStudio/Debugger/DisassemblyWidget.cpp @@ -81,6 +81,7 @@ void DisassemblyWidget::program_stopped() { m_disassembly_view->set_model({}); m_function_name_label->set_text(""); + hide_disassembly("Program isn't running"); } void DisassemblyWidget::show_disassembly() diff --git a/DevTools/HackStudio/Debugger/RegistersModel.cpp b/DevTools/HackStudio/Debugger/RegistersModel.cpp index 9eae341317..0474bc1fd1 100644 --- a/DevTools/HackStudio/Debugger/RegistersModel.cpp +++ b/DevTools/HackStudio/Debugger/RegistersModel.cpp @@ -29,6 +29,7 @@ namespace HackStudio { RegistersModel::RegistersModel(const PtraceRegisters& regs) + : m_raw_registers(regs) { m_registers.append({ "eax", regs.eax }); m_registers.append({ "ebx", regs.ebx }); @@ -48,6 +49,27 @@ RegistersModel::RegistersModel(const PtraceRegisters& regs) m_registers.append({ "gs", regs.gs }); } +RegistersModel::RegistersModel(const PtraceRegisters& current_regs, const PtraceRegisters& previous_regs) + : m_raw_registers(current_regs) +{ + m_registers.append({ "eax", current_regs.eax, current_regs.eax != previous_regs.eax }); + m_registers.append({ "ebx", current_regs.ebx, current_regs.ebx != previous_regs.ebx }); + m_registers.append({ "ecx", current_regs.ecx, current_regs.ecx != previous_regs.ecx }); + m_registers.append({ "edx", current_regs.edx, current_regs.edx != previous_regs.edx }); + m_registers.append({ "esp", current_regs.esp, current_regs.esp != previous_regs.esp }); + m_registers.append({ "ebp", current_regs.ebp, current_regs.ebp != previous_regs.ebp }); + m_registers.append({ "esi", current_regs.esi, current_regs.esi != previous_regs.esi }); + m_registers.append({ "edi", current_regs.edi, current_regs.edi != previous_regs.edi }); + m_registers.append({ "eip", current_regs.eip, current_regs.eip != previous_regs.eip }); + m_registers.append({ "eflags", current_regs.eflags, current_regs.eflags != previous_regs.eflags }); + m_registers.append({ "cs", current_regs.cs, current_regs.cs != previous_regs.cs }); + m_registers.append({ "ss", current_regs.ss, current_regs.ss != previous_regs.ss }); + m_registers.append({ "ds", current_regs.ds, current_regs.ds != previous_regs.ds }); + m_registers.append({ "es", current_regs.es, current_regs.es != previous_regs.es }); + m_registers.append({ "fs", current_regs.fs, current_regs.ds != previous_regs.fs }); + m_registers.append({ "gs", current_regs.gs, current_regs.gs != previous_regs.gs }); +} + RegistersModel::~RegistersModel() { } @@ -74,6 +96,13 @@ GUI::Variant RegistersModel::data(const GUI::ModelIndex& index, GUI::ModelRole r { auto& reg = m_registers[index.row()]; + if (role == GUI::ModelRole::ForegroundColor) { + if (reg.changed) + return Color(Color::Red); + else + return Color(Color::Black); + } + if (role == GUI::ModelRole::Display) { if (index.column() == Column::Register) return reg.name; diff --git a/DevTools/HackStudio/Debugger/RegistersModel.h b/DevTools/HackStudio/Debugger/RegistersModel.h index 8881b28505..8252f16943 100644 --- a/DevTools/HackStudio/Debugger/RegistersModel.h +++ b/DevTools/HackStudio/Debugger/RegistersModel.h @@ -35,6 +35,7 @@ namespace HackStudio { struct RegisterData { String name; u32 value; + bool changed { false }; }; class RegistersModel final : public GUI::Model { @@ -44,6 +45,11 @@ public: return adopt(*new RegistersModel(regs)); } + static RefPtr<RegistersModel> create(const PtraceRegisters& current_regs, const PtraceRegisters& previous_regs) + { + return adopt(*new RegistersModel(current_regs, previous_regs)); + } + enum Column { Register, Value, @@ -58,9 +64,13 @@ public: virtual GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override; virtual void update() override; + const PtraceRegisters& raw_registers() const { return m_raw_registers; } + private: explicit RegistersModel(const PtraceRegisters& regs); + RegistersModel(const PtraceRegisters& current_regs, const PtraceRegisters& previous_regs); + PtraceRegisters m_raw_registers; Vector<RegisterData> m_registers; }; |