Set reverse icons to invisible when not in a trace session instead of disabled

This commit is contained in:
yossizap 2020-12-19 18:52:29 +00:00
parent c6ed2c0a06
commit a6876dc3f2
4 changed files with 25 additions and 39 deletions

View File

@ -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();
});

View File

@ -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;

View File

@ -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();
}

View File

@ -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;