diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index 30c172a2..2e9b941e 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -1832,6 +1832,7 @@ void CutterCore::stopDebug() } currentlyDebugging = false; + currentlyTracing = false; emit debugTaskStateChanged(); if (currentlyEmulating) { @@ -2135,30 +2136,9 @@ void CutterCore::setDebugPlugin(QString plugin) setConfig("dbg.backend", plugin); } -bool CutterCore::isTraceSessionInProgress() { - CORE_LOCK(); - if (!currentlyDebugging) { - return false; - } - - if (currentlyEmulating) { - if (core->analysis->esil->trace) { - return true; - } else { - return false; - } - } else { - if (core->dbg->session) { - return true; - } else { - return false; - } - } -} - void CutterCore::startTraceSession() { - if (!currentlyDebugging) { + if (!currentlyDebugging || currentlyTracing) { return; } @@ -2179,6 +2159,7 @@ void CutterCore::startTraceSession() } debugTask.clear(); + currentlyTracing = true; emit debugTaskStateChanged(); }); @@ -2193,7 +2174,7 @@ void CutterCore::startTraceSession() void CutterCore::stopTraceSession() { - if (!currentlyDebugging) { + if (!currentlyDebugging || !currentlyTracing) { return; } @@ -2214,6 +2195,7 @@ void CutterCore::stopTraceSession() } debugTask.clear(); + currentlyTracing = false; emit debugTaskStateChanged(); }); diff --git a/src/core/Cutter.h b/src/core/Cutter.h index 01ff4459..9a6b67e5 100644 --- a/src/core/Cutter.h +++ b/src/core/Cutter.h @@ -403,7 +403,6 @@ public: void stepOutDebug(); void stepBackDebug(); - bool isTraceSessionInProgress(); void startTraceSession(); void stopTraceSession(); @@ -440,6 +439,7 @@ public: bool isRedirectableDebugee(); bool currentlyDebugging = false; bool currentlyEmulating = false; + bool currentlyTracing = false; int currentlyAttachedToPID = -1; QString currentlyOpenFile; diff --git a/src/widgets/DebugActions.cpp b/src/widgets/DebugActions.cpp index 71463d13..41ec95b4 100644 --- a/src/widgets/DebugActions.cpp +++ b/src/widgets/DebugActions.cpp @@ -26,8 +26,8 @@ DebugActions::DebugActions(QToolBar *toolBar, MainWindow *main) : QIcon startRemoteIcon = QIcon(":/img/icons/play_light_remote.svg"); QIcon continueBackIcon = QIcon(":/img/icons/reverse_continue.svg"); QIcon stepBackIcon = QIcon(":/img/icons/reverse_step.svg"); - QIcon startTraceIcon = QIcon(":/img/icons/start_trace.svg"); - QIcon stopTraceIcon = QIcon(":/img/icons/stop_trace.svg"); + startTraceIcon = QIcon(":/img/icons/start_trace.svg"); + stopTraceIcon = QIcon(":/img/icons/stop_trace.svg"); stopIcon = QIcon(":/img/icons/media-stop_light.svg"); restartIcon = QIcon(":/img/icons/spin_light.svg"); detachIcon = QIcon(":/img/icons/detach_debugger.svg"); @@ -50,8 +50,8 @@ DebugActions::DebugActions(QToolBar *toolBar, MainWindow *main) : QString stepOverLabel = tr("Step over"); QString stepOutLabel = tr("Step out"); QString stepBackLabel = tr("Step backwards"); - QString startTraceLabel = tr("Start trace session"); - QString stopTraceLabel = tr("Stop trace session"); + startTraceLabel = tr("Start trace session"); + stopTraceLabel = tr("Stop trace session"); suspendLabel = tr("Suspend the process"); continueLabel = tr("Continue"); restartDebugLabel = tr("Restart program"); @@ -150,11 +150,9 @@ DebugActions::DebugActions(QToolBar *toolBar, MainWindow *main) : actionContinue->setText(continueLabel); actionContinue->setIcon(continueIcon); } - // Reverse actions should only be toggled if we are tracing - if (Core()->isTraceSessionInProgress()) { - for (QAction *a : reverseActions) { - a->setDisabled(disableToolbar); - } + for (QAction *a : reverseActions) { + a->setVisible(Core()->currentlyTracing); + a->setDisabled(disableToolbar); } } else { for (QAction *a : toggleConnectionActions) { @@ -199,9 +197,9 @@ DebugActions::DebugActions(QToolBar *toolBar, MainWindow *main) : actionStartEmul->setText(restartEmulLabel); actionStartEmul->setIcon(restartIcon); actionStop->setText(stopEmulLabel); - // Reverse debug actions are disabled until we start tracing + // Reverse debug actions aren't visible until we start tracing for (QAction *a : reverseActions) { - a->setDisabled(true); + a->setVisible(false); } }); connect(actionStepOver, &QAction::triggered, Core(), &CutterCore::stepOverDebug); @@ -221,7 +219,7 @@ DebugActions::DebugActions(QToolBar *toolBar, MainWindow *main) : connect(actionTrace, &QAction::triggered, Core(), [=]() { // Check if a debug session was created to switch between start and stop - if (!Core()->isTraceSessionInProgress()) { + if (!Core()->currentlyTracing) { Core()->startTraceSession(); actionTrace->setText(stopTraceLabel); actionTrace->setIcon(stopTraceIcon); @@ -389,10 +387,12 @@ void DebugActions::startDebug() actionStart->setIcon(restartIcon); setButtonVisibleIfMainExists(); - // Reverse debug actions are disabled until we start tracing + // Reverse debug actions aren't visible until we start tracing for (QAction *a : reverseActions) { - a->setDisabled(true); + a->setVisible(false); } + actionTrace->setText(startTraceLabel); + actionTrace->setIcon(startTraceIcon); Core()->startDebug(); } diff --git a/src/widgets/DebugActions.h b/src/widgets/DebugActions.h index 7d04bcc5..cd99466c 100644 --- a/src/widgets/DebugActions.h +++ b/src/widgets/DebugActions.h @@ -40,10 +40,14 @@ public: QIcon suspendIcon; QIcon restartIcon; QIcon startDebugIcon; - QString suspendLabel; + QIcon startTraceIcon; + QIcon stopTraceIcon; QString continueLabel; + QString suspendLabel; QString restartDebugLabel; QString startDebugLabel; + QString startTraceLabel; + QString stopTraceLabel; // Stop and Detach interchange during runtime QIcon detachIcon;