diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.cpp index 521e20c4..07a4cef7 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.cpp @@ -53,7 +53,27 @@ namespace Bloom const auto hexData = QByteArray::fromHex(jsonObject.find("hexData")->toString().toUtf8()); this->data = Targets::TargetMemoryBuffer(hexData.begin(), hexData.end()); - // TODO: Memory regions + if (jsonObject.contains("focusedRegions")) { + for (const auto& regionValue : jsonObject.find("focusedRegions")->toArray()) { + try { + this->focusedRegions.emplace_back(regionValue.toObject()); + + } catch (Exception exception) { + throw Exception("Invalid focused memory region"); + } + } + } + + if (jsonObject.contains("excludedRegions")) { + for (const auto& regionValue : jsonObject.find("excludedRegions")->toArray()) { + try { + this->excludedRegions.emplace_back(regionValue.toObject()); + + } catch (Exception exception) { + throw Exception("Invalid excluded memory region"); + } + } + } } QJsonObject MemorySnapshot::toJson() const { @@ -92,6 +112,25 @@ namespace Bloom return false; } + const auto& memoryAddressRange = memoryDescriptor.addressRange; + for (const auto& focusedRegion : this->focusedRegions) { + if ( + focusedRegion.addressRange.startAddress < memoryAddressRange.startAddress + || focusedRegion.addressRange.endAddress > memoryAddressRange.endAddress + ) { + return false; + } + } + + for (const auto& excludedRegion : this->excludedRegions) { + if ( + excludedRegion.addressRange.startAddress < memoryAddressRange.startAddress + || excludedRegion.addressRange.endAddress > memoryAddressRange.endAddress + ) { + return false; + } + } + return true; } } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.cpp index 99c73cc9..adc86050 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.cpp @@ -21,6 +21,8 @@ namespace Bloom::Widgets const Targets::TargetMemoryDescriptor& memoryDescriptor, const std::optional& data, const bool& staleData, + const std::vector& focusedMemoryRegions, + const std::vector& excludedMemoryRegions, PaneState& state, PanelWidget* parent ) @@ -28,6 +30,8 @@ namespace Bloom::Widgets , memoryDescriptor(memoryDescriptor) , data(data) , staleData(staleData) + , focusedMemoryRegions(focusedMemoryRegions) + , excludedMemoryRegions(excludedMemoryRegions) { this->setObjectName("snapshot-manager"); this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); @@ -146,8 +150,8 @@ namespace Bloom::Widgets std::move(name), std::move(description), this->memoryDescriptor.type, - {}, - {}, + captureFocusedRegions ? this->focusedMemoryRegions : std::vector(), + this->excludedMemoryRegions, captureDirectlyFromTarget ? std::nullopt : this->data ), &QObject::deleteLater diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.hpp index e29f50e0..debacaee 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/SnapshotManager/SnapshotManager.hpp @@ -13,6 +13,8 @@ #include "src/Targets/TargetMemory.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemorySnapshot.hpp" +#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp" +#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/ExcludedMemoryRegion.hpp" #include "src/Insight/InsightWorker/Tasks/CaptureMemorySnapshot.hpp" @@ -33,6 +35,8 @@ namespace Bloom::Widgets const Targets::TargetMemoryDescriptor& memoryDescriptor, const std::optional& data, const bool& staleData, + const std::vector& focusedMemoryRegions, + const std::vector& excludedMemoryRegions, PaneState& state, PanelWidget* parent = nullptr ); @@ -49,6 +53,9 @@ namespace Bloom::Widgets const std::optional& data; const bool& staleData; + const std::vector& focusedMemoryRegions; + const std::vector& excludedMemoryRegions; + QHash snapshotsById; QHash snapshotItemsById; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp index 86d6f117..01ade6a2 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp @@ -124,6 +124,8 @@ namespace Bloom::Widgets this->targetMemoryDescriptor, this->data, this->staleData, + this->settings.focusedMemoryRegions, + this->settings.excludedMemoryRegions, this->settings.snapshotManagerState, this->rightPanel );