Capture memory regions in snapshots

This commit is contained in:
Nav
2023-03-27 21:32:44 +01:00
parent 2fad19f533
commit dcb723b8ce
4 changed files with 55 additions and 3 deletions

View File

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

View File

@@ -21,6 +21,8 @@ namespace Bloom::Widgets
const Targets::TargetMemoryDescriptor& memoryDescriptor,
const std::optional<Targets::TargetMemoryBuffer>& data,
const bool& staleData,
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
const std::vector<ExcludedMemoryRegion>& 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<FocusedMemoryRegion>(),
this->excludedMemoryRegions,
captureDirectlyFromTarget ? std::nullopt : this->data
),
&QObject::deleteLater

View File

@@ -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<Targets::TargetMemoryBuffer>& data,
const bool& staleData,
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions,
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions,
PaneState& state,
PanelWidget* parent = nullptr
);
@@ -49,6 +53,9 @@ namespace Bloom::Widgets
const std::optional<Targets::TargetMemoryBuffer>& data;
const bool& staleData;
const std::vector<FocusedMemoryRegion>& focusedMemoryRegions;
const std::vector<ExcludedMemoryRegion>& excludedMemoryRegions;
QHash<QString, MemorySnapshot> snapshotsById;
QHash<QString, MemorySnapshotItem*> snapshotItemsById;

View File

@@ -124,6 +124,8 @@ namespace Bloom::Widgets
this->targetMemoryDescriptor,
this->data,
this->staleData,
this->settings.focusedMemoryRegions,
this->settings.excludedMemoryRegions,
this->settings.snapshotManagerState,
this->rightPanel
);