Skip to content

Commit

Permalink
Finished 'stack' view.
Browse files Browse the repository at this point in the history
  • Loading branch information
epasveer committed Oct 5, 2024
1 parent 9844920 commit 1b2df9e
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 13 deletions.
28 changes: 23 additions & 5 deletions src/SeerStackDumpBrowserWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ SeerStackDumpBrowserWidget::SeerStackDumpBrowserWidget (QWidget* parent) : QWidg
QObject::connect(stackTableWidget, &QTableWidget::cellDoubleClicked, this, &SeerStackDumpBrowserWidget::handleCellDoubleClicked);

setStackPointerExpression("$sp");
setStackPointerColor(QColor("lightGray"));
setBytesBeforeSP(16);
setBytesAfterSP(16);
setAsciiBytes(8);
Expand Down Expand Up @@ -81,6 +82,14 @@ int SeerStackDumpBrowserWidget::asciiBytes () const {
return _asciiBytes;
}

void SeerStackDumpBrowserWidget::setStackPointerColor (const QColor& color) {
_stackPointerColor = color;
}

QColor SeerStackDumpBrowserWidget::stackPointerColor () const {
return _stackPointerColor;
}

void SeerStackDumpBrowserWidget::handleText (const QString& text) {

// -data-read-memory-bytes -o 16 $sp 32
Expand Down Expand Up @@ -178,6 +187,7 @@ void SeerStackDumpBrowserWidget::handlePreferencesToolButton () {
// Bring up the register edit dialog.
SeerStackDumpSettingsDialog dlg(this);
dlg.setStackPointerExpression(stackPointerExpression());
dlg.setStackPointerColor(stackPointerColor());
dlg.setBytesBeforeSP(bytesBeforeSP());
dlg.setBytesAfterSP(bytesAfterSP());
dlg.setAsciiBytes(asciiBytes());
Expand All @@ -191,6 +201,7 @@ void SeerStackDumpBrowserWidget::handlePreferencesToolButton () {
}

setStackPointerExpression(dlg.stackPointerExpression());
setStackPointerColor(dlg.stackPointerColor());
setBytesBeforeSP(dlg.bytesBeforeSP());
setBytesAfterSP(dlg.bytesAfterSP());
setAsciiBytes(dlg.asciiBytes());
Expand Down Expand Up @@ -285,7 +296,7 @@ void SeerStackDumpBrowserWidget::_populateTable (QString address, QString conten
item->setFont(fixedFont);

if (addressLineEdit->text().contains(str)) {
item->setBackground(QBrush(QColor(Qt::lightGray)));
item->setBackground(QBrush(stackPointerColor()));
spRow = r;
}

Expand All @@ -312,7 +323,7 @@ void SeerStackDumpBrowserWidget::_populateTable (QString address, QString conten
item->setFont(fixedFont);

if (r == spRow) {
item->setBackground(QBrush(QColor(Qt::lightGray)));
item->setBackground(QBrush(stackPointerColor()));
}

stackTableWidget->setItem(r,1,item);
Expand Down Expand Up @@ -340,7 +351,7 @@ void SeerStackDumpBrowserWidget::_populateTable (QString address, QString conten
item->setFont(fixedFont);

if (r == spRow) {
item->setBackground(QBrush(QColor(Qt::lightGray)));
item->setBackground(QBrush(stackPointerColor()));
}

stackTableWidget->setItem(r,2,item);
Expand Down Expand Up @@ -368,7 +379,7 @@ void SeerStackDumpBrowserWidget::_populateTable (QString address, QString conten
item->setFont(fixedFont);

if (r == spRow) {
item->setBackground(QBrush(QColor(Qt::lightGray)));
item->setBackground(QBrush(stackPointerColor()));
}

stackTableWidget->setItem(r,3,item);
Expand All @@ -384,7 +395,7 @@ void SeerStackDumpBrowserWidget::_populateTable (QString address, QString conten
item->setFont(fixedFont);

if (r == spRow) {
item->setBackground(QBrush(QColor(Qt::lightGray)));
item->setBackground(QBrush(stackPointerColor()));
}

stackTableWidget->setItem(r,4,item);
Expand All @@ -397,6 +408,7 @@ void SeerStackDumpBrowserWidget::writeSettings () {

settings.beginGroup("stackdumpwindow"); {
settings.setValue("stackpointerexpression", stackPointerExpression());
settings.setValue("stackpointercolor", stackPointerColor());
settings.setValue("bytesbeforesp", bytesBeforeSP());
settings.setValue("bytesaftersp", bytesAfterSP());
settings.setValue("asciibytes", asciiBytes());
Expand All @@ -410,6 +422,12 @@ void SeerStackDumpBrowserWidget::readSettings () {
settings.beginGroup("stackdumpwindow"); {

setStackPointerExpression(settings.value("stackpointerexpression", "$sp").toString());

QVariant variant = settings.value("stackpointercolor", "lightGray");
QColor color = variant.value<QColor>();

setStackPointerColor(color);

setBytesBeforeSP(settings.value("bytesbeforesp", 32).toInt());
setBytesAfterSP(settings.value("bytesaftersp", 32).toInt());
setAsciiBytes(settings.value("asciibytes", 8).toInt());
Expand Down
5 changes: 5 additions & 0 deletions src/SeerStackDumpBrowserWidget.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <QtWidgets/QWidget>
#include <QtGui/QColor>
#include <QtCore/QString>
#include "ui_SeerStackDumpBrowserWidget.h"

Expand All @@ -24,6 +25,9 @@ class SeerStackDumpBrowserWidget : public QWidget, protected Ui::SeerStackDumpBr
void setAsciiBytes (int nbytes);
int asciiBytes () const;

void setStackPointerColor (const QColor& color);
QColor stackPointerColor () const;

public slots:
void handleText (const QString& text);
void handleStoppingPointReached ();
Expand Down Expand Up @@ -53,5 +57,6 @@ class SeerStackDumpBrowserWidget : public QWidget, protected Ui::SeerStackDumpBr
int _bytesBeforeSP;
int _bytesAfterSP;
int _asciiBytes;
QColor _stackPointerColor;
};

9 changes: 9 additions & 0 deletions src/SeerStackDumpSettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ SeerStackDumpSettingsDialog::SeerStackDumpSettingsDialog (QWidget* parent) : QDi

// Setup the widgets
setStackPointerExpression("$sp");
setStackPointerColor(QColor("lightGray"));
setBytesBeforeSP(16);
setBytesAfterSP(16);
setAsciiBytes(8);
Expand All @@ -29,6 +30,14 @@ void SeerStackDumpSettingsDialog::setStackPointerExpression (const QString& expr
spExpressionLineEdit->setText(expression);
}

void SeerStackDumpSettingsDialog::setStackPointerColor (const QColor& color) {
spHighLightColorButton->setColor(color);
}

QColor SeerStackDumpSettingsDialog::stackPointerColor () const {
return spHighLightColorButton->color();
}

QString SeerStackDumpSettingsDialog::stackPointerExpression () const {
return spExpressionLineEdit->text();
}
Expand Down
4 changes: 4 additions & 0 deletions src/SeerStackDumpSettingsDialog.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <QtWidgets/QDialog>
#include <QtGui/QColor>
#include <QtCore/QString>

#include "ui_SeerStackDumpSettingsDialog.h"
Expand All @@ -16,6 +17,9 @@ class SeerStackDumpSettingsDialog : public QDialog, protected Ui::SeerStackDumpS
void setStackPointerExpression (const QString& expression);
QString stackPointerExpression () const;

void setStackPointerColor (const QColor& color);
QColor stackPointerColor () const;

void setBytesBeforeSP (int nbytes);
int bytesBeforeSP () const;

Expand Down
52 changes: 44 additions & 8 deletions src/SeerStackDumpSettingsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,39 @@
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Highlight color</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QColorButton" name="spHighLightColorButton" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Select color to highlight SP row.</string>
</property>
</widget>
</item>
<item row="0" column="5">
<spacer name="horizontalSpacer_1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>226</width>
<width>218</width>
<height>20</height>
</size>
</property>
Expand Down Expand Up @@ -72,14 +98,14 @@
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<item row="1" column="2" colspan="4">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>291</width>
<width>448</width>
<height>20</height>
</size>
</property>
Expand Down Expand Up @@ -108,14 +134,14 @@
</property>
</widget>
</item>
<item row="2" column="2" colspan="2">
<item row="2" column="2" colspan="4">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>291</width>
<width>448</width>
<height>20</height>
</size>
</property>
Expand Down Expand Up @@ -144,20 +170,20 @@
</property>
</widget>
</item>
<item row="3" column="2" colspan="2">
<item row="3" column="2" colspan="4">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>291</width>
<width>448</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="4">
<item row="4" column="0" colspan="6">
<widget class="QTextBrowser" name="textBrowser">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
Expand All @@ -170,6 +196,8 @@ li.checked::marker { content: &quot;\2612&quot;; }
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;The stack pointer (SP) points to where in the stack memory the program is currently at. The settings here control how the memory around the SP is displayed.&lt;br /&gt;&lt;br /&gt;GDB has the virtual variable called &amp;quot;$sp&amp;quot;, which contains the SP address. It is typical to use this as the SP expression. Some might prefer &amp;quot;$ss*16+$sp&amp;quot;, which is for X86 real mode. Either way, enter a gdb expression that results in an address. In most cases, $sp is enough.&lt;br /&gt;&lt;br /&gt;Seer can show N bytes before and N bytes after the SP, thus forming a window of bytes. N is rounded up to the next count of 8.&lt;br /&gt;&lt;br /&gt;The bytes are shown as 2, 4, and 8 byte version of: hex, octal, int, uint, and float values.&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Also, Seer will attempt to show the bytes as Ascii characters. The number of Ascii characters to show can be set.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Double clicking on a row will bring up a separate Memory Visualizer for that address.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;Highlight color is used to highlight the row that contains $SP. Double click on it to bring up a color chooser.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
Expand All @@ -188,6 +216,14 @@ li.checked::marker { content: &quot;\2612&quot;; }
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QColorButton</class>
<extends>QWidget</extends>
<header>QColorButton.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
Expand Down
9 changes: 9 additions & 0 deletions src/resources/help/StackInfoBrowser.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ Selecting a diffent frame in the Frames tab will show the locals for that frame.
Arg The function argument number, if any. May appear in the Arguements tab.
Value Value of the variable.
```
### Stack
This tab shows a window of bytes around the current stack pointer (SP). The window has a start address and an end address, incrementing by
2 bytes. The address of the SP is somewhere between them, depending on your settings.

The bytes are shown as 2, 4, and 8 byte groupings. Each grouping can be represented as: hex, octal, int, uint, and float.

The line that contains the SP is highlighted. Any line can be double-clicked to bring up a separate Memory Visualizer for the
address for that line.

### Refresh
The refresh button refreshes the currently exposed tab.

0 comments on commit 1b2df9e

Please sign in to comment.