mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-21 12:05:23 +00:00
Debugger: Optimize thread disasm type select
Some correctness fixes as well: dont use raw pointers where its not compatible, use std::weak_ptr instead.
This commit is contained in:
parent
e70f430b5a
commit
6d3c421823
1 changed files with 23 additions and 16 deletions
|
@ -352,6 +352,8 @@ void debugger_frame::UpdateUI()
|
|||
}
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(std::weak_ptr<cpu_thread>);
|
||||
|
||||
void debugger_frame::UpdateUnitList()
|
||||
{
|
||||
const u64 threads_created = cpu_thread::g_threads_created;
|
||||
|
@ -373,9 +375,11 @@ void debugger_frame::UpdateUnitList()
|
|||
m_choice_units->clear();
|
||||
m_choice_units->addItem(NoThreadString);
|
||||
|
||||
const auto on_select = [&](u32, cpu_thread& cpu)
|
||||
const auto on_select = [&](u32 id, cpu_thread& cpu)
|
||||
{
|
||||
QVariant var_cpu = QVariant::fromValue<void*>(&cpu);
|
||||
QVariant var_cpu = QVariant::fromValue<std::weak_ptr<cpu_thread>>(
|
||||
id >> 24 == 1 ? static_cast<std::weak_ptr<cpu_thread>>(idm::get_unlocked<named_thread<ppu_thread>>(id)) : idm::get_unlocked<named_thread<spu_thread>>(id));
|
||||
|
||||
m_choice_units->addItem(qstr(cpu.get_name()), var_cpu);
|
||||
if (old_cpu == var_cpu) m_choice_units->setCurrentIndex(m_choice_units->count() - 1);
|
||||
};
|
||||
|
@ -405,21 +409,24 @@ void debugger_frame::OnSelectUnit()
|
|||
|
||||
if (!m_no_thread_selected)
|
||||
{
|
||||
const auto on_select = [&](u32, cpu_thread& cpu)
|
||||
if (const auto cpu0 = m_choice_units->currentData().value<std::weak_ptr<cpu_thread>>().lock())
|
||||
{
|
||||
cpu_thread* data = static_cast<cpu_thread*>(m_choice_units->currentData().value<void*>());
|
||||
return data == &cpu;
|
||||
};
|
||||
|
||||
if (auto ppu = idm::select<named_thread<ppu_thread>>(on_select))
|
||||
{
|
||||
m_disasm = std::make_unique<PPUDisAsm>(CPUDisAsm_InterpreterMode);
|
||||
cpu = ppu.ptr;
|
||||
}
|
||||
else if (auto spu1 = idm::select<named_thread<spu_thread>>(on_select))
|
||||
{
|
||||
m_disasm = std::make_unique<SPUDisAsm>(CPUDisAsm_InterpreterMode);
|
||||
cpu = spu1.ptr;
|
||||
if (cpu0->id_type() == 1)
|
||||
{
|
||||
if (cpu0.get() == idm::check<named_thread<ppu_thread>>(cpu0->id))
|
||||
{
|
||||
cpu = cpu0;
|
||||
m_disasm = std::make_unique<PPUDisAsm>(CPUDisAsm_InterpreterMode);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cpu0.get() == idm::check<named_thread<spu_thread>>(cpu0->id))
|
||||
{
|
||||
cpu = cpu0;
|
||||
m_disasm = std::make_unique<SPUDisAsm>(CPUDisAsm_InterpreterMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue