mirror of https://github.com/mgba-emu/mgba.git
Support creating the GDB stub in Qt
This commit is contained in:
parent
adcfc37db2
commit
1a7656fe36
|
@ -16,6 +16,10 @@ find_package(OpenGL REQUIRED)
|
|||
|
||||
set(SOURCE_FILES AudioDevice.cpp Display.cpp GameController.cpp Window.cpp)
|
||||
|
||||
if(USE_GDB_STUB)
|
||||
set(SOURCE_FILES ${SOURCE_FILES} GDBController.cpp GDBWindow.cpp)
|
||||
endif()
|
||||
|
||||
add_executable(QGBAc WIN32 MACOSX_BUNDLE main.cpp ${SOURCE_FILES})
|
||||
|
||||
qt5_use_modules(QGBAc Widgets Multimedia OpenGL)
|
||||
|
|
|
@ -51,6 +51,23 @@ GameController::~GameController() {
|
|||
delete m_renderer;
|
||||
}
|
||||
|
||||
ARMDebugger* GameController::debugger() {
|
||||
return m_threadContext.debugger;
|
||||
}
|
||||
|
||||
void GameController::setDebugger(ARMDebugger* debugger) {
|
||||
bool wasPaused = isPaused();
|
||||
setPaused(true);
|
||||
if (m_threadContext.debugger) {
|
||||
GBADetachDebugger(m_threadContext.gba);
|
||||
}
|
||||
m_threadContext.debugger = debugger;
|
||||
if (m_threadContext.debugger) {
|
||||
GBAAttachDebugger(m_threadContext.gba, m_threadContext.debugger);
|
||||
}
|
||||
setPaused(wasPaused);
|
||||
}
|
||||
|
||||
void GameController::loadGame(const QString& path) {
|
||||
m_rom = new QFile(path);
|
||||
if (!m_rom->open(QIODevice::ReadOnly)) {
|
||||
|
@ -66,6 +83,10 @@ void GameController::loadGame(const QString& path) {
|
|||
emit gameStarted(&m_threadContext);
|
||||
}
|
||||
|
||||
bool GameController::isPaused() {
|
||||
return GBAThreadIsPaused(&m_threadContext);
|
||||
}
|
||||
|
||||
void GameController::setPaused(bool paused) {
|
||||
if (paused == GBAThreadIsPaused(&m_threadContext)) {
|
||||
return;
|
||||
|
|
|
@ -27,6 +27,13 @@ public:
|
|||
|
||||
const uint32_t* drawContext() const { return m_drawContext; }
|
||||
|
||||
bool isPaused();
|
||||
|
||||
#ifdef USE_GDB_STUB
|
||||
ARMDebugger* debugger();
|
||||
void setDebugger(ARMDebugger*);
|
||||
#endif
|
||||
|
||||
signals:
|
||||
void frameAvailable(const uint32_t*);
|
||||
void audioDeviceAvailable(GBAAudio*);
|
||||
|
|
|
@ -5,9 +5,17 @@
|
|||
#include <QKeySequence>
|
||||
#include <QMenuBar>
|
||||
|
||||
#include "GDBWindow.h"
|
||||
#include "GDBController.h"
|
||||
|
||||
using namespace QGBA;
|
||||
|
||||
Window::Window(QWidget* parent) : QMainWindow(parent) {
|
||||
Window::Window(QWidget* parent)
|
||||
: QMainWindow(parent)
|
||||
#ifdef USE_GDB_STUB
|
||||
, m_gdbController(nullptr)
|
||||
#endif
|
||||
{
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
setMinimumSize(240, 160);
|
||||
|
||||
|
@ -66,6 +74,16 @@ void Window::selectROM() {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef USE_GDB_STUB
|
||||
void Window::gdbOpen() {
|
||||
if (!m_gdbController) {
|
||||
m_gdbController = new GDBController(m_controller, this);
|
||||
}
|
||||
GDBWindow* window = new GDBWindow(m_gdbController);
|
||||
window->show();
|
||||
}
|
||||
#endif
|
||||
|
||||
void Window::keyPressEvent(QKeyEvent* event) {
|
||||
if (event->isAutoRepeat()) {
|
||||
QWidget::keyPressEvent(event);
|
||||
|
@ -134,4 +152,11 @@ void Window::setupMenu(QMenuBar* menubar) {
|
|||
connect(frameAdvance, SIGNAL(triggered()), m_controller, SLOT(frameAdvance()));
|
||||
m_gameActions.append(frameAdvance);
|
||||
emulationMenu->addAction(frameAdvance);
|
||||
|
||||
QMenu* debuggingMenu = menubar->addMenu(tr("&Debugging"));
|
||||
#ifdef USE_GDB_STUB
|
||||
QAction* gdbWindow = new QAction(tr("Start &GDB server"), nullptr);
|
||||
connect(gdbWindow, SIGNAL(triggered()), this, SLOT(gdbOpen()));
|
||||
debuggingMenu->addAction(gdbWindow);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ extern "C" {
|
|||
|
||||
namespace QGBA {
|
||||
|
||||
class GDBController;
|
||||
|
||||
class Window : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -27,6 +29,10 @@ signals:
|
|||
public slots:
|
||||
void selectROM();
|
||||
|
||||
#ifdef USE_GDB_STUB
|
||||
void gdbOpen();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent* event);
|
||||
virtual void keyReleaseEvent(QKeyEvent* event);
|
||||
|
@ -41,6 +47,10 @@ private:
|
|||
GameController* m_controller;
|
||||
Display* m_display;
|
||||
QList<QAction*> m_gameActions;
|
||||
|
||||
#ifdef USE_GDB_STUB
|
||||
GDBController* m_gdbController;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue