Debugger: Implement boot and debug

Creates a breakpoint automatically on the ELF entry point
This commit is contained in:
Ty Lamontagne 2023-01-14 22:29:42 -05:00 committed by refractionpcsx2
parent a37ff0c4f2
commit a0000a8547
7 changed files with 92 additions and 60 deletions

View File

@ -88,16 +88,18 @@ void DebuggerWindow::onVMStateChanged()
m_actionStepInto->setEnabled(true); m_actionStepInto->setEnabled(true);
m_actionStepOver->setEnabled(true); m_actionStepOver->setEnabled(true);
m_actionStepOut->setEnabled(true); m_actionStepOut->setEnabled(true);
CBreakPoints::ClearTemporaryBreakPoints(); Host::RunOnCPUThread([] {
if (CBreakPoints::GetBreakpointTriggered()) if (CBreakPoints::GetBreakpointTriggered())
{ {
CBreakPoints::ClearTemporaryBreakPoints();
CBreakPoints::SetBreakpointTriggered(false); CBreakPoints::SetBreakpointTriggered(false);
// Our current PC is on a breakpoint. // Our current PC is on a breakpoint.
// When we run the core again, we want to skip this breakpoint and run // When we run the core again, we want to skip this breakpoint and run
CBreakPoints::SetSkipFirst(BREAKPOINT_EE, r5900Debug.getPC()); CBreakPoints::SetSkipFirst(BREAKPOINT_EE, r5900Debug.getPC());
CBreakPoints::SetSkipFirst(BREAKPOINT_IOP, r3000Debug.getPC()); CBreakPoints::SetSkipFirst(BREAKPOINT_IOP, r3000Debug.getPC());
} }
});
} }
return; return;
} }

View File

@ -1489,6 +1489,7 @@ void MainWindow::onGameListEntryContextMenuRequested(const QPoint& point)
{ {
// TODO: Hook this up once it's implemented. // TODO: Hook this up once it's implemented.
action = menu.addAction(tr("Boot and Debug")); action = menu.addAction(tr("Boot and Debug"));
connect(action, &QAction::triggered, [this, entry]() { DebugInterface::setPauseOnEntry(true); startGameListEntry(entry); getDebuggerWindow()->show(); });
} }
menu.addSeparator(); menu.addSeparator();

View File

@ -19,6 +19,7 @@
#include "MIPSAnalyst.h" #include "MIPSAnalyst.h"
#include <cstdio> #include <cstdio>
#include "R5900.h" #include "R5900.h"
#include "R3000A.h"
#include "System.h" #include "System.h"
std::vector<BreakPoint> CBreakPoints::breakPoints_; std::vector<BreakPoint> CBreakPoints::breakPoints_;
@ -432,7 +433,15 @@ void CBreakPoints::Update(BreakPointCpu cpu, u32 addr)
resume = true; resume = true;
} }
SysClearExecutionCache(); if (cpu & BREAKPOINT_EE)
{
Cpu->Reset();
}
if (cpu & BREAKPOINT_IOP)
{
psxCpu->Reset();
}
if (resume) if (resume)
r5900Debug.resumeCpu(); r5900Debug.resumeCpu();

View File

@ -217,6 +217,8 @@ private:
// DebugInterface // DebugInterface
// //
bool DebugInterface::m_pause_on_entry = false;
bool DebugInterface::isAlive() bool DebugInterface::isAlive()
{ {
return VMManager::HasValidVM() && g_FrameCount > 0; return VMManager::HasValidVM() && g_FrameCount > 0;

View File

@ -92,6 +92,12 @@ public:
void pauseCpu(); void pauseCpu();
void resumeCpu(); void resumeCpu();
char* stringFromPointer(u32 p); char* stringFromPointer(u32 p);
static void setPauseOnEntry(bool pauseOnEntry) { m_pause_on_entry = pauseOnEntry; };
static bool getPauseOnEntry() { return m_pause_on_entry; }
private:
static bool m_pause_on_entry;
}; };
class R5900DebugInterface : public DebugInterface class R5900DebugInterface : public DebugInterface

View File

@ -25,6 +25,8 @@
#include "GS.h" #include "GS.h"
#include "CDVD/CDVD.h" #include "CDVD/CDVD.h"
#include "ps2/BiosTools.h" #include "ps2/BiosTools.h"
#include "DebugTools/DebugInterface.h"
#include "DebugTools/Breakpoints.h"
GS_VideoMode gsVideoMode = GS_VideoMode::Uninitialized; GS_VideoMode gsVideoMode = GS_VideoMode::Uninitialized;
bool gsIsInterlaced = false; bool gsIsInterlaced = false;
@ -942,6 +944,15 @@ void SYSCALL()
DevCon.Warning("Set GS CRTC configuration. %s %s (%s)",mode.c_str(), inter, field); DevCon.Warning("Set GS CRTC configuration. %s %s (%s)",mode.c_str(), inter, field);
} }
break; break;
case Syscall::ExecPS2:
{
if (DebugInterface::getPauseOnEntry())
{
CBreakPoints::AddBreakPoint(BREAKPOINT_EE, cpuRegs.GPR.n.a0.UL[0], true);
DebugInterface::setPauseOnEntry(false);
}
}
break;
case Syscall::SetOsdConfigParam: case Syscall::SetOsdConfigParam:
AllowParams1 = true; AllowParams1 = true;
break; break;

View File

@ -19,6 +19,7 @@
enum Syscall : u8 enum Syscall : u8
{ {
SetGsCrt = 2, SetGsCrt = 2,
ExecPS2 = 7,
SetVTLBRefillHandler = 13, SetVTLBRefillHandler = 13,
StartThread = 34, StartThread = 34,
ChangeThreadPriority = 41, ChangeThreadPriority = 41,