Implemented "Compare with Current" action in snapshot manager
This commit is contained in:
@@ -50,6 +50,38 @@ namespace Bloom::Widgets
|
|||||||
this->dataBSecondaryLabel->setText(snapshotB.createdDate.toString("dd/MM/yyyy hh:mm"));
|
this->dataBSecondaryLabel->setText(snapshotB.createdDate.toString("dd/MM/yyyy hh:mm"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SnapshotDiff::SnapshotDiff(
|
||||||
|
MemorySnapshot& snapshotA,
|
||||||
|
Targets::TargetMemoryBuffer dataB,
|
||||||
|
std::vector<FocusedMemoryRegion> focusedRegionsB,
|
||||||
|
std::vector<ExcludedMemoryRegion> excludedRegionsB,
|
||||||
|
Targets::TargetStackPointer stackPointerB,
|
||||||
|
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||||
|
QWidget* parent
|
||||||
|
)
|
||||||
|
: QWidget(parent)
|
||||||
|
, memoryDescriptor(memoryDescriptor)
|
||||||
|
, hexViewerDataA(snapshotA.data)
|
||||||
|
, focusedRegionsA(snapshotA.focusedRegions)
|
||||||
|
, excludedRegionsA(snapshotA.excludedRegions)
|
||||||
|
, stackPointerA(snapshotA.stackPointer)
|
||||||
|
, hexViewerDataB(dataB)
|
||||||
|
, focusedRegionsB(focusedRegionsB)
|
||||||
|
, excludedRegionsB(excludedRegionsB)
|
||||||
|
, stackPointerB(stackPointerB)
|
||||||
|
{
|
||||||
|
this->init();
|
||||||
|
|
||||||
|
this->setWindowTitle(
|
||||||
|
"Comparing snapshot \"" + snapshotA.name + "\" with current memory"
|
||||||
|
);
|
||||||
|
|
||||||
|
this->dataAPrimaryLabel->setText(snapshotA.name);
|
||||||
|
this->dataBPrimaryLabel->setText("Current");
|
||||||
|
this->dataASecondaryLabel->setText(snapshotA.createdDate.toString("dd/MM/yyyy hh:mm"));
|
||||||
|
this->dataBSecondaryLabel->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
void SnapshotDiff::showEvent(QShowEvent* event) {
|
void SnapshotDiff::showEvent(QShowEvent* event) {
|
||||||
QWidget::showEvent(event);
|
QWidget::showEvent(event);
|
||||||
}
|
}
|
||||||
@@ -206,16 +238,16 @@ namespace Bloom::Widgets
|
|||||||
this->hexViewerWidgetB->setOther(this->hexViewerWidgetA);
|
this->hexViewerWidgetB->setOther(this->hexViewerWidgetA);
|
||||||
|
|
||||||
// this->hexViewerWidgetA->addExternalContextMenuAction(this->restoreBytesAction);
|
// this->hexViewerWidgetA->addExternalContextMenuAction(this->restoreBytesAction);
|
||||||
if (this->stackPointerA.has_value()) {
|
if (this->memoryDescriptor.type == Targets::TargetMemoryType::RAM) {
|
||||||
this->hexViewerWidgetA->setStackPointer(*(this->stackPointerA));
|
this->hexViewerWidgetA->setStackPointer(this->stackPointerA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapshotDiff::onHexViewerBReady() {
|
void SnapshotDiff::onHexViewerBReady() {
|
||||||
this->hexViewerWidgetA->setOther(this->hexViewerWidgetB);
|
this->hexViewerWidgetA->setOther(this->hexViewerWidgetB);
|
||||||
|
|
||||||
if (this->stackPointerB.has_value()) {
|
if (this->memoryDescriptor.type == Targets::TargetMemoryType::RAM) {
|
||||||
this->hexViewerWidgetB->setStackPointer(*(this->stackPointerB));
|
this->hexViewerWidgetB->setStackPointer(this->stackPointerB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,16 @@ namespace Bloom::Widgets
|
|||||||
QWidget* parent = nullptr
|
QWidget* parent = nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
|
SnapshotDiff(
|
||||||
|
MemorySnapshot& snapshotA,
|
||||||
|
Targets::TargetMemoryBuffer dataB,
|
||||||
|
std::vector<FocusedMemoryRegion> focusedRegionsB,
|
||||||
|
std::vector<ExcludedMemoryRegion> excludedRegionsB,
|
||||||
|
Targets::TargetStackPointer stackPointerB,
|
||||||
|
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||||
|
QWidget* parent = nullptr
|
||||||
|
);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent* event) override;
|
void showEvent(QShowEvent* event) override;
|
||||||
void resizeEvent(QResizeEvent* event) override;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
@@ -65,14 +75,14 @@ namespace Bloom::Widgets
|
|||||||
std::optional<Targets::TargetMemoryBuffer> hexViewerDataA;
|
std::optional<Targets::TargetMemoryBuffer> hexViewerDataA;
|
||||||
std::vector<FocusedMemoryRegion> focusedRegionsA;
|
std::vector<FocusedMemoryRegion> focusedRegionsA;
|
||||||
std::vector<ExcludedMemoryRegion> excludedRegionsA;
|
std::vector<ExcludedMemoryRegion> excludedRegionsA;
|
||||||
std::optional<Targets::TargetStackPointer> stackPointerA;
|
Targets::TargetStackPointer stackPointerA;
|
||||||
DifferentialHexViewerWidget* hexViewerWidgetA = nullptr;
|
DifferentialHexViewerWidget* hexViewerWidgetA = nullptr;
|
||||||
HexViewerWidgetSettings hexViewerWidgetSettingsA = HexViewerWidgetSettings();
|
HexViewerWidgetSettings hexViewerWidgetSettingsA = HexViewerWidgetSettings();
|
||||||
|
|
||||||
std::optional<Targets::TargetMemoryBuffer> hexViewerDataB;
|
std::optional<Targets::TargetMemoryBuffer> hexViewerDataB;
|
||||||
std::vector<FocusedMemoryRegion> focusedRegionsB;
|
std::vector<FocusedMemoryRegion> focusedRegionsB;
|
||||||
std::vector<ExcludedMemoryRegion> excludedRegionsB;
|
std::vector<ExcludedMemoryRegion> excludedRegionsB;
|
||||||
std::optional<Targets::TargetStackPointer> stackPointerB;
|
Targets::TargetStackPointer stackPointerB;
|
||||||
DifferentialHexViewerWidget* hexViewerWidgetB = nullptr;
|
DifferentialHexViewerWidget* hexViewerWidgetB = nullptr;
|
||||||
HexViewerWidgetSettings hexViewerWidgetSettingsB = HexViewerWidgetSettings();
|
HexViewerWidgetSettings hexViewerWidgetSettingsB = HexViewerWidgetSettings();
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace Bloom::Widgets
|
|||||||
const bool& staleData,
|
const bool& staleData,
|
||||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||||
|
const std::optional<Targets::TargetStackPointer>& stackPointer,
|
||||||
PaneState& state,
|
PaneState& state,
|
||||||
PanelWidget* parent
|
PanelWidget* parent
|
||||||
)
|
)
|
||||||
@@ -36,6 +37,7 @@ namespace Bloom::Widgets
|
|||||||
, staleData(staleData)
|
, staleData(staleData)
|
||||||
, focusedMemoryRegions(focusedMemoryRegions)
|
, focusedMemoryRegions(focusedMemoryRegions)
|
||||||
, excludedMemoryRegions(excludedMemoryRegions)
|
, excludedMemoryRegions(excludedMemoryRegions)
|
||||||
|
, stackPointer(stackPointer)
|
||||||
{
|
{
|
||||||
this->setObjectName("snapshot-manager");
|
this->setObjectName("snapshot-manager");
|
||||||
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
@@ -158,6 +160,19 @@ namespace Bloom::Widgets
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
this->openSnapshotCurrentDiffAction,
|
||||||
|
&QAction::triggered,
|
||||||
|
this,
|
||||||
|
[this] {
|
||||||
|
if (this->selectedSnapshotItems.size() != 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->openSnapshotCurrentDiff(this->selectedSnapshotItems.front()->memorySnapshot.id);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
this->deleteSnapshotAction,
|
this->deleteSnapshotAction,
|
||||||
&QAction::triggered,
|
&QAction::triggered,
|
||||||
@@ -340,6 +355,40 @@ namespace Bloom::Widgets
|
|||||||
snapshotDiff->activateWindow();
|
snapshotDiff->activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SnapshotManager::openSnapshotCurrentDiff(const QString& snapshotIdA) {
|
||||||
|
if (!this->data.has_value()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto diffKey = snapshotIdA;
|
||||||
|
auto snapshotDiffIt = this->snapshotDiffs.find(diffKey);
|
||||||
|
|
||||||
|
if (snapshotDiffIt == this->snapshotDiffs.end()) {
|
||||||
|
const auto& snapshotItA = this->snapshotsById.find(snapshotIdA);
|
||||||
|
|
||||||
|
if (snapshotItA == this->snapshotsById.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshotDiffIt = this->snapshotDiffs.insert(
|
||||||
|
diffKey,
|
||||||
|
new SnapshotDiff(
|
||||||
|
snapshotItA.value(),
|
||||||
|
*(this->data),
|
||||||
|
this->focusedMemoryRegions,
|
||||||
|
this->excludedMemoryRegions,
|
||||||
|
this->stackPointer.value_or(0),
|
||||||
|
this->memoryDescriptor,
|
||||||
|
this
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* snapshotDiff = snapshotDiffIt.value();
|
||||||
|
snapshotDiff->show();
|
||||||
|
snapshotDiff->activateWindow();
|
||||||
|
}
|
||||||
|
|
||||||
void SnapshotManager::deleteSnapshot(const QString& snapshotId, bool confirmationPromptEnabled) {
|
void SnapshotManager::deleteSnapshot(const QString& snapshotId, bool confirmationPromptEnabled) {
|
||||||
const auto& snapshotIt = this->snapshotsById.find(snapshotId);
|
const auto& snapshotIt = this->snapshotsById.find(snapshotId);
|
||||||
|
|
||||||
@@ -529,10 +578,16 @@ namespace Bloom::Widgets
|
|||||||
menu->addAction(this->openSnapshotViewerAction);
|
menu->addAction(this->openSnapshotViewerAction);
|
||||||
menu->addAction(this->deleteSnapshotAction);
|
menu->addAction(this->deleteSnapshotAction);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
menu->addAction(this->openSnapshotCurrentDiffAction);
|
||||||
|
menu->addSeparator();
|
||||||
menu->addAction(this->restoreSnapshotAction);
|
menu->addAction(this->restoreSnapshotAction);
|
||||||
|
|
||||||
this->openSnapshotViewerAction->setEnabled(this->selectedSnapshotItems.size() == 1);
|
this->openSnapshotViewerAction->setEnabled(this->selectedSnapshotItems.size() == 1);
|
||||||
this->deleteSnapshotAction->setEnabled(this->selectedSnapshotItems.size() == 1);
|
this->deleteSnapshotAction->setEnabled(this->selectedSnapshotItems.size() == 1);
|
||||||
|
this->openSnapshotCurrentDiffAction->setEnabled(
|
||||||
|
this->selectedSnapshotItems.size() == 1
|
||||||
|
&& this->data.has_value()
|
||||||
|
);
|
||||||
this->restoreSnapshotAction->setEnabled(
|
this->restoreSnapshotAction->setEnabled(
|
||||||
this->selectedSnapshotItems.size() == 1 && this->targetState == Targets::TargetState::STOPPED
|
this->selectedSnapshotItems.size() == 1 && this->targetState == Targets::TargetState::STOPPED
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ namespace Bloom::Widgets
|
|||||||
const bool& staleData,
|
const bool& staleData,
|
||||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
|
||||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
|
||||||
|
const std::optional<Targets::TargetStackPointer>& stackPointer,
|
||||||
PaneState& state,
|
PaneState& state,
|
||||||
PanelWidget* parent = nullptr
|
PanelWidget* parent = nullptr
|
||||||
);
|
);
|
||||||
@@ -60,6 +61,7 @@ namespace Bloom::Widgets
|
|||||||
|
|
||||||
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions;
|
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions;
|
||||||
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
|
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
|
||||||
|
const std::optional<Targets::TargetStackPointer>& stackPointer;
|
||||||
|
|
||||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||||
|
|
||||||
@@ -81,6 +83,7 @@ namespace Bloom::Widgets
|
|||||||
|
|
||||||
QAction* openSnapshotViewerAction = new QAction("Open", this);
|
QAction* openSnapshotViewerAction = new QAction("Open", this);
|
||||||
QAction* openSnapshotDiffAction = new QAction("Compare Selection", this);
|
QAction* openSnapshotDiffAction = new QAction("Compare Selection", this);
|
||||||
|
QAction* openSnapshotCurrentDiffAction = new QAction("Compare with Current", this);
|
||||||
QAction* deleteSnapshotAction = new QAction("Delete", this);
|
QAction* deleteSnapshotAction = new QAction("Delete", this);
|
||||||
QAction* restoreSnapshotAction = new QAction("Restore", this);
|
QAction* restoreSnapshotAction = new QAction("Restore", this);
|
||||||
|
|
||||||
@@ -95,6 +98,7 @@ namespace Bloom::Widgets
|
|||||||
void onSnapshotItemSelectionChanged(const std::list<ListItem*>& selectedItems);
|
void onSnapshotItemSelectionChanged(const std::list<ListItem*>& selectedItems);
|
||||||
void openSnapshotViewer(const QString& snapshotId);
|
void openSnapshotViewer(const QString& snapshotId);
|
||||||
void openSnapshotDiff(const QString& snapshotIdA, const QString& snapshotIdB);
|
void openSnapshotDiff(const QString& snapshotIdA, const QString& snapshotIdB);
|
||||||
|
void openSnapshotCurrentDiff(const QString& snapshotIdA);
|
||||||
void deleteSnapshot(const QString& snapshotId, bool confirmationPromptEnabled);
|
void deleteSnapshot(const QString& snapshotId, bool confirmationPromptEnabled);
|
||||||
void restoreSnapshot(const QString& snapshotId, bool confirmationPromptEnabled);
|
void restoreSnapshot(const QString& snapshotId, bool confirmationPromptEnabled);
|
||||||
void onSnapshotItemDoubleClick(MemorySnapshotItem* item);
|
void onSnapshotItemDoubleClick(MemorySnapshotItem* item);
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ namespace Bloom::Widgets
|
|||||||
this->staleData,
|
this->staleData,
|
||||||
this->settings.focusedMemoryRegions,
|
this->settings.focusedMemoryRegions,
|
||||||
this->settings.excludedMemoryRegions,
|
this->settings.excludedMemoryRegions,
|
||||||
|
this->stackPointer,
|
||||||
this->settings.snapshotManagerState,
|
this->settings.snapshotManagerState,
|
||||||
this->rightPanel
|
this->rightPanel
|
||||||
);
|
);
|
||||||
@@ -350,6 +351,7 @@ namespace Bloom::Widgets
|
|||||||
&ReadStackPointer::stackPointerRead,
|
&ReadStackPointer::stackPointerRead,
|
||||||
this,
|
this,
|
||||||
[this] (Targets::TargetStackPointer stackPointer) {
|
[this] (Targets::TargetStackPointer stackPointer) {
|
||||||
|
this->stackPointer = stackPointer;
|
||||||
this->hexViewerWidget->setStackPointer(stackPointer);
|
this->hexViewerWidget->setStackPointer(stackPointer);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ namespace Bloom::Widgets
|
|||||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor;
|
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor;
|
||||||
|
|
||||||
std::optional<Targets::TargetMemoryBuffer> data;
|
std::optional<Targets::TargetMemoryBuffer> data;
|
||||||
|
std::optional<Targets::TargetStackPointer> stackPointer;
|
||||||
std::optional<QSharedPointer<ReadTargetMemory>> activeRefreshTask;
|
std::optional<QSharedPointer<ReadTargetMemory>> activeRefreshTask;
|
||||||
|
|
||||||
QWidget* container = nullptr;
|
QWidget* container = nullptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user