mirror of
https://github.com/epasveer/seer.git
synced 2026-08-29 08:34:42 +08:00
Fixed structure viewer crash in "Locals" tab.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <QtGui/QFontDatabase>
|
||||
#include <QAction>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtGlobal>
|
||||
|
||||
SeerStackLocalsBrowserWidget::SeerStackLocalsBrowserWidget (QWidget* parent) : QWidget(parent) {
|
||||
|
||||
@@ -84,9 +85,27 @@ void SeerStackLocalsBrowserWidget::handleText (const QString& text) {
|
||||
|
||||
// At this point, there are some new entries, some reused entries, and some unused ones.
|
||||
// Delete the unused ones. They are obsolete.
|
||||
// Don't use qDeleteAll() here. It doesn't work as expected for items that are "found".
|
||||
// Instead, get a list of matches and delete them from the bottom up.
|
||||
QList<QTreeWidgetItem*> matches = localsTreeWidget->findItems("unused", Qt::MatchExactly|Qt::MatchRecursive, 3);
|
||||
|
||||
qDeleteAll(matches);
|
||||
while (matches.isEmpty() == false) {
|
||||
foreach (QTreeWidgetItem* item, matches) {
|
||||
if (item->childCount() == 0) {
|
||||
QTreeWidgetItem* parent = item->parent();
|
||||
if (parent) {
|
||||
parent->removeChild(item);
|
||||
}
|
||||
|
||||
bool f = matches.removeOne(item);
|
||||
Q_ASSERT(f != false);
|
||||
|
||||
delete item;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}else if (text.startsWith("^error,msg=\"No registers.\"")) {
|
||||
localsTreeWidget->clear();
|
||||
@@ -549,7 +568,9 @@ void SeerStackLocalsBrowserWidget::handleItemCreate (QTreeWidgetItem* parentItem
|
||||
|
||||
// Simple entries don't have children. Delete them.
|
||||
QList<QTreeWidgetItem*> children = item->takeChildren();
|
||||
qDeleteAll(children);
|
||||
if (matches.size() > 0) {
|
||||
qDeleteAll(children);
|
||||
}
|
||||
|
||||
// Populate the item.
|
||||
item->setText(0, name_text);
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
mnwe
|
||||
rrun
|
||||
*.seer
|
||||
@@ -0,0 +1,10 @@
|
||||
.PHONY: all
|
||||
all: mnwe
|
||||
|
||||
mnwe: mnwe.cpp
|
||||
g++ -g -O0 -o mnwe mnwe.cpp
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f mnwe mnwe.o
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
https://github.com/epasveer/seer/issues/181
|
||||
|
||||
I can reproduce it like this:
|
||||
|
||||
Create a segfaulting file, e.g. this mnwe.cpp file:
|
||||
|
||||
int main() {
|
||||
int * i = nullptr;
|
||||
*i = 42;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Compile as g++ -g -O0 mnwe.cpp -o mnwe
|
||||
|
||||
Record the trace using rr: rr record --output-trace-dir=rrrun ./mnwe (you should see the segfault)
|
||||
|
||||
Start seergdb with this trace: seergdb --rr rrrun
|
||||
|
||||
When seergbd stops before main(), make sure that the 'Locals' tab is open
|
||||
Hit F8 to run the trace
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
int main() {
|
||||
int * i = nullptr;
|
||||
*i = 42;
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user