Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions include/IPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ class IPlugin {
public:
virtual QMenu *menu(QWidget *parent = nullptr) = 0;

public:
// optional, overload this to provide actions that are available by global shortcuts
virtual QList<QAction *> globalShortcuts() { return {}; }

public:
// optional, overload these to have there contents added to a view's context menu
virtual QList<QAction *> cpuContextMenu() { return {}; }
virtual QList<QAction *> registerContextMenu() { return {}; }
virtual QList<QAction *> stackContextMenu() { return {}; }
virtual QList<QAction *> dataContextMenu() { return {}; }
virtual QList<QAction *> cpuContextMenu(QMenu */*parent*/) { return {}; }
virtual QList<QAction *> registerContextMenu(QMenu */*parent*/) { return {}; }
virtual QList<QAction *> stackContextMenu(QMenu */*parent*/) { return {}; }
virtual QList<QAction *> dataContextMenu(QMenu */*parent*/) { return {}; }

// optional, overload this to add a page to the options dialog
virtual QWidget *optionsPage() { return nullptr; }
Expand Down
12 changes: 6 additions & 6 deletions plugins/Analyzer/Analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,15 @@ void Analyzer::gotoFunctionEnd() {
* @brief Analyzer::cpuContextMenu
* @return
*/
QList<QAction *> Analyzer::cpuContextMenu() {
QList<QAction *> Analyzer::cpuContextMenu(QMenu *parent) {

QList<QAction *> ret;

auto action_find = new QAction(tr("Analyze Here"), this);
auto action_goto_function_start = new QAction(tr("Goto Function Start"), this);
auto action_goto_function_end = new QAction(tr("Goto Function End"), this);
auto action_mark_function_start = new QAction(tr("Mark As Function Start"), this);
auto action_xrefs = new QAction(tr("Show X-Refs"), this);
auto action_find = new QAction(tr("Analyze Here"), parent);
auto action_goto_function_start = new QAction(tr("Goto Function Start"), parent);
auto action_goto_function_end = new QAction(tr("Goto Function End"), parent);
auto action_mark_function_start = new QAction(tr("Mark As Function Start"), parent);
auto action_xrefs = new QAction(tr("Show X-Refs"), parent);

connect(action_find, &QAction::triggered, this, &Analyzer::doViewAnalysis);
connect(action_goto_function_start, &QAction::triggered, this, &Analyzer::gotoFunctionStart);
Expand Down
2 changes: 1 addition & 1 deletion plugins/Analyzer/Analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Analyzer final : public QObject, public IAnalyzer, public IPlugin {

public:
QMenu *menu(QWidget *parent = nullptr) override;
QList<QAction *> cpuContextMenu() override;
QList<QAction *> cpuContextMenu(QMenu *parent) override;

private:
void privateInit() override;
Expand Down
24 changes: 16 additions & 8 deletions plugins/Assembler/Assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ namespace AssemblerPlugin {
* @param parent
*/
Assembler::Assembler(QObject *parent)
: QObject(parent) {
: QObject(parent),
action_assemble_(tr("&Assemble..."), this) {
action_assemble_.setShortcut(QKeySequence(tr("Space")));
connect(&action_assemble_, &QAction::triggered, this, &Assembler::showDialog);
}

/**
Expand All @@ -44,19 +47,24 @@ Assembler::~Assembler() {
}

/**
* @brief Assembler::cpuContextMenu
* @brief Assembler::globalShortcuts
* @return
*/
QList<QAction *> Assembler::cpuContextMenu() {
QList<QAction *> Assembler::globalShortcuts() {

QList<QAction *> ret;
ret << &action_assemble_;
return ret;
}

auto action_assemble = new QAction(tr("&Assemble..."), this);
action_assemble->setShortcut(QKeySequence(tr("Space")));

connect(action_assemble, &QAction::triggered, this, &Assembler::showDialog);
ret << action_assemble;
/**
* @brief Assembler::cpuContextMenu
* @return
*/
QList<QAction *> Assembler::cpuContextMenu(QMenu *parent) {

QList<QAction *> ret;
ret << &action_assemble_;
return ret;
}

Expand Down
5 changes: 4 additions & 1 deletion plugins/Assembler/Assembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define ASSEMBLER_H_20130611_

#include "IPlugin.h"
#include <QAction>

class QMenu;
class QDialog;
Expand All @@ -39,14 +40,16 @@ class Assembler : public QObject, public IPlugin {

public:
QMenu *menu(QWidget *parent = nullptr) override;
QList<QAction *> cpuContextMenu() override;
QList<QAction *> globalShortcuts() override;
QList<QAction *> cpuContextMenu(QMenu *parent) override;
QWidget *optionsPage() override;

private:
void showDialog();

private:
QPointer<QDialog> dialog_ = nullptr;
QAction action_assemble_;
};

}
Expand Down
4 changes: 2 additions & 2 deletions plugins/BinarySearcher/BinarySearcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ QMenu *BinarySearcher::menu(QWidget *parent) {
* @brief BinarySearcher::stackContextMenu
* @return
*/
QList<QAction *> BinarySearcher::stackContextMenu() {
QList<QAction *> BinarySearcher::stackContextMenu(QMenu *parent) {

QList<QAction *> ret;

auto action_find = new QAction(tr("&Find ASCII String"), this);
auto action_find = new QAction(tr("&Find ASCII String"), parent);
connect(action_find, &QAction::triggered, this, &BinarySearcher::mnuStackFindAscii);
ret << action_find;

Expand Down
2 changes: 1 addition & 1 deletion plugins/BinarySearcher/BinarySearcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class BinarySearcher : public QObject, public IPlugin {

public:
QMenu *menu(QWidget *parent = nullptr) override;
QList<QAction *> stackContextMenu() override;
QList<QAction *> stackContextMenu(QMenu *parent) override;

public Q_SLOTS:
void showMenu();
Expand Down
4 changes: 2 additions & 2 deletions plugins/Bookmarks/Bookmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ QMenu *Bookmarks::menu(QWidget *parent) {
* @brief Bookmarks::cpuContextMenu
* @return
*/
QList<QAction *> Bookmarks::cpuContextMenu() {
QList<QAction *> Bookmarks::cpuContextMenu(QMenu *parent) {

QList<QAction *> ret;

auto action_bookmark = new QAction(tr("Add &Bookmark"), this);
auto action_bookmark = new QAction(tr("Add &Bookmark"), parent);
connect(action_bookmark, &QAction::triggered, this, &Bookmarks::addBookmarkMenu);
ret << action_bookmark;

Expand Down
2 changes: 1 addition & 1 deletion plugins/Bookmarks/Bookmarks.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Bookmarks : public QObject, public IPlugin {

public:
QMenu *menu(QWidget *parent = nullptr) override;
QList<QAction *> cpuContextMenu() override;
QList<QAction *> cpuContextMenu(QMenu *parent) override;

public:
QVariantMap saveState() const override;
Expand Down
18 changes: 9 additions & 9 deletions plugins/HardwareBreakpoints/HardwareBreakpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ edb::EventStatus HardwareBreakpoints::handleEvent(const std::shared_ptr<IDebugEv
* @brief HardwareBreakpoints::stackContextMenu
* @return
*/
QList<QAction *> HardwareBreakpoints::stackContextMenu() {
auto menu = new QMenu(tr("Hardware Breakpoints"));
QList<QAction *> HardwareBreakpoints::stackContextMenu(QMenu *parent) {
auto menu = new QMenu(tr("Hardware Breakpoints"), parent);

auto rw1 = menu->addAction(tr("Hardware, On Read/Write #1"), this, SLOT(setAccess1()));
auto rw2 = menu->addAction(tr("Hardware, On Read/Write #2"), this, SLOT(setAccess2()));
Expand All @@ -274,7 +274,7 @@ QList<QAction *> HardwareBreakpoints::stackContextMenu() {

QList<QAction *> ret;

auto action = new QAction(tr("Hardware Breakpoints"), this);
auto action = new QAction(tr("Hardware Breakpoints"), parent);
action->setMenu(menu);
ret << action;
return ret;
Expand All @@ -284,8 +284,8 @@ QList<QAction *> HardwareBreakpoints::stackContextMenu() {
* @brief HardwareBreakpoints::dataContextMenu
* @return
*/
QList<QAction *> HardwareBreakpoints::dataContextMenu() {
auto menu = new QMenu(tr("Hardware Breakpoints"));
QList<QAction *> HardwareBreakpoints::dataContextMenu(QMenu *parent) {
auto menu = new QMenu(tr("Hardware Breakpoints"), parent);

auto rw1 = menu->addAction(tr("Hardware, On Read/Write #1"), this, SLOT(setAccess1()));
auto rw2 = menu->addAction(tr("Hardware, On Read/Write #2"), this, SLOT(setAccess2()));
Expand All @@ -309,7 +309,7 @@ QList<QAction *> HardwareBreakpoints::dataContextMenu() {

QList<QAction *> ret;

auto action = new QAction(tr("Hardware Breakpoints"), this);
auto action = new QAction(tr("Hardware Breakpoints"), parent);
action->setMenu(menu);
ret << action;
return ret;
Expand All @@ -319,9 +319,9 @@ QList<QAction *> HardwareBreakpoints::dataContextMenu() {
* @brief HardwareBreakpoints::cpuContextMenu
* @return
*/
QList<QAction *> HardwareBreakpoints::cpuContextMenu() {
QList<QAction *> HardwareBreakpoints::cpuContextMenu(QMenu *parent) {

auto menu = new QMenu(tr("Hardware Breakpoints"));
auto menu = new QMenu(tr("Hardware Breakpoints"), parent);
auto ex1 = menu->addAction(tr("Hardware, On Execute #1"), this, SLOT(setExec1()));
auto ex2 = menu->addAction(tr("Hardware, On Execute #2"), this, SLOT(setExec2()));
auto ex3 = menu->addAction(tr("Hardware, On Execute #3"), this, SLOT(setExec3()));
Expand Down Expand Up @@ -354,7 +354,7 @@ QList<QAction *> HardwareBreakpoints::cpuContextMenu() {

QList<QAction *> ret;

auto action = new QAction(tr("Hardware Breakpoints"), this);
auto action = new QAction(tr("Hardware Breakpoints"), parent);
action->setMenu(menu);
ret << action;
return ret;
Expand Down
6 changes: 3 additions & 3 deletions plugins/HardwareBreakpoints/HardwareBreakpoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class HardwareBreakpoints : public QObject, public IPlugin, public IDebugEventHa
public:
QMenu *menu(QWidget *parent = nullptr) override;
edb::EventStatus handleEvent(const std::shared_ptr<IDebugEvent> &event) override;
QList<QAction *> cpuContextMenu() override;
QList<QAction *> stackContextMenu() override;
QList<QAction *> dataContextMenu() override;
QList<QAction *> cpuContextMenu(QMenu *parent) override;
QList<QAction *> stackContextMenu(QMenu *parent) override;
QList<QAction *> dataContextMenu(QMenu *parent) override;

public Q_SLOTS:
void showMenu();
Expand Down
2 changes: 1 addition & 1 deletion plugins/InstructionInspector/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ QMenu *Plugin::menu(QWidget *) {
* @brief Plugin::cpuContextMenu
* @return
*/
QList<QAction *> Plugin::cpuContextMenu() {
QList<QAction *> Plugin::cpuContextMenu(QMenu *) {
return {menuAction_};
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/InstructionInspector/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Plugin : public QObject, public IPlugin {
public:
explicit Plugin(QObject *parent = nullptr);
QMenu *menu(QWidget *parent = nullptr) override;
QList<QAction *> cpuContextMenu() override;
QList<QAction *> cpuContextMenu(QMenu *parent) override;

private:
void showDialog() const;
Expand Down
2 changes: 1 addition & 1 deletion plugins/ODbgRegisterView/RegisterView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void ODBRegView::showMenu(const QPoint &position, const QList<QAction *> &additi

if (model_->activeIndex().isValid()) {
QList<QAction *> debuggerActions;
QMetaObject::invokeMethod(edb::v1::debugger_ui, "currentRegisterContextMenuItems", Qt::DirectConnection, Q_RETURN_ARG(QList<QAction *>, debuggerActions));
QMetaObject::invokeMethod(edb::v1::debugger_ui, "currentRegisterContextMenuItems", Qt::DirectConnection, Q_RETURN_ARG(QList<QAction *>, debuggerActions), Q_ARG(QMenu *, &menu));
items.push_back(nullptr);
items.append(debuggerActions);
}
Expand Down
16 changes: 6 additions & 10 deletions src/Debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,11 +858,7 @@ void Debugger::finishPluginSetup() {
}

// setup the shortcuts for these actions
const QList<QAction *> register_actions = p->registerContextMenu();
const QList<QAction *> cpu_actions = p->cpuContextMenu();
const QList<QAction *> stack_actions = p->stackContextMenu();
const QList<QAction *> data_actions = p->dataContextMenu();
const QList<QAction *> actions = register_actions + cpu_actions + stack_actions + data_actions;
const QList<QAction *> actions = p->globalShortcuts();

for (QAction *action : actions) {
QKeySequence shortcut = action->shortcut();
Expand Down Expand Up @@ -1231,7 +1227,7 @@ Register Debugger::activeRegister() const {
// Name: on_registerList_customContextMenuRequested
// Desc: context menu handler for register view
//------------------------------------------------------------------------------
QList<QAction *> Debugger::currentRegisterContextMenuItems() const {
QList<QAction *> Debugger::currentRegisterContextMenuItems(QMenu *parent) const {
QList<QAction *> allActions;
const auto reg = activeRegister();
if (reg.type() & (Register::TYPE_GPR | Register::TYPE_IP)) {
Expand All @@ -1243,7 +1239,7 @@ QList<QAction *> Debugger::currentRegisterContextMenuItems() const {

allActions.append(actions);
}
allActions.append(getPluginContextMenuItems(&IPlugin::registerContextMenu));
allActions.append(getPluginContextMenuItems(parent, &IPlugin::registerContextMenu));
return allActions;
}

Expand Down Expand Up @@ -3216,12 +3212,12 @@ void Debugger::mnuDumpDeleteTab() {
// NULL pointer items mean "create separator here".
//------------------------------------------------------------------------------
template <class F>
QList<QAction *> Debugger::getPluginContextMenuItems(const F &f) const {
QList<QAction *> Debugger::getPluginContextMenuItems(QMenu *parent, const F &f) const {
QList<QAction *> actions;

for (QObject *plugin : edb::v1::plugin_list()) {
if (auto p = qobject_cast<IPlugin *>(plugin)) {
const QList<QAction *> acts = (p->*f)();
const QList<QAction *> acts = (p->*f)(parent);
if (!acts.isEmpty()) {
actions.push_back(nullptr);
actions.append(acts);
Expand All @@ -3239,7 +3235,7 @@ template <class F, class T>
void Debugger::addPluginContextMenu(const T &menu, const F &f) {
for (QObject *plugin : edb::v1::plugin_list()) {
if (auto p = qobject_cast<IPlugin *>(plugin)) {
const QList<QAction *> acts = (p->*f)();
const QList<QAction *> acts = (p->*f)(menu);
if (!acts.isEmpty()) {
menu->addSeparator();
menu->addActions(acts);
Expand Down
4 changes: 2 additions & 2 deletions src/Debugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private Q_SLOTS:

private Q_SLOTS:
// the manually connected Register slots
QList<QAction *> currentRegisterContextMenuItems() const;
QList<QAction *> currentRegisterContextMenuItems(QMenu *parent) const;
void mnuRegisterFollowInDump() { followRegisterInDump(false); }
void mnuRegisterFollowInDumpNewTab() { followRegisterInDump(true); }
void mnuRegisterFollowInStack();
Expand Down Expand Up @@ -269,7 +269,7 @@ private Q_SLOTS:
Result<edb::address_t, QString> getFollowAddress(const Ptr &hexview);

template <class F>
QList<QAction *> getPluginContextMenuItems(const F &f) const;
QList<QAction *> getPluginContextMenuItems(QMenu *parent, const F &f) const;

template <class F, class T>
void addPluginContextMenu(const T &menu, const F &f);
Expand Down