From 752594f69ab0be9495fd8b33eb10212c8c0ba4bc Mon Sep 17 00:00:00 2001 From: Ty Lamontagne Date: Sat, 7 Jan 2023 01:23:15 -0500 Subject: [PATCH] Debugger Breakpoints: Implement the user data role in the model Consistent with the other models, and saves some awkward usage in the cpu widget where we have to interpret the variant as a string, to then convert it to a uint. I like this better as it provides an easy interface to get the 'raw' breakpoint data out of the model. --- pcsx2-qt/Debugger/CpuWidget.cpp | 2 +- pcsx2-qt/Debugger/Models/BreakpointModel.cpp | 46 ++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/pcsx2-qt/Debugger/CpuWidget.cpp b/pcsx2-qt/Debugger/CpuWidget.cpp index a36fa9be0b..b9dfbd7c00 100644 --- a/pcsx2-qt/Debugger/CpuWidget.cpp +++ b/pcsx2-qt/Debugger/CpuWidget.cpp @@ -244,7 +244,7 @@ void CpuWidget::onBPListDoubleClicked(const QModelIndex& index) { if (index.column() == BreakpointModel::OFFSET) { - m_ui.disassemblyWidget->gotoAddress(m_bpModel.data(index).toString().toUInt(nullptr, 16)); + m_ui.disassemblyWidget->gotoAddress(m_bpModel.data(index, Qt::UserRole).toUInt()); } } } diff --git a/pcsx2-qt/Debugger/Models/BreakpointModel.cpp b/pcsx2-qt/Debugger/Models/BreakpointModel.cpp index 46fe1e00fa..2de6112107 100644 --- a/pcsx2-qt/Debugger/Models/BreakpointModel.cpp +++ b/pcsx2-qt/Debugger/Models/BreakpointModel.cpp @@ -97,6 +97,52 @@ QVariant BreakpointModel::data(const QModelIndex& index, int role) const } } } + else if (role == Qt::UserRole) + { + auto bp_mc = m_breakpoints.at(index.row()); + + if (const auto* bp = std::get_if(&bp_mc)) + { + switch (index.column()) + { + case BreakpointColumns::TYPE: + return 0; + case BreakpointColumns::OFFSET: + return bp->addr; + case BreakpointColumns::SIZE_LABEL: + return m_cpu.GetSymbolMap().GetLabelString(bp->addr).c_str(); + case BreakpointColumns::OPCODE: + // Note: Fix up the disassemblymanager so we can use it here, instead of calling a function through the disassemblyview (yuck) + return m_cpu.disasm(bp->addr, true).c_str(); + case BreakpointColumns::CONDITION: + return bp->hasCond ? QString::fromLocal8Bit(bp->cond.expressionString) : tr(""); + case BreakpointColumns::HITS: + return 0; + case BreakpointColumns::ENABLED: + return bp->enabled; + } + } + else if (const auto* mc = std::get_if(&bp_mc)) + { + switch (index.column()) + { + case BreakpointColumns::TYPE: + return mc->cond; + case BreakpointColumns::OFFSET: + return mc->start; + case BreakpointColumns::SIZE_LABEL: + return mc->end - mc->start; + case BreakpointColumns::OPCODE: + return ""; + case BreakpointColumns::CONDITION: + return ""; + case BreakpointColumns::HITS: + return mc->numHits; + case BreakpointColumns::ENABLED: + return (mc->result & MEMCHECK_BREAK); + } + } + } else if (role == Qt::CheckStateRole) { if (index.column() == 6)