From 7fa329b5492dc5a3c9310eb38b7c708125ce0cca Mon Sep 17 00:00:00 2001 From: Ernie Pasveer Date: Mon, 9 May 2022 15:58:47 -0500 Subject: [PATCH] Add locate for Variable Types and Variable Statics. --- notes/README.info-types | 19 +++ src/CMakeLists.txt | 4 + src/SeerFunctionBrowserWidget.cpp | 7 +- src/SeerFunctionBrowserWidget.h | 3 +- src/SeerGdbWidget.cpp | 66 +++++++++- src/SeerGdbWidget.h | 6 +- src/SeerSourceLibraryManagerWidget.cpp | 14 +++ src/SeerSourceLibraryManagerWidget.h | 6 + src/SeerTypeBrowserWidget.cpp | 146 +++++++++++++++++++++ src/SeerTypeBrowserWidget.h | 31 +++++ src/SeerTypeBrowserWidget.ui | 58 +++++++++ src/SeerVariableBrowserWidget.cpp | 167 +++++++++++++++++++++++++ src/SeerVariableBrowserWidget.h | 31 +++++ src/SeerVariableBrowserWidget.ui | 90 +++++++++++++ 14 files changed, 638 insertions(+), 10 deletions(-) create mode 100644 notes/README.info-types create mode 100644 src/SeerTypeBrowserWidget.cpp create mode 100644 src/SeerTypeBrowserWidget.h create mode 100644 src/SeerTypeBrowserWidget.ui create mode 100644 src/SeerVariableBrowserWidget.cpp create mode 100644 src/SeerVariableBrowserWidget.h create mode 100644 src/SeerVariableBrowserWidget.ui diff --git a/notes/README.info-types b/notes/README.info-types new file mode 100644 index 0000000..bc3d6e4 --- /dev/null +++ b/notes/README.info-types @@ -0,0 +1,19 @@ + + -symbol-info-types [--name name_regexp] + [--max-results limit] + + ^done,symbols={ + debug=[ + { + filename="/peak/rel/include/CnvLib.h",fullname="/home/erniep/Development/Peak/rel/include/CnvLib.h", + symbols=[ + { + line="8", + name="Cnv" + } + ] + }, + + ] + } + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4f40b2c..2c1eae7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -57,6 +57,8 @@ set(HEADER_FILES SeerLibraryBrowserWidget.h SeerSourceBrowserWidget.h SeerFunctionBrowserWidget.h + SeerTypeBrowserWidget.h + SeerVariableBrowserWidget.h SeerSourceLibraryManagerWidget.h SeerStackArgumentsBrowserWidget.h SeerStackFramesBrowserWidget.h @@ -127,6 +129,8 @@ set(SOURCE_FILES SeerLibraryBrowserWidget.cpp SeerSourceBrowserWidget.cpp SeerFunctionBrowserWidget.cpp + SeerTypeBrowserWidget.cpp + SeerVariableBrowserWidget.cpp SeerSourceLibraryManagerWidget.cpp SeerStackArgumentsBrowserWidget.cpp SeerStackFramesBrowserWidget.cpp diff --git a/src/SeerFunctionBrowserWidget.cpp b/src/SeerFunctionBrowserWidget.cpp index 66fccba..aefae79 100644 --- a/src/SeerFunctionBrowserWidget.cpp +++ b/src/SeerFunctionBrowserWidget.cpp @@ -11,6 +11,9 @@ SeerFunctionBrowserWidget::SeerFunctionBrowserWidget (QWidget* parent) : QWidget(parent) { + // Set the state. + _id = Seer::createID(); + // Construct the UI. setupUi(this); @@ -39,7 +42,7 @@ void SeerFunctionBrowserWidget::handleText (const QString& text) { QApplication::setOverrideCursor(Qt::BusyCursor); - if (text.startsWith("^done,symbols={") && text.endsWith("}")) { + if (text.startsWith(QString::number(_id) + "^done,symbols={") && text.endsWith("}")) { functionTreeWidget->clear(); functionTreeWidget->setSortingEnabled(false); @@ -150,7 +153,7 @@ void SeerFunctionBrowserWidget::handleSearchLineEdit () { functionTreeWidget->resizeColumnToContents(5); if (functionSearchLineEdit->text() != "") { - emit refreshFunctionList(functionSearchLineEdit->text()); + emit refreshFunctionList(_id, functionSearchLineEdit->text()); } } diff --git a/src/SeerFunctionBrowserWidget.h b/src/SeerFunctionBrowserWidget.h index 02597dc..8d19b8e 100644 --- a/src/SeerFunctionBrowserWidget.h +++ b/src/SeerFunctionBrowserWidget.h @@ -21,10 +21,11 @@ class SeerFunctionBrowserWidget : public QWidget, protected Ui::SeerFunctionBrow void handleItemDoubleClicked (QTreeWidgetItem* item, int column); signals: - void refreshFunctionList (const QString& functionRegex); + void refreshFunctionList (int id, const QString& functionRegex); void selectedFile (QString file, QString fullname, int lineno); protected: private: + int _id; }; diff --git a/src/SeerGdbWidget.cpp b/src/SeerGdbWidget.cpp index ccb0578..0fa3937 100644 --- a/src/SeerGdbWidget.cpp +++ b/src/SeerGdbWidget.cpp @@ -110,6 +110,8 @@ SeerGdbWidget::SeerGdbWidget (QWidget* parent) : QWidget(parent) { QObject::connect(_gdbMonitor, &GdbMonitor::caretTextOutput, editorManagerWidget, &SeerEditorManagerWidget::handleText); QObject::connect(_gdbMonitor, &GdbMonitor::caretTextOutput, sourceLibraryManagerWidget->sourceBrowserWidget(), &SeerSourceBrowserWidget::handleText); QObject::connect(_gdbMonitor, &GdbMonitor::caretTextOutput, sourceLibraryManagerWidget->functionBrowserWidget(), &SeerFunctionBrowserWidget::handleText); + QObject::connect(_gdbMonitor, &GdbMonitor::caretTextOutput, sourceLibraryManagerWidget->typeBrowserWidget(), &SeerTypeBrowserWidget::handleText); + QObject::connect(_gdbMonitor, &GdbMonitor::caretTextOutput, sourceLibraryManagerWidget->variableBrowserWidget(), &SeerVariableBrowserWidget::handleText); QObject::connect(_gdbMonitor, &GdbMonitor::caretTextOutput, sourceLibraryManagerWidget->libraryBrowserWidget(), &SeerLibraryBrowserWidget::handleText); QObject::connect(_gdbMonitor, &GdbMonitor::caretTextOutput, stackManagerWidget->stackFramesBrowserWidget(), &SeerStackFramesBrowserWidget::handleText); QObject::connect(_gdbMonitor, &GdbMonitor::caretTextOutput, stackManagerWidget->stackLocalsBrowserWidget(), &SeerStackLocalsBrowserWidget::handleText); @@ -148,7 +150,11 @@ SeerGdbWidget::SeerGdbWidget (QWidget* parent) : QWidget(parent) { QObject::connect(sourceLibraryManagerWidget->sourceBrowserWidget(), &SeerSourceBrowserWidget::selectedFile, editorManagerWidget, &SeerEditorManagerWidget::handleOpenFile); QObject::connect(sourceLibraryManagerWidget->functionBrowserWidget(), &SeerFunctionBrowserWidget::refreshFunctionList, this, &SeerGdbWidget::handleGdbExecutableFunctions); QObject::connect(sourceLibraryManagerWidget->functionBrowserWidget(), &SeerFunctionBrowserWidget::selectedFile, editorManagerWidget, &SeerEditorManagerWidget::handleOpenFile); - QObject::connect(sourceLibraryManagerWidget->libraryBrowserWidget(), &SeerLibraryBrowserWidget::refreshLibraryList, this, &SeerGdbWidget::handleGdbExecutableSharedLibraries); + QObject::connect(sourceLibraryManagerWidget->typeBrowserWidget(), &SeerTypeBrowserWidget::refreshTypeList, this, &SeerGdbWidget::handleGdbExecutableTypes); + QObject::connect(sourceLibraryManagerWidget->typeBrowserWidget(), &SeerTypeBrowserWidget::selectedFile, editorManagerWidget, &SeerEditorManagerWidget::handleOpenFile); + QObject::connect(sourceLibraryManagerWidget->variableBrowserWidget(), &SeerVariableBrowserWidget::refreshVariableList, this, &SeerGdbWidget::handleGdbExecutableVariables); + QObject::connect(sourceLibraryManagerWidget->variableBrowserWidget(), &SeerVariableBrowserWidget::selectedFile, editorManagerWidget, &SeerEditorManagerWidget::handleOpenFile); + QObject::connect(sourceLibraryManagerWidget->libraryBrowserWidget(), &SeerLibraryBrowserWidget::refreshLibraryList, this, &SeerGdbWidget::handleGdbExecutableLibraries); QObject::connect(stackManagerWidget->stackFramesBrowserWidget(), &SeerStackFramesBrowserWidget::refreshStackFrames, this, &SeerGdbWidget::handleGdbStackListFrames); QObject::connect(stackManagerWidget->stackLocalsBrowserWidget(), &SeerStackLocalsBrowserWidget::refreshStackLocals, this, &SeerGdbWidget::handleGdbStackListLocals); @@ -1012,22 +1018,72 @@ void SeerGdbWidget::handleGdbExecutableSources () { handleGdbCommand("-file-list-exec-source-files"); } -void SeerGdbWidget::handleGdbExecutableFunctions (const QString& functionRegex) { +void SeerGdbWidget::handleGdbExecutableFunctions (int id, const QString& functionRegex) { if (executableLaunchMode() == "") { return; } + if (id <= 0) { + return; + } + if (functionRegex == "") { return; } - //qDebug() << functionRegex; + //qDebug() << id << functionRegex; - handleGdbCommand(QString("-symbol-info-functions --name %1").arg(functionRegex)); + handleGdbCommand(QString("%1-symbol-info-functions --name %2").arg(id).arg(functionRegex)); } -void SeerGdbWidget::handleGdbExecutableSharedLibraries () { +void SeerGdbWidget::handleGdbExecutableTypes (int id, const QString& typeRegex) { + + if (executableLaunchMode() == "") { + return; + } + + if (id <= 0) { + return; + } + + if (typeRegex == "") { + return; + } + + //qDebug() << id << typeRegex; + + handleGdbCommand(QString("%1-symbol-info-types --name %2").arg(id).arg(typeRegex)); +} + +void SeerGdbWidget::handleGdbExecutableVariables (int id, const QString& variableNameRegex, const QString& variableTypeRegex) { + + if (executableLaunchMode() == "") { + return; + } + + if (id <= 0) { + return; + } + + if (variableNameRegex == "" && variableTypeRegex == "") { + return; + } + + QString command = QString("%1-symbol-info-variables").arg(id); + + if (variableNameRegex != "") { + command += QString(" --name %1").arg(variableNameRegex); + } + + if (variableTypeRegex != "") { + command += QString(" --type %1").arg(variableTypeRegex); + } + + handleGdbCommand(command); +} + +void SeerGdbWidget::handleGdbExecutableLibraries () { if (executableLaunchMode() == "") { return; diff --git a/src/SeerGdbWidget.h b/src/SeerGdbWidget.h index 27dacc6..928ed43 100644 --- a/src/SeerGdbWidget.h +++ b/src/SeerGdbWidget.h @@ -137,8 +137,10 @@ class SeerGdbWidget : public QWidget, protected Ui::SeerGdbWidgetForm { void handleGdbInterruptSIGUSR1 (); void handleGdbInterruptSIGUSR2 (); void handleGdbExecutableSources (); - void handleGdbExecutableFunctions (const QString& functionRegex); - void handleGdbExecutableSharedLibraries (); + void handleGdbExecutableFunctions (int id, const QString& functionRegex); + void handleGdbExecutableTypes (int id, const QString& typeRegex); + void handleGdbExecutableVariables (int id, const QString& variableNameRegex, const QString& variableTypeRegex); + void handleGdbExecutableLibraries (); void handleGdbExecutableName (); void handleGdbExecutableArguments (); void handleGdbExecutableWorkingDirectory (); diff --git a/src/SeerSourceLibraryManagerWidget.cpp b/src/SeerSourceLibraryManagerWidget.cpp index 20fdad9..d5434ee 100644 --- a/src/SeerSourceLibraryManagerWidget.cpp +++ b/src/SeerSourceLibraryManagerWidget.cpp @@ -16,10 +16,14 @@ SeerSourceLibraryManagerWidget::SeerSourceLibraryManagerWidget (QWidget* parent) _sourceBrowserWidget = new SeerSourceBrowserWidget(this); _functionBrowserWidget = new SeerFunctionBrowserWidget(this); + _typeBrowserWidget = new SeerTypeBrowserWidget(this); + _variableBrowserWidget = new SeerVariableBrowserWidget(this); _libraryBrowserWidget = new SeerLibraryBrowserWidget(this); tabWidget->addTab(_sourceBrowserWidget, "Source"); tabWidget->addTab(_functionBrowserWidget, "Functions"); + tabWidget->addTab(_typeBrowserWidget, "Types"); + tabWidget->addTab(_variableBrowserWidget, "Variables"); tabWidget->addTab(_libraryBrowserWidget, "Libraries"); QToolButton* refreshToolButton = new QToolButton(tabWidget); @@ -42,6 +46,14 @@ SeerFunctionBrowserWidget* SeerSourceLibraryManagerWidget::functionBrowserWidget return _functionBrowserWidget; } +SeerTypeBrowserWidget* SeerSourceLibraryManagerWidget::typeBrowserWidget () { + return _typeBrowserWidget; +} + +SeerVariableBrowserWidget* SeerSourceLibraryManagerWidget::variableBrowserWidget () { + return _variableBrowserWidget; +} + SeerLibraryBrowserWidget* SeerSourceLibraryManagerWidget::libraryBrowserWidget () { return _libraryBrowserWidget; } @@ -50,6 +62,8 @@ void SeerSourceLibraryManagerWidget::handleRefreshToolButtonClicked () { sourceBrowserWidget()->refresh(); functionBrowserWidget()->refresh(); + typeBrowserWidget()->refresh(); + variableBrowserWidget()->refresh(); libraryBrowserWidget()->refresh(); } diff --git a/src/SeerSourceLibraryManagerWidget.h b/src/SeerSourceLibraryManagerWidget.h index 3a400d1..005d550 100644 --- a/src/SeerSourceLibraryManagerWidget.h +++ b/src/SeerSourceLibraryManagerWidget.h @@ -2,6 +2,8 @@ #include "SeerSourceBrowserWidget.h" #include "SeerFunctionBrowserWidget.h" +#include "SeerTypeBrowserWidget.h" +#include "SeerVariableBrowserWidget.h" #include "SeerLibraryBrowserWidget.h" #include @@ -18,6 +20,8 @@ class SeerSourceLibraryManagerWidget : public QWidget, protected Ui::SeerSourceL SeerSourceBrowserWidget* sourceBrowserWidget (); SeerFunctionBrowserWidget* functionBrowserWidget (); + SeerTypeBrowserWidget* typeBrowserWidget (); + SeerVariableBrowserWidget* variableBrowserWidget (); SeerLibraryBrowserWidget* libraryBrowserWidget (); signals: @@ -28,6 +32,8 @@ class SeerSourceLibraryManagerWidget : public QWidget, protected Ui::SeerSourceL private: SeerSourceBrowserWidget* _sourceBrowserWidget; SeerFunctionBrowserWidget* _functionBrowserWidget; + SeerTypeBrowserWidget* _typeBrowserWidget; + SeerVariableBrowserWidget* _variableBrowserWidget; SeerLibraryBrowserWidget* _libraryBrowserWidget; }; diff --git a/src/SeerTypeBrowserWidget.cpp b/src/SeerTypeBrowserWidget.cpp new file mode 100644 index 0000000..34d545a --- /dev/null +++ b/src/SeerTypeBrowserWidget.cpp @@ -0,0 +1,146 @@ +#include "SeerTypeBrowserWidget.h" +#include "SeerUtl.h" +#include +#include +#include +#include +#include +#include +#include +#include + +SeerTypeBrowserWidget::SeerTypeBrowserWidget (QWidget* parent) : QWidget(parent) { + + // Set the state. + _id = Seer::createID(); + + // Construct the UI. + setupUi(this); + + // Setup the widgets + typeSearchLineEdit->setPlaceholderText("Search..."); + typeSearchLineEdit->setClearButtonEnabled(true); + typeTreeWidget->setMouseTracking(true); + //typeTreeWidget->resizeColumnToContents(0); + typeTreeWidget->resizeColumnToContents(1); + typeTreeWidget->resizeColumnToContents(2); + typeTreeWidget->resizeColumnToContents(3); + typeTreeWidget->clear(); + typeTreeWidget->setSortingEnabled(false); + + // Connect things. + QObject::connect(typeTreeWidget, &QTreeWidget::itemDoubleClicked, this, &SeerTypeBrowserWidget::handleItemDoubleClicked); + QObject::connect(typeSearchLineEdit, &QLineEdit::returnPressed, this, &SeerTypeBrowserWidget::handleSearchLineEdit); +} + +SeerTypeBrowserWidget::~SeerTypeBrowserWidget () { +} + +void SeerTypeBrowserWidget::handleText (const QString& text) { + + QApplication::setOverrideCursor(Qt::BusyCursor); + + if (text.startsWith(QString::number(_id) + "^done,symbols={") && text.endsWith("}")) { + + typeTreeWidget->clear(); + typeTreeWidget->setSortingEnabled(false); + typeTreeWidget->sortByColumn(-1, Qt::AscendingOrder); + + // -symbol-info-types [--name name_regexp] + // [--max-results limit] + // + // ^done,symbols={ + // debug=[ + // { + // filename="/peak/rel/include/CnvLib.h",fullname="/home/erniep/Development/Peak/rel/include/CnvLib.h", + // symbols=[ + // { + // line="8", + // name="Cnv" + // } + // ] + // }, + // ... + // ] + // } + + QString debug_text = Seer::parseFirst(text, "debug=", '[', ']', false); + + QStringList filenames_list = Seer::parse(debug_text, "", '{', '}', false); + + for (const auto& filename_entry : filenames_list) { + + QString filename_text = Seer::parseFirst(filename_entry, "filename=", '"', '"', false); + QString fullname_text = Seer::parseFirst(filename_entry, "fullname=", '"', '"', false); + + QString symbols_text = Seer::parseFirst(filename_entry, "symbols=", '[', ']', false); + + QStringList symbols_list = Seer::parse(symbols_text, "", '{', '}', false); + + for (const auto& symbol_entry : symbols_list) { + + QString line_text = Seer::parseFirst(symbol_entry, "line=", '"', '"', false); + QString name_text = Seer::parseFirst(symbol_entry, "name=", '"', '"', false); + + // Skip type entries that have no line number. + if (line_text == "") { + continue; + } + + // Add the type to the tree. + QTreeWidgetItem* item = new QTreeWidgetItem; + + QFont f0 = item->font(0); + f0.setBold(true); + item->setFont(0,f0); + + item->setText(0, name_text); + item->setText(1, filename_text); + item->setText(2, line_text); + item->setText(3, fullname_text); + + typeTreeWidget->addTopLevelItem(item); + } + } + + }else{ + // Ignore others. + } + + //typeTreeWidget->resizeColumnToContents(0); + typeTreeWidget->resizeColumnToContents(1); + typeTreeWidget->resizeColumnToContents(2); + typeTreeWidget->resizeColumnToContents(3); + typeTreeWidget->sortByColumn(0, Qt::AscendingOrder); + typeTreeWidget->setSortingEnabled(true); + + QApplication::restoreOverrideCursor(); +} + +void SeerTypeBrowserWidget::handleItemDoubleClicked (QTreeWidgetItem* item, int column) { + + Q_UNUSED(column); + + emit selectedFile(item->text(1), item->text(3), item->text(2).toInt()); +} + +void SeerTypeBrowserWidget::handleSearchLineEdit () { + + typeTreeWidget->clear(); + typeTreeWidget->setSortingEnabled(false); + typeTreeWidget->sortByColumn(-1, Qt::AscendingOrder); + + //typeTreeWidget->resizeColumnToContents(0); + typeTreeWidget->resizeColumnToContents(1); + typeTreeWidget->resizeColumnToContents(2); + typeTreeWidget->resizeColumnToContents(3); + + if (typeSearchLineEdit->text() != "") { + emit refreshTypeList(_id, typeSearchLineEdit->text()); + } +} + +void SeerTypeBrowserWidget::refresh () { + handleSearchLineEdit(); +} + diff --git a/src/SeerTypeBrowserWidget.h b/src/SeerTypeBrowserWidget.h new file mode 100644 index 0000000..26a7cbc --- /dev/null +++ b/src/SeerTypeBrowserWidget.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include +#include "ui_SeerTypeBrowserWidget.h" + +class SeerTypeBrowserWidget : public QWidget, protected Ui::SeerTypeBrowserWidgetForm { + + Q_OBJECT + + public: + explicit SeerTypeBrowserWidget (QWidget* parent = 0); + ~SeerTypeBrowserWidget (); + + public slots: + void handleText (const QString& text); + void refresh (); + + protected slots: + void handleSearchLineEdit (); + void handleItemDoubleClicked (QTreeWidgetItem* item, int column); + + signals: + void refreshTypeList (int id, const QString& typeRegex); + void selectedFile (QString file, QString fullname, int lineno); + + protected: + private: + int _id; +}; + diff --git a/src/SeerTypeBrowserWidget.ui b/src/SeerTypeBrowserWidget.ui new file mode 100644 index 0000000..30b39cb --- /dev/null +++ b/src/SeerTypeBrowserWidget.ui @@ -0,0 +1,58 @@ + + + SeerTypeBrowserWidgetForm + + + + 0 + 0 + 730 + 698 + + + + Type Browser + + + + + + 4 + + + + Type + + + + + File + + + + + Line + + + + + Full Name + + + + + + + + Search in the list of types. "*" is allowed. + + + + + + + + + + + diff --git a/src/SeerVariableBrowserWidget.cpp b/src/SeerVariableBrowserWidget.cpp new file mode 100644 index 0000000..18dfc4e --- /dev/null +++ b/src/SeerVariableBrowserWidget.cpp @@ -0,0 +1,167 @@ +#include "SeerVariableBrowserWidget.h" +#include "SeerUtl.h" +#include +#include +#include +#include +#include +#include +#include +#include + +SeerVariableBrowserWidget::SeerVariableBrowserWidget (QWidget* parent) : QWidget(parent) { + + // Set the state. + _id = Seer::createID(); + + // Construct the UI. + setupUi(this); + + // Setup the widgets + variableNameSearchLineEdit->setPlaceholderText("Variable Name..."); + variableNameSearchLineEdit->setClearButtonEnabled(true); + variableTypeSearchLineEdit->setPlaceholderText("Variable Type..."); + variableTypeSearchLineEdit->setClearButtonEnabled(true); + variableTreeWidget->setMouseTracking(true); + //variableTreeWidget->resizeColumnToContents(0); + //variableTreeWidget->resizeColumnToContents(1); + variableTreeWidget->resizeColumnToContents(2); + variableTreeWidget->resizeColumnToContents(3); + variableTreeWidget->resizeColumnToContents(4); + variableTreeWidget->resizeColumnToContents(5); + variableTreeWidget->clear(); + variableTreeWidget->setSortingEnabled(false); + + // Connect things. + QObject::connect(variableTreeWidget, &QTreeWidget::itemDoubleClicked, this, &SeerVariableBrowserWidget::handleItemDoubleClicked); + QObject::connect(variableNameSearchLineEdit, &QLineEdit::returnPressed, this, &SeerVariableBrowserWidget::handleSearchLineEdit); + QObject::connect(variableTypeSearchLineEdit, &QLineEdit::returnPressed, this, &SeerVariableBrowserWidget::handleSearchLineEdit); +} + +SeerVariableBrowserWidget::~SeerVariableBrowserWidget () { +} + +void SeerVariableBrowserWidget::handleText (const QString& text) { + + QApplication::setOverrideCursor(Qt::BusyCursor); + + if (text.startsWith(QString::number(_id) + "^done,symbols={") && text.endsWith("}")) { + + variableTreeWidget->clear(); + variableTreeWidget->setSortingEnabled(false); + variableTreeWidget->sortByColumn(-1, Qt::AscendingOrder); + + // -symbol-info-variables + // ^done,symbols={ + // debug=[ + // { + // filename="elf-init.c", + // fullname="/home/abuild/rpmbuild/BUILD/glibc-2.31/csu/elf-init.c", + // symbols=[ + // { + // line="95", + // name="__libc_csu_fini", + // type="void (void)", + // description="void __libc_csu_fini(void);" + // }, + // { + // line="67", + // name="__libc_csu_init", + // type="void (int, char **, char **)", + // description="void __libc_csu_init(int, char **, char **);" + // } + // ] + // }, + // ... + // ] + // } + + QString debug_text = Seer::parseFirst(text, "debug=", '[', ']', false); + + QStringList filenames_list = Seer::parse(debug_text, "", '{', '}', false); + + for (const auto& filename_entry : filenames_list) { + + QString filename_text = Seer::parseFirst(filename_entry, "filename=", '"', '"', false); + QString fullname_text = Seer::parseFirst(filename_entry, "fullname=", '"', '"', false); + + QString symbols_text = Seer::parseFirst(filename_entry, "symbols=", '[', ']', false); + + QStringList symbols_list = Seer::parse(symbols_text, "", '{', '}', false); + + for (const auto& symbol_entry : symbols_list) { + + QString line_text = Seer::parseFirst(symbol_entry, "line=", '"', '"', false); + QString name_text = Seer::parseFirst(symbol_entry, "name=", '"', '"', false); + QString type_text = Seer::parseFirst(symbol_entry, "type=", '"', '"', false); + QString description_text = Seer::parseFirst(symbol_entry, "type=", '"', '"', false); + + // Skip variable entries that have no line number. + if (line_text == "") { + continue; + } + + // Add the variable to the tree. + QTreeWidgetItem* item = new QTreeWidgetItem; + + QFont f0 = item->font(0); + f0.setBold(true); + item->setFont(0,f0); + item->setFont(1,f0); + + item->setText(0, name_text); + item->setText(1, type_text); + item->setText(2, filename_text); + item->setText(3, line_text); + item->setText(4, fullname_text); + item->setText(5, description_text); + + variableTreeWidget->addTopLevelItem(item); + } + } + + }else{ + // Ignore others. + } + + //variableTreeWidget->resizeColumnToContents(0); // Name + //variableTreeWidget->resizeColumnToContents(1); // Type + variableTreeWidget->resizeColumnToContents(2); // Filename + variableTreeWidget->resizeColumnToContents(3); // Line + variableTreeWidget->resizeColumnToContents(4); // Fullname + variableTreeWidget->resizeColumnToContents(5); // Description + variableTreeWidget->sortByColumn(0, Qt::AscendingOrder); + variableTreeWidget->setSortingEnabled(true); + + QApplication::restoreOverrideCursor(); +} + +void SeerVariableBrowserWidget::handleItemDoubleClicked (QTreeWidgetItem* item, int column) { + + Q_UNUSED(column); + + emit selectedFile(item->text(2), item->text(4), item->text(3).toInt()); +} + +void SeerVariableBrowserWidget::handleSearchLineEdit () { + + variableTreeWidget->clear(); + variableTreeWidget->setSortingEnabled(false); + variableTreeWidget->sortByColumn(-1, Qt::AscendingOrder); + + //variableTreeWidget->resizeColumnToContents(0); + //variableTreeWidget->resizeColumnToContents(1); + variableTreeWidget->resizeColumnToContents(2); + variableTreeWidget->resizeColumnToContents(3); + variableTreeWidget->resizeColumnToContents(4); + variableTreeWidget->resizeColumnToContents(5); + + if (variableNameSearchLineEdit->text() != "" || variableTypeSearchLineEdit->text() != "") { + emit refreshVariableList(_id, variableNameSearchLineEdit->text(), variableTypeSearchLineEdit->text()); + } +} + +void SeerVariableBrowserWidget::refresh () { + handleSearchLineEdit(); +} + diff --git a/src/SeerVariableBrowserWidget.h b/src/SeerVariableBrowserWidget.h new file mode 100644 index 0000000..b7e022e --- /dev/null +++ b/src/SeerVariableBrowserWidget.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include +#include "ui_SeerVariableBrowserWidget.h" + +class SeerVariableBrowserWidget : public QWidget, protected Ui::SeerVariableBrowserWidgetForm { + + Q_OBJECT + + public: + explicit SeerVariableBrowserWidget (QWidget* parent = 0); + ~SeerVariableBrowserWidget (); + + public slots: + void handleText (const QString& text); + void refresh (); + + protected slots: + void handleSearchLineEdit (); + void handleItemDoubleClicked (QTreeWidgetItem* item, int column); + + signals: + void refreshVariableList (int id, const QString& variableNameRegex, const QString& variableTypeRegex); + void selectedFile (QString file, QString fullname, int lineno); + + protected: + private: + int _id; +}; + diff --git a/src/SeerVariableBrowserWidget.ui b/src/SeerVariableBrowserWidget.ui new file mode 100644 index 0000000..230a902 --- /dev/null +++ b/src/SeerVariableBrowserWidget.ui @@ -0,0 +1,90 @@ + + + SeerVariableBrowserWidgetForm + + + + 0 + 0 + 730 + 698 + + + + Variable Browser + + + + + + Search for variable names. "*" is allowed. + + + + + + Variable names + + + true + + + + + + + Search for variable types. "*" is allowed. + + + + + + Variable types + + + true + + + + + + + 6 + + + + Variable + + + + + Type + + + + + File + + + + + Line + + + + + Full Name + + + + + Description + + + + + + + + +