Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

192 add runreconnect to toolbar #206

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 45 additions & 4 deletions src/SeerFunctionBrowserWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#include <QtWidgets/QTreeWidgetItemIterator>
#include <QtWidgets/QLabel>
#include <QtWidgets/QApplication>
#include <QtCore/QFileInfo>
#include <QtWidgets/QMenu>
#include <QtGui/QAction>
#include <QtCore/Qt>
#include <QtCore/QMap>
#include <QtCore/QDebug>
Expand All @@ -20,6 +21,7 @@ SeerFunctionBrowserWidget::SeerFunctionBrowserWidget (QWidget* parent) : QWidget
// Setup the widgets
functionSearchLineEdit->setPlaceholderText("Search regex...");
functionSearchLineEdit->setClearButtonEnabled(true);
functionTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
functionTreeWidget->setMouseTracking(true);
//functionTreeWidget->resizeColumnToContents(0);
functionTreeWidget->resizeColumnToContents(1);
Expand All @@ -31,9 +33,10 @@ SeerFunctionBrowserWidget::SeerFunctionBrowserWidget (QWidget* parent) : QWidget
functionTreeWidget->setSortingEnabled(false);

// Connect things.
QObject::connect(functionTreeWidget, &QTreeWidget::itemDoubleClicked, this, &SeerFunctionBrowserWidget::handleItemDoubleClicked);
QObject::connect(functionTreeWidget, &QTreeWidget::itemEntered, this, &SeerFunctionBrowserWidget::handleItemEntered);
QObject::connect(functionSearchLineEdit, &QLineEdit::returnPressed, this, &SeerFunctionBrowserWidget::handleSearchLineEdit);
QObject::connect(functionTreeWidget, &QTreeWidget::customContextMenuRequested, this, &SeerFunctionBrowserWidget::handleContextMenu);
QObject::connect(functionTreeWidget, &QTreeWidget::itemDoubleClicked, this, &SeerFunctionBrowserWidget::handleItemDoubleClicked);
QObject::connect(functionTreeWidget, &QTreeWidget::itemEntered, this, &SeerFunctionBrowserWidget::handleItemEntered);
QObject::connect(functionSearchLineEdit, &QLineEdit::returnPressed, this, &SeerFunctionBrowserWidget::handleSearchLineEdit);
}

SeerFunctionBrowserWidget::~SeerFunctionBrowserWidget () {
Expand Down Expand Up @@ -171,6 +174,44 @@ void SeerFunctionBrowserWidget::handleSearchLineEdit () {
}
}

void SeerFunctionBrowserWidget::handleContextMenu (const QPoint& pos) {

// Get the item at the cursor.
QTreeWidgetItem* item = functionTreeWidget->itemAt(pos);

if (item == 0) {
return;
}

// Construct the menu.
QMenu menu ("Options", this);
QAction* openAction = menu.addAction(QString("Open '%1'").arg(item->text(1)));
QAction* breakpointSourceAction = menu.addAction(QString("Create breakpoint on '%1:%2'").arg(item->text(1)).arg(item->text(2)));
QAction* breakpointFunctionAction = menu.addAction(QString("Create breakpoint in '%1'").arg(item->text(0)));

// Execute the menu. Return if nothing.
QAction* action = menu.exec(functionTreeWidget->viewport()->mapToGlobal(pos));

if (action == 0) {
return;
}

if (action == openAction) {
emit selectedFile(item->text(1), item->text(3), item->text(2).toInt());
return;
}

if (action == breakpointSourceAction) {
emit insertBreakpoint(QString("--source %1 --line %2").arg(item->text(3)).arg(item->text(2)));
return;
}

if (action == breakpointFunctionAction) {
emit insertBreakpoint(QString("--function \"%1\"").arg(item->text(0)));
return;
}
}

void SeerFunctionBrowserWidget::refresh () {
handleSearchLineEdit();
}
Expand Down
2 changes: 2 additions & 0 deletions src/SeerFunctionBrowserWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class SeerFunctionBrowserWidget : public QWidget, protected Ui::SeerFunctionBrow

public slots:
void handleText (const QString& text);
void handleContextMenu (const QPoint& pos);
void refresh ();

protected slots:
Expand All @@ -24,6 +25,7 @@ class SeerFunctionBrowserWidget : public QWidget, protected Ui::SeerFunctionBrow
signals:
void refreshFunctionList (int id, const QString& functionRegex);
void selectedFile (QString file, QString fullname, int lineno);
void insertBreakpoint (QString breakpoint);

