Added support for flash memory inspection

This commit is contained in:
Nav
2023-05-03 23:13:22 +01:00
parent da5db96f11
commit eca86fcb1a
18 changed files with 316 additions and 52 deletions

View File

@@ -8,6 +8,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/ErrorDialogue/ErrorDialogue.hpp"
#include "src/Services/PathService.hpp"
#include "src/Helpers/EnumToStringMappings.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::Widgets
@@ -28,8 +29,7 @@ namespace Bloom::Widgets
this->setWindowFlag(Qt::Window);
this->setObjectName("memory-region-manager-window");
this->setWindowTitle(
"Memory Regions - "
+ QString(this->memoryDescriptor.type == Targets::TargetMemoryType::EEPROM ? "EEPROM" : "RAM")
"Memory Regions - " + EnumToStringMappings::targetMemoryTypes.at(this->memoryDescriptor.type).toUpper()
);
auto windowUiFile = QFile(

View File

@@ -9,6 +9,7 @@
#include "src/Insight/InsightSignals.hpp"
#include "src/Services/PathService.hpp"
#include "src/Helpers/EnumToStringMappings.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::Widgets
@@ -28,7 +29,7 @@ namespace Bloom::Widgets
this->setWindowFlag(Qt::Window);
this->setObjectName("create-snapshot-window");
this->setWindowTitle(
"New Snapshot - " + QString(memoryType == Targets::TargetMemoryType::EEPROM ? "EEPROM" : "RAM")
"New Snapshot - " + EnumToStringMappings::targetMemoryTypes.at(memoryType).toUpper()
);
auto windowUiFile = QFile(

View File

@@ -12,6 +12,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/ConfirmationDialog.hpp"
#include "src/Services/PathService.hpp"
#include "src/Helpers/EnumToStringMappings.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Insight/InsightSignals.hpp"
@@ -81,7 +82,13 @@ namespace Bloom::Widgets
this->dataASecondaryLabel->setText(snapshotA.createdDate.toString("dd/MM/yyyy hh:mm"));
this->dataBSecondaryLabel->setVisible(false);
this->restoreBytesAction = new ContextMenuAction("Restore Selection", std::nullopt, this);
this->restoreBytesAction = new ContextMenuAction(
"Restore Selection",
[this] (const std::unordered_map<Targets::TargetMemoryAddress, ByteItem*>&) {
return this->memoryDescriptor.access.writeableDuringDebugSession;
},
this
);
QObject::connect(
this->restoreBytesAction,
@@ -329,7 +336,7 @@ namespace Bloom::Widgets
"Restore selected bytes",
"This operation will write " + QString::number(sortedByteItemsByAddress.size())
+ " byte(s) to the target's "
+ QString(this->memoryDescriptor.type == Targets::TargetMemoryType::EEPROM ? "EEPROM" : "RAM")
+ EnumToStringMappings::targetMemoryTypes.at(this->memoryDescriptor.type).toUpper()
+ ".<br/><br/>Are you sure you want to proceed?",
"Proceed",
std::nullopt,

View File

@@ -14,6 +14,7 @@
#include "src/Insight/InsightWorker/InsightWorker.hpp"
#include "src/Services/PathService.hpp"
#include "src/Helpers/EnumToStringMappings.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Logger/Logger.hpp"
@@ -495,8 +496,8 @@ namespace Bloom::Widgets
auto* confirmationDialog = new ConfirmationDialog(
"Restore snapshot",
"This operation will overwrite the entire address range of the target's "
+ QString(this->memoryDescriptor.type == Targets::TargetMemoryType::EEPROM ? "EEPROM" : "RAM")
+ " with the contents of the selected snapshot.<br/><br/>Are you sure you want to proceed?",
+ EnumToStringMappings::targetMemoryTypes.at(this->memoryDescriptor.type).toUpper()
+ " with the contents of the selected snapshot.<br/><br/>Are you sure you want to proceed?",
"Proceed",
std::nullopt,
this
@@ -611,7 +612,9 @@ namespace Bloom::Widgets
&& this->data.has_value()
);
this->restoreSnapshotAction->setEnabled(
this->selectedSnapshotItems.size() == 1 && this->targetState == Targets::TargetState::STOPPED
this->memoryDescriptor.access.writeableDuringDebugSession
&& this->selectedSnapshotItems.size() == 1
&& this->targetState == Targets::TargetState::STOPPED
);
menu->exec(sourcePosition);

View File

@@ -17,6 +17,7 @@
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/ConfirmationDialog.hpp"
#include "src/Services/PathService.hpp"
#include "src/Helpers/EnumToStringMappings.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Insight/InsightSignals.hpp"
@@ -123,7 +124,13 @@ namespace Bloom::Widgets
memoryRegionsLayout->insertWidget(0, this->memoryRegionListView);
}
this->restoreBytesAction = new ContextMenuAction("Restore Selection", std::nullopt, this);
this->restoreBytesAction = new ContextMenuAction(
"Restore Selection",
[this] (const std::unordered_map<Targets::TargetMemoryAddress, ByteItem*>&) {
return this->memoryDescriptor.access.writeableDuringDebugSession;
},
this
);
this->hexViewerWidget = new HexViewerWidget(
this->memoryDescriptor,
@@ -214,7 +221,7 @@ namespace Bloom::Widgets
"Restore selected bytes",
"This operation will write " + QString::number(sortedByteItemsByAddress.size())
+ " byte(s) to the target's "
+ QString(this->memoryDescriptor.type == Targets::TargetMemoryType::EEPROM ? "EEPROM" : "RAM")
+ EnumToStringMappings::targetMemoryTypes.at(this->memoryDescriptor.type).toUpper()
+ ".<br/><br/>Are you sure you want to proceed?",
"Proceed",
std::nullopt,

View File

@@ -13,6 +13,7 @@
#include "src/Insight/InsightWorker/Tasks/ReadStackPointer.hpp"
#include "src/Services/PathService.hpp"
#include "src/Helpers/EnumToStringMappings.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::Widgets
@@ -35,11 +36,9 @@ namespace Bloom::Widgets
{
this->setObjectName("target-memory-inspection-pane");
const auto memoryName = QString(
this->targetMemoryDescriptor.type == TargetMemoryType::EEPROM
? "Internal EEPROM"
: "Internal RAM"
);
const auto memoryName = "Internal " + EnumToStringMappings::targetMemoryTypes.at(
this->targetMemoryDescriptor.type
).toUpper();
this->setWindowTitle("Memory Inspection - " + memoryName);
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);