-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathcontrolswidget.cpp
More file actions
732 lines (585 loc) · 20.7 KB
/
Copy pathcontrolswidget.cpp
File metadata and controls
732 lines (585 loc) · 20.7 KB
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
/*
Copyright 2020-2026 Vector 35 Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "controlswidget.h"
#include "adaptersettings.h"
#include "timestampnavigationdialog.h"
#include <QPixmap>
#include <QInputDialog>
#include <QMessageBox>
#include "binaryninjaapi.h"
#include "disassemblyview.h"
#include "theme.h"
#include "platformdialog.h"
#include "ui.h"
#include <thread>
#include "progresstask.h"
#include "attachprocess.h"
#include <filesystem>
#include <fstream>
#include <QFileDialog>
using namespace BinaryNinjaDebuggerAPI;
using namespace BinaryNinja;
DebugControlsWidget::DebugControlsWidget(QWidget* parent, const std::string name, BinaryViewRef data) :
QToolBar(parent), m_name(name)
{
m_controller = DebuggerController::GetController(data);
if (!m_controller)
return;
auto cyan = getThemeColor(CyanStandardHighlightColor);
auto green = getThemeColor(GreenStandardHighlightColor);
auto red = getThemeColor(RedStandardHighlightColor);
auto white = getThemeColor(WhiteStandardHighlightColor);
m_actionRun = addAction(getColoredIcon(":/debugger/start", red), "Launch", [this]() {
performLaunch();
});
m_actionRun->setToolTip(getToolTip("Launch"));
m_actionPause = addAction(getColoredIcon(":/debugger/pause", white), "Pause", [this]() {
performPause();
});
m_actionPause->setToolTip(getToolTip("Pause"));
m_actionResume = addAction(getColoredIcon(":/debugger/resume", green), "Resume", [this]() {
performResume();
});
m_actionResume->setToolTip(getToolTip("Resume"));
// m_actionRun->setVisible(true);
m_actionPause->setVisible(false);
m_actionResume->setVisible(false);
m_actionAttachPid = addAction(getColoredIcon(":/debugger/connect", white), "Attach To Process...", [this]() {
performAttachPID();
});
m_actionAttachPid->setToolTip(getToolTip("Attach To Process..."));
m_actionDetach = addAction(getColoredIcon(":/debugger/disconnect", red), "Detach", [this]() {
performDetach();
});
m_actionDetach->setVisible(false);
m_actionDetach->setToolTip(getToolTip("Detach"));
m_actionRestart = addAction(getColoredIcon(":/debugger/restart", red), "Restart", [this]() {
performRestart();
});
m_actionRestart->setToolTip(getToolTip("Restart"));
m_actionQuit = addAction(getColoredIcon(":/debugger/cancel", red), "Kill", [this]() {
performQuit();
});
m_actionQuit->setToolTip(getToolTip("Kill"));
addSeparator();
m_actionStepInto = addAction(getColoredIcon(":/debugger/step-into", cyan), "Step Into", [this]() {
performStepInto();
});
m_actionStepInto->setToolTip(getToolTip("Step Into"));
m_actionStepOver = addAction(getColoredIcon(":/debugger/step-over", cyan), "Step Over", [this]() {
performStepOver();
});
m_actionStepOver->setToolTip(getToolTip("Step Over"));
m_actionStepReturn = addAction(getColoredIcon(":/debugger/step-out", cyan), "Step Return", [this]() {
performStepReturn();
});
m_actionStepReturn->setToolTip(getToolTip("Step Return"));
addSeparator();
m_actionSettings = addAction(getColoredIcon(":/debugger/settings", cyan), "Settings", [this]() {
performSettings();
});
m_actionSettings->setToolTip(getToolTip("Debug Adapter Settings"));
addSeparator();
m_actionToggleBreakpoint = addAction(getColoredIcon(":/debugger/breakpoint", red), "Breakpoint", [this]() {
toggleBreakpoint();
});
m_actionToggleBreakpoint->setToolTip(getToolTip("Toggle Breakpoint"));
if(m_controller->IsTTD())
addSeparator(); //TODO: IsTTD only updates when the adapter is connected. This leaves the separator in place when the adapter is disconnected.
m_actionGoBack = addAction(getColoredIcon(":/debugger/resume-reverse", red), "Go Backwards", [this]() {
performGoReverse();
});
m_actionGoBack->setToolTip(getToolTip("Go Backwards"));
m_actionStepIntoBack = addAction(getColoredIcon(":/debugger/step-into-reverse", red), "Step Into Backwards", [this]() {
performStepIntoReverse();
});
m_actionStepIntoBack->setToolTip(getToolTip("Step Into Backwards"));
m_actionStepOverBack = addAction(getColoredIcon(":/debugger/step-back", red), "Step Over Backwards", [this]() {
performStepOverReverse();
});
m_actionStepOverBack->setToolTip(getToolTip("Step Over Backwards"));
m_actionStepReturnBack = addAction(getColoredIcon(":/debugger/step-out-reverse", red), "Step Return Backwards", [this]() {
performStepReturnReverse();
});
m_actionStepReturnBack->setToolTip(getToolTip("Step Return Backwards"));
m_actionTimestampNavigation = addAction(getColoredIcon(":/debugger/ttd-timestamp", cyan), "Navigate to Timestamp", [this]() {
performTimestampNavigation();
});
m_actionTimestampNavigation->setToolTip(getToolTip("Navigate to TTD Timestamp..."));
m_actionTTDNavigateBack = addAction(getColoredIcon(":/debugger/ttd-back", cyan), "TTD Navigate Back", [this]() {
performTTDNavigateBack();
});
m_actionTTDNavigateBack->setToolTip(getToolTip("TTD Navigate Back"));
m_actionTTDNavigateForward = addAction(getColoredIcon(":/debugger/ttd-forward", cyan), "TTD Navigate Forward", [this]() {
performTTDNavigateForward();
});
m_actionTTDNavigateForward->setToolTip(getToolTip("TTD Navigate Forward"));
updateButtons();
}
DebugControlsWidget::~DebugControlsWidget() {}
QIcon DebugControlsWidget::getColoredIcon(const QString& iconPath, const QColor& color)
{
auto pixmap = QPixmap(iconPath);
auto mask = pixmap.createMaskFromColor(QColor(0, 0, 0), Qt::MaskInColor);
pixmap.fill(color);
pixmap.setMask(mask);
return QIcon(pixmap);
}
QString DebugControlsWidget::getToolTip(const QString& name)
{
QString result = name;
auto keyBinding = UIAction::getKeyBinding(name);
if (!keyBinding.isEmpty())
result += (QString(" (") + keyBinding[0].toString() + ")");
return result;
}
static bool extractBinaryToFile(BinaryViewRef data, const std::string& outputPath)
{
BinaryViewRef rawView = data->GetParentView();
if (!rawView)
rawView = data;
uint64_t length = rawView->GetLength();
DataBuffer buffer = rawView->ReadBuffer(0, length);
if (buffer.GetLength() != length)
return false;
std::ofstream file(outputPath, std::ios::binary);
if (!file)
return false;
file.write(reinterpret_cast<const char*>(buffer.GetData()), buffer.GetLength());
return file.good();
}
bool DebugControlsWidget::handleContainerFile()
{
namespace fs = std::filesystem;
auto data = m_controller->GetData();
auto file = data->GetFile();
// Use the non-throwing overloads of fs::exists, since the throwing ones can raise a
// filesystem_error (e.g. EACCES from posix_stat) for inaccessible paths
std::error_code ec;
std::string execPath = m_controller->GetExecutablePath();
if (!execPath.empty() && fs::exists(execPath, ec))
return true;
std::string currentPath = file->GetFilename();
std::string originalPath = file->GetOriginalFilename();
bool isBndb = file->IsBackedByDatabase();
bool isVirtualPath = currentPath.find("::") != std::string::npos;
bool isVirtualFile = !fs::path(originalPath).is_absolute();
if (!isBndb && !isVirtualPath && !isVirtualFile)
return true;
// If the user is debugging without opening a file, we do not want to show the dialog
if (originalPath.empty())
return true;
if (fs::exists(originalPath, ec))
return true;
auto prompt = QString(
"The debugger requires the executable file on disk to launch.\n\n"
"Original file: %1\n\n"
"This file does not exist. Would you like to extract it?")
.arg(QString::fromStdString(originalPath));
if (QMessageBox::question(this, "File Not Found", prompt) != QMessageBox::Yes)
return false;
fs::path defaultPath = fs::current_path(ec) / fs::path(originalPath).filename();
if (isBndb)
defaultPath = fs::path(currentPath).parent_path() / fs::path(originalPath).filename();
QString extractPath = QFileDialog::getSaveFileName(
this, "Extract Binary", QString::fromStdString(defaultPath.string()), "All Files (*)");
if (extractPath.isEmpty())
return false;
if (!extractBinaryToFile(data, extractPath.toStdString()))
{
QMessageBox::critical(this, "Extraction Failed",
"Failed to extract the binary. See logs for details.");
return false;
}
m_controller->SetExecutablePath(extractPath.toStdString());
return true;
}
void DebugControlsWidget::performLaunch()
{
if (!handleContainerFile())
return;
bool firstLaunch = m_controller->IsFirstLaunch();
if (m_controller->ShouldShowAdapterSettingsForLaunch())
{
auto adapterSettings = new AdapterSettingsDialog(this, m_controller, "launch");
if (adapterSettings->exec() != QDialog::Accepted)
return;
}
// TODO: we should have the adapter returns this property
bool isLocalLaunch = true;
auto adapter = m_controller->GetAdapterType();
if ((adapter == "DBGENG_TTD") || (adapter == "LOCAL_WINDOWS_KERNEL") || (adapter == "WINDOWS_KERNEL") ||
(adapter == "WINDOWS_DUMP_FILE") || (adapter == "Corellium") || (adapter == "GDB RSP") ||
(adapter == "esReven"))
{
isLocalLaunch = false;
}
bool connectedToDebugServer = m_controller->IsConnectedToDebugServer();
if (isLocalLaunch && firstLaunch && Settings::Instance()->Get<bool>("debugger.confirmFirstLaunch"))
{
auto prompt = QString("You are about to launch \n\n%1\n\non your machine. "
"This may harm your machine. Are you sure to continue?").arg(QString::fromStdString(m_controller->GetExecutablePath()));
if (QMessageBox::question(this, "Launch Target", prompt) != QMessageBox::Yes)
return;
}
else if (!isLocalLaunch && connectedToDebugServer &&firstLaunch &&
Settings::Instance()->Get<bool>("debugger.confirmFirstLaunch"))
{
auto remoteHost = QString::fromStdString(m_controller->GetRemoteHost());
auto remotePort = m_controller->GetRemotePort();
auto prompt = QString("You are about to launch \n\n%1\n\non remote host %2:%3. "
"Are you sure to continue?").arg(QString::fromStdString(m_controller->GetExecutablePath()))
.arg(remoteHost).arg(remotePort);
if (QMessageBox::question(this, "Launch Target", prompt) != QMessageBox::Yes)
return;
}
auto data = m_controller->GetData();
if (!data->GetDefaultPlatform())
{
// No default platform, prompt user to choose one
PlatformDialog dlg(this);
if (dlg.exec() != QDialog::Accepted)
{
QMessageBox::warning(this, "No Platform", "The debugger cannot work if the binary view has no "
"platform and architecture");
return;
}
auto platform = dlg.getPlatform();
if (platform)
{
dlg.saveDefaults();
}
else
{
QMessageBox::warning(this, "Invalid Platform", "The debugger cannot work if the binary view has no "
"platform and architecture");
return;
}
data->SetDefaultArchitecture(platform->GetArchitecture());
data->SetDefaultPlatform(platform);
}
QString text = QString(
"The debugger is %1 the target and preparing the debugger binary view. \n"
"This might take a while.").arg("launching");
ProgressTask* task =
new ProgressTask(this, "Launching", text, "", [this](ProgressFunction progress) {
m_controller->Launch();
// For now, this cant be canceled, as the Debugger model wasn't
// designed with that in mind. This function below can return false if canceling is enabled
progress(1, 1);
return;
});
task->wait();
}
void DebugControlsWidget::performAttachPID()
{
// We do not show the adapter settings dialog during "attach to PID" since:
// 1. We will show another dialog to select the PID from
// 2. There is probably no settings for the "attach to PID" operation
AttachProcessDialog dialog(this, m_controller);
if (dialog.exec() != QDialog::Accepted)
return;
uint32_t pid = dialog.GetSelectedPid();
if (pid == 0)
return;
auto data = m_controller->GetData();
if (!data->GetDefaultPlatform())
{
// No default platform, prompt user to choose one
PlatformDialog dlg(this);
if (dlg.exec() != QDialog::Accepted)
{
QMessageBox::warning(this, "No Platform", "The debugger cannot work if the binary view has no "
"platform and architecture");
return;
}
auto platform = dlg.getPlatform();
if (platform)
{
dlg.saveDefaults();
}
else
{
QMessageBox::warning(this, "Invalid Platform", "The debugger cannot work if the binary view has no "
"platform and architecture");
return;
}
data->SetDefaultArchitecture(platform->GetArchitecture());
data->SetDefaultPlatform(platform);
}
m_controller->SetPIDAttach(pid);
QString text = QString(
"The debugger is %1 the target and preparing the debugger binary view. \n"
"This might take a while.").arg("attaching to");
ProgressTask* task =
new ProgressTask(this, "Attaching", text, "", [this](ProgressFunction progress) {
m_controller->Attach();
// For now, this cant be canceled, as the Debugger model wasn't
// designed with that in mind. This function below can return false if canceling is enabled
progress(1, 1);
return;
});
task->wait();
}
void DebugControlsWidget::performRestart()
{
// Restart/Quit/Detach/Pause return immediately: they signal the interrupt thread and
// queue the work onto the controller's worker thread, so no spawned UI-side thread is
// needed (same as performResume/performStepInto below).
m_controller->Restart();
}
void DebugControlsWidget::performQuit()
{
m_controller->Quit();
}
void DebugControlsWidget::performDetach()
{
m_controller->Detach();
}
void DebugControlsWidget::performPause()
{
m_controller->Pause();
}
void DebugControlsWidget::performResume()
{
m_controller->Go();
}
void DebugControlsWidget::performGoReverse()
{
m_controller->GoReverse();
}
void DebugControlsWidget::performStepInto()
{
BNFunctionGraphType graphType = NormalFunctionGraph;
UIContext* context = UIContext::contextForWidget(this);
if (context && context->getCurrentView())
graphType = context->getCurrentView()->getILViewType().type;
if (graphType == InvalidILViewType)
graphType = NormalFunctionGraph;
m_controller->StepInto(graphType);
}
void DebugControlsWidget::performStepIntoReverse()
{
BNFunctionGraphType graphType = NormalFunctionGraph;
UIContext* context = UIContext::contextForWidget(this);
if (context && context->getCurrentView())
graphType = context->getCurrentView()->getILViewType().type;
if (graphType == InvalidILViewType)
graphType = NormalFunctionGraph;
m_controller->StepIntoReverse(graphType);
}
void DebugControlsWidget::performStepOver()
{
BNFunctionGraphType graphType = NormalFunctionGraph;
UIContext* context = UIContext::contextForWidget(this);
if (context && context->getCurrentView())
graphType = context->getCurrentView()->getILViewType().type;
if (graphType == InvalidILViewType)
graphType = NormalFunctionGraph;
m_controller->StepOver(graphType);
}
void DebugControlsWidget::performStepOverReverse()
{
BNFunctionGraphType graphType = NormalFunctionGraph;
UIContext* context = UIContext::contextForWidget(this);
if (context && context->getCurrentView())
graphType = context->getCurrentView()->getILViewType().type;
if (graphType == InvalidILViewType)
graphType = NormalFunctionGraph;
m_controller->StepOverReverse(graphType);
}
void DebugControlsWidget::performStepReturn()
{
m_controller->StepReturn();
}
void DebugControlsWidget::performStepReturnReverse()
{
m_controller->StepReturnReverse();
}
void DebugControlsWidget::performSettings()
{
auto* dialog = new AdapterSettingsDialog(this, m_controller);
dialog->show();
}
void DebugControlsWidget::toggleBreakpoint()
{
UIContext* context = UIContext::contextForWidget(this);
if (!context)
return;
View* view = context->getCurrentView();
if (!view)
return;
auto addr = view->getCurrentOffset();
bool isAbsoluteAddress = false;
if (m_controller->IsConnected())
isAbsoluteAddress = true;
if (isAbsoluteAddress)
{
if (m_controller->ContainsBreakpoint(addr))
{
m_controller->DeleteBreakpoint(addr);
}
else
{
m_controller->AddBreakpoint(addr);
}
}
else
{
std::string filename = m_controller->GetInputFile();
uint64_t offset = addr - m_controller->GetViewFileSegmentsStart();
ModuleNameAndOffset info = {filename, offset};
if (m_controller->ContainsBreakpoint(info))
{
m_controller->DeleteBreakpoint(info);
}
else
{
m_controller->AddBreakpoint(info);
}
}
}
bool DebugControlsWidget::canExec()
{
auto currentAdapter = m_controller->GetAdapterType();
if (currentAdapter == "")
return false;
auto adapter = DebugAdapterType::GetByName(currentAdapter);
if (!adapter)
return false;
return adapter->CanExecute(m_controller->GetData());
}
bool DebugControlsWidget::canConnect()
{
auto currentAdapter = m_controller->GetAdapterType();
if (currentAdapter == "")
return false;
auto adapter = DebugAdapterType::GetByName(currentAdapter);
if (!adapter)
return false;
return adapter->CanConnect(m_controller->GetData());
}
void DebugControlsWidget::setStartingEnabled(bool enabled)
{
m_actionRun->setEnabled(enabled && canExec());
// TODO: we need to support specifying whether the adapter supports attaching to a pid
m_actionAttachPid->setEnabled(enabled && canExec());
m_actionAttachPid->setVisible(enabled);
}
void DebugControlsWidget::setStoppingEnabled(bool enabled)
{
m_actionRestart->setEnabled(enabled);
m_actionQuit->setEnabled(enabled);
m_actionDetach->setEnabled(enabled);
m_actionDetach->setVisible(enabled);
}
void DebugControlsWidget::setSteppingEnabled(bool enabled)
{
m_actionStepInto->setEnabled(enabled);
m_actionStepOver->setEnabled(enabled);
m_actionStepReturn->setEnabled(enabled);
}
void DebugControlsWidget::setReverseSteppingEnabled(bool enabled)
{
m_actionStepIntoBack->setEnabled(enabled);
m_actionStepIntoBack->setVisible(enabled);
m_actionStepOverBack->setEnabled(enabled);
m_actionStepOverBack->setVisible(enabled);
m_actionStepReturnBack->setEnabled(enabled);
m_actionStepReturnBack->setVisible(enabled);
m_actionTimestampNavigation->setEnabled(enabled);
m_actionTimestampNavigation->setVisible(enabled);
}
void DebugControlsWidget::updateButtons()
{
this->setIconSize(QSize(20, 20));
DebugAdapterConnectionStatus connection = m_controller->GetConnectionStatus();
DebugAdapterTargetStatus status = m_controller->GetTargetStatus();
bool isTTD = m_controller->IsTTD();
if (connection == DebugAdapterNotConnectedStatus)
{
setStartingEnabled(true);
setStoppingEnabled(false);
setSteppingEnabled(false);
setReverseSteppingEnabled(false);
m_actionPause->setEnabled(false);
m_actionResume->setEnabled(false);
m_actionGoBack->setEnabled(false);
m_actionRun->setVisible(true);
m_actionPause->setVisible(false);
m_actionResume->setVisible(false);
m_actionGoBack->setVisible(false);
m_actionTTDNavigateBack->setVisible(false);
m_actionTTDNavigateForward->setVisible(false);
}
else if (status == DebugAdapterRunningStatus)
{
setStartingEnabled(false);
setStoppingEnabled(true);
setSteppingEnabled(false);
setReverseSteppingEnabled(false);
m_actionStepIntoBack->setVisible(isTTD);
m_actionStepOverBack->setVisible(isTTD);
m_actionPause->setEnabled(true);
m_actionResume->setEnabled(false);
m_actionGoBack->setEnabled(false);
m_actionRun->setVisible(false);
m_actionPause->setVisible(true);
m_actionResume->setVisible(false);
m_actionGoBack->setVisible(false);
m_actionTTDNavigateBack->setVisible(isTTD);
m_actionTTDNavigateBack->setEnabled(false);
m_actionTTDNavigateForward->setVisible(isTTD);
m_actionTTDNavigateForward->setEnabled(false);
}
else // status == DebugAdapterPausedStatus
{
setStartingEnabled(false);
setStoppingEnabled(true);
setSteppingEnabled(true);
setReverseSteppingEnabled(isTTD);
m_actionPause->setEnabled(false);
m_actionResume->setEnabled(true);
m_actionGoBack->setEnabled(isTTD);
m_actionRun->setVisible(false);
m_actionPause->setVisible(false);
m_actionResume->setVisible(true);
m_actionGoBack->setVisible(isTTD);
m_actionTTDNavigateBack->setVisible(isTTD);
m_actionTTDNavigateBack->setEnabled(m_controller->CanTTDNavigateBack());
m_actionTTDNavigateForward->setVisible(isTTD);
m_actionTTDNavigateForward->setEnabled(m_controller->CanTTDNavigateForward());
}
}
void DebugControlsWidget::performTimestampNavigation()
{
if (!m_controller->IsTTD())
{
QMessageBox::warning(this, "Error", "Time travel debugging is not active.");
return;
}
auto* dialog = new TimestampNavigationDialog(this, m_controller);
dialog->show();
}
void DebugControlsWidget::performTTDNavigateBack()
{
if (!m_controller->CanTTDNavigateBack())
return;
m_controller->TTDNavigateBack();
}
void DebugControlsWidget::performTTDNavigateForward()
{
if (!m_controller->CanTTDNavigateForward())
return;
m_controller->TTDNavigateForward();
}