all repos — mgba @ 28a64fcbb82ba3862a873349172556f3a8fe265e

mGBA Game Boy Advance Emulator

Qt: Rename REPL to Console
Jeffrey Pfau jeffrey@endrift.com
Thu, 27 Oct 2016 10:36:57 -0700
commit

28a64fcbb82ba3862a873349172556f3a8fe265e

parent

5406130432f1a487a9768ac4fe5eb07dec4b4fed

M CHANGESCHANGES

@@ -4,7 +4,7 @@ - GBA: Support printing debug strings from inside a game

- GBA: Better cheat type autodetection - GB: Tile viewer - Sprite viewer - - Debugging REPL + - Debugging console Bugfixes: - LR35902: Fix core never exiting with certain event patterns - GB Timer: Improve DIV reset behavior
M src/platform/qt/CMakeLists.txtsrc/platform/qt/CMakeLists.txt

@@ -118,7 +118,7 @@ AboutScreen.ui

ArchiveInspector.ui AssetTile.ui CheatsView.ui - DebuggerREPL.ui + DebuggerConsole.ui GIFView.ui IOViewer.ui LoadSaveState.ui

@@ -181,8 +181,8 @@

if(USE_DEBUGGERS) list(APPEND SOURCE_FILES DebuggerController.cpp - DebuggerREPL.cpp - DebuggerREPLController.cpp) + DebuggerConsole.cpp + DebuggerConsoleController.cpp) endif() if(USE_GDB_STUB)
A src/platform/qt/DebuggerConsole.h

@@ -0,0 +1,33 @@

