Skip to content

Commit

Permalink
Merge pull request #268 from epasveer/115-visualizers-should-be-able-…
Browse files Browse the repository at this point in the history
…to-take-a-variable-expression-for-a-size-field

115 visualizers should be able to take a variable expression for a size field
  • Loading branch information
epasveer authored Nov 23, 2024
2 parents 2cdf80c + ae75a4e commit 72ad448
Show file tree
Hide file tree
Showing 25 changed files with 599 additions and 104 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
* Show stack as a hex dump, with options to view as short, int, long, ascii, ...
* The "go to address" in the Assembly view now works if address it outside
current assembly view.
* Visualizers can take a gdb expression for input fields for
length/size of something. The visualizers are:
- ArrayVisualizer
- ImageVisualizer
- MemoryVisualizer
* Fixed regression when setting/saving the editor font setting.

## [2.4] - 2024-03-18
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ set(HEADER_FILES
SeerProgressIndicator.h
SeerMessagesDialog.h
SeerAssemblyPreferenceDialog.h
SeerHistoryLineEdit.h
QProcessInfo.h
QProcessInfoWidget.h
QProgressIndicator.h
Expand Down Expand Up @@ -227,6 +228,7 @@ set(SOURCE_FILES
SeerProgressIndicator.cpp
SeerMessagesDialog.cpp
SeerAssemblyPreferenceDialog.cpp
SeerHistoryLineEdit.cpp
QProcessInfo.cpp
QProcessInfoWidget.cpp
QProgressIndicator.cpp
Expand Down
275 changes: 256 additions & 19 deletions src/SeerArrayVisualizerWidget.cpp

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions src/SeerArrayVisualizerWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,23 @@ class SeerArrayVisualizerWidget : public QWidget, protected Ui::SeerArrayVisuali
QString aVariableName () const;
void setAVariableAddress (const QString& address);
QString aVariableAddress () const;
void setAVariableLength (const QString& length);
QString aVariableLength () const;
void setAVariableOffset (const QString& offset);
QString aVariableOffset () const;
void setAVariableStride (const QString& stride);
QString aVariableStride () const;

void setBVariableName (const QString& name);
QString bVariableName () const;
void setBVariableAddress (const QString& address);
QString bVariableAddress () const;
void setBVariableLength (const QString& length);
QString bVariableLength () const;
void setBVariableOffset (const QString& offset);
QString bVariableOffset () const;
void setBVariableStride (const QString& stride);
QString bVariableStride () const;

signals:
void evaluateVariableExpression (int expressionid, QString expression);
Expand All @@ -35,6 +47,12 @@ class SeerArrayVisualizerWidget : public QWidget, protected Ui::SeerArrayVisuali
void handleHelpButton ();
void handleaVariableNameLineEdit ();
void handlebVariableNameLineEdit ();
void handleaElementLengthLineEdit ();
void handlebElementLengthLineEdit ();
void handleaElementOffsetLineEdit ();
void handlebElementOffsetLineEdit ();
void handleaElementStrideLineEdit ();
void handlebElementStrideLineEdit ();
void handleaArrayDisplayFormatComboBox (int index);
void handlebArrayDisplayFormatComboBox (int index);
void handleaAxisComboBox (int index);
Expand All @@ -61,6 +79,12 @@ class SeerArrayVisualizerWidget : public QWidget, protected Ui::SeerArrayVisuali
int _aVariableId;
int _bVariableId;
int _aMemoryId;
int _aLengthId;
int _aOffsetId;
int _aStrideId;
int _bMemoryId;
int _bLengthId;
int _bOffsetId;
int _bStrideId;
};

26 changes: 13 additions & 13 deletions src/SeerArrayVisualizerWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="5">
<widget class="QHistoryLineEdit" name="aArrayStrideLineEdit">
<widget class="SeerHistoryLineEdit" name="aArrayStrideLineEdit">
<property name="toolTip">
<string>Element stride between values. (default=1)</string>
</property>
Expand Down Expand Up @@ -80,7 +80,7 @@
</widget>
</item>
<item row="1" column="5">
<widget class="QHistoryLineEdit" name="bArrayStrideLineEdit">
<widget class="SeerHistoryLineEdit" name="bArrayStrideLineEdit">
<property name="toolTip">
<string>Element stride between values. (default=1)</string>
</property>
Expand All @@ -96,7 +96,7 @@
</widget>
</item>
<item row="1" column="3">
<widget class="QHistoryLineEdit" name="bArrayLengthLineEdit">
<widget class="SeerHistoryLineEdit" name="bArrayLengthLineEdit">
<property name="toolTip">
<string>Total number of elements in array.</string>
</property>
Expand All @@ -112,7 +112,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QHistoryLineEdit" name="bVariableNameLineEdit">
<widget class="SeerHistoryLineEdit" name="bVariableNameLineEdit">
<property name="toolTip">
<string>Variable name or expression.</string>
</property>
Expand All @@ -139,7 +139,7 @@
</widget>
</item>
<item row="0" column="4">
<widget class="QHistoryLineEdit" name="aArrayOffsetLineEdit">
<widget class="SeerHistoryLineEdit" name="aArrayOffsetLineEdit">
<property name="toolTip">
<string>Element offset into array. (default=0)</string>
</property>
Expand All @@ -158,7 +158,7 @@
</widget>
</item>
<item row="0" column="3">
<widget class="QHistoryLineEdit" name="aArrayLengthLineEdit">
<widget class="SeerHistoryLineEdit" name="aArrayLengthLineEdit">
<property name="toolTip">
<string>Total number of elements in array.</string>
</property>
Expand Down Expand Up @@ -221,7 +221,7 @@
</widget>
</item>
<item row="0" column="2">
<widget class="QHistoryLineEdit" name="aVariableAddressLineEdit">
<widget class="QLineEdit" name="aVariableAddressLineEdit">
<property name="toolTip">
<string>Variable address.</string>
</property>
Expand All @@ -237,7 +237,7 @@
</widget>
</item>
<item row="1" column="4">
<widget class="QHistoryLineEdit" name="bArrayOffsetLineEdit">
<widget class="SeerHistoryLineEdit" name="bArrayOffsetLineEdit">
<property name="toolTip">
<string>Element offset into array. (default=0)</string>
</property>
Expand All @@ -256,7 +256,7 @@
</widget>
</item>
<item row="1" column="2">
<widget class="QHistoryLineEdit" name="bVariableAddressLineEdit">
<widget class="QLineEdit" name="bVariableAddressLineEdit">
<property name="toolTip">
<string>Variable address.</string>
</property>
Expand Down Expand Up @@ -286,7 +286,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QHistoryLineEdit" name="aVariableNameLineEdit">
<widget class="SeerHistoryLineEdit" name="aVariableNameLineEdit">
<property name="toolTip">
<string>Variable name or expression.</string>
</property>
Expand Down Expand Up @@ -377,7 +377,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QHistoryLineEdit" name="titleLineEdit">
<widget class="SeerHistoryLineEdit" name="titleLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -514,9 +514,9 @@
<header location="global">QZoomChartView.h</header>
</customwidget>
<customwidget>
<class>QHistoryLineEdit</class>
<class>SeerHistoryLineEdit</class>
<extends>QLineEdit</extends>
<header location="global">QHistoryLineEdit.h</header>
<header location="global">SeerHistoryLineEdit.h</header>
</customwidget>
</customwidgets>
<tabstops>
Expand Down
30 changes: 15 additions & 15 deletions src/SeerEditorWidgetAssemblyAreas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1246,11 +1246,11 @@ void SeerEditorWidgetAssemblyArea::showContextMenu (const QPoint& pos, const QPo
QString address = _lineAddressMap[lineno];

// Create the menu actions.
QAction* runToAddressAction;
QAction* createBreakpointAction;
QAction* deleteAction;
QAction* enableAction;
QAction* disableAction;
QAction* runToAddressAction;
QAction* addMemoryAddressVisualizerAction;
QAction* addArrayAddressVisualizerAction;
QAction* addStructAddressVisualizerAction;
Expand All @@ -1260,30 +1260,30 @@ 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(QString("Run to address %1").arg(address), this);

runToAddressAction->setEnabled(true);
createBreakpointAction->setEnabled(false);
deleteAction->setEnabled(true);
enableAction->setEnabled(true);
disableAction->setEnabled(true);
runToAddressAction->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(QString("Run to address %1").arg(address), this);

runToAddressAction->setEnabled(true);
createBreakpointAction->setEnabled(true);
deleteAction->setEnabled(false);
enableAction->setEnabled(false);
disableAction->setEnabled(false);
runToAddressAction->setEnabled(true);
}

addMemoryAddressVisualizerAction = new QAction(QString("\"%1\"").arg(textCursor().selectedText()));
Expand All @@ -1292,11 +1292,11 @@ void SeerEditorWidgetAssemblyArea::showContextMenu (const QPoint& pos, const QPo

QMenu menu("Breakpoints", this);
menu.setTitle("Breakpoints");
menu.addAction(runToAddressAction);
menu.addAction(createBreakpointAction);
menu.addAction(deleteAction);
menu.addAction(enableAction);
menu.addAction(disableAction);
menu.addAction(runToAddressAction);

QMenu memoryVisualizerMenu("Add address to a Memory Visualizer");
memoryVisualizerMenu.addAction(addMemoryAddressVisualizerAction);
Expand Down Expand Up @@ -1329,6 +1329,15 @@ void SeerEditorWidgetAssemblyArea::showContextMenu (const QPoint& pos, const QPo
return;
}

// Handle running to an address.
if (action == runToAddressAction) {

// Emit the runToLine signal.
emit runToAddress(address);

return;
}

// Handle creating a new breakpoint.
if (action == createBreakpointAction) {

Expand Down Expand Up @@ -1374,15 +1383,6 @@ void SeerEditorWidgetAssemblyArea::showContextMenu (const QPoint& pos, const QPo
return;
}

// Handle running to an address.
if (action == runToAddressAction) {

// Emit the runToLine signal.
emit runToAddress(address);

return;
}

// Handle adding memory to visualize.
if (action == addMemoryAddressVisualizerAction) {

Expand Down
28 changes: 14 additions & 14 deletions src/SeerEditorWidgetSourceAreas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1077,37 +1077,37 @@ 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);
runToLineAction = new QAction(QString("Run to line %1").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);
createPrintpointAction->setEnabled(false);
deleteAction->setEnabled(true);
enableAction->setEnabled(true);
disableAction->setEnabled(true);
runToLineAction->setEnabled(true);
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);
runToLineAction = new QAction(QString("Run to 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);
createPrintpointAction->setEnabled(true);
deleteAction->setEnabled(false);
enableAction->setEnabled(false);
disableAction->setEnabled(false);
runToLineAction->setEnabled(true);
openExternalEditor->setEnabled(true);
}

Expand All @@ -1131,12 +1131,12 @@ void SeerEditorWidgetSourceArea::showContextMenu (const QPoint& pos, const QPoin

QMenu menu("Breakpoints", this);
menu.setTitle("Breakpoints");
menu.addAction(runToLineAction);
menu.addAction(createBreakpointAction);
menu.addAction(createPrintpointAction);
menu.addAction(deleteAction);
menu.addAction(enableAction);
menu.addAction(disableAction);
menu.addAction(runToLineAction);
menu.addAction(openExternalEditor);

QMenu loggerMenu("Add variable to Logger");
Expand Down Expand Up @@ -1218,6 +1218,15 @@ void SeerEditorWidgetSourceArea::showContextMenu (const QPoint& pos, const QPoin
return;
}

// Handle running to a line number.
if (action == runToLineAction) {

// Emit the runToLine signal.
emit runToLine(fullname(), lineno);

return;
}

// Handle creating a new breakpoint.
if (action == createBreakpointAction) {

Expand Down Expand Up @@ -1283,15 +1292,6 @@ void SeerEditorWidgetSourceArea::showContextMenu (const QPoint& pos, const QPoin
return;
}

// Handle running to a line number.
if (action == runToLineAction) {

// Emit the runToLine signal.
emit runToLine(fullname(), lineno);

return;
}

// Handle open code editor at a line number.
if (action == openExternalEditor) {

Expand Down
12 changes: 12 additions & 0 deletions src/SeerHistoryLineEdit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "SeerHistoryLineEdit.h"

SeerHistoryLineEdit::SeerHistoryLineEdit (const QString& contents, QWidget* parent) : QHistoryLineEdit(contents, parent) {

QObject::connect(this, &QHistoryLineEdit::lostFocus, this, &QHistoryLineEdit::execute);
}

SeerHistoryLineEdit::SeerHistoryLineEdit (QWidget* parent) : QHistoryLineEdit(parent) {

QObject::connect(this, &QHistoryLineEdit::lostFocus, this, &QHistoryLineEdit::execute);
}

Loading

0 comments on commit 72ad448

Please sign in to comment.