From f3144f3fe061d726947d08b91d240cc2ff303ffc Mon Sep 17 00:00:00 2001 From: Ernie Pasveer Date: Wed, 11 Sep 2024 17:34:46 -0500 Subject: [PATCH] Show breakpoint info as a tooltip if the breakpoint icon is clicked with LMB and held down. --- CHANGELOG.md | 2 ++ src/SeerBreakpointsBrowserWidget.cpp | 2 +- src/SeerEditorWidgetSourceAreas.cpp | 53 ++++++++++++++++++++++++++-- src/SeerGdbWidget.cpp | 2 +- src/SeerMainWindow.cpp | 1 + 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0c63fa8..674b22d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ - Detached and minimized - Attached in Seer's tab view (with gdb logs and seer logs). * Improved handling of \n \t and other escaped characters in gdb log window. +* Show breakpoint info as a tooltip if the breakpoint icon is clicked with + LMB and held down. ## [2.4] - 2024-03-18 * Changed main icon to a more license friendly one. diff --git a/src/SeerBreakpointsBrowserWidget.cpp b/src/SeerBreakpointsBrowserWidget.cpp index 24b9f50b..6df1534a 100644 --- a/src/SeerBreakpointsBrowserWidget.cpp +++ b/src/SeerBreakpointsBrowserWidget.cpp @@ -121,7 +121,7 @@ void SeerBreakpointsBrowserWidget::handleText (const QString& text) { QStringList bkpt_list = Seer::parse(newtext, "bkpt=", '{', '}', false); - for ( const auto& bkpt_text : bkpt_list ) { + for (const auto& bkpt_text : bkpt_list) { // // A different way (better?) of parsing the table output diff --git a/src/SeerEditorWidgetSourceAreas.cpp b/src/SeerEditorWidgetSourceAreas.cpp index d417572b..5bfcfb03 100644 --- a/src/SeerEditorWidgetSourceAreas.cpp +++ b/src/SeerEditorWidgetSourceAreas.cpp @@ -1739,7 +1739,7 @@ void SeerEditorWidgetSourceArea::handleText (const QString& text) { }else if (text.contains(QRegularExpression("^([0-9]+)\\^done,BreakpointTable="))) { - // 11^7^done,BreakpointTable={...} + // 11^done,BreakpointTable={...} QString id_text = text.section('^', 0,0); @@ -1816,9 +1816,56 @@ void SeerEditorWidgetSourceArea::handleWatchFileModified (const QString& path) { void SeerEditorWidgetSourceArea::handleBreakpointToolTip (QPoint pos, const QString& text) { - QString str = text; + // 11^7^done,BreakpointTable={...} + // 7^done,BreakpointTable={ + // nr_rows="1", + // nr_cols="6", + // hdr=[], + // body=[ + // bkpt={ + // number="2", + // type="breakpoint", + // disp="keep", + // enabled="y", + // addr="0x0000000000400ccd", + // func="main(int, char**)", + // file="helloworld.cpp", + // fullname="/nas/erniep/Development/seer/tests/helloworld/helloworld.cpp", + // line="30", + // thread-groups=["i1"], + // times="1", + // original-location="-source /nas/erniep/Development/seer/tests/helloworld/helloworld.cpp -line 30" + // } + // ] + // } + + QString newtext = Seer::filterEscapes(text); // Filter escaped characters. + QString tooltiptext; - QToolTip::showText(mapToGlobal(pos), str); + // + // Parse 'body' text. + // + QString body_text = Seer::parseFirst(newtext, "body=", '[', ']', false); + + if (body_text != "") { + + QStringList bkpt_list = Seer::parse(body_text, "bkpt=", '{', '}', false); + + // Construct the tooltip. + tooltiptext += "Breakpoint information\n\n"; + for (const auto& bkpt_text : bkpt_list) { + + QStringList item_list = Seer::parseCommaList(bkpt_text); + + for (const auto& item_text : item_list) { + tooltiptext += item_text + "\n"; + } + + break; // Take the first breakpoint in case, somehow, more are returned. + } + } + + QToolTip::showText(mapToGlobal(pos), tooltiptext); } // diff --git a/src/SeerGdbWidget.cpp b/src/SeerGdbWidget.cpp index 48564bfa..8b3f625b 100644 --- a/src/SeerGdbWidget.cpp +++ b/src/SeerGdbWidget.cpp @@ -1982,7 +1982,7 @@ void SeerGdbWidget::handleGdbBreakpointInfo (int breakpointid, QString breakpoin return; } - QString str = QString("%1-break-list %2").arg(breakpointid).arg(breakpoint); + QString str = QString("%1-break-info %2").arg(breakpointid).arg(breakpoint); handleGdbCommand(str); } diff --git a/src/SeerMainWindow.cpp b/src/SeerMainWindow.cpp index 40f5532c..181df459 100644 --- a/src/SeerMainWindow.cpp +++ b/src/SeerMainWindow.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include