added basic debug view and stop debug button to toolbar

This commit is contained in:
mandlebro 2018-06-12 16:42:38 +01:00 committed by xarkes
parent 7eea0ed311
commit 40ce944381
7 changed files with 82 additions and 2 deletions

View File

@ -761,6 +761,16 @@ void CutterCore::startDebug()
{
cmd("ood");
emit registersChanged();
emit changeDebugView();
}
void CutterCore::stopDebug()
{
// @TODO should first obtain correct signal to send.
// Also, we do a ds since otherwise the process does not die.
cmd("dk 9; ds; e cfg.debug = false; oo");
seek(tr("main"));
emit changeDefinedView();
}
void CutterCore::continueDebug()

View File

@ -469,6 +469,7 @@ public:
QJsonDocument getStack(int size = 0x40);
QJsonDocument getBacktrace();
void startDebug();
void stopDebug();
void continueDebug();
void continueUntilDebug(QString offset);
void stepDebug();
@ -580,6 +581,8 @@ signals:
void seekChanged(RVA offset);
void raisePrioritizedMemoryWidget(CutterCore::MemoryWidgetType type);
void changeDefinedView();
void changeDebugView();
public slots:

View File

@ -250,6 +250,9 @@ void MainWindow::initUI()
connect(core, SIGNAL(projectSaved(const QString &)), this, SLOT(projectSaved(const QString &)));
connect(core, &CutterCore::changeDebugView, this, &MainWindow::changeDebugView);
connect(core, &CutterCore::changeDefinedView, this, &MainWindow::changeDefinedView);
updateTasksIndicator();
connect(core->getAsyncTaskManager(), &AsyncTaskManager::tasksChanged, this, &MainWindow::updateTasksIndicator);
@ -475,11 +478,9 @@ void MainWindow::setPanelLock()
void MainWindow::setTabLocation()
{
if (tabsOnTop) {
ui->centralTabWidget->setTabPosition(QTabWidget::North);
this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
ui->actionTabs_on_Top->setChecked(true);
} else {
ui->centralTabWidget->setTabPosition(QTabWidget::South);
this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::South);
ui->actionTabs_on_Top->setChecked(false);
}
@ -616,6 +617,26 @@ void MainWindow::showZenDocks()
updateDockActionsChecked();
}
void MainWindow::showDebugDocks()
{
const QList<QDockWidget *> debugDocks = { functionsDock,
stringsDock,
graphDock,
disassemblyDock,
hexdumpDock,
searchDock,
stackDock,
registersDock,
backtraceDock
};
for (auto w : dockWidgets) {
if (debugDocks.contains(w)) {
w->show();
}
}
updateDockActionsChecked();
}
void MainWindow::resetToDefaultLayout()
{
hideAllDocks();
@ -654,6 +675,24 @@ void MainWindow::resetToZenLayout()
Core()->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Disassembly);
}
void MainWindow::resetToDebugLayout()
{
hideAllDocks();
restoreDocks();
showDebugDocks();
disassemblyDock->raise();
// ugly workaround to set the default widths of functions
// if anyone finds a way to do this cleaner that also works, feel free to change it!
auto restoreFunctionDock = qhelpers::forceWidth(functionsDock->widget(), 200);
qApp->processEvents();
restoreFunctionDock.restoreWidth(functionsDock->widget());
Core()->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Disassembly);
}
void MainWindow::addOutput(const QString &msg)
{
consoleDock->addOutput(msg);
@ -862,6 +901,20 @@ void MainWindow::projectSaved(const QString &name)
addOutput(tr("Project saved: ") + name);
}
void MainWindow::changeDebugView()
{
saveSettings();
resetToDebugLayout();
}
void MainWindow::changeDefinedView()
{
resetToDefaultLayout();
readSettings();
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
}
void MainWindow::mousePressEvent(QMouseEvent *event)
{
switch (event->button()) {

View File

@ -170,6 +170,8 @@ private slots:
void mousePressEvent(QMouseEvent *event) override;
bool eventFilter(QObject *object, QEvent *event);
void changeDebugView();
void changeDefinedView();
private:
CutterCore *core;
@ -230,11 +232,13 @@ private:
void resetToDefaultLayout();
void resetToZenLayout();
void resetToDebugLayout();
void restoreDocks();
void hideAllDocks();
void showDefaultDocks();
void showZenDocks();
void showDebugDocks();
void updateDockActionsChecked();
void toggleDockWidget(QDockWidget *dock_widget, bool show);

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
<path d="M0 0v6h6v-6h-6z" transform="translate(1 1)" fill="#aaacaf" />
</svg>

After

Width:  |  Height:  |  Size: 159 B

View File

@ -1,7 +1,9 @@
<RCC>
<qresource prefix="/">
<file>img/icons/arrow_left_light.svg</file>
<file>img/icons/arrow_left.svg</file>
<file>img/icons/arrow_right_light.svg</file>
<file>img/icons/arrow_right.svg</file>
<file>img/icons/sidebar.svg</file>
<file>img/icons/undo.svg</file>
<file>img/icons/redo.svg</file>
@ -18,6 +20,7 @@
<file>img/icons/plus.svg</file>
<file>img/icons/play.svg</file>
<file>img/icons/play_light.svg</file>
<file>img/icons/media-stop_light.svg</file>
<file>img/icons/media-skip-forward_light.svg</file>
<file>img/icons/continue_until_main.svg</file>
<file>img/icons/step_light.svg</file>

View File

@ -10,22 +10,26 @@ DebugToolbar::DebugToolbar(MainWindow *main, QWidget *parent) :
{
setObjectName("debugToolbar");
QIcon startIcon = QIcon(":/img/icons/play_light.svg");
QIcon stopIcon = QIcon(":/img/icons/media-stop_light.svg");
QIcon continueIcon = QIcon(":/img/icons/media-skip-forward_light.svg");
QIcon continueUntilIcon = QIcon(":/img/icons/continue_until_main.svg");
QIcon stepIcon = QIcon(":/img/icons/step_light.svg");
QIcon stepOverIcon = QIcon(":/img/icons/step_over_light.svg");
QAction *actionStart = new QAction(startIcon, tr("Start debug"), parent);
QAction *actionStop = new QAction(stopIcon, tr("Stop debug"), parent);
QAction *actionContinue = new QAction(continueIcon, tr("Continue"), parent);
QAction *actionContinueUntilMain = new QAction(continueUntilIcon, tr("Continue until main"), parent);
QAction *actionStep = new QAction(stepIcon, tr("Step"), parent);
QAction *actionStepOver = new QAction(stepOverIcon, tr("Step over"), parent);
addAction(actionStart);
addAction(actionStop);
addAction(actionContinue);
addAction(actionContinueUntilMain);
addAction(actionStep);
addAction(actionStepOver);
connect(actionStop, &QAction::triggered, Core(), &CutterCore::stopDebug);
connect(actionStep, &QAction::triggered, Core(), &CutterCore::stepDebug);
connect(actionStart, &QAction::triggered, Core(), &CutterCore::startDebug);
connect(actionStepOver, &QAction::triggered, Core(), &CutterCore::stepOverDebug);