Add option to follow execution in ProgramViewer
MODIFY
resources/icons/icons.qrc
resources/icons/icons.qrc
<file>analytics.svg</file>
<file>crosshair.svg</file>
<file>build.svg</file>
+ <file>trace.svg</file>
</qresource>
</RCC>

ADD
resources/icons/trace.svg
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ height="512px"
+ viewBox="0 0 64 64"
+ width="512px"
+ class=""
+ version="1.1"
+ id="svg3892"
+ sodipodi:docname="trace.svg"
+ inkscape:version="0.92.3 (2405546, 2018-03-11)">
+ <metadata
+ id="metadata3898">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs3896" />
+ <sodipodi:namedview
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1"
+ objecttolerance="10"
+ gridtolerance="10"
+ guidetolerance="10"
+ inkscape:pageopacity="0"
+ inkscape:pageshadow="2"
+ inkscape:window-width="1853"
+ inkscape:window-height="1025"
+ id="namedview3894"
+ showgrid="false"
+ inkscape:zoom="0.58281067"
+ inkscape:cx="343.14221"
+ inkscape:cy="25.026194"
+ inkscape:window-x="67"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1"
+ inkscape:current-layer="g3888" />
+ <g
+ id="g3890">
+ <path
+ d="m 32.18,45.25 -0.26,-2.99 -0.1,0.01 0.09,-0.06 -0.34,-3.93 -1.1,0.1 -14.66,1.28 -2.17,0.19 0.29,3.35 0.06,0.63 0.26,2.99 a 9,9 0 1 0 17.93,-1.57 z"
+ data-original="#8B5E3C"
+ class=""
+ id="path3816"
+ inkscape:connector-curvature="0"
+ style="fill:#8b5e3c" />
+ <path
+ d="m 30.77,18.27 h -0.01 l -3.92,0.34 -1.99,0.18 -2,0.17 -1.98,0.18 H 20.86 L 9.84,20.1 9.83,20.06 9.36,17.93 8.75,15.13 A 7.654,7.654 0 0 1 8.6,14.19 8.5,8.5 0 0 1 8.54,12.6 9.781,9.781 0 0 1 9.83,8.06 9.966,9.966 0 0 1 16.42,3.22 l 0.9,-0.2 a 10.981,10.981 0 0 1 10.54,3.46 10.989,10.989 0 0 1 2.67,5.79 11.647,11.647 0 0 1 0.1,1.2 l 0.01,0.27 z"
+ data-original="#A97C50"
+ class=""
+ id="path3818"
+ inkscape:connector-curvature="0"
+ style="fill:#a97c50" />
+ <path
+ d="m 55.23,53.58 a 4,4 0 1 1 -5.65,5.65 l -1.42,-1.41 5.66,-5.66 z"
+ data-original="#FF9811"
+ class="active-path"
+ data-old_color="#ff9811"
+ style="fill:#eb9b16"
+ id="path3820"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 45.573,51.574 h 8.004 v 4.002 h -8.004 z"
+ transform="matrix(0.707,-0.707,0.707,0.707,-23.363,50.747)"
+ data-original="#CC7400"
+ class=""
+ style="fill:#eb7d16"
+ data-old_color="#cc7400"
+ id="path3822"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 50.99,49.33 -5.66,5.66 -2.82,-2.83 5.65,-5.65 z"
+ data-original="#FF9811"
+ class="active-path"
+ data-old_color="#ff9811"
+ style="fill:#eb9b16"
+ id="path3824"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 39.925,45.919 h 7.99 v 4.002 h -7.99 z"
+ transform="matrix(0.707,-0.707,0.707,0.707,-21.021,45.092)"
+ data-original="#CC7400"
+ class=""
+ style="fill:#eb7d16"
+ data-old_color="#cc7400"
+ id="path3826"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 42.51,40.85 2.82,2.83 -5.65,5.65 -2.83,-2.82 z"
+ data-original="#FF9811"
+ class="active-path"
+ data-old_color="#ff9811"
+ style="fill:#eb9b16"
+ id="path3828"
+ inkscape:connector-curvature="0" />
+ <path
+ d="M 42.51,40.85 36.85,46.51 32.3,41.96 A 18.859,18.859 0 0 0 37.96,36.3 Z"
+ data-original="#CC7400"
+ class=""
+ style="fill:#eb7d16"
+ data-old_color="#cc7400"
+ id="path3830"
+ inkscape:connector-curvature="0" />
+ <path
+ d="M 31.22,34.29 13.29,35.86 12.65,32.91 12.43,31.92 12.42,31.88 11.35,27 l -0.21,-0.96 -0.01,-0.03 4.28,-0.37 1.99,-0.18 1.99,-0.17 h 0.01 l 1.98,-0.18 h 0.01 l 9.55,-0.83 0.03,1 0.14,5.06 v 0.01 l 0.03,0.93 z"
+ data-original="#A97C50"
+ class=""
+ id="path3832"
+ inkscape:connector-curvature="0"
+ style="fill:#a97c50" />
+ <path
+ d="m 30.94,24.27 v 0.01 l -9.55,0.83 h -0.01 l -1.98,0.18 h -0.01 l -1.99,0.17 -1.99,0.18 -4.28,0.37 -1.07,-4.92 -0.22,-0.99 11.02,-0.96 h 0.01 l 1.98,-0.18 2,-0.17 1.99,-0.18 3.92,-0.34 h 0.01 v 0.09 l 0.03,0.91 z"
+ data-original="#8B5E3C"
+ class=""
+ id="path3834"
+ inkscape:connector-curvature="0"
+ style="fill:#8b5e3c" />
+ <path
+ d="m 7,26 a 14.936,14.936 0 0 1 2.36,-8.07 l 0.48,2.17 1.29,5.91 1.3,5.91 0.86,3.94 17.93,-1.57 -0.28,-10.01 -0.17,-6.01 -0.13,-4.53 A 15,15 0 0 1 30.47,38.38 L 15.81,39.66 A 14.986,14.986 0 0 1 7,26 Z"
+ data-original="#E6E7E8"
+ class=""
+ id="path3836"
+ inkscape:connector-curvature="0"
+ style="fill:#e6e7e8" />
+ <path
+ d="M 29.25,8.44 A 18.793,18.793 0 0 0 22,7 1.21,1.21 0 0 0 21.81,7.01 17.961,17.961 0 0 0 17.84,7.46 19,19 0 0 0 13.93,43.2 c 0.41,0.19 0.82,0.37 1.24,0.53 a 19.016,19.016 0 0 0 16.65,-1.46 l 0.09,-0.06 c 0.13,-0.08 0.26,-0.16 0.39,-0.25 A 18.993,18.993 0 0 0 29.25,8.44 Z m 1.22,29.94 A 15,15 0 1 1 37,26 14.953,14.953 0 0 1 30.47,38.38 Z"
+ data-original="#FF9811"
+ class="active-path"
+ data-old_color="#ff9811"
+ style="fill:#eb9b16"
+ id="path3838"
+ inkscape:connector-curvature="0" />
+ <path
+ d="M 31.19,31.28 H 31.14 L 31.11,30.35 Z"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754c29"
+ id="path3840"
+ inkscape:connector-curvature="0" />
+ <path
+ d="M 20.95,20.13 10.06,21.09 9.84,20.1 9.83,20.06 9.75,19.11 l 11.03,-0.97 0.08,1 h 0.01 z"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754c29"
+ id="path3842"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 22.851,17.876 h 2 v 2 h -2 z"
+ transform="matrix(0.996,-0.087,0.087,0.996,-1.559,2.157)"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754c29"
+ id="path3844"
+ inkscape:connector-curvature="0" />
+ <path
+ d="M 30.85,19.27 H 30.8 l -0.03,-0.91 z"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754c29"
+ id="path3846"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 30.8,19.27 -3.87,0.34 -0.09,-1 -0.09,-0.99 3.93,-0.35 0.08,1 h 0.01 v 0.09 z"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754c29"
+ id="path3848"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 11.35,27 -0.13,0.01 -0.08,-0.97 z"
+ data-original="#E6E7E8"
+ class=""
+ id="path3850"
+ inkscape:connector-curvature="0"
+ style="fill:#e6e7e8" />
+ <g
+ id="g3888"
+ style="fill:#754c29">
+ <path
+ d="m 15.5,26.63 -4.15,0.37 -0.21,-0.96 -0.01,-0.03 -0.08,-0.99 4.27,-0.38 0.09,1 z"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754C29"
+ id="path3852"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 17.397,24.376 h 2 v 2 h -2 z"
+ transform="matrix(0.996,-0.087,0.087,0.996,-2.136,1.695)"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754C29"
+ id="path3854"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 31.03,25.27 -0.06,0.01 -0.03,-1 z"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754C29"
+ id="path3856"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 30.97,25.28 -9.5,0.83 -0.09,-1 -0.08,-0.99 9.55,-0.84 0.09,0.99 v 0.01 z"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754C29"
+ id="path3858"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 20,32.26 -7.35,0.65 -0.22,-0.99 -0.01,-0.04 -0.08,-0.96 7.49,-0.65 z"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754C29"
+ id="path3860"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 21.904,30.004 h 2 v 2 h -2 z"
+ transform="matrix(0.996,-0.087,0.087,0.996,-2.608,2.108)"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754C29"
+ id="path3862"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 31.14,31.28 -5.16,0.46 -0.17,-1.99 5.21,-0.46 0.09,1.05 v 0.01 z"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754C29"
+ id="path3864"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 17.318,46.379 h 4 v 2 h -4 z"
+ transform="matrix(0.996,-0.087,0.087,0.996,-4.045,1.859)"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754C29"
+ id="path3866"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 25.287,45.682 h 4 v 2 h -4 z"
+ transform="matrix(0.996,-0.087,0.087,0.996,-3.954,2.549)"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754C29"
+ id="path3868"
+ inkscape:connector-curvature="0" />
+ <path
+ d="m 21.652,50.015 h 4 v 2 h -4 z"
+ transform="matrix(0.996,-0.087,0.087,0.996,-4.369,2.263)"
+ data-original="#754C29"
+ class=""
+ style="fill:#714926"
+ data-old_color="#754C29"
+ id="path3870"
+ inkscape:connector-curvature="0" />
+ </g>
+ </g>
+</svg>

