From 48e36c08e9274395f02f6b4758dfd12641ec08c0 Mon Sep 17 00:00:00 2001 From: Ernie Pasveer Date: Sat, 12 Mar 2022 09:24:28 -0600 Subject: [PATCH] Shutdown gdb when 'close' event happens. This should take care of detaching from a remote pid. --- src/SeerGdbWidget.cpp | 14 ++++++++++++++ src/SeerGdbWidget.h | 1 + src/SeerMainWindow.cpp | 2 ++ 3 files changed, 17 insertions(+) diff --git a/src/SeerGdbWidget.cpp b/src/SeerGdbWidget.cpp index 9e26339..b9f5cec 100644 --- a/src/SeerGdbWidget.cpp +++ b/src/SeerGdbWidget.cpp @@ -749,6 +749,20 @@ void SeerGdbWidget::handleGdbCoreFileExecutable () { handleGdbCommand(QString("-target-select core %1").arg(executableCoreFilename())); } +void SeerGdbWidget::handleGdbShutdown () { + + if (isGdbRuning() == false) { + return; + } + + // Give the gdb and 'exit' command. + // This should handle detaching from an attached pid. + handleGdbExit(); + + // Kill the gdb. + killGdb(); +} + void SeerGdbWidget::handleGdbRunToLine (QString fullname, int lineno) { if (executableLaunchMode() == "") { diff --git a/src/SeerGdbWidget.h b/src/SeerGdbWidget.h index ac4c6cf..6b3eb6e 100644 --- a/src/SeerGdbWidget.h +++ b/src/SeerGdbWidget.h @@ -111,6 +111,7 @@ class SeerGdbWidget : public QWidget, protected Ui::SeerGdbWidgetForm { void handleGdbAttachExecutable (); void handleGdbConnectExecutable (); void handleGdbCoreFileExecutable (); + void handleGdbShutdown (); void handleGdbRunToLine (QString fullname, int lineno); void handleGdbNext (); void handleGdbStep (); diff --git a/src/SeerMainWindow.cpp b/src/SeerMainWindow.cpp index c163c12..b5fe72f 100644 --- a/src/SeerMainWindow.cpp +++ b/src/SeerMainWindow.cpp @@ -106,6 +106,8 @@ SeerMainWindow::SeerMainWindow(QWidget* parent) : QMainWindow(parent) { QObject::connect(runStatus, &SeerRunStatusIndicator::statusChanged, this, &SeerMainWindow::handleRunStatusChanged); + QObject::connect(qApp, &QApplication::aboutToQuit, gdbWidget, &SeerGdbWidget::handleGdbShutdown); + // Restore window settings. readSettings();