mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-15 06:41:37 +00:00
PowerPC: Refactor to class, move to System.
This commit is contained in:
parent
ebbbdc49ab
commit
23843583bf
50 changed files with 705 additions and 531 deletions
|
@ -184,7 +184,7 @@ CodeViewWidget::~CodeViewWidget() = default;
|
|||
|
||||
static u32 GetBranchFromAddress(const Core::CPUThreadGuard& guard, u32 addr)
|
||||
{
|
||||
std::string disasm = PowerPC::debug_interface.Disassemble(&guard, addr);
|
||||
std::string disasm = guard.GetSystem().GetPowerPC().GetDebugInterface().Disassemble(&guard, addr);
|
||||
size_t pos = disasm.find("->0x");
|
||||
|
||||
if (pos == std::string::npos)
|
||||
|
@ -294,8 +294,11 @@ void CodeViewWidget::Update(const Core::CPUThreadGuard* guard)
|
|||
for (int i = 0; i < rows; i++)
|
||||
setRowHeight(i, rowh);
|
||||
|
||||
auto& power_pc = m_system.GetPowerPC();
|
||||
auto& debug_interface = power_pc.GetDebugInterface();
|
||||
|
||||
const std::optional<u32> pc =
|
||||
guard ? std::make_optional(m_system.GetPPCState().pc) : std::nullopt;
|
||||
guard ? std::make_optional(power_pc.GetPPCState().pc) : std::nullopt;
|
||||
|
||||
const bool dark_theme = qApp->palette().color(QPalette::Base).valueF() < 0.5;
|
||||
|
||||
|
@ -304,16 +307,16 @@ void CodeViewWidget::Update(const Core::CPUThreadGuard* guard)
|
|||
for (int i = 0; i < rowCount(); i++)
|
||||
{
|
||||
const u32 addr = AddressForRow(i);
|
||||
const u32 color = PowerPC::debug_interface.GetColor(guard, addr);
|
||||
const u32 color = debug_interface.GetColor(guard, addr);
|
||||
auto* bp_item = new QTableWidgetItem;
|
||||
auto* addr_item = new QTableWidgetItem(QStringLiteral("%1").arg(addr, 8, 16, QLatin1Char('0')));
|
||||
|
||||
std::string disas = PowerPC::debug_interface.Disassemble(guard, addr);
|
||||
std::string disas = debug_interface.Disassemble(guard, addr);
|
||||
auto split = disas.find('\t');
|
||||
|
||||
std::string ins = (split == std::string::npos ? disas : disas.substr(0, split));
|
||||
std::string param = (split == std::string::npos ? "" : disas.substr(split + 1));
|
||||
std::string desc = PowerPC::debug_interface.GetDescription(addr);
|
||||
std::string desc = debug_interface.GetDescription(addr);
|
||||
|
||||
// Adds whitespace and a minimum size to ins and param. Helps to prevent frequent resizing while
|
||||
// scrolling.
|
||||
|
@ -360,19 +363,19 @@ void CodeViewWidget::Update(const Core::CPUThreadGuard* guard)
|
|||
branch.dst_addr = branch_addr;
|
||||
branch.is_link = IsBranchInstructionWithLink(ins);
|
||||
|
||||
description_item->setText(tr("--> %1").arg(
|
||||
QString::fromStdString(PowerPC::debug_interface.GetDescription(branch_addr))));
|
||||
description_item->setText(
|
||||
tr("--> %1").arg(QString::fromStdString(debug_interface.GetDescription(branch_addr))));
|
||||
param_item->setForeground(Qt::magenta);
|
||||
}
|
||||
|
||||
if (ins == "blr")
|
||||
ins_item->setForeground(dark_theme ? QColor(0xa0FFa0) : Qt::darkGreen);
|
||||
|
||||
if (PowerPC::debug_interface.IsBreakpoint(addr))
|
||||
if (debug_interface.IsBreakpoint(addr))
|
||||
{
|
||||
auto icon =
|
||||
Resources::GetScaledThemeIcon("debugger_breakpoint").pixmap(QSize(rowh - 2, rowh - 2));
|
||||
if (!PowerPC::breakpoints.IsBreakPointEnable(addr))
|
||||
if (!m_system.GetPowerPC().GetBreakPoints().IsBreakPointEnable(addr))
|
||||
{
|
||||
QPixmap disabled_icon(icon.size());
|
||||
disabled_icon.fill(Qt::transparent);
|
||||
|
@ -536,8 +539,8 @@ void CodeViewWidget::ReplaceAddress(u32 address, ReplaceWith replace)
|
|||
{
|
||||
Core::CPUThreadGuard guard(m_system);
|
||||
|
||||
PowerPC::debug_interface.SetPatch(guard, address,
|
||||
replace == ReplaceWith::BLR ? 0x4e800020 : 0x60000000);
|
||||
m_system.GetPowerPC().GetDebugInterface().SetPatch(
|
||||
guard, address, replace == ReplaceWith::BLR ? 0x4e800020 : 0x60000000);
|
||||
|
||||
Update(&guard);
|
||||
}
|
||||
|
@ -598,7 +601,7 @@ void CodeViewWidget::OnContextMenu()
|
|||
{
|
||||
Core::CPUThreadGuard guard(m_system);
|
||||
const u32 pc = m_system.GetPPCState().pc;
|
||||
const std::string disasm = PowerPC::debug_interface.Disassemble(&guard, pc);
|
||||
const std::string disasm = m_system.GetPowerPC().GetDebugInterface().Disassemble(&guard, pc);
|
||||
|
||||
if (addr == pc)
|
||||
{
|
||||
|
@ -642,7 +645,8 @@ void CodeViewWidget::OnContextMenu()
|
|||
action->setEnabled(valid_load_store);
|
||||
}
|
||||
|
||||
restore_action->setEnabled(running && PowerPC::debug_interface.HasEnabledPatch(addr));
|
||||
restore_action->setEnabled(running &&
|
||||
m_system.GetPowerPC().GetDebugInterface().HasEnabledPatch(addr));
|
||||
|
||||
menu->exec(QCursor::pos());
|
||||
Update();
|
||||
|
@ -745,14 +749,14 @@ void CodeViewWidget::OnCopyTargetAddress()
|
|||
|
||||
const std::string code_line = [this, addr] {
|
||||
Core::CPUThreadGuard guard(m_system);
|
||||
return PowerPC::debug_interface.Disassemble(&guard, addr);
|
||||
return m_system.GetPowerPC().GetDebugInterface().Disassemble(&guard, addr);
|
||||
}();
|
||||
|
||||
if (!IsInstructionLoadStore(code_line))
|
||||
return;
|
||||
|
||||
const std::optional<u32> target_addr =
|
||||
PowerPC::debug_interface.GetMemoryAddressFromInstruction(code_line);
|
||||
m_system.GetPowerPC().GetDebugInterface().GetMemoryAddressFromInstruction(code_line);
|
||||
|
||||
if (target_addr)
|
||||
{
|
||||
|
@ -775,14 +779,14 @@ void CodeViewWidget::OnShowTargetInMemory()
|
|||
|
||||
const std::string code_line = [this, addr] {
|
||||
Core::CPUThreadGuard guard(m_system);
|
||||
return PowerPC::debug_interface.Disassemble(&guard, addr);
|
||||
return m_system.GetPowerPC().GetDebugInterface().Disassemble(&guard, addr);
|
||||
}();
|
||||
|
||||
if (!IsInstructionLoadStore(code_line))
|
||||
return;
|
||||
|
||||
const std::optional<u32> target_addr =
|
||||
PowerPC::debug_interface.GetMemoryAddressFromInstruction(code_line);
|
||||
m_system.GetPowerPC().GetDebugInterface().GetMemoryAddressFromInstruction(code_line);
|
||||
|
||||
if (target_addr)
|
||||
emit ShowMemory(*target_addr);
|
||||
|
@ -794,7 +798,7 @@ void CodeViewWidget::OnCopyCode()
|
|||
|
||||
const std::string text = [this, addr] {
|
||||
Core::CPUThreadGuard guard(m_system);
|
||||
return PowerPC::debug_interface.Disassemble(&guard, addr);
|
||||
return m_system.GetPowerPC().GetDebugInterface().Disassemble(&guard, addr);
|
||||
}();
|
||||
|
||||
QApplication::clipboard()->setText(QString::fromStdString(text));
|
||||
|
@ -818,7 +822,8 @@ void CodeViewWidget::OnCopyFunction()
|
|||
const u32 end = start + symbol->size;
|
||||
for (u32 addr = start; addr != end; addr += 4)
|
||||
{
|
||||
const std::string disasm = PowerPC::debug_interface.Disassemble(&guard, addr);
|
||||
const std::string disasm =
|
||||
m_system.GetPowerPC().GetDebugInterface().Disassemble(&guard, addr);
|
||||
fmt::format_to(std::back_inserter(text), "{:08x}: {}\r\n", addr, disasm);
|
||||
}
|
||||
}
|
||||
|
@ -832,7 +837,7 @@ void CodeViewWidget::OnCopyHex()
|
|||
|
||||
const u32 instruction = [this, addr] {
|
||||
Core::CPUThreadGuard guard(m_system);
|
||||
return PowerPC::debug_interface.ReadInstruction(guard, addr);
|
||||
return m_system.GetPowerPC().GetDebugInterface().ReadInstruction(guard, addr);
|
||||
}();
|
||||
|
||||
QApplication::clipboard()->setText(
|
||||
|
@ -843,8 +848,8 @@ void CodeViewWidget::OnRunToHere()
|
|||
{
|
||||
const u32 addr = GetContextAddress();
|
||||
|
||||
PowerPC::debug_interface.SetBreakpoint(addr);
|
||||
PowerPC::debug_interface.RunToBreakpoint();
|
||||
m_system.GetPowerPC().GetDebugInterface().SetBreakpoint(addr);
|
||||
m_system.GetPowerPC().GetDebugInterface().RunToBreakpoint();
|
||||
Update();
|
||||
}
|
||||
|
||||
|
@ -997,11 +1002,12 @@ void CodeViewWidget::OnReplaceInstruction()
|
|||
if (!read_result.valid)
|
||||
return;
|
||||
|
||||
PatchInstructionDialog dialog(this, addr, PowerPC::debug_interface.ReadInstruction(guard, addr));
|
||||
auto& debug_interface = m_system.GetPowerPC().GetDebugInterface();
|
||||
PatchInstructionDialog dialog(this, addr, debug_interface.ReadInstruction(guard, addr));
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
PowerPC::debug_interface.SetPatch(guard, addr, dialog.GetCode());
|
||||
debug_interface.SetPatch(guard, addr, dialog.GetCode());
|
||||
Update(&guard);
|
||||
}
|
||||
}
|
||||
|
@ -1012,7 +1018,7 @@ void CodeViewWidget::OnRestoreInstruction()
|
|||
|
||||
const u32 addr = GetContextAddress();
|
||||
|
||||
PowerPC::debug_interface.UnsetPatch(guard, addr);
|
||||
m_system.GetPowerPC().GetDebugInterface().UnsetPatch(guard, addr);
|
||||
Update(&guard);
|
||||
}
|
||||
|
||||
|
@ -1091,10 +1097,11 @@ void CodeViewWidget::showEvent(QShowEvent* event)
|
|||
|
||||
void CodeViewWidget::ToggleBreakpoint()
|
||||
{
|
||||
if (PowerPC::debug_interface.IsBreakpoint(GetContextAddress()))
|
||||
PowerPC::breakpoints.Remove(GetContextAddress());
|
||||
auto& power_pc = m_system.GetPowerPC();
|
||||
if (power_pc.GetDebugInterface().IsBreakpoint(GetContextAddress()))
|
||||
power_pc.GetBreakPoints().Remove(GetContextAddress());
|
||||
else
|
||||
PowerPC::breakpoints.Add(GetContextAddress());
|
||||
power_pc.GetBreakPoints().Add(GetContextAddress());
|
||||
|
||||
emit BreakpointsChanged();
|
||||
Update();
|
||||
|
@ -1102,7 +1109,7 @@ void CodeViewWidget::ToggleBreakpoint()
|
|||
|
||||
void CodeViewWidget::AddBreakpoint()
|
||||
{
|
||||
PowerPC::breakpoints.Add(GetContextAddress());
|
||||
m_system.GetPowerPC().GetBreakPoints().Add(GetContextAddress());
|
||||
|
||||
emit BreakpointsChanged();
|
||||
Update();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue