GDBStub: boot to pause

This commit is contained in:
aldelaro5 2021-09-30 23:33:40 -04:00
parent e03ddc2116
commit e3b978cf20
1 changed files with 11 additions and 11 deletions

View File

@ -316,12 +316,12 @@ void UndeclareAsCPUThread()
} }
// For the CPU Thread only. // For the CPU Thread only.
static void CPUSetInitialExecutionState() static void CPUSetInitialExecutionState(bool force_paused = false)
{ {
// The CPU starts in stepping state, and will wait until a new state is set before executing. // The CPU starts in stepping state, and will wait until a new state is set before executing.
// SetState must be called on the host thread, so we defer it for later. // SetState must be called on the host thread, so we defer it for later.
QueueHostJob([]() { QueueHostJob([force_paused]() {
SetState(SConfig::GetInstance().bBootToPause ? State::Paused : State::Running); SetState(SConfig::GetInstance().bBootToPause || force_paused ? State::Paused : State::Running);
Host_UpdateDisasmDialog(); Host_UpdateDisasmDialog();
Host_UpdateMainFrame(); Host_UpdateMainFrame();
Host_Message(HostMessageID::WMUserCreate); Host_Message(HostMessageID::WMUserCreate);
@ -363,22 +363,22 @@ static void CpuThread(const std::optional<std::string>& savestate_path, bool del
} }
s_is_started = true; s_is_started = true;
CPUSetInitialExecutionState();
#ifdef USE_GDBSTUB
#ifndef _WIN32 #ifndef _WIN32
if (!_CoreParameter.gdb_socket.empty()) if (!_CoreParameter.gdb_socket.empty())
{ {
gdb_init_local(_CoreParameter.gdb_socket.data()); GDBStub::InitLocal(_CoreParameter.gdb_socket.data());
gdb_break(); CPUSetInitialExecutionState(true);
} }
else else
#endif #endif
if (_CoreParameter.iGDBPort > 0) if (_CoreParameter.iGDBPort > 0)
{ {
gdb_init(_CoreParameter.iGDBPort); GDBStub::Init(_CoreParameter.iGDBPort);
// break at next instruction (the first instruction) CPUSetInitialExecutionState(true);
gdb_break(); }
else
{
CPUSetInitialExecutionState();
} }
#endif #endif