Debugger: Fix instruction pointer for good

This commit is contained in:
Eladash 2022-05-01 15:04:56 +03:00 committed by Ivan
parent 5c1f79ab26
commit 8cc6a30557
4 changed files with 45 additions and 15 deletions

View file

@ -160,7 +160,7 @@ debugger_frame::debugger_frame(std::shared_ptr<gui_settings> gui_settings, QWidg
setWidget(body);
connect(m_go_to_addr, &QAbstractButton::clicked, this, &debugger_frame::ShowGotoAddressDialog);
connect(m_go_to_pc, &QAbstractButton::clicked, this, &debugger_frame::ShowPC);
connect(m_go_to_pc, &QAbstractButton::clicked, this, [this]() { ShowPC(true); });
connect(m_btn_step, &QAbstractButton::clicked, this, &debugger_frame::DoStep);
connect(m_btn_step_over, &QAbstractButton::clicked, [this]() { DoStep(true); });
@ -193,6 +193,7 @@ debugger_frame::debugger_frame(std::shared_ptr<gui_settings> gui_settings, QWidg
}
cpu->state.notify_one(s_pause_flags);
m_debugger_list->EnableThreadFollowing();
}
}
UpdateUI();
@ -213,7 +214,7 @@ debugger_frame::debugger_frame(std::shared_ptr<gui_settings> gui_settings, QWidg
connect(this, &debugger_frame::CallStackUpdateRequested, m_call_stack_list, &call_stack_list::HandleUpdate);
connect(m_call_stack_list, &call_stack_list::RequestShowAddress, m_debugger_list, &debugger_list::ShowAddress);
m_debugger_list->ShowAddress(m_debugger_list->m_pc, false);
m_debugger_list->RefreshView();
UpdateUnitList();
}
@ -952,6 +953,7 @@ void debugger_frame::OnSelectUnit()
m_debugger_list->UpdateCPUData(get_cpu(), m_disasm.get());
m_breakpoint_list->UpdateCPUData(get_cpu(), m_disasm.get());
ShowPC(true);
DoUpdate();
UpdateUI();
}
@ -1077,13 +1079,18 @@ void debugger_frame::ClearCallStack()
Q_EMIT CallStackUpdateRequested({});
}
void debugger_frame::ShowPC()
void debugger_frame::ShowPC(bool user_requested)
{
const auto cpu0 = get_cpu();
const u32 pc = (cpu0 ? cpu0->get_pc() : 0);
m_debugger_list->ShowAddress(pc, true);
if (user_requested)
{
m_debugger_list->EnableThreadFollowing();
}
m_debugger_list->ShowAddress(pc, false);
}
void debugger_frame::DoStep(bool step_over)
@ -1092,6 +1099,15 @@ void debugger_frame::DoStep(bool step_over)
{
bool should_step_over = step_over && cpu->id_type() == 1;
// If stepping over, lay at the same spot and wait for the thread to finish the call
// If not, fixate on the current pointed instruction
m_debugger_list->EnableThreadFollowing(!should_step_over);
if (should_step_over)
{
m_debugger_list->ShowAddress(cpu->get_pc() + 4, false);
}
if (const auto _state = +cpu->state; _state & s_pause_flags && _state & cpu_flag::wait && !(_state & cpu_flag::dbg_step))
{
if (should_step_over)