protected:
private:
Expand Down
96 changes: 87 additions & 9 deletions src/SeerGdbWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ SeerGdbWidget::SeerGdbWidget (QWidget* parent) : QWidget(parent) {
_gdbMonitor = 0;
_gdbProcess = 0;
_consoleWidget = 0;
_consoleMode = "normal";
_consoleScrollLines = 1000;
_breakpointsBrowserWidget = 0;
_watchpointsBrowserWidget = 0;
_catchpointsBrowserWidget = 0;
Expand All @@ -62,7 +64,7 @@ SeerGdbWidget::SeerGdbWidget (QWidget* parent) : QWidget(parent) {
_gdbEnablePrettyPrinting = true;
_gdbRecordMode = "";
_gdbRecordDirection = "";
_consoleScrollLines = 1000;
_gdbLoadPreviousBreakpoints = false;
_rememberManualCommandCount = 10;
_currentFrame = -1;

Expand Down Expand Up @@ -207,6 +209,7 @@ SeerGdbWidget::SeerGdbWidget (QWidget* parent) : QWidget(parent) {
QObject::connect(sourceLibraryManagerWidget->sourceBrowserWidget(), &SeerSourceBrowserWidget::selectedFile, editorManagerWidget, &SeerEditorManagerWidget::handleOpenFile);
QObject::connect(sourceLibraryManagerWidget->functionBrowserWidget(), &SeerFunctionBrowserWidget::refreshFunctionList, this, &SeerGdbWidget::handleGdbExecutableFunctions);
QObject::connect(sourceLibraryManagerWidget->functionBrowserWidget(), &SeerFunctionBrowserWidget::selectedFile, editorManagerWidget, &SeerEditorManagerWidget::handleOpenFile);
QObject::connect(sourceLibraryManagerWidget->functionBrowserWidget(), &SeerFunctionBrowserWidget::insertBreakpoint, this, &SeerGdbWidget::handleGdbBreakpointInsert);
QObject::connect(sourceLibraryManagerWidget->typeBrowserWidget(), &SeerTypeBrowserWidget::refreshTypeList, this, &SeerGdbWidget::handleGdbExecutableTypes);
QObject::connect(sourceLibraryManagerWidget->typeBrowserWidget(), &SeerTypeBrowserWidget::selectedFile, editorManagerWidget, &SeerEditorManagerWidget::handleOpenFile);
QObject::connect(sourceLibraryManagerWidget->staticBrowserWidget(), &SeerStaticBrowserWidget::refreshVariableList, this, &SeerGdbWidget::handleGdbExecutableVariables);
Expand Down Expand Up @@ -334,6 +337,12 @@ SeerGdbWidget::SeerGdbWidget (QWidget* parent) : QWidget(parent) {
QObject::connect(this, &SeerGdbWidget::stoppingPointReached, stackManagerWidget, &SeerStackManagerWidget::handleStoppingPointReached);
QObject::connect(this, &SeerGdbWidget::assemblyConfigChanged, editorManagerWidget, &SeerEditorManagerWidget::handleAssemblyConfigChanged);

// Send session termination signals.
QObject::connect(this, &SeerGdbWidget::sessionTerminated, this, &SeerGdbWidget::handleSessionTerminated);
QObject::connect(this, &SeerGdbWidget::sessionTerminated, variableManagerWidget->registerValuesBrowserWidget(), &SeerRegisterValuesBrowserWidget::handleSessionTerminated);
QObject::connect(this, &SeerGdbWidget::sessionTerminated, variableManagerWidget->variableLoggerBrowserWidget(), &SeerVariableLoggerBrowserWidget::handleSessionTerminated);
QObject::connect(this, &SeerGdbWidget::sessionTerminated, variableManagerWidget->variableTrackerBrowserWidget(), &SeerVariableTrackerBrowserWidget::handleSessionTerminated);

QObject::connect(leftCenterRightSplitter, &QSplitter::splitterMoved, this, &SeerGdbWidget::handleSplitterMoved);
QObject::connect(sourceLibraryVariableManagerSplitter, &QSplitter::splitterMoved, this, &SeerGdbWidget::handleSplitterMoved);
QObject::connect(codeManagerLogTabsSplitter, &QSplitter::splitterMoved, this, &SeerGdbWidget::handleSplitterMoved);
Expand Down Expand Up @@ -982,6 +991,13 @@ void SeerGdbWidget::handleGdbRunExecutable (const QString& breakMode) {
handleGdbExecutablePreCommands(); // Run any 'pre' commands before program is loaded.
handleGdbExecutableName(); // Load the program into the gdb process.
handleGdbExecutableSources(); // Load the program source files.

if (_gdbLoadPreviousBreakpoints) {
qDebug() << "Connect: Loading previous breakpoints.";
handleGdbCommand("source -v /tmp/breakpoints.seer");
_gdbLoadPreviousBreakpoints = false;
}

handleGdbExecutableLoadBreakpoints(); // Set the program's breakpoints (if any) before running.

setNewExecutableFlag(false);
Expand Down Expand Up @@ -1189,6 +1205,13 @@ void SeerGdbWidget::handleGdbConnectExecutable () {
handleGdbExecutablePreCommands(); // Run any 'pre' commands before program is loaded.
handleGdbExecutableName(); // Load the program into the gdb process.
handleGdbExecutableSources(); // Load the program source files.

if (_gdbLoadPreviousBreakpoints) {
qDebug() << "Connect: Loading previous breakpoints.";
handleGdbCommand("source -v /tmp/breakpoints.seer");
_gdbLoadPreviousBreakpoints = false;
}

handleGdbExecutableLoadBreakpoints(); // Set the program's breakpoints (if any) before running.

setNewExecutableFlag(false);
Expand Down Expand Up @@ -1337,8 +1360,6 @@ void SeerGdbWidget::handleGdbCoreFileExecutable () {

qCDebug(LC) << "Starting 'gdb corefile'.";

QApplication::setOverrideCursor(Qt::BusyCursor);

while (1) {

// Has a executable name been provided?
Expand Down Expand Up @@ -1427,6 +1448,47 @@ void SeerGdbWidget::handleGdbCoreFileExecutable () {
qCDebug(LC) << "Finishing 'gdb corefile'.";
}

void SeerGdbWidget::handleGdbTerminateExecutable () {

while (1) {

// Do you really want to restart?
if (isGdbRuning() == true) {

int result = QMessageBox::warning(this, "Seer",
QString("Terminate current session?"),
QMessageBox::Ok|QMessageBox::Cancel, QMessageBox::Cancel);

if (result == QMessageBox::Cancel) {
break;
}

QApplication::setOverrideCursor(Qt::BusyCursor);

// Save previous breakpoints.
qDebug() << "Connect: gdb is running. Saving previous breakpoints.";
handleGdbCommand("save breakpoints /tmp/breakpoints.seer");
delay(1);
_gdbLoadPreviousBreakpoints = true;

// Delete the old gdb and console if there is a new executable
killGdb();
disconnectConsole();
deleteConsole();

QApplication::restoreOverrideCursor();

// Print a message.
addMessage("Program terminated.", QMessageBox::Warning);

// Alert listeners the session has been terminated.
emit sessionTerminated();
}

break;
}
}

void SeerGdbWidget::handleGdbShutdown () {

if (isGdbRuning() == false) {
Expand Down Expand Up @@ -2822,6 +2884,15 @@ void SeerGdbWidget::handleGdbProcessErrored (QProcess::ProcessError errorStatus)
}
}

void SeerGdbWidget::handleSessionTerminated () {

// Do things after the session is terminated.

// Remove all tracked variables.
_dataExpressionId.clear();
_dataExpressionName.clear();
}

void SeerGdbWidget::writeSettings () {

//qDebug() << "Write Settings";
Expand Down Expand Up @@ -3239,18 +3310,16 @@ void SeerGdbWidget::disconnectConsole () {

void SeerGdbWidget::setConsoleMode (const QString& mode) {

_consoleMode = mode;

if (_consoleWidget != 0) {
_consoleWidget->setMode(mode);
_consoleWidget->setMode(_consoleMode);
}
}

QString SeerGdbWidget::consoleMode () const {

if (_consoleWidget != 0) {
return _consoleWidget->mode();
}

return "normal";
return _consoleMode;
}

void SeerGdbWidget::setConsoleScrollLines (int count) {
Expand Down Expand Up @@ -3599,3 +3668,12 @@ void SeerGdbWidget::sendGdbInterrupt (int signal) {
}
}

void SeerGdbWidget::delay (int seconds) {

QTime dieTime = QTime::currentTime().addSecs(seconds);

while (QTime::currentTime() < dieTime) {
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
}

6 changes: 6 additions & 0 deletions src/SeerGdbWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class SeerGdbWidget : public QWidget, protected Ui::SeerGdbWidgetForm {
void handleGdbConnectExecutable ();
void handleGdbRRExecutable ();
void handleGdbCoreFileExecutable ();
void handleGdbTerminateExecutable ();
void handleGdbShutdown ();
void handleGdbRunToLine (QString fullname, int lineno);
void handleGdbRunToAddress (QString address);
Expand Down Expand Up @@ -344,8 +345,11 @@ class SeerGdbWidget : public QWidget, protected Ui::SeerGdbWidgetForm {
void handleGdbProcessFinished (int exitCode, QProcess::ExitStatus exitStatus);
void handleGdbProcessErrored (QProcess::ProcessError errorStatus);

void handleSessionTerminated ();

signals:
void stoppingPointReached ();
void sessionTerminated ();
void changeWindowTitle (QString title);
void assemblyConfigChanged ();
void recordSettingsChanged ();
Expand All @@ -365,6 +369,7 @@ class SeerGdbWidget : public QWidget, protected Ui::SeerGdbWidgetForm {
void disconnectConsole ();
SeerConsoleWidget* console ();
void sendGdbInterrupt (int signal);
void delay (int seconds);

QString _gdbProgram;
QString _gdbArguments;
Expand All @@ -380,6 +385,7 @@ class SeerGdbWidget : public QWidget, protected Ui::SeerGdbWidgetForm {
bool _gdbEnablePrettyPrinting;
QString _gdbRecordMode;
QString _gdbRecordDirection;
bool _gdbLoadPreviousBreakpoints;
QString _dprintfStyle;
QString _dprintfFunction;
QString _dprintfChannel;
Expand Down
Loading
Loading