Persisting TargetMemoryInspectionPane settings (including memory regions) through debug sessions

This commit is contained in:
Nav
2021-12-25 01:46:47 +00:00
parent 844c7e78ae
commit 45c6470548
6 changed files with 85 additions and 12 deletions

View File

@@ -465,6 +465,9 @@ void InsightWindow::createPanes() {
auto& ramDescriptor = this->targetDescriptor.memoryDescriptorsByType.at(TargetMemoryType::RAM); auto& ramDescriptor = this->targetDescriptor.memoryDescriptorsByType.at(TargetMemoryType::RAM);
this->ramInspectionPane = new TargetMemoryInspectionPane( this->ramInspectionPane = new TargetMemoryInspectionPane(
ramDescriptor, ramDescriptor,
this->memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::RAM) ?
this->memoryInspectionPaneSettingsByMemoryType.at(TargetMemoryType::RAM)
: TargetMemoryInspectionPaneSettings(),
this->insightWorker, this->insightWorker,
this->bottomPanel this->bottomPanel
); );
@@ -478,6 +481,9 @@ void InsightWindow::createPanes() {
auto& eepromDescriptor = this->targetDescriptor.memoryDescriptorsByType.at(TargetMemoryType::EEPROM); auto& eepromDescriptor = this->targetDescriptor.memoryDescriptorsByType.at(TargetMemoryType::EEPROM);
this->eepromInspectionPane = new TargetMemoryInspectionPane( this->eepromInspectionPane = new TargetMemoryInspectionPane(
eepromDescriptor, eepromDescriptor,
this->memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::EEPROM) ?
this->memoryInspectionPaneSettingsByMemoryType.at(TargetMemoryType::EEPROM)
: TargetMemoryInspectionPaneSettings(),
this->insightWorker, this->insightWorker,
this->bottomPanel this->bottomPanel
); );
@@ -497,7 +503,13 @@ void InsightWindow::destroyPanes() {
this->targetRegistersButton->setDisabled(true); this->targetRegistersButton->setDisabled(true);
} }
/*
* Before we destroy the memory inspection pane widgets, we take a copy of their current settings (memory regions,
* hex viewer settings, etc), in order to persist them through debug sessions.
*/
if (this->ramInspectionPane != nullptr) { if (this->ramInspectionPane != nullptr) {
this->memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::RAM] = this->ramInspectionPane->settings;
this->ramInspectionPane->deactivate(); this->ramInspectionPane->deactivate();
this->ramInspectionPane->deleteLater(); this->ramInspectionPane->deleteLater();
this->ramInspectionPane = nullptr; this->ramInspectionPane = nullptr;
@@ -508,6 +520,8 @@ void InsightWindow::destroyPanes() {
} }
if (this->eepromInspectionPane != nullptr) { if (this->eepromInspectionPane != nullptr) {
this->memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::EEPROM] = this->eepromInspectionPane->settings;
this->eepromInspectionPane->deactivate(); this->eepromInspectionPane->deactivate();
this->eepromInspectionPane->deleteLater(); this->eepromInspectionPane->deleteLater();
this->eepromInspectionPane = nullptr; this->eepromInspectionPane = nullptr;

View File

@@ -20,6 +20,7 @@
#include "Widgets/TargetWidgets/TargetPackageWidget.hpp" #include "Widgets/TargetWidgets/TargetPackageWidget.hpp"
#include "Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp" #include "Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp"
#include "Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp" #include "Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp"
#include "Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPaneSettings.hpp"
#include "AboutWindow.hpp" #include "AboutWindow.hpp"
namespace Bloom namespace Bloom
@@ -83,6 +84,10 @@ namespace Bloom
Widgets::PanelWidget* bottomPanel = nullptr; Widgets::PanelWidget* bottomPanel = nullptr;
Widgets::TargetMemoryInspectionPane* ramInspectionPane = nullptr; Widgets::TargetMemoryInspectionPane* ramInspectionPane = nullptr;
Widgets::TargetMemoryInspectionPane* eepromInspectionPane = nullptr; Widgets::TargetMemoryInspectionPane* eepromInspectionPane = nullptr;
std::map<
Targets::TargetMemoryType,
Widgets::TargetMemoryInspectionPaneSettings
> memoryInspectionPaneSettingsByMemoryType;
QToolButton* ramInspectionButton = nullptr; QToolButton* ramInspectionButton = nullptr;
QToolButton* eepromInspectionButton = nullptr; QToolButton* eepromInspectionButton = nullptr;

View File

@@ -29,7 +29,7 @@ namespace Bloom
QString name; QString name;
QDateTime createdDate = DateTime::currentDateTime(); QDateTime createdDate = DateTime::currentDateTime();
MemoryRegionType type; MemoryRegionType type;
const Targets::TargetMemoryDescriptor& memoryDescriptor; Targets::TargetMemoryDescriptor memoryDescriptor;
Targets::TargetMemoryAddressRange addressRange; Targets::TargetMemoryAddressRange addressRange;
MemoryRegionAddressType addressRangeType = MemoryRegionAddressType::ABSOLUTE; MemoryRegionAddressType addressRangeType = MemoryRegionAddressType::ABSOLUTE;

View File

@@ -20,9 +20,16 @@ using Bloom::Targets::TargetMemoryType;
TargetMemoryInspectionPane::TargetMemoryInspectionPane( TargetMemoryInspectionPane::TargetMemoryInspectionPane(
const TargetMemoryDescriptor& targetMemoryDescriptor, const TargetMemoryDescriptor& targetMemoryDescriptor,
const TargetMemoryInspectionPaneSettings& settings,
InsightWorker& insightWorker, InsightWorker& insightWorker,
PanelWidget* parent PanelWidget* parent
): QWidget(parent), parent(parent), targetMemoryDescriptor(targetMemoryDescriptor), insightWorker(insightWorker) { ):
QWidget(parent),
targetMemoryDescriptor(targetMemoryDescriptor),
settings(settings),
insightWorker(insightWorker),
parent(parent)
{
this->setObjectName("target-memory-inspection-pane"); this->setObjectName("target-memory-inspection-pane");
auto memoryInspectionPaneUiFile = QFile( auto memoryInspectionPaneUiFile = QFile(
@@ -47,12 +54,15 @@ TargetMemoryInspectionPane::TargetMemoryInspectionPane(
this->targetMemoryDescriptor.type == TargetMemoryType::EEPROM ? "Internal EEPROM" : "Internal RAM" this->targetMemoryDescriptor.type == TargetMemoryType::EEPROM ? "Internal EEPROM" : "Internal RAM"
); );
// Quick sanity check to ensure the validity of persisted settings.
this->sanitiseSettings();
auto* subContainerLayout = this->container->findChild<QHBoxLayout*>("sub-container-layout"); auto* subContainerLayout = this->container->findChild<QHBoxLayout*>("sub-container-layout");
this->manageMemoryRegionsButton = this->container->findChild<SvgToolButton*>("manage-memory-regions-btn"); this->manageMemoryRegionsButton = this->container->findChild<SvgToolButton*>("manage-memory-regions-btn");
this->hexViewerWidget = new HexViewerWidget( this->hexViewerWidget = new HexViewerWidget(
this->targetMemoryDescriptor, this->targetMemoryDescriptor,
this->focusedMemoryRegions, this->settings.focusedMemoryRegions,
this->excludedMemoryRegions, this->settings.excludedMemoryRegions,
this->insightWorker, this->insightWorker,
this this
); );
@@ -167,6 +177,31 @@ void TargetMemoryInspectionPane::postDeactivate() {
} }
void TargetMemoryInspectionPane::sanitiseSettings() {
// Remove any invalid memory regions. It's very unlikely that there will be any, but not impossible.
this->settings.focusedMemoryRegions.erase(
std::remove_if(
this->settings.focusedMemoryRegions.begin(),
this->settings.focusedMemoryRegions.end(),
[this] (const FocusedMemoryRegion& region) {
return region.memoryDescriptor != this->targetMemoryDescriptor;
}
),
this->settings.focusedMemoryRegions.end()
);
this->settings.excludedMemoryRegions.erase(
std::remove_if(
this->settings.excludedMemoryRegions.begin(),
this->settings.excludedMemoryRegions.end(),
[this] (const ExcludedMemoryRegion& region) {
return region.memoryDescriptor != this->targetMemoryDescriptor;
}
),
this->settings.excludedMemoryRegions.end()
);
}
void TargetMemoryInspectionPane::onTargetStateChanged(Targets::TargetState newState) { void TargetMemoryInspectionPane::onTargetStateChanged(Targets::TargetState newState) {
using Targets::TargetState; using Targets::TargetState;
this->targetState = newState; this->targetState = newState;
@@ -189,9 +224,10 @@ void TargetMemoryInspectionPane::openMemoryRegionManagerWindow() {
if (this->memoryRegionManagerWindow == nullptr) { if (this->memoryRegionManagerWindow == nullptr) {
this->memoryRegionManagerWindow = new MemoryRegionManagerWindow( this->memoryRegionManagerWindow = new MemoryRegionManagerWindow(
this->targetMemoryDescriptor, this->targetMemoryDescriptor,
this->focusedMemoryRegions, this->settings.focusedMemoryRegions,
this->excludedMemoryRegions, this->settings.excludedMemoryRegions,
this this
); );
QObject::connect( QObject::connect(

View File

@@ -13,11 +13,9 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp" #include "src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp"
#include "HexViewerWidget/HexViewerWidget.hpp" #include "HexViewerWidget/HexViewerWidget.hpp"
#include "MemoryRegionManager/MemoryRegionManagerWindow.hpp" #include "MemoryRegionManager/MemoryRegionManagerWindow.hpp"
#include "MemoryRegion.hpp"
#include "FocusedMemoryRegion.hpp" #include "TargetMemoryInspectionPaneSettings.hpp"
#include "ExcludedMemoryRegion.hpp"
namespace Bloom::Widgets namespace Bloom::Widgets
{ {
@@ -26,10 +24,12 @@ namespace Bloom::Widgets
Q_OBJECT Q_OBJECT
public: public:
TargetMemoryInspectionPaneSettings settings;
bool activated = false; bool activated = false;
TargetMemoryInspectionPane( TargetMemoryInspectionPane(
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor, const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
const TargetMemoryInspectionPaneSettings& settings,
InsightWorker& insightWorker, InsightWorker& insightWorker,
PanelWidget *parent PanelWidget *parent
); );
@@ -57,10 +57,9 @@ namespace Bloom::Widgets
Targets::TargetState targetState = Targets::TargetState::UNKNOWN; Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
std::vector<FocusedMemoryRegion> focusedMemoryRegions;
std::vector<ExcludedMemoryRegion> excludedMemoryRegions;
MemoryRegionManagerWindow* memoryRegionManagerWindow = nullptr; MemoryRegionManagerWindow* memoryRegionManagerWindow = nullptr;
void sanitiseSettings();
void onTargetStateChanged(Targets::TargetState newState); void onTargetStateChanged(Targets::TargetState newState);
void onMemoryRead(const Targets::TargetMemoryBuffer& buffer); void onMemoryRead(const Targets::TargetMemoryBuffer& buffer);
void openMemoryRegionManagerWindow(); void openMemoryRegionManagerWindow();

View File

@@ -0,0 +1,19 @@
#pragma once
#include <vector>
#include "FocusedMemoryRegion.hpp"
#include "ExcludedMemoryRegion.hpp"
#include "HexViewerWidget/HexViewerWidgetSettings.hpp"
namespace Bloom::Widgets
{
struct TargetMemoryInspectionPaneSettings
{
std::vector<FocusedMemoryRegion> focusedMemoryRegions;
std::vector<ExcludedMemoryRegion> excludedMemoryRegions;
HexViewerWidgetSettings hexViewerWidgetSettings;
};
}