mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix several debugger hangs and odd cases (fixes #691)
This commit is contained in:
parent
8c095ec885
commit
3b4ccb84d2
|
@ -268,6 +268,7 @@ static void GBAProcessEvents(struct ARMCore* cpu) {
|
|||
}
|
||||
}
|
||||
|
||||
#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 @@ void GBAAttachDebugger(struct GBA* gba, struct mDebugger* 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);
|
||||
|
|
|
@ -38,7 +38,14 @@ void DebuggerConsoleController::enterLine(const QString& line) {
|
|||
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::init(struct CLIDebuggerBackend* be) {
|
|||
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 @@ const char* DebuggerConsoleController::readLine(struct CLIDebuggerBackend* be, s
|
|||
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 @@ const char* DebuggerConsoleController::historyLast(struct CLIDebuggerBackend* be
|
|||
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();
|
||||
|
|
|
@ -30,6 +30,7 @@ signals:
|
|||
|
||||
public slots:
|
||||
void enterLine(const QString&);
|
||||
virtual void detach() override;
|
||||
|
||||
protected:
|
||||
virtual void attachInternal() override;
|
||||
|
|
|
@ -623,6 +623,7 @@ void GameController::closeGame() {
|
|||
return;
|
||||
}
|
||||
|
||||
setDebugger(nullptr);
|
||||
if (mCoreThreadIsPaused(&m_threadContext)) {
|
||||
mCoreThreadUnpause(&m_threadContext);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue