mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-18 19:06:10 +00:00
Added new buttons to breakpoint widget (#548)
* Added new buttons to breakpoint widget
This commit is contained in:
parent
837ffef20f
commit
975e4c4a3d
@ -868,6 +868,13 @@ void CutterCore::addBreakpoint(RVA addr)
|
||||
emit breakpointsChanged();
|
||||
}
|
||||
|
||||
void CutterCore::addBreakpoint(QString addr)
|
||||
{
|
||||
cmd("db " + addr);
|
||||
emit instructionChanged(addr.toULongLong());
|
||||
emit breakpointsChanged();
|
||||
}
|
||||
|
||||
void CutterCore::delBreakpoint(RVA addr)
|
||||
{
|
||||
cmd("db- " + RAddressString(addr));
|
||||
@ -878,7 +885,7 @@ void CutterCore::delBreakpoint(RVA addr)
|
||||
void CutterCore::delAllBreakpoints()
|
||||
{
|
||||
cmd("db-*");
|
||||
emit breakpointsChanged();
|
||||
emit deletedAllBreakpoints();
|
||||
}
|
||||
|
||||
void CutterCore::enableBreakpoint(RVA addr)
|
||||
|
@ -488,6 +488,7 @@ public:
|
||||
void stepDebug();
|
||||
void stepOverDebug();
|
||||
void addBreakpoint(RVA addr);
|
||||
void addBreakpoint(QString addr);
|
||||
void delBreakpoint(RVA addr);
|
||||
void delAllBreakpoints();
|
||||
void enableBreakpoint(RVA addr);
|
||||
@ -583,6 +584,7 @@ signals:
|
||||
void registersChanged();
|
||||
void instructionChanged(RVA offset);
|
||||
void breakpointsChanged();
|
||||
void deletedAllBreakpoints();
|
||||
|
||||
void notesChanged(const QString ¬es);
|
||||
void projectSaved(const QString &name);
|
||||
|
@ -179,7 +179,8 @@ SOURCES += \
|
||||
widgets/DebugToolbar.cpp \
|
||||
widgets/MemoryMapWidget.cpp \
|
||||
dialogs/preferences/DebugOptionsWidget.cpp \
|
||||
widgets/BreakpointWidget.cpp
|
||||
widgets/BreakpointWidget.cpp \
|
||||
dialogs/BreakpointsDialog.cpp
|
||||
|
||||
HEADERS += \
|
||||
Cutter.h \
|
||||
@ -270,7 +271,8 @@ HEADERS += \
|
||||
widgets/DebugToolbar.h \
|
||||
widgets/MemoryMapWidget.h \
|
||||
dialogs/preferences/DebugOptionsWidget.h \
|
||||
widgets/BreakpointWidget.h
|
||||
widgets/BreakpointWidget.h \
|
||||
dialogs/BreakpointsDialog.h
|
||||
|
||||
FORMS += \
|
||||
dialogs/AboutDialog.ui \
|
||||
@ -322,7 +324,8 @@ FORMS += \
|
||||
widgets/MemoryMapWidget.ui \
|
||||
widgets/MemoryMapWidget.ui \
|
||||
dialogs/preferences/DebugOptionsWidget.ui \
|
||||
widgets/BreakpointWidget.ui
|
||||
widgets/BreakpointWidget.ui \
|
||||
dialogs/BreakpointsDialog.ui
|
||||
|
||||
RESOURCES += \
|
||||
resources.qrc \
|
||||
|
47
src/dialogs/BreakpointsDialog.cpp
Normal file
47
src/dialogs/BreakpointsDialog.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
#include "BreakpointsDialog.h"
|
||||
#include "ui_BreakpointsDialog.h"
|
||||
|
||||
BreakpointsDialog::BreakpointsDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::BreakpointsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
|
||||
// Event filter for capturing Ctrl/Cmd+Return
|
||||
ui->textEdit->installEventFilter(this);
|
||||
}
|
||||
|
||||
BreakpointsDialog::~BreakpointsDialog() {}
|
||||
|
||||
void BreakpointsDialog::on_buttonBox_accepted()
|
||||
{
|
||||
}
|
||||
|
||||
void BreakpointsDialog::on_buttonBox_rejected()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
QString BreakpointsDialog::getBreakpoints()
|
||||
{
|
||||
QString ret = ui->textEdit->document()->toPlainText();
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool BreakpointsDialog::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
Q_UNUSED(obj);
|
||||
if (event -> type() == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = static_cast <QKeyEvent *> (event);
|
||||
|
||||
// Confirm comment by pressing Ctrl/Cmd+Return
|
||||
if ((keyEvent -> modifiers() & Qt::ControlModifier) &&
|
||||
((keyEvent -> key() == Qt::Key_Enter) || (keyEvent -> key() == Qt::Key_Return))) {
|
||||
this->accept();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
28
src/dialogs/BreakpointsDialog.h
Normal file
28
src/dialogs/BreakpointsDialog.h
Normal file
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
#include <memory>
|
||||
|
||||
namespace Ui {
|
||||
class BreakpointsDialog;
|
||||
}
|
||||
|
||||
class BreakpointsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BreakpointsDialog(QWidget *parent = nullptr);
|
||||
~BreakpointsDialog();
|
||||
|
||||
QString getBreakpoints();
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
void on_buttonBox_rejected();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::BreakpointsDialog> ui;
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
};
|
89
src/dialogs/BreakpointsDialog.ui
Normal file
89
src/dialogs/BreakpointsDialog.ui
Normal file
@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BreakpointsDialog</class>
|
||||
<widget class="QDialog" name="BreakpointsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>118</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Add breakpoints</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="textEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>BreakpointsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>BreakpointsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -1,5 +1,6 @@
|
||||
#include "BreakpointWidget.h"
|
||||
#include "ui_BreakpointWidget.h"
|
||||
#include "dialogs/BreakpointsDialog.h"
|
||||
#include "MainWindow.h"
|
||||
#include "utils/Helpers.h"
|
||||
#include <QMenu>
|
||||
@ -135,6 +136,9 @@ BreakpointWidget::BreakpointWidget(MainWindow *main, QAction *action) :
|
||||
connect(actionToggleBreakpoint, &QAction::triggered, this, &BreakpointWidget::toggleBreakpoint);
|
||||
connect(Core(), &CutterCore::refreshAll, this, &BreakpointWidget::refreshBreakpoint);
|
||||
connect(Core(), &CutterCore::breakpointsChanged, this, &BreakpointWidget::refreshBreakpoint);
|
||||
connect(Core(), &CutterCore::deletedAllBreakpoints, this, &BreakpointWidget::refreshBreakpoint);
|
||||
connect(ui->addBreakpoint, &QAbstractButton::clicked, this, &BreakpointWidget::addBreakpointDialog);
|
||||
connect(ui->delBreakpoint, &QAbstractButton::clicked, this, &BreakpointWidget::delBreakpoint);
|
||||
connect(ui->delAllBreakpoints, &QAbstractButton::clicked, Core(), &CutterCore::delAllBreakpoints);
|
||||
ui->breakpointTreeView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->breakpointTreeView, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||
@ -178,6 +182,21 @@ void BreakpointWidget::showBreakpointContextMenu(const QPoint &pt)
|
||||
delete menu;
|
||||
}
|
||||
|
||||
void BreakpointWidget::addBreakpointDialog()
|
||||
{
|
||||
BreakpointsDialog *dialog = new BreakpointsDialog(this);
|
||||
|
||||
if (dialog->exec()) {
|
||||
QString bps = dialog->getBreakpoints();
|
||||
if (!bps.isEmpty()) {
|
||||
QStringList bpList = bps.split(" ", QString::SkipEmptyParts);
|
||||
for ( QString bp : bpList) {
|
||||
Core()->addBreakpoint(bp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BreakpointWidget::delBreakpoint()
|
||||
{
|
||||
BreakpointDescription bp = ui->breakpointTreeView->selectionModel()->currentIndex().data(
|
||||
|
@ -73,7 +73,7 @@ private slots:
|
||||
void showBreakpointContextMenu(const QPoint &pt);
|
||||
void delBreakpoint();
|
||||
void toggleBreakpoint();
|
||||
|
||||
void addBreakpointDialog();
|
||||
void refreshBreakpoint();
|
||||
|
||||
private:
|
||||
|
@ -51,11 +51,29 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="delAllBreakpoints">
|
||||
<property name="text">
|
||||
<string>Delete all breakpoints</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="hLayout">
|
||||
<item>
|
||||
<widget class="QToolButton" name="addBreakpoint">
|
||||
<property name="text">
|
||||
<string>Add new breakpoint</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="delBreakpoint">
|
||||
<property name="text">
|
||||
<string>Delete breakpoint</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="QToolButton" name="delAllBreakpoints">
|
||||
<property name="text">
|
||||
<string>Delete all breakpoints</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -36,6 +36,7 @@ DisassemblerGraphView::DisassemblerGraphView(QWidget *parent)
|
||||
connect(Core(), SIGNAL(functionsChanged()), this, SLOT(refreshView()));
|
||||
connect(Core(), SIGNAL(graphOptionsChanged()), this, SLOT(refreshView()));
|
||||
connect(Core(), SIGNAL(asmOptionsChanged()), this, SLOT(refreshView()));
|
||||
connect(Core(), SIGNAL(deletedAllBreakpoints()), this, SLOT(refreshView()));
|
||||
|
||||
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(colorsUpdatedSlot()));
|
||||
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(fontsUpdatedSlot()));
|
||||
|
@ -119,6 +119,7 @@ DisassemblyWidget::DisassemblyWidget(MainWindow *main, QAction *action)
|
||||
refreshDisasm();
|
||||
}
|
||||
});
|
||||
connect(Core(), SIGNAL(deletedAllBreakpoints()), this, SLOT(refreshDisasm()));
|
||||
|
||||
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(fontsUpdatedSlot()));
|
||||
connect(Config(), SIGNAL(colorsUpdated()), this, SLOT(colorsUpdatedSlot()));
|
||||
|
Loading…
Reference in New Issue
Block a user