fix debugger o.O (#2903)

* fix debugger o.O

* minor simplification

* how did I not see this the first time
This commit is contained in:
Megamouse 2017-06-23 14:08:38 +02:00 committed by Ivan
parent 51ce8f6c20
commit 4ce8e9ba16
1 changed files with 33 additions and 29 deletions

View File

@ -88,9 +88,6 @@ debugger_frame::debugger_frame(QWidget *parent) : QDockWidget(tr("Debugger"), pa
});
connect(m_choice_units, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this, &debugger_frame::UpdateUI);
connect(m_choice_units, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &debugger_frame::OnSelectUnit);
connect(m_choice_units, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), m_list, [=](int index) {
m_list->m_noThreadSelected = m_choice_units->itemText(index) == NoThread ? true : false;
});
connect(this, &QDockWidget::visibilityChanged, this, &debugger_frame::EnableUpdateTimer);
m_list->ShowAddr(CentrePc(m_list->m_pc));
@ -103,7 +100,6 @@ void debugger_frame::closeEvent(QCloseEvent *event)
emit DebugFrameClosed();
}
//static const int show_lines = 30;
#include <map>
std::map<u32, bool> g_breakpoints;
@ -137,6 +133,8 @@ void debugger_frame::UpdateUI()
{
UpdateUnitList();
if (m_noThreadSelected) return;
const auto cpu = this->cpu.lock();
if (!cpu)
@ -228,37 +226,43 @@ void debugger_frame::UpdateUnitList()
void debugger_frame::OnSelectUnit()
{
if (m_choice_units->count() < 1 || m_current_choice == m_choice_units->currentText() || m_choice_units->currentText() == NoThread) return;
if (m_choice_units->count() < 1 || m_current_choice == m_choice_units->currentText()) return;
m_current_choice = m_choice_units->currentText();
m_noThreadSelected = m_current_choice == NoThread;
m_list->m_noThreadSelected = m_noThreadSelected;
m_disasm.reset();
cpu.reset();
const auto on_select = [&](u32, cpu_thread& cpu)
if (!m_noThreadSelected)
{
cpu_thread* data = (cpu_thread *)m_choice_units->currentData().value<void *>();
return data == &cpu;
};
const auto on_select = [&](u32, cpu_thread& cpu)
{
cpu_thread* data = (cpu_thread *)m_choice_units->currentData().value<void *>();
return data == &cpu;
};
if (auto ppu = idm::select<ppu_thread>(on_select))
{
m_disasm = std::make_unique<PPUDisAsm>(CPUDisAsm_InterpreterMode);
cpu = ppu.ptr;
}
else if (auto spu1 = idm::select<SPUThread>(on_select))
{
m_disasm = std::make_unique<SPUDisAsm>(CPUDisAsm_InterpreterMode);
cpu = spu1.ptr;
}
else if (auto rspu = idm::select<RawSPUThread>(on_select))
{
m_disasm = std::make_unique<SPUDisAsm>(CPUDisAsm_InterpreterMode);
cpu = rspu.ptr;
}
else if (auto arm = idm::select<ARMv7Thread>(on_select))
{
m_disasm = std::make_unique<ARMv7DisAsm>(CPUDisAsm_InterpreterMode);
cpu = arm.ptr;
if (auto ppu = idm::select<ppu_thread>(on_select))
{
m_disasm = std::make_unique<PPUDisAsm>(CPUDisAsm_InterpreterMode);
cpu = ppu.ptr;
}
else if (auto spu1 = idm::select<SPUThread>(on_select))
{
m_disasm = std::make_unique<SPUDisAsm>(CPUDisAsm_InterpreterMode);
cpu = spu1.ptr;
}
else if (auto rspu = idm::select<RawSPUThread>(on_select))
{
m_disasm = std::make_unique<SPUDisAsm>(CPUDisAsm_InterpreterMode);
cpu = rspu.ptr;
}
else if (auto arm = idm::select<ARMv7Thread>(on_select))
{
m_disasm = std::make_unique<ARMv7DisAsm>(CPUDisAsm_InterpreterMode);
cpu = arm.ptr;
}
}
DoUpdate();
@ -373,7 +377,7 @@ void debugger_frame::Show_Val()
void debugger_frame::Show_PC()
{
if (const auto cpu = this->cpu.lock()) m_list->ShowAddr(CentrePc(GetPc()));
m_list->ShowAddr(CentrePc(GetPc()));
}
void debugger_frame::DoStep()