mirror of https://github.com/mgba-emu/mgba.git
Qt: Add error message if listening for GDB port fails
This commit is contained in:
parent
c7593d7073
commit
acb510619f
|
@ -449,7 +449,7 @@ void GDBStubCreate(struct GDBStub* stub) {
|
||||||
stub->untilPoll = GDB_STUB_INTERVAL;
|
stub->untilPoll = GDB_STUB_INTERVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GDBStubListen(struct GDBStub* stub, int port, const struct Address* bindAddress) {
|
bool GDBStubListen(struct GDBStub* stub, int port, const struct Address* bindAddress) {
|
||||||
if (!SOCKET_FAILED(stub->socket)) {
|
if (!SOCKET_FAILED(stub->socket)) {
|
||||||
GDBStubShutdown(stub);
|
GDBStubShutdown(stub);
|
||||||
}
|
}
|
||||||
|
@ -458,7 +458,7 @@ int GDBStubListen(struct GDBStub* stub, int port, const struct Address* bindAddr
|
||||||
if (stub->d.log) {
|
if (stub->d.log) {
|
||||||
stub->d.log(&stub->d, DEBUGGER_LOG_ERROR, "Couldn't open socket");
|
stub->d.log(&stub->d, DEBUGGER_LOG_ERROR, "Couldn't open socket");
|
||||||
}
|
}
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
if (!SocketSetBlocking(stub->socket, false)) {
|
if (!SocketSetBlocking(stub->socket, false)) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -468,7 +468,7 @@ int GDBStubListen(struct GDBStub* stub, int port, const struct Address* bindAddr
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (stub->d.log) {
|
if (stub->d.log) {
|
||||||
|
@ -476,7 +476,7 @@ cleanup:
|
||||||
}
|
}
|
||||||
SocketClose(stub->socket);
|
SocketClose(stub->socket);
|
||||||
stub->socket = INVALID_SOCKET;
|
stub->socket = INVALID_SOCKET;
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDBStubHangup(struct GDBStub* stub) {
|
void GDBStubHangup(struct GDBStub* stub) {
|
||||||
|
|
|
@ -37,7 +37,7 @@ struct GDBStub {
|
||||||
};
|
};
|
||||||
|
|
||||||
void GDBStubCreate(struct GDBStub*);
|
void GDBStubCreate(struct GDBStub*);
|
||||||
int GDBStubListen(struct GDBStub*, int port, const struct Address* bindAddress);
|
bool GDBStubListen(struct GDBStub*, int port, const struct Address* bindAddress);
|
||||||
|
|
||||||
void GDBStubHangup(struct GDBStub*);
|
void GDBStubHangup(struct GDBStub*);
|
||||||
void GDBStubShutdown(struct GDBStub*);
|
void GDBStubShutdown(struct GDBStub*);
|
||||||
|
|
|
@ -58,6 +58,11 @@ void GDBController::listen() {
|
||||||
if (!isAttached()) {
|
if (!isAttached()) {
|
||||||
attach();
|
attach();
|
||||||
}
|
}
|
||||||
GDBStubListen(&m_gdbStub, m_port, &m_bindAddress);
|
if (GDBStubListen(&m_gdbStub, m_port, &m_bindAddress)) {
|
||||||
|
emit listening();
|
||||||
|
} else {
|
||||||
|
detach();
|
||||||
|
emit listenFailed();
|
||||||
|
}
|
||||||
m_gameController->threadContinue();
|
m_gameController->threadContinue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,10 @@ public slots:
|
||||||
void detach();
|
void detach();
|
||||||
void listen();
|
void listen();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void listening();
|
||||||
|
void listenFailed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GDBStub m_gdbStub;
|
GDBStub m_gdbStub;
|
||||||
GameController* m_gameController;
|
GameController* m_gameController;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
@ -46,6 +47,9 @@ GDBWindow::GDBWindow(GDBController* controller, QWidget* parent)
|
||||||
|
|
||||||
m_startStopButton = new QPushButton;
|
m_startStopButton = new QPushButton;
|
||||||
mainSegment->addWidget(m_startStopButton);
|
mainSegment->addWidget(m_startStopButton);
|
||||||
|
connect(m_gdbController, SIGNAL(listening()), this, SLOT(started()));
|
||||||
|
connect(m_gdbController, SIGNAL(listenFailed()), this, SLOT(failed()));
|
||||||
|
|
||||||
if (m_gdbController->isAttached()) {
|
if (m_gdbController->isAttached()) {
|
||||||
started();
|
started();
|
||||||
} else {
|
} else {
|
||||||
|
@ -88,7 +92,6 @@ void GDBWindow::started() {
|
||||||
m_bindAddressEdit->setEnabled(false);
|
m_bindAddressEdit->setEnabled(false);
|
||||||
m_startStopButton->setText(tr("Stop"));
|
m_startStopButton->setText(tr("Stop"));
|
||||||
disconnect(m_startStopButton, SIGNAL(clicked()), m_gdbController, SLOT(listen()));
|
disconnect(m_startStopButton, SIGNAL(clicked()), m_gdbController, SLOT(listen()));
|
||||||
disconnect(m_startStopButton, SIGNAL(clicked()), this, SLOT(started()));
|
|
||||||
connect(m_startStopButton, SIGNAL(clicked()), m_gdbController, SLOT(detach()));
|
connect(m_startStopButton, SIGNAL(clicked()), m_gdbController, SLOT(detach()));
|
||||||
connect(m_startStopButton, SIGNAL(clicked()), this, SLOT(stopped()));
|
connect(m_startStopButton, SIGNAL(clicked()), this, SLOT(stopped()));
|
||||||
}
|
}
|
||||||
|
@ -100,5 +103,12 @@ void GDBWindow::stopped() {
|
||||||
disconnect(m_startStopButton, SIGNAL(clicked()), m_gdbController, SLOT(detach()));
|
disconnect(m_startStopButton, SIGNAL(clicked()), m_gdbController, SLOT(detach()));
|
||||||
disconnect(m_startStopButton, SIGNAL(clicked()), this, SLOT(stopped()));
|
disconnect(m_startStopButton, SIGNAL(clicked()), this, SLOT(stopped()));
|
||||||
connect(m_startStopButton, SIGNAL(clicked()), m_gdbController, SLOT(listen()));
|
connect(m_startStopButton, SIGNAL(clicked()), m_gdbController, SLOT(listen()));
|
||||||
connect(m_startStopButton, SIGNAL(clicked()), this, SLOT(started()));
|
}
|
||||||
|
|
||||||
|
void GDBWindow::failed() {
|
||||||
|
QMessageBox* failure = new QMessageBox(QMessageBox::Warning, tr("Crash"),
|
||||||
|
tr("Could not start GDB server"),
|
||||||
|
QMessageBox::Ok, this, Qt::Sheet);
|
||||||
|
failure->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
failure->show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ private slots:
|
||||||
void started();
|
void started();
|
||||||
void stopped();
|
void stopped();
|
||||||
|
|
||||||
|
void failed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GDBController* m_gdbController;
|
GDBController* m_gdbController;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue