Qt: Fix several debugger hangs and odd cases (fixes #691)
Vicki Pfau vi@endrift.com
Sat, 22 Apr 2017 01:39:21 -0700
4 files changed,
22 insertions(+),
4 deletions(-)
M
src/gba/gba.c
→
src/gba/gba.c
@@ -268,6 +268,7 @@ #endif
} } +#ifdef USE_DEBUGGERS void GBAAttachDebugger(struct GBA* gba, struct mDebugger* debugger) { gba->debugger = (struct ARMDebugger*) debugger->platform; gba->debugger->setSoftwareBreakpoint = _setSoftwareBreakpoint;@@ -277,10 +278,13 @@ ARMHotplugAttach(gba->cpu, CPU_COMPONENT_DEBUGGER);
} void GBADetachDebugger(struct GBA* gba) { - gba->debugger = 0; - ARMHotplugDetach(gba->cpu, CPU_COMPONENT_DEBUGGER); - gba->cpu->components[CPU_COMPONENT_DEBUGGER] = 0; + if (gba->debugger) { + ARMHotplugDetach(gba->cpu, CPU_COMPONENT_DEBUGGER); + } + gba->cpu->components[CPU_COMPONENT_DEBUGGER] = NULL; + gba->debugger = NULL; } +#endif bool GBALoadMB(struct GBA* gba, struct VFile* vf) { GBAUnloadROM(gba);
M
src/platform/qt/DebuggerConsoleController.cpp
→
src/platform/qt/DebuggerConsoleController.cpp
@@ -38,7 +38,14 @@ }
m_cond.wakeOne(); } +void DebuggerConsoleController::detach() { + m_lines.append(QString()); + m_cond.wakeOne(); + DebuggerController::detach(); +} + void DebuggerConsoleController::attachInternal() { + m_history.clear(); mCore* core = m_gameController->thread()->core; CLIDebuggerAttachBackend(&m_cliDebugger, &m_backend.d); CLIDebuggerAttachSystem(&m_cliDebugger, core->cliDebuggerSystem(core));@@ -61,6 +68,8 @@
void DebuggerConsoleController::deinit(struct CLIDebuggerBackend* be) { Backend* consoleBe = reinterpret_cast<Backend*>(be); DebuggerConsoleController* self = consoleBe->self; + self->m_lines.append(QString()); + self->m_cond.wakeOne(); } const char* DebuggerConsoleController::readLine(struct CLIDebuggerBackend* be, size_t* len) {@@ -72,6 +81,9 @@ while (self->m_lines.isEmpty()) {
self->m_cond.wait(&self->m_mutex); } self->m_last = self->m_lines.takeFirst().toUtf8(); + if (self->m_last.isEmpty()) { + self->m_last = "\n"; + } *len = self->m_last.size(); return self->m_last.constData();@@ -89,7 +101,7 @@ DebuggerConsoleController* self = consoleBe->self;
GameController::Interrupter interrupter(self->m_gameController, true); QMutexLocker lock(&self->m_mutex); if (self->m_history.isEmpty()) { - return nullptr; + return "\n"; } self->m_last = self->m_history.last().toUtf8(); return self->m_last.constData();
M
src/platform/qt/DebuggerConsoleController.h
→
src/platform/qt/DebuggerConsoleController.h
@@ -30,6 +30,7 @@ void lineAppend(const QString&);
public slots: void enterLine(const QString&); + virtual void detach() override; protected: virtual void attachInternal() override;
M
src/platform/qt/GameController.cpp
→
src/platform/qt/GameController.cpp
@@ -623,6 +623,7 @@ if (!m_gameOpen) {
return; } + setDebugger(nullptr); if (mCoreThreadIsPaused(&m_threadContext)) { mCoreThreadUnpause(&m_threadContext); }