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;
|
||||
}
|
||||
|
||||
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)) {
|
||||
GDBStubShutdown(stub);
|
||||
}
|
||||
|
@ -458,7 +458,7 @@ int GDBStubListen(struct GDBStub* stub, int port, const struct Address* bindAddr
|
|||
if (stub->d.log) {
|
||||
stub->d.log(&stub->d, DEBUGGER_LOG_ERROR, "Couldn't open socket");
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
if (!SocketSetBlocking(stub->socket, false)) {
|
||||
goto cleanup;
|
||||
|
@ -468,7 +468,7 @@ int GDBStubListen(struct GDBStub* stub, int port, const struct Address* bindAddr
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
|
||||
cleanup:
|
||||
if (stub->d.log) {
|
||||
|
@ -476,7 +476,7 @@ cleanup:
|
|||
}
|
||||
SocketClose(stub->socket);
|
||||
stub->socket = INVALID_SOCKET;
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void GDBStubHangup(struct GDBStub* stub) {
|
||||
|
|
|
@ -37,7 +37,7 @@ 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 GDBStubShutdown(struct GDBStub*);
|
||||
|
|
|
@ -58,6 +58,11 @@ void GDBController::listen() {
|
|||
if (!isAttached()) {
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,10 @@ public slots:
|
|||
void detach();
|
||||
void listen();
|
||||
|
||||
signals:
|
||||
void listening();
|
||||
void listenFailed();
|
||||
|
||||
private:
|
||||
GDBStub m_gdbStub;
|
||||
GameController* m_gameController;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <QGroupBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
@ -46,6 +47,9 @@ GDBWindow::GDBWindow(GDBController* controller, QWidget* parent)
|
|||
|
||||
m_startStopButton = new QPushButton;
|
||||
mainSegment->addWidget(m_startStopButton);
|
||||
connect(m_gdbController, SIGNAL(listening()), this, SLOT(started()));
|
||||
connect(m_gdbController, SIGNAL(listenFailed()), this, SLOT(failed()));
|
||||
|
||||
if (m_gdbController->isAttached()) {
|
||||
started();
|
||||
} else {
|
||||
|
@ -88,7 +92,6 @@ void GDBWindow::started() {
|
|||
m_bindAddressEdit->setEnabled(false);
|
||||
m_startStopButton->setText(tr("Stop"));
|
||||
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()), this, SLOT(stopped()));
|
||||
}
|
||||
|
@ -100,5 +103,12 @@ void GDBWindow::stopped() {
|
|||
disconnect(m_startStopButton, SIGNAL(clicked()), m_gdbController, SLOT(detach()));
|
||||
disconnect(m_startStopButton, SIGNAL(clicked()), this, SLOT(stopped()));
|
||||
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 stopped();
|
||||
|
||||
void failed();
|
||||
|
||||
private:
|
||||
GDBController* m_gdbController;
|
||||
|
||||
|
|
Loading…
Reference in New Issue