PPU breakpoints resurrected

Now with zero overhead
This commit is contained in:
Nekotekina 2017-02-10 16:13:17 +03:00
parent 8262d56574
commit b20d7ff48c
3 changed files with 54 additions and 3 deletions

View file

@ -118,6 +118,46 @@ extern void ppu_register_function_at(u32 addr, u32 size, ppu_function_t ptr)
}
}
// Breakpoint entry point
static bool ppu_break(ppu_thread& ppu, ppu_opcode_t op)
{
// Pause and wait if necessary
if (!ppu.state.test_and_set(cpu_flag::dbg_pause) && ppu.check_state())
{
return false;
}
// Fallback to the interpreter function
if (reinterpret_cast<decltype(&ppu_interpreter::UNK)>(std::uintptr_t{ppu_cache(ppu.cia)})(ppu, op))
{
ppu.cia += 4;
}
return false;
}
// Set or remove breakpoint
extern void ppu_breakpoint(u32 addr)
{
if (g_cfg_ppu_decoder.get() == ppu_decoder_type::llvm)
{
return;
}
const auto _break = ::narrow<u32>(reinterpret_cast<std::uintptr_t>(&ppu_break));
if (s_ppu_compiled[addr / 4] == _break)
{
// Remove breakpoint
s_ppu_compiled[addr / 4] = ppu_cache(addr);
}
else
{
// Set breakpoint
s_ppu_compiled[addr / 4] = _break;
}
}
std::string ppu_thread::get_name() const
{
return fmt::format("PPU[0x%x] Thread (%s)", id, m_name);

View file

@ -13,14 +13,18 @@
#include "Emu/Cell/PPUDisAsm.h"
#include "Emu/Cell/SPUDisAsm.h"
#include "Emu/PSP2/ARMv7DisAsm.h"
#include "Emu/Cell/PPUInterpreter.h"
#include "InstructionEditor.h"
#include "RegisterEditor.h"
//static const int show_lines = 30;
#include <map>
std::map<u32, bool> g_breakpoints;
extern void ppu_breakpoint(u32 addr);
u32 InterpreterDisAsmFrame::GetPc() const
{
const auto cpu = this->cpu.lock();
@ -159,6 +163,11 @@ void InterpreterDisAsmFrame::UpdateUI()
}
}
}
if (Emu.IsStopped())
{
g_breakpoints.clear();
}
}
void InterpreterDisAsmFrame::UpdateUnitList()
@ -516,9 +525,11 @@ bool InterpreterDisAsmFrame::IsBreakPoint(u32 pc)
void InterpreterDisAsmFrame::AddBreakPoint(u32 pc)
{
g_breakpoints.emplace(pc, false);
ppu_breakpoint(pc);
}
bool InterpreterDisAsmFrame::RemoveBreakPoint(u32 pc)
void InterpreterDisAsmFrame::RemoveBreakPoint(u32 pc)
{
return g_breakpoints.erase(pc) != 0;
g_breakpoints.erase(pc);
ppu_breakpoint(pc);
}

View file

@ -51,5 +51,5 @@ public:
void MouseWheel(wxMouseEvent& event);
bool IsBreakPoint(u32 pc);
void AddBreakPoint(u32 pc);
bool RemoveBreakPoint(u32 pc);
void RemoveBreakPoint(u32 pc);
};