2019-09-06 05:40:20 +00:00
|
|
|
#include "DecompilerWidget.h"
|
|
|
|
#include "ui_DecompilerWidget.h"
|
2019-08-07 11:38:22 +00:00
|
|
|
#include "menus/DisassemblyContextMenu.h"
|
2017-12-15 10:52:47 +00:00
|
|
|
|
2018-10-17 07:55:53 +00:00
|
|
|
#include "common/Configuration.h"
|
|
|
|
#include "common/Helpers.h"
|
|
|
|
#include "common/TempConfig.h"
|
2019-07-12 08:57:07 +00:00
|
|
|
#include "common/SelectionHighlight.h"
|
2019-07-15 12:08:44 +00:00
|
|
|
#include "common/Decompiler.h"
|
2019-12-14 12:57:36 +00:00
|
|
|
#include "common/CutterSeekable.h"
|
2017-12-06 23:19:14 +00:00
|
|
|
|
2019-07-11 13:21:54 +00:00
|
|
|
#include <QTextEdit>
|
2019-07-12 08:57:07 +00:00
|
|
|
#include <QPlainTextEdit>
|
|
|
|
#include <QTextBlock>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QTextBlockUserData>
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
DecompilerWidget::DecompilerWidget(MainWindow *main, QAction *action) :
|
|
|
|
MemoryDockWidget(MemoryWidgetType::Decompiler, main, action),
|
2019-08-07 11:38:22 +00:00
|
|
|
mCtxMenu(new DisassemblyContextMenu(this, main)),
|
2019-09-06 05:40:20 +00:00
|
|
|
ui(new Ui::DecompilerWidget)
|
2017-12-06 23:19:14 +00:00
|
|
|
{
|
2017-12-21 14:23:44 +00:00
|
|
|
ui->setupUi(this);
|
|
|
|
|
2019-07-11 13:21:54 +00:00
|
|
|
syntaxHighlighter = Config()->createSyntaxHighlighter(ui->textEdit->document());
|
2017-12-16 13:22:56 +00:00
|
|
|
|
2019-12-14 12:57:36 +00:00
|
|
|
// Event filter to intercept double clicks in the textbox
|
|
|
|
ui->textEdit->viewport()->installEventFilter(this);
|
|
|
|
|
2017-12-06 23:19:14 +00:00
|
|
|
setupFonts();
|
|
|
|
colorsUpdatedSlot();
|
|
|
|
|
2019-10-12 05:50:10 +00:00
|
|
|
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(fontsUpdatedSlot()));
|
2017-12-06 23:19:14 +00:00
|
|
|
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(colorsUpdatedSlot()));
|
2019-12-19 17:58:30 +00:00
|
|
|
connect(Core(), SIGNAL(registersChanged()), this, SLOT(highlightPC()));
|
2017-12-06 23:19:14 +00:00
|
|
|
|
2019-09-01 09:06:54 +00:00
|
|
|
decompiledFunctionAddr = RVA_INVALID;
|
|
|
|
decompilerWasBusy = false;
|
|
|
|
|
2017-12-21 14:23:44 +00:00
|
|
|
connect(ui->refreshButton, &QAbstractButton::clicked, this, [this]() {
|
2019-09-01 09:06:54 +00:00
|
|
|
doRefresh();
|
|
|
|
});
|
|
|
|
|
|
|
|
refreshDeferrer = createRefreshDeferrer([this]() {
|
|
|
|
doRefresh();
|
|
|
|
});
|
|
|
|
|
|
|
|
autoRefreshEnabled = Config()->getDecompilerAutoRefreshEnabled();
|
|
|
|
ui->autoRefreshCheckBox->setChecked(autoRefreshEnabled);
|
|
|
|
setAutoRefresh(autoRefreshEnabled);
|
|
|
|
connect(ui->autoRefreshCheckBox, &QCheckBox::stateChanged, this, [this](int state) {
|
|
|
|
setAutoRefresh(state == Qt::Checked);
|
|
|
|
Config()->setDecompilerAutoRefreshEnabled(autoRefreshEnabled);
|
|
|
|
doAutoRefresh();
|
2017-12-06 23:19:14 +00:00
|
|
|
});
|
|
|
|
|
2019-07-15 12:08:44 +00:00
|
|
|
auto decompilers = Core()->getDecompilers();
|
2019-07-16 18:33:05 +00:00
|
|
|
auto selectedDecompilerId = Config()->getSelectedDecompiler();
|
2019-07-15 12:08:44 +00:00
|
|
|
for (auto dec : decompilers) {
|
|
|
|
ui->decompilerComboBox->addItem(dec->getName(), dec->getId());
|
2019-07-16 18:33:05 +00:00
|
|
|
if (dec->getId() == selectedDecompilerId) {
|
|
|
|
ui->decompilerComboBox->setCurrentIndex(ui->decompilerComboBox->count() - 1);
|
|
|
|
}
|
2019-09-06 05:40:20 +00:00
|
|
|
connect(dec, &Decompiler::finished, this, &DecompilerWidget::decompilationFinished);
|
2019-07-15 12:08:44 +00:00
|
|
|
}
|
|
|
|
|
2019-08-28 17:01:12 +00:00
|
|
|
decompilerSelectionEnabled = decompilers.size() > 1;
|
|
|
|
ui->decompilerComboBox->setEnabled(decompilerSelectionEnabled);
|
|
|
|
|
|
|
|
if (decompilers.isEmpty()) {
|
|
|
|
ui->textEdit->setPlainText(tr("No Decompiler available."));
|
2018-09-08 07:12:08 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
connect(ui->decompilerComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &DecompilerWidget::decompilerSelected);
|
2019-07-12 08:57:07 +00:00
|
|
|
connectCursorPositionChanged(false);
|
2019-09-06 05:40:20 +00:00
|
|
|
connect(Core(), &CutterCore::seekChanged, this, &DecompilerWidget::seekChanged);
|
2019-08-07 11:38:22 +00:00
|
|
|
ui->textEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
connect(ui->textEdit, SIGNAL(customContextMenuRequested(const QPoint &)),
|
|
|
|
this, SLOT(showDisasContextMenu(const QPoint &)));
|
|
|
|
|
|
|
|
// refresh the widget when an action in this menu is triggered
|
2019-09-06 05:40:20 +00:00
|
|
|
connect(mCtxMenu, &QMenu::triggered, this, &DecompilerWidget::refreshDecompiler);
|
2019-08-07 11:38:22 +00:00
|
|
|
addActions(mCtxMenu->actions());
|
2019-07-12 08:57:07 +00:00
|
|
|
|
2019-08-28 17:01:12 +00:00
|
|
|
ui->progressLabel->setVisible(false);
|
2019-01-12 17:02:51 +00:00
|
|
|
doRefresh(RVA_INVALID);
|
2019-09-01 09:06:54 +00:00
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
connect(Core(), &CutterCore::refreshAll, this, &DecompilerWidget::doAutoRefresh);
|
|
|
|
connect(Core(), &CutterCore::functionRenamed, this, &DecompilerWidget::doAutoRefresh);
|
|
|
|
connect(Core(), &CutterCore::varsChanged, this, &DecompilerWidget::doAutoRefresh);
|
|
|
|
connect(Core(), &CutterCore::functionsChanged, this, &DecompilerWidget::doAutoRefresh);
|
|
|
|
connect(Core(), &CutterCore::flagsChanged, this, &DecompilerWidget::doAutoRefresh);
|
|
|
|
connect(Core(), &CutterCore::commentsChanged, this, &DecompilerWidget::doAutoRefresh);
|
|
|
|
connect(Core(), &CutterCore::instructionChanged, this, &DecompilerWidget::doAutoRefresh);
|
|
|
|
connect(Core(), &CutterCore::refreshCodeViews, this, &DecompilerWidget::doAutoRefresh);
|
2019-12-14 12:57:36 +00:00
|
|
|
|
|
|
|
// Esc to seek backward
|
|
|
|
QAction *seekPrevAction = new QAction(this);
|
|
|
|
seekPrevAction->setShortcut(Qt::Key_Escape);
|
|
|
|
seekPrevAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
|
|
|
addAction(seekPrevAction);
|
|
|
|
connect(seekPrevAction, &QAction::triggered, seekable, &CutterSeekable::seekPrev);
|
2017-12-06 23:19:14 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
DecompilerWidget::~DecompilerWidget() = default;
|
2017-12-06 23:19:14 +00:00
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
Decompiler *DecompilerWidget::getCurrentDecompiler()
|
2019-09-01 09:06:54 +00:00
|
|
|
{
|
|
|
|
return Core()->getDecompilerById(ui->decompilerComboBox->currentData().toString());
|
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::setAutoRefresh(bool enabled)
|
2019-09-01 09:06:54 +00:00
|
|
|
{
|
|
|
|
autoRefreshEnabled = enabled;
|
|
|
|
updateRefreshButton();
|
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::doAutoRefresh()
|
2019-09-01 09:06:54 +00:00
|
|
|
{
|
|
|
|
if (!autoRefreshEnabled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
doRefresh();
|
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::updateRefreshButton()
|
2019-09-01 09:06:54 +00:00
|
|
|
{
|
|
|
|
Decompiler *dec = getCurrentDecompiler();
|
|
|
|
ui->refreshButton->setEnabled(!autoRefreshEnabled && dec && !dec->isRunning());
|
|
|
|
if (dec && dec->isRunning() && dec->isCancelable()) {
|
|
|
|
ui->refreshButton->setText(tr("Cancel"));
|
|
|
|
} else {
|
|
|
|
ui->refreshButton->setText(tr("Refresh"));
|
|
|
|
}
|
|
|
|
}
|
2017-12-06 23:19:14 +00:00
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::doRefresh(RVA addr)
|
2017-12-06 23:19:14 +00:00
|
|
|
{
|
2019-09-01 09:06:54 +00:00
|
|
|
if (!refreshDeferrer->attemptRefresh(nullptr)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-15 12:08:44 +00:00
|
|
|
if (ui->decompilerComboBox->currentIndex() < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-09-01 09:06:54 +00:00
|
|
|
Decompiler *dec = getCurrentDecompiler();
|
|
|
|
if (!dec) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dec->isRunning()) {
|
|
|
|
decompilerWasBusy = true;
|
2019-07-15 12:08:44 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
if (addr == RVA_INVALID) {
|
2019-09-06 05:40:20 +00:00
|
|
|
ui->textEdit->setPlainText(tr("Click Refresh to generate Decompiler from current offset."));
|
2017-12-21 14:23:44 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-12-19 17:58:30 +00:00
|
|
|
// Clear all selections since we just refreshed
|
|
|
|
ui->textEdit->setExtraSelections({});
|
2019-09-03 14:25:28 +00:00
|
|
|
decompiledFunctionAddr = Core()->getFunctionStart(addr);
|
2019-08-28 17:01:12 +00:00
|
|
|
dec->decompileAt(addr);
|
|
|
|
if (dec->isRunning()) {
|
|
|
|
ui->progressLabel->setVisible(true);
|
|
|
|
ui->decompilerComboBox->setEnabled(false);
|
2019-09-01 09:06:54 +00:00
|
|
|
updateRefreshButton();
|
2019-08-28 17:01:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::refreshDecompiler()
|
2019-08-28 17:01:12 +00:00
|
|
|
{
|
2019-09-01 09:06:54 +00:00
|
|
|
doRefresh();
|
2019-08-28 17:01:12 +00:00
|
|
|
}
|
|
|
|
|
2019-12-19 17:58:30 +00:00
|
|
|
QTextCursor DecompilerWidget::getCursorForAddress(RVA addr)
|
|
|
|
{
|
|
|
|
size_t pos = code.PositionForOffset(addr);
|
|
|
|
if (pos == SIZE_MAX || pos == 0) {
|
|
|
|
return QTextCursor();
|
|
|
|
}
|
|
|
|
|
|
|
|
QTextCursor cursor = ui->textEdit->textCursor();
|
|
|
|
cursor.setPosition(pos);
|
|
|
|
return cursor;
|
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::decompilationFinished(AnnotatedCode code)
|
2019-08-28 17:01:12 +00:00
|
|
|
{
|
|
|
|
ui->progressLabel->setVisible(false);
|
|
|
|
ui->decompilerComboBox->setEnabled(decompilerSelectionEnabled);
|
2019-09-01 09:06:54 +00:00
|
|
|
updateRefreshButton();
|
2019-08-28 17:01:12 +00:00
|
|
|
|
|
|
|
this->code = code;
|
2019-08-27 15:27:39 +00:00
|
|
|
if (code.code.isEmpty()) {
|
2019-08-28 17:01:12 +00:00
|
|
|
ui->textEdit->setPlainText(tr("Cannot decompile at this address (Not a function?)"));
|
2017-12-15 10:52:47 +00:00
|
|
|
return;
|
2019-07-12 08:57:07 +00:00
|
|
|
} else {
|
|
|
|
connectCursorPositionChanged(true);
|
2019-08-27 15:27:39 +00:00
|
|
|
ui->textEdit->setPlainText(code.code);
|
2019-07-12 08:57:07 +00:00
|
|
|
connectCursorPositionChanged(false);
|
2019-09-01 09:06:54 +00:00
|
|
|
updateCursorPosition();
|
2019-12-19 17:58:30 +00:00
|
|
|
highlightPC();
|
|
|
|
highlightBreakpoints();
|
2019-09-01 09:06:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (decompilerWasBusy) {
|
|
|
|
decompilerWasBusy = false;
|
|
|
|
doAutoRefresh();
|
2017-12-06 23:19:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::decompilerSelected()
|
2019-07-16 18:33:05 +00:00
|
|
|
{
|
2019-08-23 20:06:44 +00:00
|
|
|
Config()->setSelectedDecompiler(ui->decompilerComboBox->currentData().toString());
|
2019-09-01 09:06:54 +00:00
|
|
|
if (autoRefreshEnabled) {
|
|
|
|
doRefresh();
|
|
|
|
}
|
2019-07-16 18:33:05 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::connectCursorPositionChanged(bool disconnect)
|
2019-07-12 08:57:07 +00:00
|
|
|
{
|
|
|
|
if (disconnect) {
|
2019-09-06 05:40:20 +00:00
|
|
|
QObject::disconnect(ui->textEdit, &QPlainTextEdit::cursorPositionChanged, this, &DecompilerWidget::cursorPositionChanged);
|
2019-07-12 08:57:07 +00:00
|
|
|
} else {
|
2019-09-06 05:40:20 +00:00
|
|
|
connect(ui->textEdit, &QPlainTextEdit::cursorPositionChanged, this, &DecompilerWidget::cursorPositionChanged);
|
2019-07-12 08:57:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::cursorPositionChanged()
|
2019-07-12 08:57:07 +00:00
|
|
|
{
|
2019-12-14 10:42:24 +00:00
|
|
|
// Do not perform seeks along with the cursor while selecting multiple lines
|
|
|
|
if (!ui->textEdit->textCursor().selectedText().isEmpty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-27 15:27:39 +00:00
|
|
|
size_t pos = ui->textEdit->textCursor().position();
|
|
|
|
RVA offset = code.OffsetForPosition(pos);
|
2019-07-12 08:57:07 +00:00
|
|
|
if (offset != RVA_INVALID && offset != Core()->getOffset()) {
|
|
|
|
seekFromCursor = true;
|
|
|
|
Core()->seek(offset);
|
2019-08-07 11:38:22 +00:00
|
|
|
mCtxMenu->setOffset(offset);
|
2019-07-12 08:57:07 +00:00
|
|
|
seekFromCursor = false;
|
|
|
|
}
|
|
|
|
updateSelection();
|
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::seekChanged()
|
2019-07-12 08:57:07 +00:00
|
|
|
{
|
|
|
|
if (seekFromCursor) {
|
|
|
|
return;
|
|
|
|
}
|
2019-09-01 09:06:54 +00:00
|
|
|
|
|
|
|
if (autoRefreshEnabled) {
|
|
|
|
auto fcnAddr = Core()->getFunctionStart(Core()->getOffset());
|
|
|
|
if (fcnAddr == RVA_INVALID || fcnAddr != decompiledFunctionAddr) {
|
|
|
|
doRefresh();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-12 08:57:07 +00:00
|
|
|
updateCursorPosition();
|
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::updateCursorPosition()
|
2019-07-12 08:57:07 +00:00
|
|
|
{
|
|
|
|
RVA offset = Core()->getOffset();
|
2019-08-27 15:27:39 +00:00
|
|
|
size_t pos = code.PositionForOffset(offset);
|
|
|
|
if (pos == SIZE_MAX) {
|
|
|
|
return;
|
2019-07-12 08:57:07 +00:00
|
|
|
}
|
2019-10-20 08:58:58 +00:00
|
|
|
mCtxMenu->setOffset(offset);
|
2019-08-27 15:27:39 +00:00
|
|
|
connectCursorPositionChanged(true);
|
|
|
|
QTextCursor cursor = ui->textEdit->textCursor();
|
|
|
|
cursor.setPosition(pos);
|
|
|
|
ui->textEdit->setTextCursor(cursor);
|
|
|
|
updateSelection();
|
2019-07-12 08:57:07 +00:00
|
|
|
connectCursorPositionChanged(false);
|
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::setupFonts()
|
2017-12-06 23:19:14 +00:00
|
|
|
{
|
2019-10-12 05:50:10 +00:00
|
|
|
ui->textEdit->setFont(Config()->getFont());
|
2017-12-06 23:19:14 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::updateSelection()
|
2019-07-12 08:57:07 +00:00
|
|
|
{
|
|
|
|
QList<QTextEdit::ExtraSelection> extraSelections;
|
|
|
|
|
|
|
|
// Highlight the current line
|
|
|
|
auto cursor = ui->textEdit->textCursor();
|
2019-08-27 15:27:39 +00:00
|
|
|
extraSelections.append(createLineHighlightSelection(cursor));
|
2019-07-12 08:57:07 +00:00
|
|
|
|
|
|
|
// Highlight all the words in the document same as the current one
|
|
|
|
cursor.select(QTextCursor::WordUnderCursor);
|
|
|
|
QString searchString = cursor.selectedText();
|
|
|
|
extraSelections.append(createSameWordsSelections(ui->textEdit, searchString));
|
|
|
|
|
|
|
|
ui->textEdit->setExtraSelections(extraSelections);
|
2019-12-19 17:58:30 +00:00
|
|
|
// Highlight PC after updating the selected line
|
|
|
|
highlightPC();
|
2019-08-07 11:38:22 +00:00
|
|
|
mCtxMenu->setCurHighlightedWord(searchString);
|
2019-07-12 08:57:07 +00:00
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
QString DecompilerWidget::getWindowTitle() const
|
2019-06-18 13:02:41 +00:00
|
|
|
{
|
2019-09-06 05:40:20 +00:00
|
|
|
return tr("Decompiler");
|
2019-06-18 13:02:41 +00:00
|
|
|
}
|
|
|
|
|
2019-10-12 05:50:10 +00:00
|
|
|
void DecompilerWidget::fontsUpdatedSlot()
|
2017-12-06 23:19:14 +00:00
|
|
|
{
|
|
|
|
setupFonts();
|
|
|
|
}
|
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::colorsUpdatedSlot()
|
2017-12-06 23:19:14 +00:00
|
|
|
{
|
|
|
|
}
|
2019-08-07 11:38:22 +00:00
|
|
|
|
2019-09-06 05:40:20 +00:00
|
|
|
void DecompilerWidget::showDisasContextMenu(const QPoint &pt)
|
2019-08-07 11:38:22 +00:00
|
|
|
{
|
|
|
|
mCtxMenu->exec(ui->textEdit->mapToGlobal(pt));
|
2019-09-01 09:06:54 +00:00
|
|
|
doRefresh();
|
2019-12-14 12:57:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DecompilerWidget::seekToReference()
|
|
|
|
{
|
|
|
|
size_t pos = ui->textEdit->textCursor().position();
|
|
|
|
RVA offset = code.OffsetForPosition(pos);
|
|
|
|
seekable->seekToReference(offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DecompilerWidget::eventFilter(QObject *obj, QEvent *event)
|
|
|
|
{
|
|
|
|
if (event->type() == QEvent::MouseButtonDblClick
|
|
|
|
&& (obj == ui->textEdit || obj == ui->textEdit->viewport())) {
|
|
|
|
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
|
|
|
|
|
|
|
const QTextCursor& cursor = ui->textEdit->cursorForPosition(QPoint(mouseEvent->x(), mouseEvent->y()));
|
|
|
|
seekToReference();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return MemoryDockWidget::eventFilter(obj, event);
|
|
|
|
}
|
2019-12-19 17:58:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DecompilerWidget::highlightPC()
|
|
|
|
{
|
|
|
|
RVA PCAddress = Core()->getProgramCounterValue();
|
|
|
|
if (PCAddress == RVA_INVALID || (Core()->getFunctionStart(PCAddress) != decompiledFunctionAddr)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QTextCursor cursor = getCursorForAddress(PCAddress);
|
|
|
|
if (!cursor.isNull()) {
|
|
|
|
colorLine(createLineHighlightPC(cursor));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void DecompilerWidget::highlightBreakpoints()
|
|
|
|
{
|
|
|
|
|
|
|
|
QList<RVA> functionBreakpoints = Core()->getBreakpointsInFunction(decompiledFunctionAddr);
|
|
|
|
QTextCursor cursor;
|
|
|
|
foreach(auto &bp, functionBreakpoints) {
|
|
|
|
if (bp == RVA_INVALID) {
|
|
|
|
continue;;
|
|
|
|
}
|
|
|
|
|
|
|
|
cursor = getCursorForAddress(bp);
|
|
|
|
if (!cursor.isNull()) {
|
|
|
|
// Use a Block formatting since these lines are not updated frequently as selections and PC
|
|
|
|
QTextBlockFormat f;
|
|
|
|
f.setBackground(ConfigColor("gui.breakpoint_background"));
|
|
|
|
cursor.setBlockFormat(f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DecompilerWidget::colorLine(QTextEdit::ExtraSelection extraSelection)
|
|
|
|
{
|
|
|
|
QList<QTextEdit::ExtraSelection> extraSelections = ui->textEdit->extraSelections();
|
|
|
|
extraSelections.append(extraSelection);
|
|
|
|
ui->textEdit->setExtraSelections(extraSelections);
|
|
|
|
return true;
|
|
|
|
}
|