Skip to content

Commit

Permalink
Debugger: Fixes crash on debugger open when cpu not alive
Browse files Browse the repository at this point in the history
The debugger was crashing on open if no game was running due to failing to read from the CPU while the cpu was not alive.

The opcode was read before checking if it should be shown, so I have moved it to only read if the showOpcode boolean is true, and set it to not show opcodes of the cpu is not alive.
  • Loading branch information
Daniel-McCarthy committed Feb 23, 2024
1 parent 78b6323 commit 13b1c8b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pcsx2-qt/Debugger/DisassemblyWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,12 +746,12 @@ inline QString DisassemblyWidget::DisassemblyStringFromAddress(u32 address, QFon
const bool isCurrentPC = m_cpu->getPC() == address;

const std::string addressSymbol = m_cpu->GetSymbolMap().GetLabelName(address);
const u32 opcode = m_cpu->read32(address);

const auto demangler = demangler::CDemangler::createGcc();
const bool showOpcode = m_showInstructionOpcode && m_cpu->isAlive();

QString lineString;
if (m_showInstructionOpcode)
if (showOpcode)
{
lineString = QString(" %1 %2 %3 %4 %5 %6");
}
Expand Down Expand Up @@ -783,8 +783,11 @@ inline QString DisassemblyWidget::DisassemblyStringFromAddress(u32 address, QFon
lineString = lineString.arg(metric.elidedText(symbolString, Qt::ElideRight, (selected ? 32.0f : 7.5f) * font.pointSize()));
}

if (m_showInstructionOpcode)
if (showOpcode)
{
const u32 opcode = m_cpu->read32(address);
lineString = lineString.arg(QtUtils::FilledQStringFromValue(opcode, 16));
}

lineString = lineString.leftJustified(4, ' ') // Address / symbol
.arg(line.name.c_str())
Expand Down

0 comments on commit 13b1c8b

Please sign in to comment.