mirror of
https://github.com/epasveer/seer.git
synced 2026-08-29 08:34:42 +08:00
Add locate for Variable Types and Variable Statics.
This commit is contained in:
@@ -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"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
+61
-5
@@ -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;
|
||||
|
||||
+4
-2
@@ -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 ();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "SeerSourceBrowserWidget.h"
|
||||
#include "SeerFunctionBrowserWidget.h"
|
||||
#include "SeerTypeBrowserWidget.h"
|
||||
#include "SeerVariableBrowserWidget.h"
|
||||
#include "SeerLibraryBrowserWidget.h"
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
#include "SeerTypeBrowserWidget.h"
|
||||
#include "SeerUtl.h"
|
||||
#include <QtWidgets/QTreeWidget>
|
||||
#include <QtWidgets/QTreeWidgetItemIterator>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/Qt>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QtCore/QString>
|
||||
#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;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SeerTypeBrowserWidgetForm</class>
|
||||
<widget class="QWidget" name="SeerTypeBrowserWidgetForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>730</width>
|
||||
<height>698</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Type Browser</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QTreeWidget" name="typeTreeWidget">
|
||||
<property name="columnCount">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>File</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Line</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Full Name</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLineEdit" name="typeSearchLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>Search in the list of types. "*" is allowed.</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,167 @@
|
||||
#include "SeerVariableBrowserWidget.h"
|
||||
#include "SeerUtl.h"
|
||||
#include <QtWidgets/QTreeWidget>
|
||||
#include <QtWidgets/QTreeWidgetItemIterator>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/Qt>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QtCore/QString>
|
||||
#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;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SeerVariableBrowserWidgetForm</class>
|
||||
<widget class="QWidget" name="SeerVariableBrowserWidgetForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>730</width>
|
||||
<height>698</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Variable Browser</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLineEdit" name="variableNameSearchLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>Search for variable names. "*" is allowed.</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Variable names</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="variableTypeSearchLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>Search for variable types. "*" is allowed.</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Variable types</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QTreeWidget" name="variableTreeWidget">
|
||||
<property name="columnCount">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Variable</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>File</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Line</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Full Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user