More work on the stack browser.

This commit is contained in:
Ernie Pasveer
2024-10-05 10:37:29 -05:00
parent 171ea8c170
commit 98449201e4
5 changed files with 60 additions and 10 deletions
+1 -1
View File
@@ -11,7 +11,7 @@
* 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.
* Show stack as a hex dump, with options to view as short, int, long, ...
* Show stack as a hex dump, with options to view as short, int, long, ascii, ...
## [2.4] - 2024-03-18
* Changed main icon to a more license friendly one.
+49 -5
View File
@@ -7,6 +7,7 @@
#include <QtCore/QSettings>
#include <QtCore/QVector>
#include <QtCore/QDebug>
#include <cmath>
SeerStackDumpBrowserWidget::SeerStackDumpBrowserWidget (QWidget* parent) : QWidget(parent) {
@@ -32,10 +33,11 @@ SeerStackDumpBrowserWidget::SeerStackDumpBrowserWidget (QWidget* parent) : QWidg
QObject::connect(formatComboBox, &QComboBox::currentTextChanged, this, &SeerStackDumpBrowserWidget::handleFormatComboBox);
QObject::connect(visualizerToolButton, &QToolButton::clicked, this, &SeerStackDumpBrowserWidget::handleVisualizerToolButton);
QObject::connect(preferencesToolButton, &QToolButton::clicked, this, &SeerStackDumpBrowserWidget::handlePreferencesToolButton);
QObject::connect(stackTableWidget, &QTableWidget::cellDoubleClicked, this, &SeerStackDumpBrowserWidget::handleCellDoubleClicked);
setStackPointerExpression("$sp");
setBytesBeforeSP(32);
setBytesAfterSP(32);
setBytesBeforeSP(16);
setBytesAfterSP(16);
setAsciiBytes(8);
// Restore settings.
@@ -56,7 +58,7 @@ QString SeerStackDumpBrowserWidget::stackPointerExpression () const {
}
void SeerStackDumpBrowserWidget::setBytesBeforeSP (int nbytes) {
_bytesBeforeSP = nbytes;
_bytesBeforeSP = ceil(nbytes / 8.0) * 8; // Round to 8.
}
int SeerStackDumpBrowserWidget::bytesBeforeSP () const {
@@ -64,7 +66,7 @@ int SeerStackDumpBrowserWidget::bytesBeforeSP () const {
}
void SeerStackDumpBrowserWidget::setBytesAfterSP (int nbytes) {
_bytesAfterSP = nbytes;
_bytesAfterSP = ceil(nbytes / 8.0) * 8; // Round to 8.
}
int SeerStackDumpBrowserWidget::bytesAfterSP () const {
@@ -111,7 +113,7 @@ void SeerStackDumpBrowserWidget::handleText (const QString& text) {
addressLineEdit->setText(value_text);
emit refreshStackDump(_dumpExpressionId, value_text, 0, 64);
emit refreshStackDump(_dumpExpressionId, value_text, -bytesBeforeSP(), bytesBeforeSP()+bytesAfterSP()+2);
}else if (text.contains(QRegularExpression("^([0-9]+)\\^done,memory="))) {
@@ -198,6 +200,25 @@ void SeerStackDumpBrowserWidget::handlePreferencesToolButton () {
refresh();
}
void SeerStackDumpBrowserWidget::handleCellDoubleClicked (int row, int col) {
Q_UNUSED(col);
QTableWidgetItem* item = stackTableWidget->item(row, 0);
if (item == 0) {
return;
}
QString address = item->text();
if (address.mid(0,2) != "0x") {
address.insert(0,"0x");
}
emit addMemoryVisualize(address);
}
void SeerStackDumpBrowserWidget::refresh () {
// Don't do any work if the widget is hidden.
@@ -253,6 +274,8 @@ void SeerStackDumpBrowserWidget::_populateTable (QString address, QString conten
stackTableWidget->clearContents();
stackTableWidget->setRowCount(nrows);
int spRow = -1;
// Fill in the address column.
for (int i=0,r=0; i < contents.length()/2; i+=2,pos64+=2,r++) {
QString str = QString::number(pos64, 16);
@@ -261,6 +284,11 @@ void SeerStackDumpBrowserWidget::_populateTable (QString address, QString conten
item->setText(str);
item->setFont(fixedFont);
if (addressLineEdit->text().contains(str)) {
item->setBackground(QBrush(QColor(Qt::lightGray)));
spRow = r;
}
stackTableWidget->setItem(r,0,item);
}
@@ -283,6 +311,10 @@ void SeerStackDumpBrowserWidget::_populateTable (QString address, QString conten
item->setText(str);
item->setFont(fixedFont);
if (r == spRow) {
item->setBackground(QBrush(QColor(Qt::lightGray)));
}
stackTableWidget->setItem(r,1,item);
}
@@ -307,6 +339,10 @@ void SeerStackDumpBrowserWidget::_populateTable (QString address, QString conten
item->setText(str);
item->setFont(fixedFont);
if (r == spRow) {
item->setBackground(QBrush(QColor(Qt::lightGray)));
}
stackTableWidget->setItem(r,2,item);
}
@@ -331,6 +367,10 @@ void SeerStackDumpBrowserWidget::_populateTable (QString address, QString conten
item->setText(str);
item->setFont(fixedFont);
if (r == spRow) {
item->setBackground(QBrush(QColor(Qt::lightGray)));
}
stackTableWidget->setItem(r,3,item);
}
@@ -343,6 +383,10 @@ void SeerStackDumpBrowserWidget::_populateTable (QString address, QString conten
item->setText(str);
item->setFont(fixedFont);
if (r == spRow) {
item->setBackground(QBrush(QColor(Qt::lightGray)));
}
stackTableWidget->setItem(r,4,item);
}
}
+1
View File
@@ -33,6 +33,7 @@ class SeerStackDumpBrowserWidget : public QWidget, protected Ui::SeerStackDumpBr
void handleFormatComboBox (const QString& text);
void handleVisualizerToolButton ();
void handlePreferencesToolButton ();
void handleCellDoubleClicked (int row, int col);
signals:
void refreshStackPointer (int id, QString expression);
+2 -2
View File
@@ -15,8 +15,8 @@ SeerStackDumpSettingsDialog::SeerStackDumpSettingsDialog (QWidget* parent) : QDi
// Setup the widgets
setStackPointerExpression("$sp");
setBytesBeforeSP(0);
setBytesAfterSP(32);
setBytesBeforeSP(16);
setBytesAfterSP(16);
setAsciiBytes(8);
// Connect things.
+7 -2
View File
@@ -67,6 +67,9 @@
<property name="singleStep">
<number>8</number>
</property>
<property name="value">
<number>16</number>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
@@ -101,7 +104,7 @@
<number>8</number>
</property>
<property name="value">
<number>32</number>
<number>16</number>
</property>
</widget>
</item>
@@ -164,7 +167,9 @@ hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&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;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;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: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;-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>