mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix up debugger console slightly
This commit is contained in:
parent
0235b6da9b
commit
47728c7a8d
|
@ -8,6 +8,7 @@
|
||||||
#include "CoreController.h"
|
#include "CoreController.h"
|
||||||
|
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
#include <mgba/internal/debugger/cli-debugger.h>
|
#include <mgba/internal/debugger/cli-debugger.h>
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ DebuggerConsoleController::DebuggerConsoleController(QObject* parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerConsoleController::enterLine(const QString& line) {
|
void DebuggerConsoleController::enterLine(const QString& line) {
|
||||||
|
CoreController::Interrupter interrupter(m_gameController);
|
||||||
QMutexLocker lock(&m_mutex);
|
QMutexLocker lock(&m_mutex);
|
||||||
m_lines.append(line);
|
m_lines.append(line);
|
||||||
if (m_cliDebugger.d.state == DEBUGGER_RUNNING) {
|
if (m_cliDebugger.d.state == DEBUGGER_RUNNING) {
|
||||||
|
@ -39,14 +41,20 @@ void DebuggerConsoleController::enterLine(const QString& line) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerConsoleController::detach() {
|
void DebuggerConsoleController::detach() {
|
||||||
|
{
|
||||||
|
CoreController::Interrupter interrupter(m_gameController);
|
||||||
|
QMutexLocker lock(&m_mutex);
|
||||||
if (m_cliDebugger.d.state != DEBUGGER_SHUTDOWN) {
|
if (m_cliDebugger.d.state != DEBUGGER_SHUTDOWN) {
|
||||||
m_lines.append(QString());
|
m_lines.append(QString());
|
||||||
m_cond.wakeOne();
|
m_cond.wakeOne();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
DebuggerController::detach();
|
DebuggerController::detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerConsoleController::attachInternal() {
|
void DebuggerConsoleController::attachInternal() {
|
||||||
|
CoreController::Interrupter interrupter(m_gameController);
|
||||||
|
QMutexLocker lock(&m_mutex);
|
||||||
m_history.clear();
|
m_history.clear();
|
||||||
mCore* core = m_gameController->thread()->core;
|
mCore* core = m_gameController->thread()->core;
|
||||||
CLIDebuggerAttachBackend(&m_cliDebugger, &m_backend.d);
|
CLIDebuggerAttachBackend(&m_cliDebugger, &m_backend.d);
|
||||||
|
@ -65,12 +73,13 @@ void DebuggerConsoleController::printf(struct CLIDebuggerBackend* be, const char
|
||||||
void DebuggerConsoleController::init(struct CLIDebuggerBackend* be) {
|
void DebuggerConsoleController::init(struct CLIDebuggerBackend* be) {
|
||||||
Backend* consoleBe = reinterpret_cast<Backend*>(be);
|
Backend* consoleBe = reinterpret_cast<Backend*>(be);
|
||||||
DebuggerConsoleController* self = consoleBe->self;
|
DebuggerConsoleController* self = consoleBe->self;
|
||||||
|
UNUSED(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DebuggerConsoleController::deinit(struct CLIDebuggerBackend* be) {
|
void DebuggerConsoleController::deinit(struct CLIDebuggerBackend* be) {
|
||||||
Backend* consoleBe = reinterpret_cast<Backend*>(be);
|
Backend* consoleBe = reinterpret_cast<Backend*>(be);
|
||||||
DebuggerConsoleController* self = consoleBe->self;
|
DebuggerConsoleController* self = consoleBe->self;
|
||||||
if (be->p->d.state != DEBUGGER_SHUTDOWN) {
|
if (QThread::currentThread() == self->thread() && be->p->d.state != DEBUGGER_SHUTDOWN) {
|
||||||
self->m_lines.append(QString());
|
self->m_lines.append(QString());
|
||||||
self->m_cond.wakeOne();
|
self->m_cond.wakeOne();
|
||||||
}
|
}
|
||||||
|
@ -109,6 +118,7 @@ const char* DebuggerConsoleController::historyLast(struct CLIDebuggerBackend* be
|
||||||
return "i";
|
return "i";
|
||||||
}
|
}
|
||||||
self->m_last = self->m_history.last().toUtf8();
|
self->m_last = self->m_history.last().toUtf8();
|
||||||
|
*len = self->m_last.size();
|
||||||
return self->m_last.constData();
|
return self->m_last.constData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue