From 35b66e111b994b0051d80776ec0b7e06e70aed01 Mon Sep 17 00:00:00 2001 From: Ernie Pasveer Date: Mon, 8 Dec 2025 13:46:13 -0600 Subject: [PATCH] Simply launcher code. Make it changable. --- src/SeerConfigDialog.cpp | 10 ++++-- src/SeerConfigDialog.h | 7 ++-- src/SeerGdbConfigPage.cpp | 15 +++++++-- src/SeerGdbConfigPage.h | 3 +- src/SeerGdbConfigPage.ui | 6 ++-- src/SeerGdbWidget.cpp | 27 +++++++++------ src/SeerGdbWidget.h | 4 ++- src/SeerMainWindow.cpp | 4 +-- src/SeerRRConfigPage.cpp | 6 ---- src/SeerRRConfigPage.h | 1 - src/SeerRRConfigPage.ui | 71 ++++++++++++--------------------------- 11 files changed, 71 insertions(+), 83 deletions(-) diff --git a/src/SeerConfigDialog.cpp b/src/SeerConfigDialog.cpp index 8422134..2d9899f 100644 --- a/src/SeerConfigDialog.cpp +++ b/src/SeerConfigDialog.cpp @@ -164,10 +164,14 @@ bool SeerConfigDialog::seerClearManualCommandHistory () const { return _seerConfigPage->clearManualCommandHistory(); } -void SeerConfigDialog::setProgramLauncher (const QString& launcher) { +void SeerConfigDialog::setGdbLauncher (const QString& launcher) { - _gdbConfigPage->setGdbProgramLauncher(launcher); - _rrConfigPage->setRRProgramLauncher(launcher); + _gdbConfigPage->setGdbLauncher(launcher); +} + +QString SeerConfigDialog::gdbLauncher () const { + + return _gdbConfigPage->gdbLauncher(); } void SeerConfigDialog::setGdbProgram (const QString& program) { diff --git a/src/SeerConfigDialog.h b/src/SeerConfigDialog.h index 9c74cf8..37b8680 100644 --- a/src/SeerConfigDialog.h +++ b/src/SeerConfigDialog.h @@ -43,10 +43,11 @@ class SeerConfigDialog : public QDialog, protected Ui::SeerConfigDialogForm { void setSeerClearManualCommandHistory (bool flag); bool seerClearManualCommandHistory () const; - // Program to launch gdb, rr, etc. Can be blank. Needed by flatpak. - void setProgramLauncher (const QString& launcher); - // Gdb settings. + // Program to launch gdb, rr, etc. Can be blank. Needed by flatpak. + void setGdbLauncher (const QString& launcher); + QString gdbLauncher () const; + void setGdbProgram (const QString& program); QString gdbProgram () const; diff --git a/src/SeerGdbConfigPage.cpp b/src/SeerGdbConfigPage.cpp index 24848a2..4b34353 100644 --- a/src/SeerGdbConfigPage.cpp +++ b/src/SeerGdbConfigPage.cpp @@ -28,6 +28,11 @@ QString SeerGdbConfigPage::gdbProgram () const { return gdbProgramLineEdit->text(); } +QString SeerGdbConfigPage::gdbLauncher () const { + + return gdbLauncherLineEdit->text(); +} + QString SeerGdbConfigPage::gdbArguments () const { return gdbArgumentsLineEdit->text(); @@ -77,7 +82,7 @@ void SeerGdbConfigPage::setGdbProgram (const QString& program) { gdbProgramLineEdit->setText(program); } -void SeerGdbConfigPage::setGdbProgramLauncher (const QString& launcher) { +void SeerGdbConfigPage::setGdbLauncher (const QString& launcher) { return gdbLauncherLineEdit->setText(launcher); } @@ -129,7 +134,13 @@ void SeerGdbConfigPage::reset () { #else setGdbProgram("/usr/bin/gdb"; #endif - setGdbProgramLauncher(""); + +#ifdef SEER_GDB_LAUNCHER + setGdbLauncher(STRINGIFY(SEER_GDB_LAUNCHER)); +#else + setGdbLauncher(""); +#endif + setGdbArguments("--interpreter=mi"); setGdbAsyncMode(true); setGdbNonStopMode(false); diff --git a/src/SeerGdbConfigPage.h b/src/SeerGdbConfigPage.h index 7a3656d..9bb0ca4 100644 --- a/src/SeerGdbConfigPage.h +++ b/src/SeerGdbConfigPage.h @@ -17,6 +17,7 @@ class SeerGdbConfigPage : public QWidget, protected Ui::SeerGdbConfigPage { ~SeerGdbConfigPage (); QString gdbProgram () const; + QString gdbLauncher () const; QString gdbArguments () const; bool gdbAsyncMode () const; bool gdbNonStopMode () const; @@ -28,7 +29,7 @@ class SeerGdbConfigPage : public QWidget, protected Ui::SeerGdbConfigPage { void setGdbProgram (const QString& program); - void setGdbProgramLauncher (const QString& launcher); + void setGdbLauncher (const QString& launcher); void setGdbArguments (const QString& arguments); void setGdbAsyncMode (bool flag); void setGdbNonStopMode (bool flag); diff --git a/src/SeerGdbConfigPage.ui b/src/SeerGdbConfigPage.ui index 968edae..31457a2 100644 --- a/src/SeerGdbConfigPage.ui +++ b/src/SeerGdbConfigPage.ui @@ -84,10 +84,10 @@ - true + false - No launcher is needed. + If needed, program and arguments to launch gdb. true @@ -238,7 +238,7 @@ li.checked::marker { content: "\2612"; } <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Note, Seer relies on the &quot;mi&quot; interpreter that is built into gdb. If a different debugger is used, it must provide that. So, usually, the &quot;--interpreter=mi&quot; argument is a must.</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Sometimes, gdb needs to be launched by another program. For example, under flatpak, gdb needs to be launched by flatpak-spawn. This is defined when compiling Seer. See the CMakefile.txt file. Normally, this does not need to be set.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Sometimes gdb needs to be launched by another program. For example, under flatpak, gdb needs to be launched by flatpak-spawn. This can be defined when compiling Seer. See the CMakefile.txt file. Or manually set here. Normally, this does not need to be set. This launcher is also used for launching RR.</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Async mode allows all gdb actions to happen in the background. This allows interrupting of a running program possible. Note, this is disabled for 'connect' mode as background commands may overwhelm the gdbserver.</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> diff --git a/src/SeerGdbWidget.cpp b/src/SeerGdbWidget.cpp index e5d7444..c02b499 100644 --- a/src/SeerGdbWidget.cpp +++ b/src/SeerGdbWidget.cpp @@ -61,11 +61,19 @@ SeerGdbWidget::SeerGdbWidget (QWidget* parent) : QWidget(parent) { _catchpointsBrowserWidget = 0; _gdbOutputLog = 0; _seerOutputLog = 0; + #ifdef SEER_GDB_NAME _gdbProgram = STRINGIFY(SEER_GDB_NAME); #else _gdbProgram = "/usr/bin/gdb"; #endif + +#ifdef SEER_GDB_LAUNCHER + _gdbLauncher = STRINGIFY(SEER_GDB_LAUNCHER); +#else + _gdbLauncher = ""; +#endif + _gdbArguments = "--interpreter=mi"; _gdbASyncMode = true; _gdbNonStopMode = false; @@ -630,15 +638,14 @@ QString SeerGdbWidget::gdbProgram () const { return _gdbProgram; } -QString SeerGdbWidget::gdbProgramLauncher () const { +void SeerGdbWidget::setGdbLauncher (const QString& launchProgram) { - QString gdbLauncher = ""; + _gdbLauncher = launchProgram; +} -#ifdef SEER_GDB_LAUNCHER - gdbLauncher = STRINGIFY(SEER_GDB_LAUNCHER); -#endif +QString SeerGdbWidget::gdbLauncher () const { - return gdbLauncher; + return _gdbLauncher; } void SeerGdbWidget::setGdbArguments (const QString& arguments) { @@ -3659,8 +3666,8 @@ bool SeerGdbWidget::startGdb () { QString rawcommand; // Is a 'launcher' being used? Like 'flatpak-spawn'. - if (gdbProgramLauncher() != "") { - rawcommand += gdbProgramLauncher() + " "; + if (gdbLauncher() != "") { + rawcommand += gdbLauncher() + " "; } // Set the gdb program name to use. @@ -3736,8 +3743,8 @@ bool SeerGdbWidget::startGdbRR () { QString rawcommand; // Is a 'launcher' being used? Like 'flatpak-spawn'. - if (gdbProgramLauncher() != "") { - rawcommand += gdbProgramLauncher() + " "; + if (gdbLauncher() != "") { + rawcommand += gdbLauncher() + " "; } // Set the RR program name to use. diff --git a/src/SeerGdbWidget.h b/src/SeerGdbWidget.h index e597144..181c828 100644 --- a/src/SeerGdbWidget.h +++ b/src/SeerGdbWidget.h @@ -79,7 +79,8 @@ class SeerGdbWidget : public QWidget, protected Ui::SeerGdbWidgetForm { const QString& executableBreakMode () const; // Gdb settings. - QString gdbProgramLauncher () const; + void setGdbLauncher (const QString& launchProgram); + QString gdbLauncher () const; void setGdbProgram (const QString& program); QString gdbProgram () const; @@ -419,6 +420,7 @@ class SeerGdbWidget : public QWidget, protected Ui::SeerGdbWidgetForm { void delay (int seconds); bool _isQuitting; + QString _gdbLauncher; QString _gdbProgram; QString _gdbArguments; QString _gdbProgramOverride; diff --git a/src/SeerMainWindow.cpp b/src/SeerMainWindow.cpp index 49a07f6..4e46962 100644 --- a/src/SeerMainWindow.cpp +++ b/src/SeerMainWindow.cpp @@ -733,6 +733,7 @@ void SeerMainWindow::handleSettingsConfiguration () { dlg.setSeerConsoleMode(gdbWidget->consoleMode()); dlg.setSeerConsoleScrollLines(gdbWidget->consoleScrollLines()); dlg.setSeerRememberManualCommandCount(gdbWidget->rememberManualCommandCount()); + dlg.setGdbLauncher(gdbWidget->gdbLauncher()); dlg.setGdbProgram(gdbWidget->gdbProgram()); dlg.setGdbArguments(gdbWidget->gdbArguments()); dlg.setGdbAsyncMode(gdbWidget->gdbAsyncMode()); @@ -768,9 +769,6 @@ void SeerMainWindow::handleSettingsConfiguration () { dlg.setRRArguments(gdbWidget->rrArguments()); dlg.setRRGdbArguments(gdbWidget->rrGdbArguments()); - // Launcher is a read-only thing. Just need to show it. - dlg.setProgramLauncher(gdbWidget->gdbProgramLauncher()); - int ret = dlg.exec(); if (ret == 0) { diff --git a/src/SeerRRConfigPage.cpp b/src/SeerRRConfigPage.cpp index d0ef378..f720f03 100644 --- a/src/SeerRRConfigPage.cpp +++ b/src/SeerRRConfigPage.cpp @@ -42,11 +42,6 @@ void SeerRRConfigPage::setRRProgram (const QString& program) { rrProgramLineEdit->setText(program); } -void SeerRRConfigPage::setRRProgramLauncher (const QString& launcher) { - - return rrLauncherLineEdit->setText(launcher); -} - void SeerRRConfigPage::setRRArguments (const QString& arguments) { rrArgumentsLineEdit->setText(arguments); @@ -60,7 +55,6 @@ void SeerRRConfigPage::setGdbArguments (const QString& arguments) { void SeerRRConfigPage::reset () { setRRProgram("/usr/bin/rr"); - setRRProgramLauncher(""); setRRArguments("replay --interpreter=mi"); setGdbArguments(""); } diff --git a/src/SeerRRConfigPage.h b/src/SeerRRConfigPage.h index 5212e5c..e0322a8 100644 --- a/src/SeerRRConfigPage.h +++ b/src/SeerRRConfigPage.h @@ -20,7 +20,6 @@ class SeerRRConfigPage : public QWidget, protected Ui::SeerRRConfigPage { QString gdbArguments () const; void setRRProgram (const QString& program); - void setRRProgramLauncher (const QString& launcher); void setRRArguments (const QString& arguments); void setGdbArguments (const QString& arguments); diff --git a/src/SeerRRConfigPage.ui b/src/SeerRRConfigPage.ui index aa32381..250566d 100644 --- a/src/SeerRRConfigPage.ui +++ b/src/SeerRRConfigPage.ui @@ -20,6 +20,16 @@ RR Settings + + + + Specify the path and name of the RR debugger. + + + true + + + @@ -27,10 +37,17 @@ - - + + + + RR arguments + + + + + - Specify the path and name of the RR debugger. + Any extra arguments to pass to the gdb debugger. true @@ -51,13 +68,6 @@ - - - - RR arguments - - - @@ -69,48 +79,12 @@ - - - RR launcher - - - - - - - The program, if needed, to launch the RR binary. - - - - - - true - - - No launcher is needed. - - - true - - - - GDB arguments - - - - Any extra arguments to pass to the gdb debugger. - - - true - - - @@ -128,9 +102,8 @@ li.checked::marker { content: "\2612"; } <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Changing many of these require saving the new configuration and restarting Seer to take effect</span>.</p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif';"><br />&quot;RR program&quot; points to the path and name of the RR program.</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif';">&quot;RR arguments&quot; specifies the arguments to pass to RR. It must minimally have 'replay --interpreter=mi'. And other arguments you may need for RR.</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Sometimes, RR needs to be launched by another program. For example, under flatpak, RR needs to be launched by flatpak-spawn. This is defined when compiling Seer. See the CMakefile.txt file. Normally, this does not need to be set.</p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif';">&quot;GDB arguments&quot; specified the arguments to pass on to gdb. Usually not needed.</span></p> -<p style="-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif';"><br /></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">RR will be started by the launcher specified in the GDB config tab.</p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif';">Between these input fields, Seer forms the command:</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif';"> $ /usr/bin/rr replay --interpreter=mi [RR-arguments] [trace-directory] [--tty /dev/pts] [-- gdb-arguments] </span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif';"><br /></span>Note, Seer relies on the &quot;mi&quot; interpreter that is built into gdb. So, the &quot;--interpreter=mi&quot; argument is a must. This is specified in the &quot;RR arguments&quot; field.</p> @@ -142,8 +115,6 @@ li.checked::marker { content: "\2612"; } - rrGroupBox - textBrowser