Persisting TargetMemoryInspectionPane settings (including memory regions) through debug sessions
This commit is contained in:
@@ -465,6 +465,9 @@ void InsightWindow::createPanes() {
|
||||
auto& ramDescriptor = this->targetDescriptor.memoryDescriptorsByType.at(TargetMemoryType::RAM);
|
||||
this->ramInspectionPane = new TargetMemoryInspectionPane(
|
||||
ramDescriptor,
|
||||
this->memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::RAM) ?
|
||||
this->memoryInspectionPaneSettingsByMemoryType.at(TargetMemoryType::RAM)
|
||||
: TargetMemoryInspectionPaneSettings(),
|
||||
this->insightWorker,
|
||||
this->bottomPanel
|
||||
);
|
||||
@@ -478,6 +481,9 @@ void InsightWindow::createPanes() {
|
||||
auto& eepromDescriptor = this->targetDescriptor.memoryDescriptorsByType.at(TargetMemoryType::EEPROM);
|
||||
this->eepromInspectionPane = new TargetMemoryInspectionPane(
|
||||
eepromDescriptor,
|
||||
this->memoryInspectionPaneSettingsByMemoryType.contains(TargetMemoryType::EEPROM) ?
|
||||
this->memoryInspectionPaneSettingsByMemoryType.at(TargetMemoryType::EEPROM)
|
||||
: TargetMemoryInspectionPaneSettings(),
|
||||
this->insightWorker,
|
||||
this->bottomPanel
|
||||
);
|
||||
@@ -497,7 +503,13 @@ void InsightWindow::destroyPanes() {
|
||||
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) {
|
||||
this->memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::RAM] = this->ramInspectionPane->settings;
|
||||
|
||||
this->ramInspectionPane->deactivate();
|
||||
this->ramInspectionPane->deleteLater();
|
||||
this->ramInspectionPane = nullptr;
|
||||
@@ -508,6 +520,8 @@ void InsightWindow::destroyPanes() {
|
||||
}
|
||||
|
||||
if (this->eepromInspectionPane != nullptr) {
|
||||
this->memoryInspectionPaneSettingsByMemoryType[TargetMemoryType::EEPROM] = this->eepromInspectionPane->settings;
|
||||
|
||||
this->eepromInspectionPane->deactivate();
|
||||
this->eepromInspectionPane->deleteLater();
|
||||
this->eepromInspectionPane = nullptr;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "Widgets/TargetWidgets/TargetPackageWidget.hpp"
|
||||
#include "Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp"
|
||||
#include "Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.hpp"
|
||||
#include "Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPaneSettings.hpp"
|
||||
#include "AboutWindow.hpp"
|
||||
|
||||
namespace Bloom
|
||||
@@ -83,6 +84,10 @@ namespace Bloom
|
||||
Widgets::PanelWidget* bottomPanel = nullptr;
|
||||
Widgets::TargetMemoryInspectionPane* ramInspectionPane = nullptr;
|
||||
Widgets::TargetMemoryInspectionPane* eepromInspectionPane = nullptr;
|
||||
std::map<
|
||||
Targets::TargetMemoryType,
|
||||
Widgets::TargetMemoryInspectionPaneSettings
|
||||
> memoryInspectionPaneSettingsByMemoryType;
|
||||
QToolButton* ramInspectionButton = nullptr;
|
||||
QToolButton* eepromInspectionButton = nullptr;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Bloom
|
||||
QString name;
|
||||
QDateTime createdDate = DateTime::currentDateTime();
|
||||
MemoryRegionType type;
|
||||
const Targets::TargetMemoryDescriptor& memoryDescriptor;
|
||||
Targets::TargetMemoryDescriptor memoryDescriptor;
|
||||
Targets::TargetMemoryAddressRange addressRange;
|
||||
MemoryRegionAddressType addressRangeType = MemoryRegionAddressType::ABSOLUTE;
|
||||
|
||||
|
||||
@@ -20,9 +20,16 @@ using Bloom::Targets::TargetMemoryType;
|
||||
|
||||
TargetMemoryInspectionPane::TargetMemoryInspectionPane(
|
||||
const TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const TargetMemoryInspectionPaneSettings& settings,
|
||||
InsightWorker& insightWorker,
|
||||
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");
|
||||
|
||||
auto memoryInspectionPaneUiFile = QFile(
|
||||
@@ -47,12 +54,15 @@ TargetMemoryInspectionPane::TargetMemoryInspectionPane(
|
||||
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");
|
||||
this->manageMemoryRegionsButton = this->container->findChild<SvgToolButton*>("manage-memory-regions-btn");
|
||||
this->hexViewerWidget = new HexViewerWidget(
|
||||
this->targetMemoryDescriptor,
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->settings.focusedMemoryRegions,
|
||||
this->settings.excludedMemoryRegions,
|
||||
this->insightWorker,
|
||||
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) {
|
||||
using Targets::TargetState;
|
||||
this->targetState = newState;
|
||||
@@ -189,9 +224,10 @@ void TargetMemoryInspectionPane::openMemoryRegionManagerWindow() {
|
||||
if (this->memoryRegionManagerWindow == nullptr) {
|
||||
this->memoryRegionManagerWindow = new MemoryRegionManagerWindow(
|
||||
this->targetMemoryDescriptor,
|
||||
this->focusedMemoryRegions,
|
||||
this->excludedMemoryRegions,
|
||||
this->settings.focusedMemoryRegions,
|
||||
this->settings.excludedMemoryRegions,
|
||||
this
|
||||
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
|
||||
@@ -13,11 +13,9 @@
|
||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/SvgToolButton.hpp"
|
||||
|
||||
#include "HexViewerWidget/HexViewerWidget.hpp"
|
||||
|
||||
#include "MemoryRegionManager/MemoryRegionManagerWindow.hpp"
|
||||
#include "MemoryRegion.hpp"
|
||||
#include "FocusedMemoryRegion.hpp"
|
||||
#include "ExcludedMemoryRegion.hpp"
|
||||
|
||||
#include "TargetMemoryInspectionPaneSettings.hpp"
|
||||
|
||||
namespace Bloom::Widgets
|
||||
{
|
||||
@@ -26,10 +24,12 @@ namespace Bloom::Widgets
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TargetMemoryInspectionPaneSettings settings;
|
||||
bool activated = false;
|
||||
|
||||
TargetMemoryInspectionPane(
|
||||
const Targets::TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||
const TargetMemoryInspectionPaneSettings& settings,
|
||||
InsightWorker& insightWorker,
|
||||
PanelWidget *parent
|
||||
);
|
||||
@@ -57,10 +57,9 @@ namespace Bloom::Widgets
|
||||
|
||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||
|
||||
std::vector<FocusedMemoryRegion> focusedMemoryRegions;
|
||||
std::vector<ExcludedMemoryRegion> excludedMemoryRegions;
|
||||
MemoryRegionManagerWindow* memoryRegionManagerWindow = nullptr;
|
||||
|
||||
void sanitiseSettings();
|
||||
void onTargetStateChanged(Targets::TargetState newState);
|
||||
void onMemoryRead(const Targets::TargetMemoryBuffer& buffer);
|
||||
void openMemoryRegionManagerWindow();
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user