mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 19:06:10 +00:00
Rename PseudoCode widget to Decompiler (#1728)
This commit is contained in:
parent
806de0b341
commit
1d692db261
@ -287,7 +287,7 @@ SOURCES += \
|
||||
common/TempConfig.cpp \
|
||||
common/SvgIconEngine.cpp \
|
||||
common/SyntaxHighlighter.cpp \
|
||||
widgets/PseudocodeWidget.cpp \
|
||||
widgets/DecompilerWidget.cpp \
|
||||
widgets/VisualNavbar.cpp \
|
||||
widgets/GraphView.cpp \
|
||||
dialogs/preferences/PreferencesDialog.cpp \
|
||||
@ -415,7 +415,7 @@ HEADERS += \
|
||||
common/TempConfig.h \
|
||||
common/SvgIconEngine.h \
|
||||
common/SyntaxHighlighter.h \
|
||||
widgets/PseudocodeWidget.h \
|
||||
widgets/DecompilerWidget.h \
|
||||
widgets/VisualNavbar.h \
|
||||
widgets/GraphView.h \
|
||||
dialogs/preferences/PreferencesDialog.h \
|
||||
@ -524,7 +524,7 @@ FORMS += \
|
||||
dialogs/preferences/AppearanceOptionsWidget.ui \
|
||||
dialogs/preferences/GraphOptionsWidget.ui \
|
||||
widgets/QuickFilterView.ui \
|
||||
widgets/PseudocodeWidget.ui \
|
||||
widgets/DecompilerWidget.ui \
|
||||
widgets/ClassesWidget.ui \
|
||||
widgets/VTablesWidget.ui \
|
||||
widgets/TypesWidget.ui \
|
||||
|
10
src/Main.cpp
10
src/Main.cpp
@ -35,7 +35,7 @@ static bool migrateSettingsPre18(QSettings &newSettings)
|
||||
return true;
|
||||
}
|
||||
|
||||
#define CUTTER_SETTINGS_VERSION_CURRENT 1
|
||||
#define CUTTER_SETTINGS_VERSION_CURRENT 2
|
||||
#define CUTTER_SETTINGS_VERSION_KEY "version"
|
||||
|
||||
/*
|
||||
@ -52,6 +52,12 @@ static void migrateSettingsTo1(QSettings &settings) {
|
||||
settings.remove("updated_custom_themes"); // now handled by theme_version
|
||||
}
|
||||
|
||||
static void migrateSettingsTo2(QSettings &settings) {
|
||||
QStringList docks = settings.value("docks").toStringList(); // get current list of docks
|
||||
// replace occurences of "PseudocodeWidget" with "DecompilerWidget"
|
||||
settings.setValue("docks", docks.replaceInStrings("PseudocodeWidget", "DecompilerWidget"));
|
||||
}
|
||||
|
||||
static void initializeSettings()
|
||||
{
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
@ -71,6 +77,8 @@ static void initializeSettings()
|
||||
switch (v) {
|
||||
case 1:
|
||||
migrateSettingsTo1(settings); break;
|
||||
case 2:
|
||||
migrateSettingsTo2(settings);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@
|
||||
#include "widgets/RegistersWidget.h"
|
||||
#include "widgets/BacktraceWidget.h"
|
||||
#include "widgets/HexdumpWidget.h"
|
||||
#include "widgets/PseudocodeWidget.h"
|
||||
#include "widgets/DecompilerWidget.h"
|
||||
#include "widgets/HexWidget.h"
|
||||
|
||||
// Qt Headers
|
||||
@ -266,7 +266,7 @@ void MainWindow::initToolBar()
|
||||
void MainWindow::initDocks()
|
||||
{
|
||||
dockWidgets.reserve(20);
|
||||
pseudocodeDock = new PseudocodeWidget(this, ui->actionPseudocode);
|
||||
decompilerDock = new DecompilerWidget(this, ui->actionDecompiler);
|
||||
consoleDock = new ConsoleWidget(this, ui->actionConsole);
|
||||
|
||||
overviewDock = new OverviewWidget(this, ui->actionOverview);
|
||||
@ -780,7 +780,7 @@ void MainWindow::restoreDocks()
|
||||
|
||||
// Function | Dashboard
|
||||
splitDockWidget(functionsDock, dashboardDock, Qt::Horizontal);
|
||||
tabifyDockWidget(dashboardDock, pseudocodeDock);
|
||||
tabifyDockWidget(dashboardDock, decompilerDock);
|
||||
tabifyDockWidget(dashboardDock, entrypointDock);
|
||||
tabifyDockWidget(dashboardDock, flagsDock);
|
||||
tabifyDockWidget(dashboardDock, stringsDock);
|
||||
@ -953,8 +953,8 @@ MemoryDockWidget *MainWindow::addNewMemoryWidget(MemoryWidgetType type, RVA addr
|
||||
case MemoryWidgetType::Disassembly:
|
||||
memoryWidget = new DisassemblyWidget(this);
|
||||
break;
|
||||
case MemoryWidgetType::Pseudocode:
|
||||
memoryWidget = new PseudocodeWidget(this);
|
||||
case MemoryWidgetType::Decompiler:
|
||||
memoryWidget = new DecompilerWidget(this);
|
||||
break;
|
||||
}
|
||||
auto seekable = memoryWidget->getSeekable();
|
||||
|
@ -48,7 +48,7 @@ class QDockWidget;
|
||||
class DisassemblyWidget;
|
||||
class GraphWidget;
|
||||
class HexdumpWidget;
|
||||
class PseudocodeWidget;
|
||||
class DecompilerWidget;
|
||||
class OverviewWidget;
|
||||
|
||||
namespace Ui {
|
||||
@ -221,7 +221,7 @@ private:
|
||||
|
||||
QList<QDockWidget *> dockWidgets;
|
||||
QMultiMap<QAction *, QDockWidget *> dockWidgetsOfAction;
|
||||
PseudocodeWidget *pseudocodeDock = nullptr;
|
||||
DecompilerWidget *decompilerDock = nullptr;
|
||||
OverviewWidget *overviewDock = nullptr;
|
||||
EntrypointWidget *entrypointDock = nullptr;
|
||||
FunctionsWidget *functionsDock = nullptr;
|
||||
|
@ -149,7 +149,7 @@
|
||||
<addaction name="actionDashboard"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionFunctions"/>
|
||||
<addaction name="actionPseudocode"/>
|
||||
<addaction name="actionDecompiler"/>
|
||||
<addaction name="actionOverview"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSearch"/>
|
||||
@ -838,7 +838,7 @@
|
||||
<string>Show ESIL rather than assembly</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDisplay_Pseudocode">
|
||||
<action name="actionDisplay_Decompiler">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -896,12 +896,12 @@
|
||||
<string>Graph Overview</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPseudocode">
|
||||
<action name="actionDecompiler">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Pseudocode</string>
|
||||
<string>Decompiler</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionConsole">
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "PseudocodeWidget.h"
|
||||
#include "ui_PseudocodeWidget.h"
|
||||
#include "DecompilerWidget.h"
|
||||
#include "ui_DecompilerWidget.h"
|
||||
#include "menus/DisassemblyContextMenu.h"
|
||||
|
||||
#include "common/Configuration.h"
|
||||
@ -14,10 +14,10 @@
|
||||
#include <QObject>
|
||||
#include <QTextBlockUserData>
|
||||
|
||||
PseudocodeWidget::PseudocodeWidget(MainWindow *main, QAction *action) :
|
||||
MemoryDockWidget(MemoryWidgetType::Pseudocode, main, action),
|
||||
DecompilerWidget::DecompilerWidget(MainWindow *main, QAction *action) :
|
||||
MemoryDockWidget(MemoryWidgetType::Decompiler, main, action),
|
||||
mCtxMenu(new DisassemblyContextMenu(this, main)),
|
||||
ui(new Ui::PseudocodeWidget)
|
||||
ui(new Ui::DecompilerWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@ -56,7 +56,7 @@ PseudocodeWidget::PseudocodeWidget(MainWindow *main, QAction *action) :
|
||||
if (dec->getId() == selectedDecompilerId) {
|
||||
ui->decompilerComboBox->setCurrentIndex(ui->decompilerComboBox->count() - 1);
|
||||
}
|
||||
connect(dec, &Decompiler::finished, this, &PseudocodeWidget::decompilationFinished);
|
||||
connect(dec, &Decompiler::finished, this, &DecompilerWidget::decompilationFinished);
|
||||
}
|
||||
|
||||
decompilerSelectionEnabled = decompilers.size() > 1;
|
||||
@ -66,44 +66,44 @@ PseudocodeWidget::PseudocodeWidget(MainWindow *main, QAction *action) :
|
||||
ui->textEdit->setPlainText(tr("No Decompiler available."));
|
||||
}
|
||||
|
||||
connect(ui->decompilerComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &PseudocodeWidget::decompilerSelected);
|
||||
connect(ui->decompilerComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &DecompilerWidget::decompilerSelected);
|
||||
connectCursorPositionChanged(false);
|
||||
connect(Core(), &CutterCore::seekChanged, this, &PseudocodeWidget::seekChanged);
|
||||
connect(Core(), &CutterCore::seekChanged, this, &DecompilerWidget::seekChanged);
|
||||
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
|
||||
connect(mCtxMenu, &QMenu::triggered, this, &PseudocodeWidget::refreshPseudocode);
|
||||
connect(mCtxMenu, &QMenu::triggered, this, &DecompilerWidget::refreshDecompiler);
|
||||
addActions(mCtxMenu->actions());
|
||||
|
||||
ui->progressLabel->setVisible(false);
|
||||
doRefresh(RVA_INVALID);
|
||||
|
||||
connect(Core(), &CutterCore::refreshAll, this, &PseudocodeWidget::doAutoRefresh);
|
||||
connect(Core(), &CutterCore::functionRenamed, this, &PseudocodeWidget::doAutoRefresh);
|
||||
connect(Core(), &CutterCore::varsChanged, this, &PseudocodeWidget::doAutoRefresh);
|
||||
connect(Core(), &CutterCore::functionsChanged, this, &PseudocodeWidget::doAutoRefresh);
|
||||
connect(Core(), &CutterCore::flagsChanged, this, &PseudocodeWidget::doAutoRefresh);
|
||||
connect(Core(), &CutterCore::commentsChanged, this, &PseudocodeWidget::doAutoRefresh);
|
||||
connect(Core(), &CutterCore::instructionChanged, this, &PseudocodeWidget::doAutoRefresh);
|
||||
connect(Core(), &CutterCore::refreshCodeViews, this, &PseudocodeWidget::doAutoRefresh);
|
||||
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);
|
||||
}
|
||||
|
||||
PseudocodeWidget::~PseudocodeWidget() = default;
|
||||
DecompilerWidget::~DecompilerWidget() = default;
|
||||
|
||||
Decompiler *PseudocodeWidget::getCurrentDecompiler()
|
||||
Decompiler *DecompilerWidget::getCurrentDecompiler()
|
||||
{
|
||||
return Core()->getDecompilerById(ui->decompilerComboBox->currentData().toString());
|
||||
}
|
||||
|
||||
void PseudocodeWidget::setAutoRefresh(bool enabled)
|
||||
void DecompilerWidget::setAutoRefresh(bool enabled)
|
||||
{
|
||||
autoRefreshEnabled = enabled;
|
||||
updateRefreshButton();
|
||||
}
|
||||
|
||||
void PseudocodeWidget::doAutoRefresh()
|
||||
void DecompilerWidget::doAutoRefresh()
|
||||
{
|
||||
if (!autoRefreshEnabled) {
|
||||
return;
|
||||
@ -111,7 +111,7 @@ void PseudocodeWidget::doAutoRefresh()
|
||||
doRefresh();
|
||||
}
|
||||
|
||||
void PseudocodeWidget::updateRefreshButton()
|
||||
void DecompilerWidget::updateRefreshButton()
|
||||
{
|
||||
Decompiler *dec = getCurrentDecompiler();
|
||||
ui->refreshButton->setEnabled(!autoRefreshEnabled && dec && !dec->isRunning());
|
||||
@ -122,7 +122,7 @@ void PseudocodeWidget::updateRefreshButton()
|
||||
}
|
||||
}
|
||||
|
||||
void PseudocodeWidget::doRefresh(RVA addr)
|
||||
void DecompilerWidget::doRefresh(RVA addr)
|
||||
{
|
||||
if (!refreshDeferrer->attemptRefresh(nullptr)) {
|
||||
return;
|
||||
@ -143,7 +143,7 @@ void PseudocodeWidget::doRefresh(RVA addr)
|
||||
}
|
||||
|
||||
if (addr == RVA_INVALID) {
|
||||
ui->textEdit->setPlainText(tr("Click Refresh to generate Pseudocode from current offset."));
|
||||
ui->textEdit->setPlainText(tr("Click Refresh to generate Decompiler from current offset."));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -157,12 +157,12 @@ void PseudocodeWidget::doRefresh(RVA addr)
|
||||
}
|
||||
}
|
||||
|
||||
void PseudocodeWidget::refreshPseudocode()
|
||||
void DecompilerWidget::refreshDecompiler()
|
||||
{
|
||||
doRefresh();
|
||||
}
|
||||
|
||||
void PseudocodeWidget::decompilationFinished(AnnotatedCode code)
|
||||
void DecompilerWidget::decompilationFinished(AnnotatedCode code)
|
||||
{
|
||||
ui->progressLabel->setVisible(false);
|
||||
ui->decompilerComboBox->setEnabled(decompilerSelectionEnabled);
|
||||
@ -185,7 +185,7 @@ void PseudocodeWidget::decompilationFinished(AnnotatedCode code)
|
||||
}
|
||||
}
|
||||
|
||||
void PseudocodeWidget::decompilerSelected()
|
||||
void DecompilerWidget::decompilerSelected()
|
||||
{
|
||||
Config()->setSelectedDecompiler(ui->decompilerComboBox->currentData().toString());
|
||||
if (autoRefreshEnabled) {
|
||||
@ -193,16 +193,16 @@ void PseudocodeWidget::decompilerSelected()
|
||||
}
|
||||
}
|
||||
|
||||
void PseudocodeWidget::connectCursorPositionChanged(bool disconnect)
|
||||
void DecompilerWidget::connectCursorPositionChanged(bool disconnect)
|
||||
{
|
||||
if (disconnect) {
|
||||
QObject::disconnect(ui->textEdit, &QPlainTextEdit::cursorPositionChanged, this, &PseudocodeWidget::cursorPositionChanged);
|
||||
QObject::disconnect(ui->textEdit, &QPlainTextEdit::cursorPositionChanged, this, &DecompilerWidget::cursorPositionChanged);
|
||||
} else {
|
||||
connect(ui->textEdit, &QPlainTextEdit::cursorPositionChanged, this, &PseudocodeWidget::cursorPositionChanged);
|
||||
connect(ui->textEdit, &QPlainTextEdit::cursorPositionChanged, this, &DecompilerWidget::cursorPositionChanged);
|
||||
}
|
||||
}
|
||||
|
||||
void PseudocodeWidget::cursorPositionChanged()
|
||||
void DecompilerWidget::cursorPositionChanged()
|
||||
{
|
||||
size_t pos = ui->textEdit->textCursor().position();
|
||||
RVA offset = code.OffsetForPosition(pos);
|
||||
@ -215,7 +215,7 @@ void PseudocodeWidget::cursorPositionChanged()
|
||||
updateSelection();
|
||||
}
|
||||
|
||||
void PseudocodeWidget::seekChanged()
|
||||
void DecompilerWidget::seekChanged()
|
||||
{
|
||||
if (seekFromCursor) {
|
||||
return;
|
||||
@ -232,7 +232,7 @@ void PseudocodeWidget::seekChanged()
|
||||
updateCursorPosition();
|
||||
}
|
||||
|
||||
void PseudocodeWidget::updateCursorPosition()
|
||||
void DecompilerWidget::updateCursorPosition()
|
||||
{
|
||||
RVA offset = Core()->getOffset();
|
||||
size_t pos = code.PositionForOffset(offset);
|
||||
@ -247,13 +247,13 @@ void PseudocodeWidget::updateCursorPosition()
|
||||
connectCursorPositionChanged(false);
|
||||
}
|
||||
|
||||
void PseudocodeWidget::setupFonts()
|
||||
void DecompilerWidget::setupFonts()
|
||||
{
|
||||
QFont font = Config()->getFont();
|
||||
ui->textEdit->setFont(font);
|
||||
}
|
||||
|
||||
void PseudocodeWidget::updateSelection()
|
||||
void DecompilerWidget::updateSelection()
|
||||
{
|
||||
QList<QTextEdit::ExtraSelection> extraSelections;
|
||||
|
||||
@ -270,21 +270,21 @@ void PseudocodeWidget::updateSelection()
|
||||
mCtxMenu->setCurHighlightedWord(searchString);
|
||||
}
|
||||
|
||||
QString PseudocodeWidget::getWindowTitle() const
|
||||
QString DecompilerWidget::getWindowTitle() const
|
||||
{
|
||||
return tr("Pseudocode");
|
||||
return tr("Decompiler");
|
||||
}
|
||||
|
||||
void PseudocodeWidget::fontsUpdated()
|
||||
void DecompilerWidget::fontsUpdated()
|
||||
{
|
||||
setupFonts();
|
||||
}
|
||||
|
||||
void PseudocodeWidget::colorsUpdatedSlot()
|
||||
void DecompilerWidget::colorsUpdatedSlot()
|
||||
{
|
||||
}
|
||||
|
||||
void PseudocodeWidget::showDisasContextMenu(const QPoint &pt)
|
||||
void DecompilerWidget::showDisasContextMenu(const QPoint &pt)
|
||||
{
|
||||
mCtxMenu->exec(ui->textEdit->mapToGlobal(pt));
|
||||
doRefresh();
|
@ -1,5 +1,5 @@
|
||||
#ifndef PSEUDOCODEWIDGET_H
|
||||
#define PSEUDOCODEWIDGET_H
|
||||
#ifndef DECOMPILERWIDGET_H
|
||||
#define DECOMPILERWIDGET_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
#include "Decompiler.h"
|
||||
|
||||
namespace Ui {
|
||||
class PseudocodeWidget;
|
||||
class DecompilerWidget;
|
||||
}
|
||||
|
||||
class QTextEdit;
|
||||
@ -17,29 +17,29 @@ class QTextCursor;
|
||||
class DisassemblyContextMenu;
|
||||
struct DecompiledCodeTextLine;
|
||||
|
||||
class PseudocodeWidget : public MemoryDockWidget
|
||||
class DecompilerWidget : public MemoryDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
DisassemblyContextMenu *mCtxMenu;
|
||||
|
||||
public:
|
||||
explicit PseudocodeWidget(MainWindow *main, QAction *action = nullptr);
|
||||
~PseudocodeWidget();
|
||||
explicit DecompilerWidget(MainWindow *main, QAction *action = nullptr);
|
||||
~DecompilerWidget();
|
||||
public slots:
|
||||
void showDisasContextMenu(const QPoint &pt);
|
||||
|
||||
private slots:
|
||||
void fontsUpdated();
|
||||
void colorsUpdatedSlot();
|
||||
void refreshPseudocode();
|
||||
void refreshDecompiler();
|
||||
void decompilerSelected();
|
||||
void cursorPositionChanged();
|
||||
void seekChanged();
|
||||
void decompilationFinished(AnnotatedCode code);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::PseudocodeWidget> ui;
|
||||
std::unique_ptr<Ui::DecompilerWidget> ui;
|
||||
|
||||
RefreshDeferrer *refreshDeferrer;
|
||||
|
||||
@ -72,4 +72,4 @@ private:
|
||||
QString getWindowTitle() const override;
|
||||
};
|
||||
|
||||
#endif // PSEUDOCODEWIDGET_H
|
||||
#endif // DECOMPILERWIDGET_H
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PseudocodeWidget</class>
|
||||
<widget class="QDockWidget" name="PseudocodeWidget">
|
||||
<class>DecompilerWidget</class>
|
||||
<widget class="QDockWidget" name="DecompilerWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Pseudocode</string>
|
||||
<string>Decompiler</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
@ -6,8 +6,8 @@
|
||||
|
||||
class CutterSeekable;
|
||||
|
||||
/* Disassembly/Graph/Hexdump/Pseudocode view priority */
|
||||
enum class MemoryWidgetType { Disassembly, Graph, Hexdump, Pseudocode };
|
||||
/* Disassembly/Graph/Hexdump/Decompiler view priority */
|
||||
enum class MemoryWidgetType { Disassembly, Graph, Hexdump, Decompiler };
|
||||
|
||||
class MemoryDockWidget : public CutterDockWidget
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user