diff --git a/docs/source/user-docs/menus/disassembly-context-menu.rst b/docs/source/user-docs/menus/disassembly-context-menu.rst index 5f114f68..15ced58d 100644 --- a/docs/source/user-docs/menus/disassembly-context-menu.rst +++ b/docs/source/user-docs/menus/disassembly-context-menu.rst @@ -103,15 +103,6 @@ Set Structure Offset **Steps:** -> Structure offset -Link a Type to Address ----------------------------------------- -**Description:** You can link type, enum or structure to a specific address. Types, structures and enums can be defined in the Types widget. - -**Steps:** Right-click on an instruction and choose ``Link Type to Address``. - -**Shortcut:** :kbd:`L` - - Show Cross References ---------------------------------------- **Description:** Show X-Refs from and to the specific location. This option will open Cutter's X-Refs dialog in which you will be able to see a list of X-Refs from and to the selected location, in addition to a preview of each cross-reference to quickly inspect the different usages. diff --git a/docs/source/user-docs/shortcuts.rst b/docs/source/user-docs/shortcuts.rst index 9f95a185..68c2dc2b 100644 --- a/docs/source/user-docs/shortcuts.rst +++ b/docs/source/user-docs/shortcuts.rst @@ -62,8 +62,6 @@ Disassembly View Shortcuts +-------------+----------------------------------+ | Y | Edit/rename local variables | +-------------+----------------------------------+ -| L | Link a type/struct to address | -+-------------+----------------------------------+ | A | Set current address to String | +-------------+----------------------------------+ | C | Set current address to Code | diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8cead25..651af4bb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -109,7 +109,6 @@ set(SOURCES plugins/PluginManager.cpp common/BasicBlockHighlighter.cpp common/BasicInstructionHighlighter.cpp - dialogs/LinkTypeDialog.cpp widgets/ColorPicker.cpp common/ColorThemeWorker.cpp widgets/ColorThemeComboBox.cpp @@ -271,7 +270,6 @@ set(HEADER_FILES widgets/MemoryDockWidget.h widgets/ColorThemeListView.h dialogs/preferences/ColorThemeEditDialog.h - dialogs/LinkTypeDialog.h common/BugReporting.h common/HighDpiPixmap.h widgets/GraphLayout.h @@ -365,7 +363,6 @@ set(UI_FILES dialogs/EditMethodDialog.ui dialogs/TypesInteractionDialog.ui widgets/SdbWidget.ui - dialogs/LinkTypeDialog.ui widgets/ColorPicker.ui dialogs/preferences/ColorThemeEditDialog.ui widgets/ListDockWidget.ui diff --git a/src/dialogs/LinkTypeDialog.cpp b/src/dialogs/LinkTypeDialog.cpp deleted file mode 100644 index 6d2a9110..00000000 --- a/src/dialogs/LinkTypeDialog.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include "LinkTypeDialog.h" -#include "ui_LinkTypeDialog.h" - -LinkTypeDialog::LinkTypeDialog(QWidget *parent) : QDialog(parent), ui(new Ui::LinkTypeDialog) -{ - addrValid = false; - - ui->setupUi(this); - - setWindowTitle(tr("Link type to address")); - - // Populate the structureTypeComboBox - ui->structureTypeComboBox->addItem(tr("(No Type)")); - for (const TypeDescription &thisType : Core()->getAllStructs()) { - ui->structureTypeComboBox->addItem(thisType.type); - } -} - -LinkTypeDialog::~LinkTypeDialog() -{ - delete ui; -} - -void LinkTypeDialog::setDefaultType(const QString &type) -{ - int index = ui->structureTypeComboBox->findText(type); - if (index != -1) { - // index is valid so set is as the default - ui->structureTypeComboBox->setCurrentIndex(index); - } -} - -bool LinkTypeDialog::setDefaultAddress(const QString &address) -{ - // setting the text here will trigger on_exprLineEdit_textChanged, which will update addrValid - ui->exprLineEdit->setText(address); - - if (!addrValid) { - return false; - } - - // check if the current address is already linked to a type and set it as default - QString type = findLinkedType(Core()->math(ui->addressLineEdit->text())); - if (!type.isEmpty()) { - setDefaultType(type); - } - return true; -} - -void LinkTypeDialog::done(int r) -{ - if (r == QDialog::Accepted) { - QString address = ui->addressLineEdit->text(); - if (Core()->isAddressMapped(Core()->math(address))) { - // Address is valid so link the type to the address - QString type = ui->structureTypeComboBox->currentText(); - if (type == tr("(No Type)")) { - // Delete link - RzCoreLocked core(Core()); - ut64 addr = rz_num_math(core->num, address.toUtf8().constData()); - rz_analysis_type_unlink(core->analysis, addr); - } else { - // Create link - RzCoreLocked core(Core()); - ut64 addr = rz_num_math(core->num, address.toUtf8().constData()); - rz_core_types_link(core, type.toUtf8().constData(), addr); - } - QDialog::done(r); - - // Seek to the specified address - Core()->seekAndShow(address); - - // Refresh the views - emit Core()->refreshCodeViews(); - return; - } - - // Address is invalid so display error message - QMessageBox::warning(this, tr("Error"), tr("The given address is invalid")); - } else { - QDialog::done(r); - } -} - -QString LinkTypeDialog::findLinkedType(RVA address) -{ - if (address == RVA_INVALID) { - return QString(); - } - - RzCoreLocked core(Core()); - RzType *link = rz_analysis_type_link_at(core->analysis, address); - if (!link) { - return QString(); - } - RzBaseType *base = rz_type_get_base_type(core->analysis->typedb, link); - if (!base) { - return QString(); - } - - return QString(base->name); -} - -void LinkTypeDialog::on_exprLineEdit_textChanged(const QString &text) -{ - RVA addr = Core()->math(text); - if (Core()->isAddressMapped(addr)) { - ui->addressLineEdit->setText(RzAddressString(addr)); - addrValid = true; - } else { - ui->addressLineEdit->setText(tr("Invalid Address")); - addrValid = false; - } -} diff --git a/src/dialogs/LinkTypeDialog.h b/src/dialogs/LinkTypeDialog.h deleted file mode 100644 index 4f914805..00000000 --- a/src/dialogs/LinkTypeDialog.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef LINKTYPEDIALOG_H -#define LINKTYPEDIALOG_H - -#include "core/Cutter.h" -#include - -namespace Ui { -class LinkTypeDialog; -} - -class LinkTypeDialog : public QDialog -{ - Q_OBJECT - -public: - explicit LinkTypeDialog(QWidget *parent = nullptr); - ~LinkTypeDialog(); - - /** - * @brief Sets the default type which will be displayed in the combo box - * @param type Default type to be used as default type - */ - void setDefaultType(const QString &type); - - /** - * @brief Sets the value of the default address which will be displayed - * If the given address is linked to a type, then it also sets the default - * type to the currently linked type - * @param address The address to be used as default address - * @return true iff the given address string was valid - */ - bool setDefaultAddress(const QString &address); - -private slots: - - /** - * @brief Overrides the done() method of QDialog - * On clicking the Ok button, it links a valid address to a type. - * If "(No Type)" is selected as type, it removes the link. - * In case of an invalid address, it displays error message - * @param r The value which will be returned by exec() - */ - void done(int r) override; - - /** - * @brief Executed whenever the text inside exprLineEdit changes - * If expression evaluates to valid address, it is displayed in addressLineEdit - * Otherwise "Invalid Address" is shown in addressLineEdit - * @param text The current value of exprLineEdit - */ - void on_exprLineEdit_textChanged(const QString &text); - -private: - Ui::LinkTypeDialog *ui; - - bool addrValid; - - /** - * @brief Used for finding the type which is linked to the given address - * @param address - * @return The type linked to "address" if it exists, or empty string otherwise - */ - QString findLinkedType(RVA address); -}; - -#endif // LINKTYPEDIALOG_H diff --git a/src/dialogs/LinkTypeDialog.ui b/src/dialogs/LinkTypeDialog.ui deleted file mode 100644 index 172cc6e9..00000000 --- a/src/dialogs/LinkTypeDialog.ui +++ /dev/null @@ -1,117 +0,0 @@ - - - LinkTypeDialog - - - - 0 - 0 - 500 - 105 - - - - - 500 - 0 - - - - Dialog - - - - - - = - - - - - - - true - - - true - - - - - - - Enter Address - - - - - - - Structure Type - - - structureTypeComboBox - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - Address/Flag - - - exprLineEdit - - - - - - - - - buttonBox - accepted() - LinkTypeDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - LinkTypeDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/menus/DisassemblyContextMenu.cpp b/src/menus/DisassemblyContextMenu.cpp index 57c63537..1cc290b7 100644 --- a/src/menus/DisassemblyContextMenu.cpp +++ b/src/menus/DisassemblyContextMenu.cpp @@ -7,7 +7,6 @@ #include "dialogs/EditVariablesDialog.h" #include "dialogs/SetToDataDialog.h" #include "dialogs/EditFunctionDialog.h" -#include "dialogs/LinkTypeDialog.h" #include "dialogs/EditStringDialog.h" #include "dialogs/BreakpointsDialog.h" #include "MainWindow.h" @@ -42,7 +41,6 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent, MainWindow *main actionDeleteComment(this), actionDeleteFlag(this), actionDeleteFunction(this), - actionLinkType(this), actionSetBaseBinary(this), actionSetBaseOctal(this), actionSetBaseDecimal(this), @@ -122,10 +120,6 @@ DisassemblyContextMenu::DisassemblyContextMenu(QWidget *parent, MainWindow *main connect(structureOffsetMenu, &QMenu::triggered, this, &DisassemblyContextMenu::on_actionStructureOffsetMenu_triggered); - initAction(&actionLinkType, tr("Link Type to Address"), SLOT(on_actionLinkType_triggered()), - getLinkTypeSequence()); - addAction(&actionLinkType); - addSetAsMenu(); addSeparator(); @@ -667,11 +661,6 @@ QKeySequence DisassemblyContextMenu::getDisplayOptionsSequence() const return {}; // TODO insert correct sequence } -QKeySequence DisassemblyContextMenu::getLinkTypeSequence() const -{ - return { Qt::Key_L }; -} - QList DisassemblyContextMenu::getAddBPSequence() const { return { Qt::Key_F2, Qt::CTRL | Qt::Key_B }; @@ -986,15 +975,6 @@ void DisassemblyContextMenu::on_actionStructureOffsetMenu_triggered(QAction *act Core()->applyStructureOffset(action->data().toString(), offset); } -void DisassemblyContextMenu::on_actionLinkType_triggered() -{ - LinkTypeDialog dialog(mainWindow); - if (!dialog.setDefaultAddress(curHighlightedWord)) { - dialog.setDefaultAddress(RzAddressString(offset)); - } - dialog.exec(); -} - void DisassemblyContextMenu::on_actionDeleteComment_triggered() { Core()->delComment(offset); diff --git a/src/menus/DisassemblyContextMenu.h b/src/menus/DisassemblyContextMenu.h index fe2f40a1..158b1ec7 100644 --- a/src/menus/DisassemblyContextMenu.h +++ b/src/menus/DisassemblyContextMenu.h @@ -74,13 +74,6 @@ private slots: */ void on_actionStructureOffsetMenu_triggered(QAction *action); - /** - * @brief Executed on selecting the "Link Type to Address" option - * Opens the LinkTypeDialog box from where the user can link the address - * to a type - */ - void on_actionLinkType_triggered(); - private: QKeySequence getCopySequence() const; QKeySequence getCommentSequence() const; @@ -99,11 +92,6 @@ private: QKeySequence getEditFunctionSequence() const; QList getAddBPSequence() const; - /** - * @return the shortcut key for "Link Type to Address" option - */ - QKeySequence getLinkTypeSequence() const; - RVA offset; bool canCopy; QString curHighlightedWord; // The current highlighted word @@ -137,8 +125,6 @@ private: QMenu *structureOffsetMenu; - QAction actionLinkType; - QMenu *setBaseMenu; QAction actionSetBaseBinary; QAction actionSetBaseOctal; diff --git a/src/widgets/TypesWidget.cpp b/src/widgets/TypesWidget.cpp index c2e069a6..8e7a0e6e 100644 --- a/src/widgets/TypesWidget.cpp +++ b/src/widgets/TypesWidget.cpp @@ -3,7 +3,6 @@ #include "core/MainWindow.h" #include "common/Helpers.h" #include "dialogs/TypesInteractionDialog.h" -#include "dialogs/LinkTypeDialog.h" #include #include @@ -242,9 +241,6 @@ void TypesWidget::showTypesContextMenu(const QPoint &pt) // Add "Link To Address" option menu.addAction(actionViewType); menu.addAction(actionEditType); - if (t.category == "Struct") { - menu.addAction(ui->actionLink_Type_To_Address); - } } } @@ -338,19 +334,6 @@ void TypesWidget::on_actionDelete_Type_triggered() } } -void TypesWidget::on_actionLink_Type_To_Address_triggered() -{ - LinkTypeDialog dialog(this); - - QModelIndex index = ui->typesTreeView->currentIndex(); - if (index.isValid()) { - TypeDescription t = index.data(TypesModel::TypeDescriptionRole).value(); - dialog.setDefaultType(t.type); - dialog.setDefaultAddress(RzAddressString(Core()->getOffset())); - dialog.exec(); - } -} - void TypesWidget::typeItemDoubleClicked(const QModelIndex &index) { if (!index.isValid()) { diff --git a/src/widgets/TypesWidget.h b/src/widgets/TypesWidget.h index e567a146..dec3ece5 100644 --- a/src/widgets/TypesWidget.h +++ b/src/widgets/TypesWidget.h @@ -105,12 +105,6 @@ private slots: */ void on_actionDelete_Type_triggered(); - /** - * @brief Executed on clicking the Link To Address option in the context menu - * Opens the LinkTypeDialog box from where the user can link a address to a type - */ - void on_actionLink_Type_To_Address_triggered(); - /** * @brief triggers when the user double-clicks an item. This will open * a dialog that shows the Type's content diff --git a/src/widgets/TypesWidget.ui b/src/widgets/TypesWidget.ui index c86b6225..171b8f52 100644 --- a/src/widgets/TypesWidget.ui +++ b/src/widgets/TypesWidget.ui @@ -95,11 +95,6 @@ Delete Type - - - Link Type to Address - -