File: DecompilerContextMenu.h

package info (click to toggle)
radare2-cutter 1.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,768 kB
  • sloc: cpp: 38,432; python: 507; sh: 505; xml: 115; makefile: 89; ansic: 10; javascript: 3
file content (180 lines) | stat: -rw-r--r-- 4,891 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#ifndef DECOMPILERCONTEXTMENU_H
#define DECOMPILERCONTEXTMENU_H

#include "core/Cutter.h"
#include <QMenu>
#include <QKeySequence>

#include <r_util/r_annotated_code.h>

class MainWindow;

class DecompilerContextMenu : public QMenu
{
    Q_OBJECT

public:
    DecompilerContextMenu(QWidget *parent, MainWindow *mainWindow);
    ~DecompilerContextMenu();

    bool getIsTogglingBreakpoints();
    void setAnnotationHere(RCodeAnnotation *annotation);
    RVA getFirstOffsetInLine();

signals:
    void copy();

public slots:
    void setCurHighlightedWord(QString word);
    void setOffset(RVA newOffset);
    void setDecompiledFunctionAddress(RVA functionAddr);
    void setFirstOffsetInLine(RVA firstOffset);
    void setAvailableBreakpoints(QVector<RVA> offsetList);

private slots:
    void aboutToShowSlot();
    void aboutToHideSlot();

    void actionCopyTriggered();
    void actionCopyInstructionAddressTriggered();
    void actionCopyReferenceAddressTriggered();

    void actionAddCommentTriggered();
    void actionDeleteCommentTriggered();

    void actionRenameThingHereTriggered();
    void actionDeleteNameTriggered();

    void actionEditFunctionVariablesTriggered();

    void actionXRefsTriggered();

    void actionToggleBreakpointTriggered();
    void actionAdvancedBreakpointTriggered();

    void actionContinueUntilTriggered();
    void actionSetPCTriggered();

private:
    // Private variables
    MainWindow *mainWindow;
    QString curHighlightedWord;
    RVA offset;
    RVA decompiledFunctionAddress;
    /**
     * Lowest offset among all offsets present in the line under cursor in the decompiler widget.
     */
    RVA firstOffsetInLine;
    /**
     * When the actionToggleBreakpoint has been triggered, and it hasn't finished executing,
     * the value of this variable will be true, otherwise false
     */
    bool isTogglingBreakpoints;
    /**
     * List of the offsets of all the breakpoints (enabled and disabled) that are present in the line under cursor.
     */
    QVector<RVA> availableBreakpoints;
    /**
     * Context-related annotation for the data under cursor in the decompiler widget.
     * If such an annotation doesn't exist, its value is nullptr.
     */
    RCodeAnnotation *annotationHere;

    // Actions and menus in the context menu
    QAction actionCopy;
    QAction actionCopyInstructionAddress;
    QAction actionCopyReferenceAddress;
    QAction *copySeparator;

    QAction actionShowInSubmenu;
    QList<QAction *> showTargetMenuActions;

    QAction actionAddComment;
    QAction actionDeleteComment;

    QAction actionRenameThingHere;
    QAction actionDeleteName;

    QAction actionEditFunctionVariables;

    QAction actionXRefs;

    QMenu *breakpointMenu;
    QAction actionToggleBreakpoint;
    QAction actionAdvancedBreakpoint;

    QMenu *breakpointsInLineMenu;

    QMenu *debugMenu;
    QAction actionContinueUntil;
    QAction actionSetPC;

    // Private Functions
    /**
     * @brief Sets the shortcut context in all the actions contained
     * in the specified QMenu to Qt::WidgetWithChildrenShortcut.
     *
     * @param menu - QMenu specified
     */
    void setShortcutContextInActions(QMenu *menu);
    void setupBreakpointsInLineMenu();
    void setIsTogglingBreakpoints(bool isToggling);

    // Set actions
    void setActionCopy();

    void setActionShowInSubmenu();

    void setActionAddComment();
    void setActionDeleteComment();

    void setActionXRefs();

    void setActionRenameThingHere();
    void setActionDeleteName();

    void setActionEditFunctionVariables();

    void setActionToggleBreakpoint();
    void setActionAdvancedBreakpoint();

    void setActionContinueUntil();
    void setActionSetPC();

    // Add Menus
    void addBreakpointMenu();
    void addDebugMenu();

    /**
     * @brief Updates targeted "Show in" menu.
     *
     * Removes all actions from the existing targeted "show in" menu. If annotationHere
     * represents an item that has an address assigned to it, insert actions compatible with the
     * type of this item in the targeted "Show in" menu.
     */
    void updateTargetMenuActions();

    /**
     * @brief Check if annotationHere is a reference (function name,
     * global variable, constant variable with an address).
     *
     * @return True if annotationHere is a reference, otherwise false.
     */
    bool isReference();
    /**
     * @brief Check if annotationHere is a function variable
     * (local variable or function parameter).
     *
     * @return True if annotationHere is a function variable, otherwise false.
     */
    bool isFunctionVariable();
    /**
     * @brief Check if the function variable annotated by annotationHere is
     * present in radare2.
     *
     * @return True if the variable is present, otherwise false
     */
    bool variablePresentInR2();
};

#endif // DECOMPILERCONTEXTMENU_H