2018-06-06 11:05:20 +00:00
|
|
|
#include "BacktraceWidget.h"
|
|
|
|
#include "ui_BacktraceWidget.h"
|
2018-10-17 07:55:53 +00:00
|
|
|
#include "common/JsonModel.h"
|
2018-06-06 11:05:20 +00:00
|
|
|
|
|
|
|
#include "MainWindow.h"
|
|
|
|
|
|
|
|
BacktraceWidget::BacktraceWidget(MainWindow *main, QAction *action) :
|
|
|
|
CutterDockWidget(main, action),
|
|
|
|
ui(new Ui::BacktraceWidget)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
// setup backtrace model
|
|
|
|
QString PC = Core()->getRegisterName("PC");
|
|
|
|
QString SP = Core()->getRegisterName("SP");
|
2018-07-31 17:16:05 +00:00
|
|
|
modelBacktrace->setHorizontalHeaderItem(0, new QStandardItem(tr("Func Name")));
|
2018-06-06 11:05:20 +00:00
|
|
|
modelBacktrace->setHorizontalHeaderItem(1, new QStandardItem(SP));
|
2018-07-31 17:16:05 +00:00
|
|
|
modelBacktrace->setHorizontalHeaderItem(2, new QStandardItem(PC));
|
|
|
|
modelBacktrace->setHorizontalHeaderItem(3, new QStandardItem(tr("Description")));
|
|
|
|
modelBacktrace->setHorizontalHeaderItem(4, new QStandardItem(tr("Frame Size")));
|
2018-07-18 10:15:10 +00:00
|
|
|
viewBacktrace->setFont(Config()->getFont());
|
2018-06-06 11:05:20 +00:00
|
|
|
viewBacktrace->setModel(modelBacktrace);
|
2018-10-03 11:30:12 +00:00
|
|
|
viewBacktrace->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
|
2018-06-06 11:05:20 +00:00
|
|
|
ui->verticalLayout->addWidget(viewBacktrace);
|
|
|
|
|
2019-01-13 18:11:59 +00:00
|
|
|
refreshDeferrer = createRefreshDeferrer([this]() {
|
|
|
|
updateContents();
|
|
|
|
});
|
|
|
|
|
2018-06-06 11:05:20 +00:00
|
|
|
connect(Core(), &CutterCore::refreshAll, this, &BacktraceWidget::updateContents);
|
|
|
|
connect(Core(), &CutterCore::seekChanged, this, &BacktraceWidget::updateContents);
|
2018-07-18 10:15:10 +00:00
|
|
|
connect(Config(), &Configuration::fontsUpdated, this, &BacktraceWidget::fontsUpdatedSlot);
|
2018-06-06 11:05:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BacktraceWidget::~BacktraceWidget() {}
|
|
|
|
|
|
|
|
void BacktraceWidget::updateContents()
|
|
|
|
{
|
2019-01-13 18:11:59 +00:00
|
|
|
if (!refreshDeferrer->attemptRefresh(nullptr)) {
|
|
|
|
return;
|
|
|
|
}
|
2018-06-06 11:05:20 +00:00
|
|
|
setBacktraceGrid();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BacktraceWidget::setBacktraceGrid()
|
|
|
|
{
|
|
|
|
QJsonArray backtraceValues = Core()->getBacktrace().array();
|
|
|
|
int i = 0;
|
2018-11-26 22:34:34 +00:00
|
|
|
for (const QJsonValue &value : backtraceValues) {
|
2018-06-06 11:05:20 +00:00
|
|
|
QJsonObject backtraceItem = value.toObject();
|
|
|
|
QString progCounter = RAddressString(backtraceItem["pc"].toVariant().toULongLong());
|
|
|
|
QString stackPointer = RAddressString(backtraceItem["sp"].toVariant().toULongLong());
|
2018-07-31 17:16:05 +00:00
|
|
|
int frameSize = backtraceItem["frame_size"].toVariant().toInt();
|
2018-06-06 11:05:20 +00:00
|
|
|
QString funcName = backtraceItem["fname"].toString();
|
|
|
|
QString desc = backtraceItem["desc"].toString();
|
|
|
|
|
|
|
|
QStandardItem *rowPC = new QStandardItem(progCounter);
|
|
|
|
QStandardItem *rowSP = new QStandardItem(stackPointer);
|
2018-07-31 17:16:05 +00:00
|
|
|
QStandardItem *rowFrameSize = new QStandardItem(QString::number(frameSize));
|
2018-06-06 11:05:20 +00:00
|
|
|
QStandardItem *rowFuncName = new QStandardItem(funcName);
|
|
|
|
QStandardItem *rowDesc = new QStandardItem(desc);
|
|
|
|
|
2018-07-31 17:16:05 +00:00
|
|
|
modelBacktrace->setItem(i, 0, rowFuncName);
|
2018-06-06 11:05:20 +00:00
|
|
|
modelBacktrace->setItem(i, 1, rowSP);
|
2018-07-31 17:16:05 +00:00
|
|
|
modelBacktrace->setItem(i, 2, rowPC);
|
|
|
|
modelBacktrace->setItem(i, 3, rowDesc);
|
|
|
|
modelBacktrace->setItem(i, 4, rowFrameSize);
|
2018-06-06 11:05:20 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
viewBacktrace->setModel(modelBacktrace);
|
|
|
|
viewBacktrace->resizeColumnsToContents();;
|
|
|
|
}
|
2018-07-18 10:15:10 +00:00
|
|
|
|
|
|
|
void BacktraceWidget::fontsUpdatedSlot()
|
|
|
|
{
|
|
|
|
viewBacktrace->setFont(Config()->getFont());
|
2018-11-26 22:34:34 +00:00
|
|
|
}
|