+/* Copyright (c) 2013-2016 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef QGBA_DEBUGGER_CONSOLE +#define QGBA_DEBUGGER_CONSOLE + +#include "ui_DebuggerConsole.h" + +namespace QGBA { + +class DebuggerConsoleController; + +class DebuggerConsole : public QWidget { +Q_OBJECT + +public: + DebuggerConsole(DebuggerConsoleController* controller, QWidget* parent = nullptr); + +private slots: + void log(const QString&); + void postLine(); + +private: + Ui::DebuggerConsole m_ui; + + DebuggerConsoleController* m_consoleController; +}; + +} + +#endif
A src/platform/qt/DebuggerConsoleController.cpp

@@ -0,0 +1,102 @@

+/* Copyright (c) 2013-2016 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "DebuggerConsoleController.h" + +#include "GameController.h" + +#include <QMutexLocker> + +extern "C" { +#include "debugger/cli-debugger.h" +} + +using namespace QGBA; + +DebuggerConsoleController::DebuggerConsoleController(GameController* controller, QObject* parent) + : DebuggerController(controller, &m_cliDebugger.d, parent) +{ + m_backend.d.printf = printf; + m_backend.d.init = init; + m_backend.d.deinit = deinit; + m_backend.d.readline = readLine; + m_backend.d.lineAppend = lineAppend; + m_backend.d.historyLast = historyLast; + m_backend.d.historyAppend = historyAppend; + m_backend.self = this; + + CLIDebuggerCreate(&m_cliDebugger); + CLIDebuggerAttachBackend(&m_cliDebugger, &m_backend.d); +} + +void DebuggerConsoleController::enterLine(const QString& line) { + QMutexLocker lock(&m_mutex); + m_lines.append(line); + if (m_cliDebugger.d.state == DEBUGGER_RUNNING) { + mDebuggerEnter(&m_cliDebugger.d, DEBUGGER_ENTER_MANUAL, nullptr); + } + m_cond.wakeOne(); +} + +void DebuggerConsoleController::attachInternal() { + mCore* core = m_gameController->thread()->core; + CLIDebuggerAttachSystem(&m_cliDebugger, core->cliDebuggerSystem(core)); +} + +void DebuggerConsoleController::printf(struct CLIDebuggerBackend* be, const char* fmt, ...) { + Backend* consoleBe = reinterpret_cast<Backend*>(be); + DebuggerConsoleController* self = consoleBe->self; + va_list args; + va_start(args, fmt); + self->log(QString().vsprintf(fmt, args)); + va_end(args); +} + +void DebuggerConsoleController::init(struct CLIDebuggerBackend* be) { + Backend* consoleBe = reinterpret_cast<Backend*>(be); + DebuggerConsoleController* self = consoleBe->self; +} + +void DebuggerConsoleController::deinit(struct CLIDebuggerBackend* be) { + Backend* consoleBe = reinterpret_cast<Backend*>(be); + DebuggerConsoleController* self = consoleBe->self; +} + +const char* DebuggerConsoleController::readLine(struct CLIDebuggerBackend* be, size_t* len) { + Backend* consoleBe = reinterpret_cast<Backend*>(be); + DebuggerConsoleController* self = consoleBe->self; + GameController::Interrupter interrupter(self->m_gameController, true); + QMutexLocker lock(&self->m_mutex); + while (self->m_lines.isEmpty()) { + self->m_cond.wait(&self->m_mutex); + } + self->m_last = self->m_lines.takeFirst().toUtf8(); + *len = self->m_last.size(); + return self->m_last.constData(); + +} + +void DebuggerConsoleController::lineAppend(struct CLIDebuggerBackend* be, const char* line) { + Backend* consoleBe = reinterpret_cast<Backend*>(be); + DebuggerConsoleController* self = consoleBe->self; + self->lineAppend(QString::fromUtf8(line)); +} + +const char* DebuggerConsoleController::historyLast(struct CLIDebuggerBackend* be, size_t* len) { + Backend* consoleBe = reinterpret_cast<Backend*>(be); + DebuggerConsoleController* self = consoleBe->self; + GameController::Interrupter interrupter(self->m_gameController, true); + QMutexLocker lock(&self->m_mutex); + self->m_last = self->m_history.last().toUtf8(); + return self->m_last.constData(); +} + +void DebuggerConsoleController::historyAppend(struct CLIDebuggerBackend* be, const char* line) { + Backend* consoleBe = reinterpret_cast<Backend*>(be); + DebuggerConsoleController* self = consoleBe->self; + GameController::Interrupter interrupter(self->m_gameController, true); + QMutexLocker lock(&self->m_mutex); + self->m_history.append(QString::fromUtf8(line)); +}
M src/platform/qt/DebuggerREPL.cppsrc/platform/qt/DebuggerConsole.cpp

@@ -3,17 +3,17 @@ *

* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "DebuggerREPL.h" +#include "DebuggerConsole.h" -#include "DebuggerREPLController.h" +#include "DebuggerConsoleController.h" #include <QScrollBar> using namespace QGBA; -DebuggerREPL::DebuggerREPL(DebuggerREPLController* controller, QWidget* parent) +DebuggerConsole::DebuggerConsole(DebuggerConsoleController* controller, QWidget* parent) : QWidget(parent) - , m_replController(controller) + , m_consoleController(controller) { m_ui.setupUi(this);

@@ -24,19 +24,19 @@

controller->attach(); } -void DebuggerREPL::log(const QString& line) { +void DebuggerConsole::log(const QString& line) { m_ui.log->moveCursor(QTextCursor::End); m_ui.log->insertPlainText(line); m_ui.log->verticalScrollBar()->setValue(m_ui.log->verticalScrollBar()->maximum()); } -void DebuggerREPL::postLine() { +void DebuggerConsole::postLine() { QString line = m_ui.prompt->text(); m_ui.prompt->clear(); if (line.isEmpty()) { - m_replController->enterLine(QString("\n")); + m_consoleController->enterLine(QString("\n")); } else { log(QString("> %1\n").arg(line)); - m_replController->enterLine(line); + m_consoleController->enterLine(line); } }
D src/platform/qt/DebuggerREPL.h

@@ -1,33 +0,0 @@

-/* Copyright (c) 2013-2016 Jeffrey Pfau - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef QGBA_DEBUGGER_REPL -#define QGBA_DEBUGGER_REPL - -#include "ui_DebuggerREPL.h" - -namespace QGBA { - -class DebuggerREPLController; - -class DebuggerREPL : public QWidget { -Q_OBJECT - -public: - DebuggerREPL(DebuggerREPLController* controller, QWidget* parent = nullptr); - -private slots: - void log(const QString&); - void postLine(); - -private: - Ui::DebuggerREPL m_ui; - - DebuggerREPLController* m_replController; -}; - -} - -#endif
M src/platform/qt/DebuggerREPL.uisrc/platform/qt/DebuggerConsole.ui

@@ -1,7 +1,7 @@

<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>DebuggerREPL</class> - <widget class="QWidget" name="DebuggerREPL"> + <class>DebuggerConsole</class> + <widget class="QWidget" name="DebuggerConsole"> <property name="geometry"> <rect> <x>0</x>
D src/platform/qt/DebuggerREPLController.cpp

@@ -1,102 +0,0 @@

-/* Copyright (c) 2013-2016 Jeffrey Pfau - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "DebuggerREPLController.h" - -#include "GameController.h" - -#include <QMutexLocker> - -extern "C" { -#include "debugger/cli-debugger.h" -} - -using namespace QGBA; - -DebuggerREPLController::DebuggerREPLController(GameController* controller, QObject* parent) - : DebuggerController(controller, &m_cliDebugger.d, parent) -{ - m_backend.d.printf = printf; - m_backend.d.init = init; - m_backend.d.deinit = deinit; - m_backend.d.readline = readLine; - m_backend.d.lineAppend = lineAppend; - m_backend.d.historyLast = historyLast; - m_backend.d.historyAppend = historyAppend; - m_backend.self = this; - - CLIDebuggerCreate(&m_cliDebugger); - CLIDebuggerAttachBackend(&m_cliDebugger, &m_backend.d); -} - -void DebuggerREPLController::enterLine(const QString& line) { - QMutexLocker lock(&m_mutex); - m_lines.append(line); - if (m_cliDebugger.d.state == DEBUGGER_RUNNING) { - mDebuggerEnter(&m_cliDebugger.d, DEBUGGER_ENTER_MANUAL, nullptr); - } - m_cond.wakeOne(); -} - -void DebuggerREPLController::attachInternal() { - mCore* core = m_gameController->thread()->core; - CLIDebuggerAttachSystem(&m_cliDebugger, core->cliDebuggerSystem(core)); -} - -void DebuggerREPLController::printf(struct CLIDebuggerBackend* be, const char* fmt, ...) { - Backend* replBe = reinterpret_cast<Backend*>(be); - DebuggerREPLController* self = replBe->self; - va_list args; - va_start(args, fmt); - self->log(QString().vsprintf(fmt, args)); - va_end(args); -} - -void DebuggerREPLController::init(struct CLIDebuggerBackend* be) { - Backend* replBe = reinterpret_cast<Backend*>(be); - DebuggerREPLController* self = replBe->self; -} - -void DebuggerREPLController::deinit(struct CLIDebuggerBackend* be) { - Backend* replBe = reinterpret_cast<Backend*>(be); - DebuggerREPLController* self = replBe->self; -} - -const char* DebuggerREPLController::readLine(struct CLIDebuggerBackend* be, size_t* len) { - Backend* replBe = reinterpret_cast<Backend*>(be); - DebuggerREPLController* self = replBe->self; - GameController::Interrupter interrupter(self->m_gameController, true); - QMutexLocker lock(&self->m_mutex); - while (self->m_lines.isEmpty()) { - self->m_cond.wait(&self->m_mutex); - } - self->m_last = self->m_lines.takeFirst().toUtf8(); - *len = self->m_last.size(); - return self->m_last.constData(); - -} - -void DebuggerREPLController::lineAppend(struct CLIDebuggerBackend* be, const char* line) { - Backend* replBe = reinterpret_cast<Backend*>(be); - DebuggerREPLController* self = replBe->self; - self->lineAppend(QString::fromUtf8(line)); -} - -const char* DebuggerREPLController::historyLast(struct CLIDebuggerBackend* be, size_t* len) { - Backend* replBe = reinterpret_cast<Backend*>(be); - DebuggerREPLController* self = replBe->self; - GameController::Interrupter interrupter(self->m_gameController, true); - QMutexLocker lock(&self->m_mutex); - self->m_last = self->m_history.last().toUtf8(); - return self->m_last.constData(); -} - -void DebuggerREPLController::historyAppend(struct CLIDebuggerBackend* be, const char* line) { - Backend* replBe = reinterpret_cast<Backend*>(be); - DebuggerREPLController* self = replBe->self; - GameController::Interrupter interrupter(self->m_gameController, true); - QMutexLocker lock(&self->m_mutex); - self->m_history.append(QString::fromUtf8(line)); -}
M src/platform/qt/DebuggerREPLController.hsrc/platform/qt/DebuggerConsoleController.h

@@ -3,8 +3,8 @@ *

* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef QGBA_DEBUGGER_REPL_CONTROLLER -#define QGBA_DEBUGGER_REPL_CONTROLLER +#ifndef QGBA_DEBUGGER_CONSOLE_CONTROLLER +#define QGBA_DEBUGGER_CONSOLE_CONTROLLER #include "DebuggerController.h"

@@ -20,11 +20,11 @@ namespace QGBA {

class GameController; -class DebuggerREPLController : public DebuggerController { +class DebuggerConsoleController : public DebuggerController { Q_OBJECT public: - DebuggerREPLController(GameController* controller, QObject* parent = nullptr); + DebuggerConsoleController(GameController* controller, QObject* parent = nullptr); signals: void log(const QString&);

@@ -55,7 +55,7 @@ QByteArray m_last;

struct Backend { CLIDebuggerBackend d; - DebuggerREPLController* self; + DebuggerConsoleController* self; } m_backend; };
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -18,8 +18,8 @@ #include "AboutScreen.h"

#include "ArchiveInspector.h" #include "CheatsView.h" #include "ConfigController.h" -#include "DebuggerREPL.h" -#include "DebuggerREPLController.h" +#include "DebuggerConsole.h" +#include "DebuggerConsoleController.h" #include "Display.h" #include "GameController.h" #include "GBAApp.h"

@@ -73,7 +73,7 @@ #ifdef USE_GDB_STUB

, m_gdbController(nullptr) #endif #ifdef USE_DEBUGGERS - , m_repl(nullptr) + , m_console(nullptr) #endif , m_mruMenu(nullptr) , m_shortcutController(new ShortcutController(this))

@@ -519,11 +519,11 @@ }

#endif #ifdef USE_DEBUGGERS -void Window::replOpen() { - if (!m_repl) { - m_repl = new DebuggerREPLController(m_controller, this); +void Window::consoleOpen() { + if (!m_console) { + m_console = new DebuggerConsoleController(m_controller, this); } - DebuggerREPL* window = new DebuggerREPL(m_repl); + DebuggerConsole* window = new DebuggerConsole(m_console); openView(window); } #endif

@@ -1353,9 +1353,9 @@

toolsMenu->addSeparator(); #ifdef USE_DEBUGGERS - QAction* replWindow = new QAction(tr("Open debugger REPL..."), toolsMenu); - connect(replWindow, SIGNAL(triggered()), this, SLOT(replOpen())); - addControlledAction(toolsMenu, replWindow, "debuggerWindow"); + QAction* consoleWindow = new QAction(tr("Open debugger console..."), toolsMenu); + connect(consoleWindow, SIGNAL(triggered()), this, SLOT(consoleOpen())); + addControlledAction(toolsMenu, consoleWindow, "debuggerWindow"); #endif #ifdef USE_GDB_STUB
M src/platform/qt/Window.hsrc/platform/qt/Window.h

@@ -26,7 +26,7 @@

namespace QGBA { class ConfigController; -class DebuggerREPLController; +class DebuggerConsoleController; class Display; class GameController; class GDBController;

@@ -82,7 +82,7 @@ void openSettingsWindow();

void openAboutScreen(); #ifdef USE_DEBUGGERS - void replOpen(); + void consoleOpen(); #endif #ifdef USE_FFMPEG

@@ -162,7 +162,7 @@ QMap<int, QAction*> m_frameSizes;

LogController m_log; LogView* m_logView; #ifdef USE_DEBUGGERS - DebuggerREPLController* m_repl; + DebuggerConsoleController* m_console; #endif LoadSaveState* m_stateWindow; WindowBackground* m_screenWidget;