Merge pull request #512 from QuangNguyenMinh123/improve/Openocd_DotoDefinition_Linux

Let feature gdbLiveWatch handles GotoDefinition
This commit is contained in:
Ernie Pasveer
2026-08-09 12:49:36 -05:00
committed by GitHub
3 changed files with 26 additions and 4 deletions
+14 -2
View File
@@ -1910,7 +1910,13 @@ void SeerGdbWidget::handleGdbExecutableFunctions (int id, const QString& functio
} }
QApplication::setOverrideCursor(Qt::BusyCursor); QApplication::setOverrideCursor(Qt::BusyCursor);
handleGdbCommand(QString("%1-symbol-info-functions --include-nondebug --name %2").arg(id).arg(functionRegex));
// If openocd is running, then let _gdbLiveWatchProcess handles it
if (executableLaunchMode() == "openocd") {
_openocdWidget->gdbLiveWatchRunCommand(QString("%1-symbol-info-functions --include-nondebug --name %2").arg(id).arg(functionRegex));
}
else
handleGdbCommand(QString("%1-symbol-info-functions --include-nondebug --name %2").arg(id).arg(functionRegex));
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
@@ -4088,7 +4094,8 @@ void SeerGdbWidget::handleGdbMultiarchOpenOCDExecutable ()
QObject::connect(this, &SeerGdbWidget::sessionTerminated, _openocdWidget, &SeerOpenOCDWidget::terminate, Qt::UniqueConnection); QObject::connect(this, &SeerGdbWidget::sessionTerminated, _openocdWidget, &SeerOpenOCDWidget::terminate, Qt::UniqueConnection);
// Openocd Live watch // Openocd Live watch
QObject::connect(_gdbMonitor, &GdbMonitor::caretTextOutput, _openocdWidget, &SeerOpenOCDWidget::handleText,Qt::UniqueConnection); QObject::connect(_gdbMonitor, &GdbMonitor::caretTextOutput, _openocdWidget, &SeerOpenOCDWidget::handleText,Qt::UniqueConnection);
QObject::connect(_openocdWidget,&SeerOpenOCDWidget::toTracker, variableManagerWidget->variableTrackerBrowserWidget(), &SeerVariableTrackerBrowserWidget::handleText,Qt::UniqueConnection); QObject::connect(_openocdWidget,&SeerOpenOCDWidget::toTracker, variableManagerWidget->variableTrackerBrowserWidget(), &SeerVariableTrackerBrowserWidget::handleText, Qt::UniqueConnection);
QObject::connect(_openocdWidget,&SeerOpenOCDWidget::toEditor, editorManagerWidget, &SeerEditorManagerWidget::handleText, Qt::UniqueConnection);
_openocdWidget->createOpenOCDConsole(commandLogsWidget->logsTabWidgetInstance()); _openocdWidget->createOpenOCDConsole(commandLogsWidget->logsTabWidgetInstance());
// Start OpenOCD with the given path and command // Start OpenOCD with the given path and command
@@ -4156,6 +4163,11 @@ void SeerGdbWidget::handleGdbMultiarchOpenOCDExecutable ()
if (executablePreGdbCommands().isEmpty() == false) if (executablePreGdbCommands().isEmpty() == false)
handleGdbExecutablePreCommands(); // Run any 'pre' commands before program is loaded. handleGdbExecutablePreCommands(); // Run any 'pre' commands before program is loaded.
// Openocd handle gdb pre commands
for (const auto& i : _executablePreGdbCommands) {
_openocdWidget->gdbLiveWatchRunCommand(i);
}
if (gdbServerDebug()) { if (gdbServerDebug()) {
handleGdbCommand("-gdb-set debug remote 1"); // Turn on gdbserver debug handleGdbCommand("-gdb-set debug remote 1"); // Turn on gdbserver debug
}else{ }else{
+11 -2
View File
@@ -173,7 +173,7 @@ bool SeerOpenOCDWidget::startGdbLiveWatch (const QString &gdbExe)
_gdbLiveWatchProcess->start(gdbExe, QStringList() << "-q" << "--interpreter=mi"); _gdbLiveWatchProcess->start(gdbExe, QStringList() << "-q" << "--interpreter=mi");
} }
connect(_liveWatchTimer, &QTimer::timeout, [this](){ connect(_liveWatchTimer, &QTimer::timeout, [this](){
gdbLiveWatchRunCommand("-var-update-live-watch"); _gdbLiveWatchProcess->write("-var-update-live-watch");
}); });
_liveWatchTimer->start(500); // Hard code Refresh rate = 2Hz _liveWatchTimer->start(500); // Hard code Refresh rate = 2Hz
connect(_gdbLiveWatchProcess, &QProcess::readyReadStandardOutput, this, &SeerOpenOCDWidget::handleGdbOutput); connect(_gdbLiveWatchProcess, &QProcess::readyReadStandardOutput, this, &SeerOpenOCDWidget::handleGdbOutput);
@@ -194,7 +194,7 @@ void SeerOpenOCDWidget::terminateGdbLiveWatch()
{ {
if (_gdbLiveWatchProcess) { if (_gdbLiveWatchProcess) {
_gdbLiveWatchProcess->terminate(); _gdbLiveWatchProcess->terminate();
_gdbLiveWatchProcess->waitForFinished(); // _gdbLiveWatchProcess->waitForFinished();
delete _gdbLiveWatchProcess; delete _gdbLiveWatchProcess;
_gdbLiveWatchProcess = nullptr; _gdbLiveWatchProcess = nullptr;
_liveWatchTimer->stop(); _liveWatchTimer->stop();
@@ -211,6 +211,15 @@ void SeerOpenOCDWidget::handleGdbOutput()
if (line.contains("^done,value=")) if (line.contains("^done,value="))
emit toTracker(line); emit toTracker(line);
} }
// If output contains symbol of functions, variables, struct -> handle go to definition -> emit to SeerEditorManagerWidget::handleText
if (output.contains(QRegularExpression("^([0-9]+)\\^done,symbols="))) {
// Format: 4^done,symbols={debug=[{filename="/usr/src/kernel/init/main.c",
// fullname="/usr/src/kernel/init/main.c",
// symbols=[{line="887",name="arch_call_rest_init",type="void (void)",
// description="void arch_call_rest_init(void);"}]}]}
emit toEditor(output);
}
} }
void SeerOpenOCDWidget::handleText(const QString& text) void SeerOpenOCDWidget::handleText(const QString& text)
+1
View File
@@ -36,6 +36,7 @@ class SeerOpenOCDWidget: public SeerLogWidget{
signals: signals:
void openocdStartFailed (); void openocdStartFailed ();
void toTracker (const QString& text); void toTracker (const QString& text);
void toEditor (const QString& text);
private slots: private slots:
void handleReadOutput (); void handleReadOutput ();