diff --git a/src/SeerEditorManagerWidget.cpp b/src/SeerEditorManagerWidget.cpp index c2390cc..99e1a6f 100644 --- a/src/SeerEditorManagerWidget.cpp +++ b/src/SeerEditorManagerWidget.cpp @@ -1410,7 +1410,26 @@ void SeerEditorManagerWidget::handleRunToLine (QString fullname, int lineno) { void SeerEditorManagerWidget::handleRunToAddress (QString address) { // rethrow - emit runToAddress (address); + if (address != "") { + emit runToAddress (address); + } +} + +void SeerEditorManagerWidget::handleRunToSelectedLine () { + + SeerEditorWidgetSource* sourceTab = currentEditorWidgetTab(); + SeerEditorWidgetAssembly* assemblyTab = assemblyWidgetTab(); + + if (sourceTab) { + emit runToLine (sourceTab->sourceArea()->fullname(), sourceTab->sourceArea()->currentLine()); + } + + if (assemblyTab) { + QString address = assemblyTab->assemblyArea()->currentLine(); + if (address != "") { + emit runToAddress (address); + } + } } void SeerEditorManagerWidget::handleAddVariableLoggerExpression (QString expression) { diff --git a/src/SeerEditorManagerWidget.h b/src/SeerEditorManagerWidget.h index fb4278b..ebf32fe 100644 --- a/src/SeerEditorManagerWidget.h +++ b/src/SeerEditorManagerWidget.h @@ -92,6 +92,7 @@ class SeerEditorManagerWidget : public QWidget, protected Ui::SeerEditorManagerW void handleRefreshBreakpointsStackFrames (); void handleRunToLine (QString fullname, int lineno); void handleRunToAddress (QString address); + void handleRunToSelectedLine (); void handleAddVariableLoggerExpression (QString expression); void handleAddVariableTrackerExpression (QString expression); void handleRefreshVariableTrackerValues (); diff --git a/src/SeerEditorWidgetAssembly.h b/src/SeerEditorWidgetAssembly.h index 589967c..5675dc6 100644 --- a/src/SeerEditorWidgetAssembly.h +++ b/src/SeerEditorWidgetAssembly.h @@ -63,6 +63,7 @@ class SeerEditorWidgetAssemblyArea : public SeerPlainTextEdit { void setAddress (const QString& address, bool force=false); const QString& address () const; bool setCurrentLine (const QString& address); + const QString currentLine () const; void scrollToLine (const QString& address); void clearCurrentLines (); diff --git a/src/SeerEditorWidgetAssemblyAreas.cpp b/src/SeerEditorWidgetAssemblyAreas.cpp index 08d0e07..904aed0 100644 --- a/src/SeerEditorWidgetAssemblyAreas.cpp +++ b/src/SeerEditorWidgetAssemblyAreas.cpp @@ -877,6 +877,16 @@ bool SeerEditorWidgetAssemblyArea::setCurrentLine (const QString& address) { return true; } +const QString SeerEditorWidgetAssemblyArea::currentLine () const { + + // Get current lineno. + int lineno = textCursor().blockNumber() + 1; + + QString address = _lineAddressMap[lineno]; + + return address; +} + void SeerEditorWidgetAssemblyArea::scrollToLine (const QString& address) { // Just return. @@ -1142,11 +1152,11 @@ void SeerEditorWidgetAssemblyArea::showContextMenu (const QPoint& pos, const QPo int breakno = breakpointAddressToNumber(address); - runToAddressAction = new QAction(QString("Run to address %1").arg(address), this); - createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on address %1").arg(address), this); - deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint %1 on address %2").arg(breakno).arg(address), this); - enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint %1 on address %2").arg(breakno).arg(address), this); - disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint %1 on address %2").arg(breakno).arg(address), this); + runToAddressAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/debug-execute-from-cursor.svg"), QString("Run to address %1").arg(address), this); + createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on address %1").arg(address), this); + deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint %1 on address %2").arg(breakno).arg(address), this); + enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint %1 on address %2").arg(breakno).arg(address), this); + disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint %1 on address %2").arg(breakno).arg(address), this); runToAddressAction->setEnabled(true); createBreakpointAction->setEnabled(false); @@ -1155,11 +1165,11 @@ void SeerEditorWidgetAssemblyArea::showContextMenu (const QPoint& pos, const QPo disableAction->setEnabled(true); }else{ - runToAddressAction = new QAction(QString("Run to address %1").arg(address), this); - createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on address %1").arg(address), this); - deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint on address %1").arg(address), this); - enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint on address %1").arg(address), this); - disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint on address %1").arg(address), this); + runToAddressAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/debug-execute-from-cursor.svg"), QString("Run to address %1").arg(address), this); + createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on address %1").arg(address), this); + deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint on address %1").arg(address), this); + enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint on address %1").arg(address), this); + disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint on address %1").arg(address), this); runToAddressAction->setEnabled(true); createBreakpointAction->setEnabled(true); diff --git a/src/SeerEditorWidgetSource.h b/src/SeerEditorWidgetSource.h index 573f385..f8283a0 100644 --- a/src/SeerEditorWidgetSource.h +++ b/src/SeerEditorWidgetSource.h @@ -95,6 +95,7 @@ class SeerEditorWidgetSourceArea : public SeerPlainTextEdit { int breakpointLineToNumber (int lineno) const; bool breakpointLineEnabled (int lineno) const; void breakpointToggle (); + void runToSelectedLine (); void showContextMenu (QMouseEvent* event); void showContextMenu (QContextMenuEvent* event); @@ -121,6 +122,7 @@ class SeerEditorWidgetSourceArea : public SeerPlainTextEdit { SeerCurrentFile readCurrentPosition (); void eraseColorCurrentLine (int lineno); + signals: void insertBreakpoint (QString breakpoint); void insertPrintpoint (QString type, QString function, QString channel, QString parameters); diff --git a/src/SeerEditorWidgetSourceAreas.cpp b/src/SeerEditorWidgetSourceAreas.cpp index 4227f26..f6f2a37 100644 --- a/src/SeerEditorWidgetSourceAreas.cpp +++ b/src/SeerEditorWidgetSourceAreas.cpp @@ -948,6 +948,13 @@ void SeerEditorWidgetSourceArea::breakpointToggle () { } } +void SeerEditorWidgetSourceArea::runToSelectedLine () { + + // Emit the runToLine signal. + emit runToLine(fullname(), currentLine()); + +} + void SeerEditorWidgetSourceArea::showContextMenu (QMouseEvent* event) { #if QT_VERSION >= 0x060000 @@ -1005,13 +1012,13 @@ void SeerEditorWidgetSourceArea::showContextMenu (const QPoint& pos, const QPoin int breakno = breakpointLineToNumber(lineno); - runToLineAction = new QAction(QString("Run to line %1").arg(lineno), this); - createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on line %1").arg(lineno), this); - createPrintpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create printpoint on line %1").arg(lineno), this); - deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint %1 on line %2").arg(breakno).arg(lineno), this); - enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint %1 on line %2").arg(breakno).arg(lineno), this); - disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint %1 on line %2").arg(breakno).arg(lineno), this); - openExternalEditor = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Open external editor on line %1").arg(lineno), this); + runToLineAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/debug-execute-from-cursor.svg"), QString("Run to line %1").arg(lineno), this); + createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on line %1").arg(lineno), this); + createPrintpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create printpoint on line %1").arg(lineno), this); + deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint %1 on line %2").arg(breakno).arg(lineno), this); + enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint %1 on line %2").arg(breakno).arg(lineno), this); + disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint %1 on line %2").arg(breakno).arg(lineno), this); + openExternalEditor = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Open external editor on line %1").arg(lineno), this); runToLineAction->setEnabled(true); createBreakpointAction->setEnabled(false); @@ -1022,13 +1029,13 @@ void SeerEditorWidgetSourceArea::showContextMenu (const QPoint& pos, const QPoin openExternalEditor->setEnabled(true); }else{ - runToLineAction = new QAction(QString("Run to line %1").arg(lineno), this); - createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on line %1").arg(lineno), this); - createPrintpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create printpoint on line %1").arg(lineno), this); - deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint on line %1").arg(lineno), this); - enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint on line %1").arg(lineno), this); - disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint on line %1").arg(lineno), this); - openExternalEditor = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Open file in external editor"), this); + runToLineAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/debug-execute-from-cursor.svg"), QString("Run to line %1").arg(lineno), this); + createBreakpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create breakpoint on line %1").arg(lineno), this); + createPrintpointAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Create printpoint on line %1").arg(lineno), this); + deleteAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/edit-delete.svg"), QString("Delete breakpoint on line %1").arg(lineno), this); + enableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-add.svg"), QString("Enable breakpoint on line %1").arg(lineno), this); + disableAction = new QAction(QIcon(":/seer/resources/RelaxLightIcons/list-remove.svg"), QString("Disable breakpoint on line %1").arg(lineno), this); + openExternalEditor = new QAction(QIcon(":/seer/resources/RelaxLightIcons/document-new.svg"), QString("Open file in external editor"), this); runToLineAction->setEnabled(true); createBreakpointAction->setEnabled(true); @@ -1734,14 +1741,15 @@ void SeerEditorWidgetSourceArea::eraseColorCurrentLine (int lineno) { } // Read current position in the source area: file name, line, column of cursor and first displayed line -SeerEditorWidgetSourceArea::SeerCurrentFile SeerEditorWidgetSourceArea::readCurrentPosition() -{ +SeerEditorWidgetSourceArea::SeerCurrentFile SeerEditorWidgetSourceArea::readCurrentPosition() { + SeerCurrentFile info; info.file = QFileInfo(file()).fileName(); // extract file name from full path info.fullname = fullname(); info.cursorRow = currentLine(); info.cursorCol = currentColumn(); info.firstDisplayLine = firstDisplayLine(); + return info; } diff --git a/src/SeerKeySettings.cpp b/src/SeerKeySettings.cpp index 38a3fe6..5811f53 100644 --- a/src/SeerKeySettings.cpp +++ b/src/SeerKeySettings.cpp @@ -87,6 +87,7 @@ SeerKeySettings SeerKeySettings::populate () { keySettings.add("ReverseNexti", SeerKeySetting("ReverseNexti", QKeySequence::fromString("Shift+Ctrl+F5"), "Execute the previous instruction. Step over functions.")); keySettings.add("ReverseStepi", SeerKeySetting("ReverseStepi", QKeySequence::fromString("Shift+Ctrl+F6"), "Execute the previous instruction. Step into functions.")); keySettings.add("ReverseFinish", SeerKeySetting("ReverseFinish", QKeySequence::fromString("Shift+F7"), "Finish the current function in reverse.")); + keySettings.add("RunToLine", SeerKeySetting("RunToLine", QKeySequence::fromString("F9"), "Run to the currently selected line.")); return keySettings; } diff --git a/src/SeerMainWindow.cpp b/src/SeerMainWindow.cpp index 2f1d27b..1598fc7 100644 --- a/src/SeerMainWindow.cpp +++ b/src/SeerMainWindow.cpp @@ -144,25 +144,26 @@ SeerMainWindow::SeerMainWindow(QWidget* parent) : QMainWindow(parent) { QObject::connect(actionConsoleDetachedMinimized, &QAction::triggered, this, &SeerMainWindow::handleViewConsoleDetachedMinimized); QObject::connect(actionHelpAbout, &QAction::triggered, this, &SeerMainWindow::handleHelpAbout); - QObject::connect(actionControlRestart, &QAction::triggered, this, &SeerMainWindow::handleRestartExecutable); - QObject::connect(actionControlTerminate, &QAction::triggered, this, &SeerMainWindow::handleTerminateExecutable); - QObject::connect(actionControlContinue, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbContinue); - QObject::connect(actionControlNext, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbNext); - QObject::connect(actionControlStep, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbStep); - QObject::connect(actionControlNexti, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbNexti); - QObject::connect(actionControlStepi, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbStepi); - QObject::connect(actionControlFinish, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbFinish); - QObject::connect(actionControlReverseContinue, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbReverseContinue); - QObject::connect(actionControlReverseNext, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbReverseNext); - QObject::connect(actionControlReverseStep, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbReverseStep); - QObject::connect(actionControlReverseNexti, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbReverseNexti); - QObject::connect(actionControlReverseStepi, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbReverseStepi); - QObject::connect(actionControlReverseFinish, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbReverseFinish); - QObject::connect(actionControlRecordStart, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbRecordStart); - QObject::connect(actionControlRecordForward, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbRecordForward); - QObject::connect(actionControlRecordReverse, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbRecordReverse); - QObject::connect(actionControlRecordStop, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbRecordStop); - QObject::connect(actionControlInterrupt, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbInterrupt); + QObject::connect(actionControlRestart, &QAction::triggered, this, &SeerMainWindow::handleRestartExecutable); + QObject::connect(actionControlTerminate, &QAction::triggered, this, &SeerMainWindow::handleTerminateExecutable); + QObject::connect(actionControlContinue, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbContinue); + QObject::connect(actionControlNext, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbNext); + QObject::connect(actionControlStep, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbStep); + QObject::connect(actionControlNexti, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbNexti); + QObject::connect(actionControlStepi, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbStepi); + QObject::connect(actionControlFinish, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbFinish); + QObject::connect(actionControlRunToLine, &QAction::triggered, gdbWidget->editorManager(), &SeerEditorManagerWidget::handleRunToSelectedLine); + QObject::connect(actionControlReverseContinue, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbReverseContinue); + QObject::connect(actionControlReverseNext, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbReverseNext); + QObject::connect(actionControlReverseStep, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbReverseStep); + QObject::connect(actionControlReverseNexti, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbReverseNexti); + QObject::connect(actionControlReverseStepi, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbReverseStepi); + QObject::connect(actionControlReverseFinish, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbReverseFinish); + QObject::connect(actionControlRecordStart, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbRecordStart); + QObject::connect(actionControlRecordForward, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbRecordForward); + QObject::connect(actionControlRecordReverse, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbRecordReverse); + QObject::connect(actionControlRecordStop, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbRecordStop); + QObject::connect(actionControlInterrupt, &QAction::triggered, gdbWidget, &SeerGdbWidget::handleGdbInterrupt); QObject::connect(actionSettingsConfiguration, &QAction::triggered, this, &SeerMainWindow::handleSettingsConfiguration); QObject::connect(actionSettingsSaveConfiguration, &QAction::triggered, this, &SeerMainWindow::handleSettingsSaveConfiguration); @@ -1974,6 +1975,13 @@ void SeerMainWindow::refreshShortCuts () { actionControlDirectionMenu->setTitle(QString("Direction") + " (Toggle " + setting._sequence.toString() + ")"); } + if (_keySettings.has("RunToLine")) { + + SeerKeySetting setting = _keySettings.get("RunToLine"); + + actionControlRunToLine->setShortcut(setting._sequence); + } + // Notify the editor manager of changes. gdbWidget->editorManager()->setEditorKeySettings(keySettings()); } diff --git a/src/SeerMainWindow.ui b/src/SeerMainWindow.ui index bc9244e..80d5960 100644 --- a/src/SeerMainWindow.ui +++ b/src/SeerMainWindow.ui @@ -143,6 +143,7 @@ + @@ -797,6 +798,21 @@ Reverse Stepi + + + + :/seer/resources/RelaxLightIcons/debug-execute-from-cursor.svg:/seer/resources/RelaxLightIcons/debug-execute-from-cursor.svg + + + Run To Line + + + Run to the currently selected line. Stop at any breakpoints, or when the program exits. + + + QAction::NoRole + +