mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-06 21:40:05 +00:00
DolphinQt: Avoid ppcState global.
This commit is contained in:
parent
192d8b6e40
commit
2d1f661118
@ -135,7 +135,7 @@ constexpr int CODE_VIEW_COLUMN_DESCRIPTION = 4;
|
|||||||
constexpr int CODE_VIEW_COLUMN_BRANCH_ARROWS = 5;
|
constexpr int CODE_VIEW_COLUMN_BRANCH_ARROWS = 5;
|
||||||
constexpr int CODE_VIEW_COLUMNCOUNT = 6;
|
constexpr int CODE_VIEW_COLUMNCOUNT = 6;
|
||||||
|
|
||||||
CodeViewWidget::CodeViewWidget()
|
CodeViewWidget::CodeViewWidget() : m_system(Core::System::GetInstance())
|
||||||
{
|
{
|
||||||
setColumnCount(CODE_VIEW_COLUMNCOUNT);
|
setColumnCount(CODE_VIEW_COLUMNCOUNT);
|
||||||
setShowGrid(false);
|
setShowGrid(false);
|
||||||
@ -168,11 +168,11 @@ CodeViewWidget::CodeViewWidget()
|
|||||||
&CodeViewWidget::FontBasedSizing);
|
&CodeViewWidget::FontBasedSizing);
|
||||||
|
|
||||||
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this] {
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this] {
|
||||||
m_address = PowerPC::ppcState.pc;
|
m_address = m_system.GetPPCState().pc;
|
||||||
Update();
|
Update();
|
||||||
});
|
});
|
||||||
connect(Host::GetInstance(), &Host::UpdateDisasmDialog, this, [this] {
|
connect(Host::GetInstance(), &Host::UpdateDisasmDialog, this, [this] {
|
||||||
m_address = PowerPC::ppcState.pc;
|
m_address = m_system.GetPPCState().pc;
|
||||||
Update();
|
Update();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ void CodeViewWidget::Update()
|
|||||||
|
|
||||||
if (Core::GetState() == Core::State::Paused)
|
if (Core::GetState() == Core::State::Paused)
|
||||||
{
|
{
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
Update(&guard);
|
Update(&guard);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -294,7 +294,8 @@ void CodeViewWidget::Update(const Core::CPUThreadGuard* guard)
|
|||||||
for (int i = 0; i < rows; i++)
|
for (int i = 0; i < rows; i++)
|
||||||
setRowHeight(i, rowh);
|
setRowHeight(i, rowh);
|
||||||
|
|
||||||
const std::optional<u32> pc = guard ? std::make_optional(PowerPC::ppcState.pc) : std::nullopt;
|
const std::optional<u32> pc =
|
||||||
|
guard ? std::make_optional(m_system.GetPPCState().pc) : std::nullopt;
|
||||||
|
|
||||||
const bool dark_theme = qApp->palette().color(QPalette::Base).valueF() < 0.5;
|
const bool dark_theme = qApp->palette().color(QPalette::Base).valueF() < 0.5;
|
||||||
|
|
||||||
@ -533,7 +534,7 @@ void CodeViewWidget::SetAddress(u32 address, SetAddressUpdate update)
|
|||||||
|
|
||||||
void CodeViewWidget::ReplaceAddress(u32 address, ReplaceWith replace)
|
void CodeViewWidget::ReplaceAddress(u32 address, ReplaceWith replace)
|
||||||
{
|
{
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
|
|
||||||
PowerPC::debug_interface.SetPatch(guard, address,
|
PowerPC::debug_interface.SetPatch(guard, address,
|
||||||
replace == ReplaceWith::BLR ? 0x4e800020 : 0x60000000);
|
replace == ReplaceWith::BLR ? 0x4e800020 : 0x60000000);
|
||||||
@ -595,10 +596,11 @@ void CodeViewWidget::OnContextMenu()
|
|||||||
bool follow_branch_enabled = false;
|
bool follow_branch_enabled = false;
|
||||||
if (paused)
|
if (paused)
|
||||||
{
|
{
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
const std::string disasm = PowerPC::debug_interface.Disassemble(&guard, PowerPC::ppcState.pc);
|
const u32 pc = m_system.GetPPCState().pc;
|
||||||
|
const std::string disasm = PowerPC::debug_interface.Disassemble(&guard, pc);
|
||||||
|
|
||||||
if (addr == PowerPC::ppcState.pc)
|
if (addr == pc)
|
||||||
{
|
{
|
||||||
const auto target_it = std::find(disasm.begin(), disasm.end(), '\t');
|
const auto target_it = std::find(disasm.begin(), disasm.end(), '\t');
|
||||||
const auto target_end = std::find(target_it, disasm.end(), ',');
|
const auto target_end = std::find(target_it, disasm.end(), ',');
|
||||||
@ -651,7 +653,7 @@ void CodeViewWidget::AutoStep(CodeTrace::AutoStop option)
|
|||||||
// Autosteps and follows value in the target (left-most) register. The Used and Changed options
|
// Autosteps and follows value in the target (left-most) register. The Used and Changed options
|
||||||
// silently follows target through reshuffles in memory and registers and stops on use or update.
|
// silently follows target through reshuffles in memory and registers and stops on use or update.
|
||||||
|
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
|
|
||||||
CodeTrace code_trace;
|
CodeTrace code_trace;
|
||||||
bool repeat = false;
|
bool repeat = false;
|
||||||
@ -741,8 +743,8 @@ void CodeViewWidget::OnCopyTargetAddress()
|
|||||||
|
|
||||||
const u32 addr = GetContextAddress();
|
const u32 addr = GetContextAddress();
|
||||||
|
|
||||||
const std::string code_line = [addr] {
|
const std::string code_line = [this, addr] {
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
return PowerPC::debug_interface.Disassemble(&guard, addr);
|
return PowerPC::debug_interface.Disassemble(&guard, addr);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
@ -771,8 +773,8 @@ void CodeViewWidget::OnShowTargetInMemory()
|
|||||||
|
|
||||||
const u32 addr = GetContextAddress();
|
const u32 addr = GetContextAddress();
|
||||||
|
|
||||||
const std::string code_line = [addr] {
|
const std::string code_line = [this, addr] {
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
return PowerPC::debug_interface.Disassemble(&guard, addr);
|
return PowerPC::debug_interface.Disassemble(&guard, addr);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
@ -790,8 +792,8 @@ void CodeViewWidget::OnCopyCode()
|
|||||||
{
|
{
|
||||||
const u32 addr = GetContextAddress();
|
const u32 addr = GetContextAddress();
|
||||||
|
|
||||||
const std::string text = [addr] {
|
const std::string text = [this, addr] {
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
return PowerPC::debug_interface.Disassemble(&guard, addr);
|
return PowerPC::debug_interface.Disassemble(&guard, addr);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
@ -809,7 +811,7 @@ void CodeViewWidget::OnCopyFunction()
|
|||||||
std::string text = symbol->name + "\r\n";
|
std::string text = symbol->name + "\r\n";
|
||||||
|
|
||||||
{
|
{
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
|
|
||||||
// we got a function
|
// we got a function
|
||||||
const u32 start = symbol->address;
|
const u32 start = symbol->address;
|
||||||
@ -828,8 +830,8 @@ void CodeViewWidget::OnCopyHex()
|
|||||||
{
|
{
|
||||||
const u32 addr = GetContextAddress();
|
const u32 addr = GetContextAddress();
|
||||||
|
|
||||||
const u32 instruction = [addr] {
|
const u32 instruction = [this, addr] {
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
return PowerPC::debug_interface.ReadInstruction(guard, addr);
|
return PowerPC::debug_interface.ReadInstruction(guard, addr);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
@ -857,7 +859,7 @@ void CodeViewWidget::OnAddFunction()
|
|||||||
{
|
{
|
||||||
const u32 addr = GetContextAddress();
|
const u32 addr = GetContextAddress();
|
||||||
|
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
|
|
||||||
g_symbolDB.AddFunction(guard, addr);
|
g_symbolDB.AddFunction(guard, addr);
|
||||||
emit SymbolsChanged();
|
emit SymbolsChanged();
|
||||||
@ -882,8 +884,8 @@ void CodeViewWidget::OnFollowBranch()
|
|||||||
{
|
{
|
||||||
const u32 addr = GetContextAddress();
|
const u32 addr = GetContextAddress();
|
||||||
|
|
||||||
const u32 branch_addr = [addr] {
|
const u32 branch_addr = [this, addr] {
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
return GetBranchFromAddress(guard, addr);
|
return GetBranchFromAddress(guard, addr);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
@ -917,7 +919,7 @@ void CodeViewWidget::OnRenameSymbol()
|
|||||||
|
|
||||||
void CodeViewWidget::OnSelectionChanged()
|
void CodeViewWidget::OnSelectionChanged()
|
||||||
{
|
{
|
||||||
if (m_address == PowerPC::ppcState.pc)
|
if (m_address == m_system.GetPPCState().pc)
|
||||||
{
|
{
|
||||||
setStyleSheet(
|
setStyleSheet(
|
||||||
QStringLiteral("QTableView::item:selected {background-color: #00FF00; color: #000000;}"));
|
QStringLiteral("QTableView::item:selected {background-color: #00FF00; color: #000000;}"));
|
||||||
@ -946,7 +948,7 @@ void CodeViewWidget::OnSetSymbolSize()
|
|||||||
if (!good)
|
if (!good)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
|
|
||||||
PPCAnalyst::ReanalyzeFunction(guard, symbol->address, *symbol, size);
|
PPCAnalyst::ReanalyzeFunction(guard, symbol->address, *symbol, size);
|
||||||
emit SymbolsChanged();
|
emit SymbolsChanged();
|
||||||
@ -974,7 +976,7 @@ void CodeViewWidget::OnSetSymbolEndAddress()
|
|||||||
if (!good)
|
if (!good)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
|
|
||||||
PPCAnalyst::ReanalyzeFunction(guard, symbol->address, *symbol, address - symbol->address);
|
PPCAnalyst::ReanalyzeFunction(guard, symbol->address, *symbol, address - symbol->address);
|
||||||
emit SymbolsChanged();
|
emit SymbolsChanged();
|
||||||
@ -983,7 +985,7 @@ void CodeViewWidget::OnSetSymbolEndAddress()
|
|||||||
|
|
||||||
void CodeViewWidget::OnReplaceInstruction()
|
void CodeViewWidget::OnReplaceInstruction()
|
||||||
{
|
{
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
|
|
||||||
const u32 addr = GetContextAddress();
|
const u32 addr = GetContextAddress();
|
||||||
|
|
||||||
@ -1006,7 +1008,7 @@ void CodeViewWidget::OnReplaceInstruction()
|
|||||||
|
|
||||||
void CodeViewWidget::OnRestoreInstruction()
|
void CodeViewWidget::OnRestoreInstruction()
|
||||||
{
|
{
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
|
|
||||||
const u32 addr = GetContextAddress();
|
const u32 addr = GetContextAddress();
|
||||||
|
|
||||||
|
@ -18,7 +18,8 @@ class QShowEvent;
|
|||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
class CPUThreadGuard;
|
class CPUThreadGuard;
|
||||||
};
|
class System;
|
||||||
|
} // namespace Core
|
||||||
|
|
||||||
struct CodeViewBranch;
|
struct CodeViewBranch;
|
||||||
class BranchDisplayDelegate;
|
class BranchDisplayDelegate;
|
||||||
@ -98,6 +99,8 @@ private:
|
|||||||
|
|
||||||
void CalculateBranchIndentation();
|
void CalculateBranchIndentation();
|
||||||
|
|
||||||
|
Core::System& m_system;
|
||||||
|
|
||||||
bool m_updating = false;
|
bool m_updating = false;
|
||||||
|
|
||||||
u32 m_address = 0;
|
u32 m_address = 0;
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "DolphinQt/Host.h"
|
#include "DolphinQt/Host.h"
|
||||||
#include "DolphinQt/Settings.h"
|
#include "DolphinQt/Settings.h"
|
||||||
|
|
||||||
CodeWidget::CodeWidget(QWidget* parent) : QDockWidget(parent)
|
CodeWidget::CodeWidget(QWidget* parent) : QDockWidget(parent), m_system(Core::System::GetInstance())
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Code"));
|
setWindowTitle(tr("Code"));
|
||||||
setObjectName(QStringLiteral("code"));
|
setObjectName(QStringLiteral("code"));
|
||||||
@ -51,7 +51,7 @@ CodeWidget::CodeWidget(QWidget* parent) : QDockWidget(parent)
|
|||||||
|
|
||||||
connect(Host::GetInstance(), &Host::UpdateDisasmDialog, this, [this] {
|
connect(Host::GetInstance(), &Host::UpdateDisasmDialog, this, [this] {
|
||||||
if (Core::GetState() == Core::State::Paused)
|
if (Core::GetState() == Core::State::Paused)
|
||||||
SetAddress(PowerPC::ppcState.pc, CodeViewWidget::SetAddressUpdate::WithoutUpdate);
|
SetAddress(m_system.GetPPCState().pc, CodeViewWidget::SetAddressUpdate::WithoutUpdate);
|
||||||
Update();
|
Update();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -329,9 +329,9 @@ void CodeWidget::UpdateCallstack()
|
|||||||
|
|
||||||
std::vector<Dolphin_Debugger::CallstackEntry> stack;
|
std::vector<Dolphin_Debugger::CallstackEntry> stack;
|
||||||
|
|
||||||
const bool success = [&stack] {
|
const bool success = [this, &stack] {
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
return Dolphin_Debugger::GetCallstack(Core::System::GetInstance(), guard, stack);
|
return Dolphin_Debugger::GetCallstack(m_system, guard, stack);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
@ -435,8 +435,7 @@ void CodeWidget::UpdateFunctionCallers(const Common::Symbol* symbol)
|
|||||||
|
|
||||||
void CodeWidget::Step()
|
void CodeWidget::Step()
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& cpu = m_system.GetCPU();
|
||||||
auto& cpu = system.GetCPU();
|
|
||||||
|
|
||||||
if (!cpu.IsStepping())
|
if (!cpu.IsStepping())
|
||||||
return;
|
return;
|
||||||
@ -455,21 +454,20 @@ void CodeWidget::Step()
|
|||||||
|
|
||||||
void CodeWidget::StepOver()
|
void CodeWidget::StepOver()
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& cpu = m_system.GetCPU();
|
||||||
auto& cpu = system.GetCPU();
|
|
||||||
|
|
||||||
if (!cpu.IsStepping())
|
if (!cpu.IsStepping())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const UGeckoInstruction inst = [&] {
|
const UGeckoInstruction inst = [&] {
|
||||||
Core::CPUThreadGuard guard(system);
|
Core::CPUThreadGuard guard(m_system);
|
||||||
return PowerPC::MMU::HostRead_Instruction(guard, PowerPC::ppcState.pc);
|
return PowerPC::MMU::HostRead_Instruction(guard, m_system.GetPPCState().pc);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
if (inst.LK)
|
if (inst.LK)
|
||||||
{
|
{
|
||||||
PowerPC::breakpoints.ClearAllTemporary();
|
PowerPC::breakpoints.ClearAllTemporary();
|
||||||
PowerPC::breakpoints.Add(PowerPC::ppcState.pc + 4, true);
|
PowerPC::breakpoints.Add(m_system.GetPPCState().pc + 4, true);
|
||||||
cpu.EnableStepping(false);
|
cpu.EnableStepping(false);
|
||||||
Core::DisplayMessage(tr("Step over in progress...").toStdString(), 2000);
|
Core::DisplayMessage(tr("Step over in progress...").toStdString(), 2000);
|
||||||
}
|
}
|
||||||
@ -480,23 +478,21 @@ void CodeWidget::StepOver()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns true on a rfi, blr or on a bclr that evaluates to true.
|
// Returns true on a rfi, blr or on a bclr that evaluates to true.
|
||||||
static bool WillInstructionReturn(UGeckoInstruction inst)
|
static bool WillInstructionReturn(Core::System& system, UGeckoInstruction inst)
|
||||||
{
|
{
|
||||||
// Is a rfi instruction
|
// Is a rfi instruction
|
||||||
if (inst.hex == 0x4C000064u)
|
if (inst.hex == 0x4C000064u)
|
||||||
return true;
|
return true;
|
||||||
bool counter =
|
const auto& ppc_state = system.GetPPCState();
|
||||||
(inst.BO_2 >> 2 & 1) != 0 || (CTR(PowerPC::ppcState) != 0) != ((inst.BO_2 >> 1 & 1) != 0);
|
bool counter = (inst.BO_2 >> 2 & 1) != 0 || (CTR(ppc_state) != 0) != ((inst.BO_2 >> 1 & 1) != 0);
|
||||||
bool condition =
|
bool condition = inst.BO_2 >> 4 != 0 || ppc_state.cr.GetBit(inst.BI_2) == (inst.BO_2 >> 3 & 1);
|
||||||
inst.BO_2 >> 4 != 0 || PowerPC::ppcState.cr.GetBit(inst.BI_2) == (inst.BO_2 >> 3 & 1);
|
|
||||||
bool isBclr = inst.OPCD_7 == 0b010011 && (inst.hex >> 1 & 0b10000) != 0;
|
bool isBclr = inst.OPCD_7 == 0b010011 && (inst.hex >> 1 & 0b10000) != 0;
|
||||||
return isBclr && counter && condition && !inst.LK_3;
|
return isBclr && counter && condition && !inst.LK_3;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeWidget::StepOut()
|
void CodeWidget::StepOut()
|
||||||
{
|
{
|
||||||
auto& system = Core::System::GetInstance();
|
auto& cpu = m_system.GetCPU();
|
||||||
auto& cpu = system.GetCPU();
|
|
||||||
|
|
||||||
if (!cpu.IsStepping())
|
if (!cpu.IsStepping())
|
||||||
return;
|
return;
|
||||||
@ -505,8 +501,9 @@ void CodeWidget::StepOut()
|
|||||||
using clock = std::chrono::steady_clock;
|
using clock = std::chrono::steady_clock;
|
||||||
clock::time_point timeout = clock::now() + std::chrono::seconds(5);
|
clock::time_point timeout = clock::now() + std::chrono::seconds(5);
|
||||||
|
|
||||||
|
auto& ppc_state = m_system.GetPPCState();
|
||||||
{
|
{
|
||||||
Core::CPUThreadGuard guard(system);
|
Core::CPUThreadGuard guard(m_system);
|
||||||
|
|
||||||
PowerPC::breakpoints.ClearAllTemporary();
|
PowerPC::breakpoints.ClearAllTemporary();
|
||||||
|
|
||||||
@ -516,10 +513,10 @@ void CodeWidget::StepOut()
|
|||||||
// Loop until either the current instruction is a return instruction with no Link flag
|
// Loop until either the current instruction is a return instruction with no Link flag
|
||||||
// or a breakpoint is detected so it can step at the breakpoint. If the PC is currently
|
// or a breakpoint is detected so it can step at the breakpoint. If the PC is currently
|
||||||
// on a breakpoint, skip it.
|
// on a breakpoint, skip it.
|
||||||
UGeckoInstruction inst = PowerPC::MMU::HostRead_Instruction(guard, PowerPC::ppcState.pc);
|
UGeckoInstruction inst = PowerPC::MMU::HostRead_Instruction(guard, ppc_state.pc);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (WillInstructionReturn(inst))
|
if (WillInstructionReturn(m_system, inst))
|
||||||
{
|
{
|
||||||
PowerPC::SingleStep();
|
PowerPC::SingleStep();
|
||||||
break;
|
break;
|
||||||
@ -528,28 +525,27 @@ void CodeWidget::StepOut()
|
|||||||
if (inst.LK)
|
if (inst.LK)
|
||||||
{
|
{
|
||||||
// Step over branches
|
// Step over branches
|
||||||
u32 next_pc = PowerPC::ppcState.pc + 4;
|
u32 next_pc = ppc_state.pc + 4;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
PowerPC::SingleStep();
|
PowerPC::SingleStep();
|
||||||
} while (PowerPC::ppcState.pc != next_pc && clock::now() < timeout &&
|
} while (ppc_state.pc != next_pc && clock::now() < timeout &&
|
||||||
!PowerPC::breakpoints.IsAddressBreakPoint(PowerPC::ppcState.pc));
|
!PowerPC::breakpoints.IsAddressBreakPoint(ppc_state.pc));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PowerPC::SingleStep();
|
PowerPC::SingleStep();
|
||||||
}
|
}
|
||||||
|
|
||||||
inst = PowerPC::MMU::HostRead_Instruction(guard, PowerPC::ppcState.pc);
|
inst = PowerPC::MMU::HostRead_Instruction(guard, ppc_state.pc);
|
||||||
} while (clock::now() < timeout &&
|
} while (clock::now() < timeout && !PowerPC::breakpoints.IsAddressBreakPoint(ppc_state.pc));
|
||||||
!PowerPC::breakpoints.IsAddressBreakPoint(PowerPC::ppcState.pc));
|
|
||||||
|
|
||||||
PowerPC::SetMode(old_mode);
|
PowerPC::SetMode(old_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit Host::GetInstance()->UpdateDisasmDialog();
|
emit Host::GetInstance()->UpdateDisasmDialog();
|
||||||
|
|
||||||
if (PowerPC::breakpoints.IsAddressBreakPoint(PowerPC::ppcState.pc))
|
if (PowerPC::breakpoints.IsAddressBreakPoint(ppc_state.pc))
|
||||||
Core::DisplayMessage(tr("Breakpoint encountered! Step out aborted.").toStdString(), 2000);
|
Core::DisplayMessage(tr("Breakpoint encountered! Step out aborted.").toStdString(), 2000);
|
||||||
else if (clock::now() >= timeout)
|
else if (clock::now() >= timeout)
|
||||||
Core::DisplayMessage(tr("Step out timed out!").toStdString(), 2000);
|
Core::DisplayMessage(tr("Step out timed out!").toStdString(), 2000);
|
||||||
@ -559,19 +555,19 @@ void CodeWidget::StepOut()
|
|||||||
|
|
||||||
void CodeWidget::Skip()
|
void CodeWidget::Skip()
|
||||||
{
|
{
|
||||||
PowerPC::ppcState.pc += 4;
|
m_system.GetPPCState().pc += 4;
|
||||||
ShowPC();
|
ShowPC();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeWidget::ShowPC()
|
void CodeWidget::ShowPC()
|
||||||
{
|
{
|
||||||
m_code_view->SetAddress(PowerPC::ppcState.pc, CodeViewWidget::SetAddressUpdate::WithUpdate);
|
m_code_view->SetAddress(m_system.GetPPCState().pc, CodeViewWidget::SetAddressUpdate::WithUpdate);
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeWidget::SetPC()
|
void CodeWidget::SetPC()
|
||||||
{
|
{
|
||||||
PowerPC::ppcState.pc = m_code_view->GetAddress();
|
m_system.GetPPCState().pc = m_code_view->GetAddress();
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,10 @@ namespace Common
|
|||||||
{
|
{
|
||||||
struct Symbol;
|
struct Symbol;
|
||||||
}
|
}
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
class CodeWidget : public QDockWidget
|
class CodeWidget : public QDockWidget
|
||||||
{
|
{
|
||||||
@ -66,6 +70,8 @@ private:
|
|||||||
void closeEvent(QCloseEvent*) override;
|
void closeEvent(QCloseEvent*) override;
|
||||||
void showEvent(QShowEvent* event) override;
|
void showEvent(QShowEvent* event) override;
|
||||||
|
|
||||||
|
Core::System& m_system;
|
||||||
|
|
||||||
CodeDiffDialog* m_diff_dialog = nullptr;
|
CodeDiffDialog* m_diff_dialog = nullptr;
|
||||||
QLineEdit* m_search_address;
|
QLineEdit* m_search_address;
|
||||||
QPushButton* m_code_diff;
|
QPushButton* m_code_diff;
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
#include "DolphinQt/Host.h"
|
#include "DolphinQt/Host.h"
|
||||||
#include "DolphinQt/Settings.h"
|
#include "DolphinQt/Settings.h"
|
||||||
|
|
||||||
RegisterWidget::RegisterWidget(QWidget* parent) : QDockWidget(parent)
|
RegisterWidget::RegisterWidget(QWidget* parent)
|
||||||
|
: QDockWidget(parent), m_system(Core::System::GetInstance())
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Registers"));
|
setWindowTitle(tr("Registers"));
|
||||||
setObjectName(QStringLiteral("registers"));
|
setObjectName(QStringLiteral("registers"));
|
||||||
@ -295,8 +296,8 @@ void RegisterWidget::AutoStep(const std::string& reg) const
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
const AutoStepResults results = [&trace] {
|
const AutoStepResults results = [this, &trace] {
|
||||||
Core::CPUThreadGuard guard(Core::System::GetInstance());
|
Core::CPUThreadGuard guard(m_system);
|
||||||
return trace.AutoStepping(guard, true);
|
return trace.AutoStepping(guard, true);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
@ -318,18 +319,19 @@ void RegisterWidget::PopulateTable()
|
|||||||
{
|
{
|
||||||
// General purpose registers (int)
|
// General purpose registers (int)
|
||||||
AddRegister(
|
AddRegister(
|
||||||
i, 0, RegisterType::gpr, "r" + std::to_string(i), [i] { return PowerPC::ppcState.gpr[i]; },
|
i, 0, RegisterType::gpr, "r" + std::to_string(i),
|
||||||
[i](u64 value) { PowerPC::ppcState.gpr[i] = value; });
|
[this, i] { return m_system.GetPPCState().gpr[i]; },
|
||||||
|
[this, i](u64 value) { m_system.GetPPCState().gpr[i] = value; });
|
||||||
|
|
||||||
// Floating point registers (double)
|
// Floating point registers (double)
|
||||||
AddRegister(
|
AddRegister(
|
||||||
i, 2, RegisterType::fpr, "f" + std::to_string(i),
|
i, 2, RegisterType::fpr, "f" + std::to_string(i),
|
||||||
[i] { return PowerPC::ppcState.ps[i].PS0AsU64(); },
|
[this, i] { return m_system.GetPPCState().ps[i].PS0AsU64(); },
|
||||||
[i](u64 value) { PowerPC::ppcState.ps[i].SetPS0(value); });
|
[this, i](u64 value) { m_system.GetPPCState().ps[i].SetPS0(value); });
|
||||||
|
|
||||||
AddRegister(
|
AddRegister(
|
||||||
i, 4, RegisterType::fpr, "", [i] { return PowerPC::ppcState.ps[i].PS1AsU64(); },
|
i, 4, RegisterType::fpr, "", [this, i] { return m_system.GetPPCState().ps[i].PS1AsU64(); },
|
||||||
[i](u64 value) { PowerPC::ppcState.ps[i].SetPS1(value); });
|
[this, i](u64 value) { m_system.GetPPCState().ps[i].SetPS1(value); });
|
||||||
}
|
}
|
||||||
|
|
||||||
// The IBAT and DBAT registers have a large gap between
|
// The IBAT and DBAT registers have a large gap between
|
||||||
@ -340,32 +342,36 @@ void RegisterWidget::PopulateTable()
|
|||||||
// IBAT registers
|
// IBAT registers
|
||||||
AddRegister(
|
AddRegister(
|
||||||
i, 5, RegisterType::ibat, "IBAT" + std::to_string(i),
|
i, 5, RegisterType::ibat, "IBAT" + std::to_string(i),
|
||||||
[i] {
|
[this, i] {
|
||||||
return (static_cast<u64>(PowerPC::ppcState.spr[SPR_IBAT0U + i * 2]) << 32) +
|
const auto& ppc_state = m_system.GetPPCState();
|
||||||
PowerPC::ppcState.spr[SPR_IBAT0L + i * 2];
|
return (static_cast<u64>(ppc_state.spr[SPR_IBAT0U + i * 2]) << 32) +
|
||||||
|
ppc_state.spr[SPR_IBAT0L + i * 2];
|
||||||
},
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
AddRegister(
|
AddRegister(
|
||||||
i + 4, 5, RegisterType::ibat, "IBAT" + std::to_string(4 + i),
|
i + 4, 5, RegisterType::ibat, "IBAT" + std::to_string(4 + i),
|
||||||
[i] {
|
[this, i] {
|
||||||
return (static_cast<u64>(PowerPC::ppcState.spr[SPR_IBAT4U + i * 2]) << 32) +
|
const auto& ppc_state = m_system.GetPPCState();
|
||||||
PowerPC::ppcState.spr[SPR_IBAT4L + i * 2];
|
return (static_cast<u64>(ppc_state.spr[SPR_IBAT4U + i * 2]) << 32) +
|
||||||
|
ppc_state.spr[SPR_IBAT4L + i * 2];
|
||||||
},
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
// DBAT registers
|
// DBAT registers
|
||||||
AddRegister(
|
AddRegister(
|
||||||
i + 8, 5, RegisterType::dbat, "DBAT" + std::to_string(i),
|
i + 8, 5, RegisterType::dbat, "DBAT" + std::to_string(i),
|
||||||
[i] {
|
[this, i] {
|
||||||
return (static_cast<u64>(PowerPC::ppcState.spr[SPR_DBAT0U + i * 2]) << 32) +
|
const auto& ppc_state = m_system.GetPPCState();
|
||||||
PowerPC::ppcState.spr[SPR_DBAT0L + i * 2];
|
return (static_cast<u64>(ppc_state.spr[SPR_DBAT0U + i * 2]) << 32) +
|
||||||
|
ppc_state.spr[SPR_DBAT0L + i * 2];
|
||||||
},
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
AddRegister(
|
AddRegister(
|
||||||
i + 12, 5, RegisterType::dbat, "DBAT" + std::to_string(4 + i),
|
i + 12, 5, RegisterType::dbat, "DBAT" + std::to_string(4 + i),
|
||||||
[i] {
|
[this, i] {
|
||||||
return (static_cast<u64>(PowerPC::ppcState.spr[SPR_DBAT4U + i * 2]) << 32) +
|
const auto& ppc_state = m_system.GetPPCState();
|
||||||
PowerPC::ppcState.spr[SPR_DBAT4L + i * 2];
|
return (static_cast<u64>(ppc_state.spr[SPR_DBAT4U + i * 2]) << 32) +
|
||||||
|
ppc_state.spr[SPR_DBAT4L + i * 2];
|
||||||
},
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
@ -375,29 +381,30 @@ void RegisterWidget::PopulateTable()
|
|||||||
// Graphics quantization registers
|
// Graphics quantization registers
|
||||||
AddRegister(
|
AddRegister(
|
||||||
i + 16, 7, RegisterType::gqr, "GQR" + std::to_string(i),
|
i + 16, 7, RegisterType::gqr, "GQR" + std::to_string(i),
|
||||||
[i] { return PowerPC::ppcState.spr[SPR_GQR0 + i]; }, nullptr);
|
[this, i] { return m_system.GetPPCState().spr[SPR_GQR0 + i]; }, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// HID registers
|
// HID registers
|
||||||
AddRegister(
|
AddRegister(
|
||||||
24, 7, RegisterType::hid, "HID0", [] { return PowerPC::ppcState.spr[SPR_HID0]; },
|
24, 7, RegisterType::hid, "HID0", [this] { return m_system.GetPPCState().spr[SPR_HID0]; },
|
||||||
[](u64 value) { PowerPC::ppcState.spr[SPR_HID0] = static_cast<u32>(value); });
|
[this](u64 value) { m_system.GetPPCState().spr[SPR_HID0] = static_cast<u32>(value); });
|
||||||
AddRegister(
|
AddRegister(
|
||||||
25, 7, RegisterType::hid, "HID1", [] { return PowerPC::ppcState.spr[SPR_HID1]; },
|
25, 7, RegisterType::hid, "HID1", [this] { return m_system.GetPPCState().spr[SPR_HID1]; },
|
||||||
[](u64 value) { PowerPC::ppcState.spr[SPR_HID1] = static_cast<u32>(value); });
|
[this](u64 value) { m_system.GetPPCState().spr[SPR_HID1] = static_cast<u32>(value); });
|
||||||
AddRegister(
|
AddRegister(
|
||||||
26, 7, RegisterType::hid, "HID2", [] { return PowerPC::ppcState.spr[SPR_HID2]; },
|
26, 7, RegisterType::hid, "HID2", [this] { return m_system.GetPPCState().spr[SPR_HID2]; },
|
||||||
[](u64 value) { PowerPC::ppcState.spr[SPR_HID2] = static_cast<u32>(value); });
|
[this](u64 value) { m_system.GetPPCState().spr[SPR_HID2] = static_cast<u32>(value); });
|
||||||
AddRegister(
|
AddRegister(
|
||||||
27, 7, RegisterType::hid, "HID4", [] { return PowerPC::ppcState.spr[SPR_HID4]; },
|
27, 7, RegisterType::hid, "HID4", [this] { return m_system.GetPPCState().spr[SPR_HID4]; },
|
||||||
[](u64 value) { PowerPC::ppcState.spr[SPR_HID4] = static_cast<u32>(value); });
|
[this](u64 value) { m_system.GetPPCState().spr[SPR_HID4] = static_cast<u32>(value); });
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
// SR registers
|
// SR registers
|
||||||
AddRegister(
|
AddRegister(
|
||||||
i, 7, RegisterType::sr, "SR" + std::to_string(i), [i] { return PowerPC::ppcState.sr[i]; },
|
i, 7, RegisterType::sr, "SR" + std::to_string(i),
|
||||||
[i](u64 value) { PowerPC::ppcState.sr[i] = value; });
|
[this, i] { return m_system.GetPPCState().sr[i]; },
|
||||||
|
[this, i](u64 value) { m_system.GetPPCState().sr[i] = value; });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special registers
|
// Special registers
|
||||||
@ -406,83 +413,79 @@ void RegisterWidget::PopulateTable()
|
|||||||
|
|
||||||
// PC
|
// PC
|
||||||
AddRegister(
|
AddRegister(
|
||||||
17, 5, RegisterType::pc, "PC", [] { return PowerPC::ppcState.pc; },
|
17, 5, RegisterType::pc, "PC", [this] { return m_system.GetPPCState().pc; },
|
||||||
[](u64 value) { PowerPC::ppcState.pc = value; });
|
[this](u64 value) { m_system.GetPPCState().pc = value; });
|
||||||
|
|
||||||
// LR
|
// LR
|
||||||
AddRegister(
|
AddRegister(
|
||||||
18, 5, RegisterType::lr, "LR", [] { return PowerPC::ppcState.spr[SPR_LR]; },
|
18, 5, RegisterType::lr, "LR", [this] { return m_system.GetPPCState().spr[SPR_LR]; },
|
||||||
[](u64 value) { PowerPC::ppcState.spr[SPR_LR] = value; });
|
[this](u64 value) { m_system.GetPPCState().spr[SPR_LR] = value; });
|
||||||
|
|
||||||
// CTR
|
// CTR
|
||||||
AddRegister(
|
AddRegister(
|
||||||
19, 5, RegisterType::ctr, "CTR", [] { return PowerPC::ppcState.spr[SPR_CTR]; },
|
19, 5, RegisterType::ctr, "CTR", [this] { return m_system.GetPPCState().spr[SPR_CTR]; },
|
||||||
[](u64 value) { PowerPC::ppcState.spr[SPR_CTR] = value; });
|
[this](u64 value) { m_system.GetPPCState().spr[SPR_CTR] = value; });
|
||||||
|
|
||||||
// CR
|
// CR
|
||||||
AddRegister(
|
AddRegister(
|
||||||
20, 5, RegisterType::cr, "CR", [] { return PowerPC::ppcState.cr.Get(); },
|
20, 5, RegisterType::cr, "CR", [this] { return m_system.GetPPCState().cr.Get(); },
|
||||||
[](u64 value) { PowerPC::ppcState.cr.Set(value); });
|
[this](u64 value) { m_system.GetPPCState().cr.Set(value); });
|
||||||
|
|
||||||
// XER
|
// XER
|
||||||
AddRegister(
|
AddRegister(
|
||||||
21, 5, RegisterType::xer, "XER", [] { return PowerPC::ppcState.GetXER().Hex; },
|
21, 5, RegisterType::xer, "XER", [this] { return m_system.GetPPCState().GetXER().Hex; },
|
||||||
[](u64 value) { PowerPC::ppcState.SetXER(UReg_XER(value)); });
|
[this](u64 value) { m_system.GetPPCState().SetXER(UReg_XER(value)); });
|
||||||
|
|
||||||
// FPSCR
|
// FPSCR
|
||||||
AddRegister(
|
AddRegister(
|
||||||
22, 5, RegisterType::fpscr, "FPSCR", [] { return PowerPC::ppcState.fpscr.Hex; },
|
22, 5, RegisterType::fpscr, "FPSCR", [this] { return m_system.GetPPCState().fpscr.Hex; },
|
||||||
[](u64 value) { PowerPC::ppcState.fpscr = static_cast<u32>(value); });
|
[this](u64 value) { m_system.GetPPCState().fpscr = static_cast<u32>(value); });
|
||||||
|
|
||||||
// MSR
|
// MSR
|
||||||
AddRegister(
|
AddRegister(
|
||||||
23, 5, RegisterType::msr, "MSR", [] { return PowerPC::ppcState.msr.Hex; },
|
23, 5, RegisterType::msr, "MSR", [this] { return m_system.GetPPCState().msr.Hex; },
|
||||||
[](u64 value) { PowerPC::ppcState.msr.Hex = value; });
|
[this](u64 value) { m_system.GetPPCState().msr.Hex = value; });
|
||||||
|
|
||||||
// SRR 0-1
|
// SRR 0-1
|
||||||
AddRegister(
|
AddRegister(
|
||||||
24, 5, RegisterType::srr, "SRR0", [] { return PowerPC::ppcState.spr[SPR_SRR0]; },
|
24, 5, RegisterType::srr, "SRR0", [this] { return m_system.GetPPCState().spr[SPR_SRR0]; },
|
||||||
[](u64 value) { PowerPC::ppcState.spr[SPR_SRR0] = value; });
|
[this](u64 value) { m_system.GetPPCState().spr[SPR_SRR0] = value; });
|
||||||
AddRegister(
|
AddRegister(
|
||||||
25, 5, RegisterType::srr, "SRR1", [] { return PowerPC::ppcState.spr[SPR_SRR1]; },
|
25, 5, RegisterType::srr, "SRR1", [this] { return m_system.GetPPCState().spr[SPR_SRR1]; },
|
||||||
[](u64 value) { PowerPC::ppcState.spr[SPR_SRR1] = value; });
|
[this](u64 value) { m_system.GetPPCState().spr[SPR_SRR1] = value; });
|
||||||
|
|
||||||
// Exceptions
|
// Exceptions
|
||||||
AddRegister(
|
AddRegister(
|
||||||
26, 5, RegisterType::exceptions, "Exceptions", [] { return PowerPC::ppcState.Exceptions; },
|
26, 5, RegisterType::exceptions, "Exceptions",
|
||||||
[](u64 value) { PowerPC::ppcState.Exceptions = value; });
|
[this] { return m_system.GetPPCState().Exceptions; },
|
||||||
|
[this](u64 value) { m_system.GetPPCState().Exceptions = value; });
|
||||||
|
|
||||||
// Int Mask
|
// Int Mask
|
||||||
AddRegister(
|
AddRegister(
|
||||||
27, 5, RegisterType::int_mask, "Int Mask",
|
27, 5, RegisterType::int_mask, "Int Mask",
|
||||||
[] {
|
[this] { return m_system.GetProcessorInterface().GetMask(); }, nullptr);
|
||||||
auto& system = Core::System::GetInstance();
|
|
||||||
return system.GetProcessorInterface().GetMask();
|
|
||||||
},
|
|
||||||
nullptr);
|
|
||||||
|
|
||||||
// Int Cause
|
// Int Cause
|
||||||
AddRegister(
|
AddRegister(
|
||||||
28, 5, RegisterType::int_cause, "Int Cause",
|
28, 5, RegisterType::int_cause, "Int Cause",
|
||||||
[] {
|
[this] { return m_system.GetProcessorInterface().GetCause(); }, nullptr);
|
||||||
auto& system = Core::System::GetInstance();
|
|
||||||
return system.GetProcessorInterface().GetCause();
|
|
||||||
},
|
|
||||||
nullptr);
|
|
||||||
|
|
||||||
// DSISR
|
// DSISR
|
||||||
AddRegister(
|
AddRegister(
|
||||||
29, 5, RegisterType::dsisr, "DSISR", [] { return PowerPC::ppcState.spr[SPR_DSISR]; },
|
29, 5, RegisterType::dsisr, "DSISR", [this] { return m_system.GetPPCState().spr[SPR_DSISR]; },
|
||||||
[](u64 value) { PowerPC::ppcState.spr[SPR_DSISR] = value; });
|
[this](u64 value) { m_system.GetPPCState().spr[SPR_DSISR] = value; });
|
||||||
// DAR
|
// DAR
|
||||||
AddRegister(
|
AddRegister(
|
||||||
30, 5, RegisterType::dar, "DAR", [] { return PowerPC::ppcState.spr[SPR_DAR]; },
|
30, 5, RegisterType::dar, "DAR", [this] { return m_system.GetPPCState().spr[SPR_DAR]; },
|
||||||
[](u64 value) { PowerPC::ppcState.spr[SPR_DAR] = value; });
|
[this](u64 value) { m_system.GetPPCState().spr[SPR_DAR] = value; });
|
||||||
|
|
||||||
// Hash Mask
|
// Hash Mask
|
||||||
AddRegister(
|
AddRegister(
|
||||||
31, 5, RegisterType::pt_hashmask, "Hash Mask",
|
31, 5, RegisterType::pt_hashmask, "Hash Mask",
|
||||||
[] { return (PowerPC::ppcState.pagetable_hashmask << 6) | PowerPC::ppcState.pagetable_base; },
|
[this] {
|
||||||
|
const auto& ppc_state = m_system.GetPPCState();
|
||||||
|
return (ppc_state.pagetable_hashmask << 6) | ppc_state.pagetable_base;
|
||||||
|
},
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
emit RequestTableUpdate();
|
emit RequestTableUpdate();
|
||||||
|
@ -13,6 +13,10 @@
|
|||||||
class QTableWidget;
|
class QTableWidget;
|
||||||
class QCloseEvent;
|
class QCloseEvent;
|
||||||
class QShowEvent;
|
class QShowEvent;
|
||||||
|
namespace Core
|
||||||
|
{
|
||||||
|
class System;
|
||||||
|
}
|
||||||
|
|
||||||
class RegisterWidget : public QDockWidget
|
class RegisterWidget : public QDockWidget
|
||||||
{
|
{
|
||||||
@ -49,6 +53,8 @@ private:
|
|||||||
void AutoStep(const std::string& reg) const;
|
void AutoStep(const std::string& reg) const;
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
|
Core::System& m_system;
|
||||||
|
|
||||||
QTableWidget* m_table;
|
QTableWidget* m_table;
|
||||||
bool m_updating = false;
|
bool m_updating = false;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user