MODIFY
src/edittab.cpp
src/edittab.cpp
@@ -21,6 +21,16 @@ namespace Ripes {
EditTab::EditTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolbar, parent), m_ui(new Ui::EditTab) {
m_ui->setupUi(this);
+ m_followAction = new QAction(this);
+ m_followAction->setIcon(QIcon(":/icons/trace.svg"));
+ m_followAction->setCheckable(true);
+ m_followAction->setToolTip(
+ "Follow program execution.\nEnsures that the instruction present in the\nfirst stage of the processor is "
+ "always visible\nin the disassembled view.");
+ m_toolbar->addAction(m_followAction);
+ connect(m_followAction, &QAction::triggered, m_ui->programViewer, &ProgramViewer::setFollowEnabled);
+ m_followAction->setChecked(true);
+
m_buildAction = new QAction(this);
m_buildAction->setIcon(QIcon(":/icons/build.svg"));
m_buildAction->setEnabled(false);

MODIFY
src/edittab.h
src/edittab.h
@@ -81,6 +81,7 @@ private:
void disableEditor();
QAction* m_buildAction = nullptr;
+ QAction* m_followAction = nullptr;
Ui::EditTab* m_ui = nullptr;
std::unique_ptr<Assembler> m_assembler;

MODIFY
src/programviewer.cpp
src/programviewer.cpp
@@ -70,6 +70,21 @@ void ProgramViewer::updateSidebarWidth(int /* newBlockCount */) {
setViewportMargins(m_sidebarWidth, 0, 0, 0);
}
+void ProgramViewer::updateCenterAddress() {
+ const auto stageInfo = ProcessorHandler::get()->getProcessor()->stageInfo(0);
+ auto block = blockForAddress(stageInfo.pc);
+ setTextCursor(QTextCursor(block));
+ ensureCursorVisible();
+}
+
+void ProgramViewer::setFollowEnabled(bool enabled) {
+ m_following = enabled;
+
+ if (enabled) {
+ updateCenterAddress();
+ }
+}
+
void ProgramViewer::updateHighlightedAddresses() {
const unsigned stages = ProcessorHandler::get()->getProcessor()->stageCount();
QColor bg = QColor(Qt::red).lighter(120);
@@ -110,6 +125,10 @@ void ProgramViewer::updateHighlightedAddresses() {
bg = bg.lighter(decRatio);
}
setExtraSelections(highlights);
+
+ if (m_following) {
+ updateCenterAddress();
+ }
}
void ProgramViewer::paintEvent(QPaintEvent* event) {

MODIFY
src/programviewer.h
src/programviewer.h
@@ -24,6 +24,7 @@ public:
void breakpointClick(const QPoint& pos);
bool hasBreakpoint(const QPoint& pos) const;
void clearBreakpoints();
+ void setFollowEnabled(bool enabled);
long addressForPos(const QPoint& pos) const;
long addressForBlock(QTextBlock block) const;
@@ -47,11 +48,20 @@ private slots:
void updateSidebarWidth(int newBlockCount);
private:
+ /**
+ * @brief updateCenterAddress
+ * If program following is enabled, this function will ensure that the current instruction in the first stage of the
+ * processor is always visible within the program viewer.
+ */
+ void updateCenterAddress();
+
// A timer is needed for only catching one of the multiple wheel events that
// occur on a regular mouse scroll
QTimer m_fontTimer;
QTimer m_changeTimer;
+ bool m_following = true;
+
QFont m_font;
int m_sidebarWidth;

Add option to follow execution in ProgramViewer