diff --git a/debuginterface.cpp b/debuginterface.cpp index f11dcdd..b311600 100644 --- a/debuginterface.cpp +++ b/debuginterface.cpp @@ -4,6 +4,8 @@ #include "qgdb/opendialog.h" #include +#include +#include #include struct DebugInterface::Priv_t { @@ -55,6 +57,7 @@ void DebugInterface::ICore_onStateChanged(TargetState state) void DebugInterface::ICore_onSignalReceived(QString signalName) { + QMessageBox::information(this->window(), tr("Signal recevied"), tr("Signal <<%1>>").arg(signalName)); } void DebugInterface::ICore_onLocalVarReset() @@ -89,12 +92,36 @@ void DebugInterface::ICore_onBreakpointsChanged() void DebugInterface::ICore_onThreadListChanged() { + QStandardItemModel *m = new QStandardItemModel(this); + foreach(ThreadInfo thd, Core::getInstance().getThreadList()) { + QStandardItem* thdItem = new QStandardItem(tr("[%3] %1: %2") + .arg(thd.m_name) + .arg(thd.m_func) + .arg(thd.id)); + thdItem->setData(QVariant::fromValue(thd), Qt::UserRole); + qDebug() << "create thread" << thd.id; + m->appendRow(thdItem); + } + ui->treeFrame->setModel(m); } void DebugInterface::ICore_onCurrentThreadChanged(int threadId) { qDebug() << "thread change" << threadId; - Core::getInstance().selectThread(threadId); + auto *m = qobject_cast(ui->treeFrame->model()); + if (m && threadId > 0 && threadId <= m->invisibleRootItem()->rowCount()) { + Core::getInstance().selectThread(threadId); + QStandardItem *thdItem = m->invisibleRootItem()->child(threadId-1, 0); + if (thdItem) { + ThreadInfo info = thdItem->data(Qt::UserRole).value(); + qDebug() << "select thread id" << info.id << info.m_func << info.m_name; + ui->treeFrame->selectionModel()->select(thdItem->index(), + QItemSelectionModel::Rows | + QItemSelectionModel::Select); + } else + qDebug() << "No thread item for " << threadId; + } else + qDebug() << "ignoring it" << threadId; } void DebugInterface::ICore_onStackFrameChange(QList stackFrameList) @@ -116,9 +143,26 @@ void DebugInterface::ICore_onTargetOutput(QString message) void DebugInterface::ICore_onCurrentFrameChanged(int frameIdx) { qDebug() << "current frame" << frameIdx << priv->currentStackFrameList.size(); - if (frameIdx < priv->currentStackFrameList.size()) { + if (frameIdx >= 0 && frameIdx < priv->currentStackFrameList.size()) { StackFrameEntry &entry = priv->currentStackFrameList[priv->currentStackFrameList.size()-frameIdx-1]; documentArea->fileOpenAndSetIP(entry.m_sourcePath, entry.m_line, &projectView->makeInfo()); + auto *m = qobject_cast(ui->treeFrame->model()); + if (m) { + QStandardItem *selectThread = nullptr; + foreach(auto i, ui->treeFrame->selectionModel()->selectedIndexes()) { + selectThread = m->itemFromIndex(i); + if (selectThread) { + if (selectThread->data(Qt::UserRole).canConvert()) { + break; + } + } + } + if (selectThread) { + ThreadInfo info = selectThread->data(Qt::UserRole).value(); + qDebug() << "inserting frames on" << info.id << info.m_name; + + } + } } } diff --git a/debuginterface.ui b/debuginterface.ui index 439d26c..616288d 100644 --- a/debuginterface.ui +++ b/debuginterface.ui @@ -13,7 +13,7 @@ Form - + 0 @@ -213,7 +213,7 @@ Qt::Vertical - + 0 @@ -224,13 +224,47 @@ + + + 0 + 23 + + + + Stack Frame + + + + + + + + + QAbstractItemView::NoEditTriggers + + + + + + + + + 0 + + + + + 0 + + + Watch View - + Add Watch @@ -250,7 +284,7 @@ - + Remove Selected Watch @@ -270,7 +304,7 @@ - + Clear All Watchs @@ -292,7 +326,11 @@ - + + + QAbstractItemView::NoEditTriggers + + @@ -356,7 +394,11 @@ - + + + QAbstractItemView::NoEditTriggers + + diff --git a/main.cpp b/main.cpp index 52b3807..4086f4a 100644 --- a/main.cpp +++ b/main.cpp @@ -18,6 +18,7 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationDomain("none.unknown.com"); QCoreApplication::setApplicationName("embedded IDE"); MainWindow w; + a.setWindowIcon(QIcon(":/images/embedded-ide.png")); adjustPath(); w.show(); diff --git a/mapviewer.cpp b/mapviewer.cpp index a23cd6f..f46b7d4 100644 --- a/mapviewer.cpp +++ b/mapviewer.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -302,6 +303,27 @@ class BarItemDelegate: public QStyledItemDelegate { } }; +class SymbolSortFilter: public QSortFilterProxyModel +{ +public: + SymbolSortFilter(QObject *parent = 0l) : QSortFilterProxyModel(parent) + { + setSourceModel(new QStandardItemModel(this)); + } + QStandardItemModel *itemModel() { return static_cast(sourceModel()); } + bool lessThan(const QModelIndex &left, const QModelIndex &right) const; +}; + +bool SymbolSortFilter::lessThan(const QModelIndex &left, const QModelIndex &right) const +{ + QVariant leftData = sourceModel()->data(left, Qt::UserRole); + QVariant rightData = sourceModel()->data(right, Qt::UserRole); + bool ok1 = false, ok2 = false; + uint32_t l = leftData.toUInt(&ok1); + uint32_t r = rightData.toUInt(&ok2); + return (ok1 && ok2)? (l < r) : false; +} + BarItemDelegate::~BarItemDelegate() { } @@ -320,11 +342,12 @@ MapViewer::MapViewer(QWidget *parent) : ui->memoryTable->setSelectionBehavior(QAbstractItemView::SelectRows); ui->memoryTable->setItemDelegateForColumn(4, new BarItemDelegate(this)); - ui->symbolsTable->setModel(new QStandardItemModel(this)); + ui->symbolsTable->setModel(new SymbolSortFilter(this)); ui->symbolsTable->setEditTriggers(QTableView::NoEditTriggers); ui->symbolsTable->setAlternatingRowColors(true); ui->symbolsTable->header()->setStretchLastSection(true); ui->symbolsTable->setSelectionBehavior(QAbstractItemView::SelectRows); + ui->symbolsTable->setSortingEnabled(true); } MapViewer::~MapViewer() @@ -360,7 +383,7 @@ bool MapViewer::load(const QString &path) items[4]->setData((r.used * 100.0) / r.size, Qt::UserRole); memoryModel->appendRow(items); } - auto symbolsTree = qobject_cast(ui->symbolsTable->model()); + auto symbolsTree = static_cast(ui->symbolsTable->model())->itemModel(); symbolsTree->clear(); symbolsTree->setHorizontalHeaderLabels(QStringList({tr("Name"), tr("Store address"), @@ -376,8 +399,11 @@ bool MapViewer::load(const QString &path) QList items; items += new QStandardItem(name.isEmpty()? tr("Symbols without section") : name); items += new QStandardItem(toHex(section.base)); + items.last()->setData(section.base, Qt::UserRole); items += new QStandardItem(toHex(section.load)); + items.last()->setData(section.load, Qt::UserRole); items += new QStandardItem(toHumanReadableSize(section.size)); + items.last()->setData(section.size, Qt::UserRole); symbolsTree->appendRow(items); foreach(auto tru, section.translationUnits) { if (tru.symbols.isEmpty()) @@ -385,8 +411,10 @@ bool MapViewer::load(const QString &path) QList childItems; childItems += new QStandardItem(tru.isNull()? tr("No unit") : tru.path); childItems += new QStandardItem(tru.isNull()? QString() : toHex(tru.addr)); + childItems.last()->setData(tru.addr, Qt::UserRole); childItems += new QStandardItem(); childItems += new QStandardItem(toHumanReadableSize(tru.size)); + childItems.last()->setData(tru.size, Qt::UserRole); items.first()->appendRow(childItems); foreach(auto symbol,tru.symbols) { QList symbolItems; diff --git a/qgdb/core.h b/qgdb/core.h index 247f5b1..6eb5047 100644 --- a/qgdb/core.h +++ b/qgdb/core.h @@ -16,6 +16,8 @@ struct ThreadInfo { QString m_func; }; +Q_DECLARE_METATYPE(ThreadInfo) + struct StackFrameEntry { public: