Removed TargetMemoryDescriptor dependency in MemoryRegion class (in preparation for saving & loading memory regions from Bloom's project settings file)
This commit is contained in:
@@ -192,7 +192,6 @@ add_executable(Bloom
|
|||||||
|
|
||||||
# Target memory inspection pane
|
# Target memory inspection pane
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.cpp
|
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.cpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.cpp
|
||||||
src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp
|
src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ namespace Bloom
|
|||||||
public:
|
public:
|
||||||
explicit ExcludedMemoryRegion(
|
explicit ExcludedMemoryRegion(
|
||||||
const QString& name,
|
const QString& name,
|
||||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
|
||||||
const Targets::TargetMemoryAddressRange& addressRange
|
const Targets::TargetMemoryAddressRange& addressRange
|
||||||
): MemoryRegion(name, MemoryRegionType::EXCLUDED, memoryDescriptor, addressRange) {};
|
): MemoryRegion(name, MemoryRegionType::EXCLUDED, addressRange) {};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,7 @@ namespace Bloom
|
|||||||
|
|
||||||
explicit FocusedMemoryRegion(
|
explicit FocusedMemoryRegion(
|
||||||
const QString& name,
|
const QString& name,
|
||||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
|
||||||
const Targets::TargetMemoryAddressRange& addressRange
|
const Targets::TargetMemoryAddressRange& addressRange
|
||||||
): MemoryRegion(name, MemoryRegionType::FOCUSED, memoryDescriptor, addressRange) {};
|
): MemoryRegion(name, MemoryRegionType::FOCUSED, addressRange) {};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ AnnotationItem::AnnotationItem(
|
|||||||
|
|
||||||
AnnotationItem::AnnotationItem(const FocusedMemoryRegion& focusedMemoryRegion, AnnotationItemPosition position)
|
AnnotationItem::AnnotationItem(const FocusedMemoryRegion& focusedMemoryRegion, AnnotationItemPosition position)
|
||||||
: AnnotationItem(
|
: AnnotationItem(
|
||||||
focusedMemoryRegion.getAbsoluteAddressRange(),
|
focusedMemoryRegion.addressRange,
|
||||||
focusedMemoryRegion.name,
|
focusedMemoryRegion.name,
|
||||||
position
|
position
|
||||||
) {}
|
) {}
|
||||||
|
|||||||
@@ -89,16 +89,18 @@ void ByteItemGraphicsScene::refreshRegions() {
|
|||||||
byteWidget->excludedMemoryRegion = nullptr;
|
byteWidget->excludedMemoryRegion = nullptr;
|
||||||
|
|
||||||
for (const auto& focusedRegion : this->focusedMemoryRegions) {
|
for (const auto& focusedRegion : this->focusedMemoryRegions) {
|
||||||
const auto addressRange = focusedRegion.getAbsoluteAddressRange();
|
if (byteAddress >= focusedRegion.addressRange.startAddress
|
||||||
if (byteAddress >= addressRange.startAddress && byteAddress <= addressRange.endAddress) {
|
&& byteAddress <= focusedRegion.addressRange.endAddress
|
||||||
|
) {
|
||||||
byteWidget->focusedMemoryRegion = &focusedRegion;
|
byteWidget->focusedMemoryRegion = &focusedRegion;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& excludedRegion : this->excludedMemoryRegions) {
|
for (const auto& excludedRegion : this->excludedMemoryRegions) {
|
||||||
const auto addressRange = excludedRegion.getAbsoluteAddressRange();
|
if (byteAddress >= excludedRegion.addressRange.startAddress
|
||||||
if (byteAddress >= addressRange.startAddress && byteAddress <= addressRange.endAddress) {
|
&& byteAddress <= excludedRegion.addressRange.endAddress
|
||||||
|
) {
|
||||||
byteWidget->excludedMemoryRegion = &excludedRegion;
|
byteWidget->excludedMemoryRegion = &excludedRegion;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
#include "MemoryRegion.hpp"
|
|
||||||
|
|
||||||
using namespace Bloom;
|
|
||||||
|
|
||||||
using Bloom::Targets::TargetMemoryAddressRange;
|
|
||||||
|
|
||||||
TargetMemoryAddressRange MemoryRegion::getAbsoluteAddressRange() const {
|
|
||||||
if (this->addressRangeType == MemoryRegionAddressType::ABSOLUTE) {
|
|
||||||
return this->addressRange;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TargetMemoryAddressRange(
|
|
||||||
this->addressRange.startAddress + this->memoryDescriptor.addressRange.startAddress,
|
|
||||||
this->addressRange.endAddress + this->memoryDescriptor.addressRange.startAddress
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
TargetMemoryAddressRange MemoryRegion::getRelativeAddressRange() const {
|
|
||||||
if (this->addressRangeType == MemoryRegionAddressType::RELATIVE) {
|
|
||||||
return this->addressRange;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TargetMemoryAddressRange(
|
|
||||||
this->addressRange.startAddress - this->memoryDescriptor.addressRange.startAddress,
|
|
||||||
this->addressRange.endAddress - this->memoryDescriptor.addressRange.startAddress
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -29,16 +29,31 @@ namespace Bloom
|
|||||||
QString name;
|
QString name;
|
||||||
QDateTime createdDate = DateTime::currentDateTime();
|
QDateTime createdDate = DateTime::currentDateTime();
|
||||||
MemoryRegionType type;
|
MemoryRegionType type;
|
||||||
Targets::TargetMemoryDescriptor memoryDescriptor;
|
|
||||||
Targets::TargetMemoryAddressRange addressRange;
|
/**
|
||||||
|
* The addressRangeType holds the user's preference when inputting address ranges in the memory region manager
|
||||||
|
* window, for this particular memory region.
|
||||||
|
*
|
||||||
|
* It has no significance anywhere else. We never store the address in relative form - this->addressRange will
|
||||||
|
* always be in absolute form. Conversion is done at the point of applying the changes.
|
||||||
|
*
|
||||||
|
* For more, see the following and their call sites:
|
||||||
|
* See RegionItem::convertRelativeToAbsoluteAddressRange()
|
||||||
|
* See RegionItem::convertAbsoluteToRelativeAddressRange()
|
||||||
|
*/
|
||||||
MemoryRegionAddressType addressRangeType = MemoryRegionAddressType::ABSOLUTE;
|
MemoryRegionAddressType addressRangeType = MemoryRegionAddressType::ABSOLUTE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This address range will always be in absolute form. Regardless of the value of this->addressRangeType.
|
||||||
|
* See the comment above, for this->addressRangeType, for more.
|
||||||
|
*/
|
||||||
|
Targets::TargetMemoryAddressRange addressRange;
|
||||||
|
|
||||||
MemoryRegion(
|
MemoryRegion(
|
||||||
QString name,
|
QString name,
|
||||||
MemoryRegionType type,
|
MemoryRegionType type,
|
||||||
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
|
||||||
const Targets::TargetMemoryAddressRange& addressRange
|
const Targets::TargetMemoryAddressRange& addressRange
|
||||||
): name(std::move(name)), type(type), memoryDescriptor(memoryDescriptor), addressRange(addressRange) {};
|
): name(std::move(name)), type(type), addressRange(addressRange) {};
|
||||||
|
|
||||||
virtual ~MemoryRegion() = default;
|
virtual ~MemoryRegion() = default;
|
||||||
|
|
||||||
@@ -57,12 +72,9 @@ namespace Bloom
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool intersectsWith(const MemoryRegion& other) const {
|
[[nodiscard]] bool intersectsWith(const MemoryRegion& other) const {
|
||||||
return this->getAbsoluteAddressRange().intersectsWith(other.getAbsoluteAddressRange());
|
return this->addressRange.intersectsWith(other.addressRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] Targets::TargetMemoryAddressRange getAbsoluteAddressRange() const;
|
|
||||||
[[nodiscard]] Targets::TargetMemoryAddressRange getRelativeAddressRange() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static inline std::atomic<std::size_t> lastId = 0;
|
static inline std::atomic<std::size_t> lastId = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,10 +9,13 @@
|
|||||||
using namespace Bloom;
|
using namespace Bloom;
|
||||||
using namespace Bloom::Widgets;
|
using namespace Bloom::Widgets;
|
||||||
|
|
||||||
|
using Targets::TargetMemoryAddressRange;
|
||||||
|
|
||||||
ExcludedRegionItem::ExcludedRegionItem(
|
ExcludedRegionItem::ExcludedRegionItem(
|
||||||
const ExcludedMemoryRegion& region,
|
const ExcludedMemoryRegion& region,
|
||||||
|
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||||
QWidget* parent
|
QWidget* parent
|
||||||
): memoryRegion(region), RegionItem(region, parent) {
|
): memoryRegion(region), RegionItem(region, memoryDescriptor, parent) {
|
||||||
auto formUiFile = QFile(
|
auto formUiFile = QFile(
|
||||||
QString::fromStdString(Paths::compiledResourcesPath()
|
QString::fromStdString(Paths::compiledResourcesPath()
|
||||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||||
@@ -30,11 +33,14 @@ ExcludedRegionItem::ExcludedRegionItem(
|
|||||||
this->initFormInputs();
|
this->initFormInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExcludedMemoryRegion ExcludedRegionItem::generateExcludedMemoryRegionFromInput() {
|
void ExcludedRegionItem::applyChanges() {
|
||||||
this->memoryRegion.name = this->nameInput->text();
|
this->memoryRegion.name = this->nameInput->text();
|
||||||
this->memoryRegion.addressRange.startAddress = this->startAddressInput->text().toUInt(nullptr, 16);
|
|
||||||
this->memoryRegion.addressRange.endAddress = this->endAddressInput->text().toUInt(nullptr, 16);
|
|
||||||
this->memoryRegion.addressRangeType = this->getSelectedAddressType();
|
|
||||||
|
|
||||||
return this->memoryRegion;
|
const auto inputAddressRange = TargetMemoryAddressRange(
|
||||||
|
this->startAddressInput->text().toUInt(nullptr, 16),
|
||||||
|
this->endAddressInput->text().toUInt(nullptr, 16)
|
||||||
|
);
|
||||||
|
this->memoryRegion.addressRangeType = this->getSelectedAddressType();
|
||||||
|
this->memoryRegion.addressRange = this->memoryRegion.addressRangeType == MemoryRegionAddressType::RELATIVE ?
|
||||||
|
this->convertRelativeToAbsoluteAddressRange(inputAddressRange) : inputAddressRange;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,13 +10,17 @@ namespace Bloom::Widgets
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ExcludedRegionItem(const ExcludedMemoryRegion& region, QWidget *parent);
|
ExcludedRegionItem(
|
||||||
|
const ExcludedMemoryRegion& region,
|
||||||
|
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||||
|
QWidget *parent
|
||||||
|
);
|
||||||
|
|
||||||
[[nodiscard]] const MemoryRegion& getMemoryRegion() const override {
|
[[nodiscard]] const ExcludedMemoryRegion& getMemoryRegion() const override {
|
||||||
return this->memoryRegion;
|
return this->memoryRegion;
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] virtual ExcludedMemoryRegion generateExcludedMemoryRegionFromInput();
|
virtual void applyChanges();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExcludedMemoryRegion memoryRegion;
|
ExcludedMemoryRegion memoryRegion;
|
||||||
|
|||||||
@@ -9,10 +9,13 @@
|
|||||||
using namespace Bloom;
|
using namespace Bloom;
|
||||||
using namespace Bloom::Widgets;
|
using namespace Bloom::Widgets;
|
||||||
|
|
||||||
|
using Targets::TargetMemoryAddressRange;
|
||||||
|
|
||||||
FocusedRegionItem::FocusedRegionItem(
|
FocusedRegionItem::FocusedRegionItem(
|
||||||
const FocusedMemoryRegion& region,
|
const FocusedMemoryRegion& region,
|
||||||
|
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||||
QWidget* parent
|
QWidget* parent
|
||||||
): memoryRegion(region), RegionItem(region, parent) {
|
): memoryRegion(region), RegionItem(region, memoryDescriptor, parent) {
|
||||||
auto formUiFile = QFile(
|
auto formUiFile = QFile(
|
||||||
QString::fromStdString(Paths::compiledResourcesPath()
|
QString::fromStdString(Paths::compiledResourcesPath()
|
||||||
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
+ "/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane"
|
||||||
@@ -30,18 +33,21 @@ FocusedRegionItem::FocusedRegionItem(
|
|||||||
this->initFormInputs();
|
this->initFormInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
FocusedMemoryRegion FocusedRegionItem::generateFocusedMemoryRegionFromInput() {
|
void FocusedRegionItem::applyChanges() {
|
||||||
this->memoryRegion.name = this->nameInput->text();
|
this->memoryRegion.name = this->nameInput->text();
|
||||||
this->memoryRegion.addressRange.startAddress = this->startAddressInput->text().toUInt(nullptr, 16);
|
|
||||||
this->memoryRegion.addressRange.endAddress = this->endAddressInput->text().toUInt(nullptr, 16);
|
const auto inputAddressRange = TargetMemoryAddressRange(
|
||||||
|
this->startAddressInput->text().toUInt(nullptr, 16),
|
||||||
|
this->endAddressInput->text().toUInt(nullptr, 16)
|
||||||
|
);
|
||||||
this->memoryRegion.addressRangeType = this->getSelectedAddressType();
|
this->memoryRegion.addressRangeType = this->getSelectedAddressType();
|
||||||
|
this->memoryRegion.addressRange = this->memoryRegion.addressRangeType == MemoryRegionAddressType::RELATIVE ?
|
||||||
|
this->convertRelativeToAbsoluteAddressRange(inputAddressRange) : inputAddressRange;
|
||||||
|
|
||||||
auto selectedDataTypeOptionName = this->dataTypeInput->currentData().toString();
|
auto selectedDataTypeOptionName = this->dataTypeInput->currentData().toString();
|
||||||
if (FocusedRegionItem::dataTypeOptionsByName.contains(selectedDataTypeOptionName)) {
|
if (FocusedRegionItem::dataTypeOptionsByName.contains(selectedDataTypeOptionName)) {
|
||||||
this->memoryRegion.dataType = FocusedRegionItem::dataTypeOptionsByName.at(selectedDataTypeOptionName).dataType;
|
this->memoryRegion.dataType = FocusedRegionItem::dataTypeOptionsByName.at(selectedDataTypeOptionName).dataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this->memoryRegion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FocusedRegionItem::initFormInputs() {
|
void FocusedRegionItem::initFormInputs() {
|
||||||
|
|||||||
@@ -19,13 +19,17 @@ namespace Bloom::Widgets
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FocusedRegionItem(const FocusedMemoryRegion& region, QWidget *parent);
|
FocusedRegionItem(
|
||||||
|
const FocusedMemoryRegion& region,
|
||||||
|
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||||
|
QWidget *parent
|
||||||
|
);
|
||||||
|
|
||||||
[[nodiscard]] const MemoryRegion& getMemoryRegion() const override {
|
[[nodiscard]] const FocusedMemoryRegion& getMemoryRegion() const override {
|
||||||
return this->memoryRegion;
|
return this->memoryRegion;
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] virtual FocusedMemoryRegion generateFocusedMemoryRegionFromInput();
|
virtual void applyChanges();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initFormInputs() override;
|
void initFormInputs() override;
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ void MemoryRegionManagerWindow::sortRegionItems() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FocusedRegionItem* MemoryRegionManagerWindow::addFocusedRegion(const FocusedMemoryRegion& region) {
|
FocusedRegionItem* MemoryRegionManagerWindow::addFocusedRegion(const FocusedMemoryRegion& region) {
|
||||||
auto* focusedRegionItem = new FocusedRegionItem(region, this->regionItemScrollAreaViewport);
|
auto* focusedRegionItem = new FocusedRegionItem(region, this->memoryDescriptor, this->regionItemScrollAreaViewport);
|
||||||
this->focusedRegionItems.insert(focusedRegionItem);
|
this->focusedRegionItems.insert(focusedRegionItem);
|
||||||
|
|
||||||
this->regionItemScrollAreaViewportLayout->addWidget(focusedRegionItem);
|
this->regionItemScrollAreaViewportLayout->addWidget(focusedRegionItem);
|
||||||
@@ -207,7 +207,7 @@ FocusedRegionItem* MemoryRegionManagerWindow::addFocusedRegion(const FocusedMemo
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExcludedRegionItem* MemoryRegionManagerWindow::addExcludedRegion(const ExcludedMemoryRegion& region) {
|
ExcludedRegionItem* MemoryRegionManagerWindow::addExcludedRegion(const ExcludedMemoryRegion& region) {
|
||||||
auto* excludedRegionItem = new ExcludedRegionItem(region, this->regionItemScrollAreaViewport);
|
auto* excludedRegionItem = new ExcludedRegionItem(region, this->memoryDescriptor, this->regionItemScrollAreaViewport);
|
||||||
this->excludedRegionItems.insert(excludedRegionItem);
|
this->excludedRegionItems.insert(excludedRegionItem);
|
||||||
|
|
||||||
this->regionItemScrollAreaViewportLayout->addWidget(excludedRegionItem);
|
this->regionItemScrollAreaViewportLayout->addWidget(excludedRegionItem);
|
||||||
@@ -232,7 +232,6 @@ void MemoryRegionManagerWindow::onNewFocusedRegionTrigger() {
|
|||||||
|
|
||||||
auto* region = this->addFocusedRegion(FocusedMemoryRegion(
|
auto* region = this->addFocusedRegion(FocusedMemoryRegion(
|
||||||
"Untitled Region",
|
"Untitled Region",
|
||||||
this->memoryDescriptor,
|
|
||||||
TargetMemoryAddressRange(
|
TargetMemoryAddressRange(
|
||||||
this->memoryDescriptor.addressRange.startAddress,
|
this->memoryDescriptor.addressRange.startAddress,
|
||||||
this->memoryDescriptor.addressRange.startAddress + 10
|
this->memoryDescriptor.addressRange.startAddress + 10
|
||||||
@@ -247,7 +246,6 @@ void MemoryRegionManagerWindow::onNewExcludedRegionTrigger() {
|
|||||||
|
|
||||||
auto* region = this->addExcludedRegion(ExcludedMemoryRegion(
|
auto* region = this->addExcludedRegion(ExcludedMemoryRegion(
|
||||||
"Untitled Region",
|
"Untitled Region",
|
||||||
this->memoryDescriptor,
|
|
||||||
TargetMemoryAddressRange(
|
TargetMemoryAddressRange(
|
||||||
this->memoryDescriptor.addressRange.startAddress,
|
this->memoryDescriptor.addressRange.startAddress,
|
||||||
this->memoryDescriptor.addressRange.startAddress + 10
|
this->memoryDescriptor.addressRange.startAddress + 10
|
||||||
@@ -315,7 +313,8 @@ void MemoryRegionManagerWindow::applyChanges() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto focusedRegion = focusedRegionItem->generateFocusedMemoryRegionFromInput();
|
focusedRegionItem->applyChanges();
|
||||||
|
const auto& focusedRegion = focusedRegionItem->getMemoryRegion();
|
||||||
for (const auto& processedFocusedRegion : processedFocusedMemoryRegions) {
|
for (const auto& processedFocusedRegion : processedFocusedMemoryRegions) {
|
||||||
if (processedFocusedRegion.intersectsWith(focusedRegion)) {
|
if (processedFocusedRegion.intersectsWith(focusedRegion)) {
|
||||||
auto* errorDialogue = new ErrorDialogue(
|
auto* errorDialogue = new ErrorDialogue(
|
||||||
@@ -347,7 +346,8 @@ void MemoryRegionManagerWindow::applyChanges() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto excludedRegion = excludedRegionItem->generateExcludedMemoryRegionFromInput();
|
excludedRegionItem->applyChanges();
|
||||||
|
auto excludedRegion = excludedRegionItem->getMemoryRegion();
|
||||||
for (const auto& processedFocusedRegion : processedFocusedMemoryRegions) {
|
for (const auto& processedFocusedRegion : processedFocusedMemoryRegions) {
|
||||||
if (processedFocusedRegion.intersectsWith(excludedRegion)) {
|
if (processedFocusedRegion.intersectsWith(excludedRegion)) {
|
||||||
auto* errorDialogue = new ErrorDialogue(
|
auto* errorDialogue = new ErrorDialogue(
|
||||||
|
|||||||
@@ -6,10 +6,13 @@
|
|||||||
using namespace Bloom;
|
using namespace Bloom;
|
||||||
using namespace Bloom::Widgets;
|
using namespace Bloom::Widgets;
|
||||||
|
|
||||||
|
using Targets::TargetMemoryAddressRange;
|
||||||
|
|
||||||
RegionItem::RegionItem(
|
RegionItem::RegionItem(
|
||||||
const MemoryRegion& region,
|
const MemoryRegion& region,
|
||||||
|
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||||
QWidget* parent
|
QWidget* parent
|
||||||
): ClickableWidget(parent) {
|
): memoryDescriptor(memoryDescriptor), ClickableWidget(parent) {
|
||||||
this->setObjectName("region-item");
|
this->setObjectName("region-item");
|
||||||
this->setFixedHeight(50);
|
this->setFixedHeight(50);
|
||||||
this->layout->setContentsMargins(5, 5, 5, 0);
|
this->layout->setContentsMargins(5, 5, 5, 0);
|
||||||
@@ -25,10 +28,9 @@ RegionItem::RegionItem(
|
|||||||
this->typeLabel->setText(region.type == MemoryRegionType::FOCUSED ? "Focused" : "Excluded");
|
this->typeLabel->setText(region.type == MemoryRegionType::FOCUSED ? "Focused" : "Excluded");
|
||||||
this->typeLabel->setObjectName("type-label");
|
this->typeLabel->setObjectName("type-label");
|
||||||
|
|
||||||
auto addressRange = region.getAbsoluteAddressRange();
|
|
||||||
this->addressRangeLabel->setText(
|
this->addressRangeLabel->setText(
|
||||||
"0x" + QString::number(addressRange.startAddress, 16).toUpper() + QString(" -> ")
|
"0x" + QString::number(region.addressRange.startAddress, 16).toUpper() + QString(" -> ")
|
||||||
+ "0x" + QString::number(addressRange.endAddress, 16).toUpper()
|
+ "0x" + QString::number(region.addressRange.endAddress, 16).toUpper()
|
||||||
);
|
);
|
||||||
this->addressRangeLabel->setObjectName("address-label");
|
this->addressRangeLabel->setObjectName("address-label");
|
||||||
|
|
||||||
@@ -74,8 +76,6 @@ void RegionItem::setSelected(bool selected) {
|
|||||||
QStringList RegionItem::getValidationFailures() const {
|
QStringList RegionItem::getValidationFailures() const {
|
||||||
auto validationFailures = QStringList();
|
auto validationFailures = QStringList();
|
||||||
|
|
||||||
const auto& memoryDescriptor = this->getMemoryRegion().memoryDescriptor;
|
|
||||||
|
|
||||||
if (this->nameInput->text().isEmpty()) {
|
if (this->nameInput->text().isEmpty()) {
|
||||||
validationFailures.emplace_back("Missing region name.");
|
validationFailures.emplace_back("Missing region name.");
|
||||||
}
|
}
|
||||||
@@ -97,28 +97,28 @@ QStringList RegionItem::getValidationFailures() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto addressType = this->getSelectedAddressType();
|
auto addressType = this->getSelectedAddressType();
|
||||||
const auto memoryAddressRange = memoryDescriptor.addressRange;
|
const auto memoryAddressRange = this->memoryDescriptor.addressRange;
|
||||||
|
|
||||||
const auto memoryAddressRangeStr = QString(
|
const auto memoryAddressRangeStr = QString(
|
||||||
"0x" + QString::number(memoryAddressRange.startAddress, 16).toUpper() + QString(" -> ")
|
"0x" + QString::number(memoryAddressRange.startAddress, 16).toUpper() + QString(" -> ")
|
||||||
+ "0x" + QString::number(memoryAddressRange.endAddress, 16).toUpper()
|
+ "0x" + QString::number(memoryAddressRange.endAddress, 16).toUpper()
|
||||||
);
|
);
|
||||||
|
|
||||||
std::uint32_t absoluteStartAddress = addressType == MemoryRegionAddressType::RELATIVE ?
|
const auto absoluteAddressRange = addressType == MemoryRegionAddressType::RELATIVE ?
|
||||||
memoryAddressRange.startAddress + startAddress : startAddress;
|
this->convertRelativeToAbsoluteAddressRange(TargetMemoryAddressRange(startAddress, endAddress))
|
||||||
|
: TargetMemoryAddressRange(startAddress, endAddress);
|
||||||
|
|
||||||
std::uint32_t absoluteEndAddress = addressType == MemoryRegionAddressType::RELATIVE ?
|
if (absoluteAddressRange.startAddress < memoryAddressRange.startAddress
|
||||||
memoryAddressRange.startAddress + endAddress : endAddress;
|
|| absoluteAddressRange.startAddress > memoryAddressRange.endAddress
|
||||||
|
|
||||||
if (absoluteStartAddress < memoryAddressRange.startAddress
|
|
||||||
|| absoluteStartAddress > memoryAddressRange.endAddress
|
|
||||||
) {
|
) {
|
||||||
validationFailures.emplace_back(
|
validationFailures.emplace_back(
|
||||||
"The start address is not within the absolute memory address range (" + memoryAddressRangeStr + ")."
|
"The start address is not within the absolute memory address range (" + memoryAddressRangeStr + ")."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (absoluteEndAddress < memoryAddressRange.startAddress || absoluteEndAddress > memoryAddressRange.endAddress) {
|
if (absoluteAddressRange.endAddress < memoryAddressRange.startAddress
|
||||||
|
|| absoluteAddressRange.endAddress > memoryAddressRange.endAddress
|
||||||
|
) {
|
||||||
validationFailures.emplace_back(
|
validationFailures.emplace_back(
|
||||||
"The end address not within the absolute memory address range (" + memoryAddressRangeStr + ")."
|
"The end address not within the absolute memory address range (" + memoryAddressRangeStr + ")."
|
||||||
);
|
);
|
||||||
@@ -144,18 +144,17 @@ void RegionItem::initFormInputs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (region.addressRangeType == MemoryRegionAddressType::RELATIVE) {
|
if (region.addressRangeType == MemoryRegionAddressType::RELATIVE) {
|
||||||
|
auto relativeAddressRange = this->convertAbsoluteToRelativeAddressRange(region.addressRange);
|
||||||
this->addressTypeInput->setCurrentText(RegionItem::addressRangeTypeOptionsByName.at("relative").text);
|
this->addressTypeInput->setCurrentText(RegionItem::addressRangeTypeOptionsByName.at("relative").text);
|
||||||
|
|
||||||
auto addressRange = region.getRelativeAddressRange();
|
this->startAddressInput->setText("0x" + QString::number(relativeAddressRange.startAddress, 16).toUpper());
|
||||||
this->startAddressInput->setText("0x" + QString::number(addressRange.startAddress, 16).toUpper());
|
this->endAddressInput->setText("0x" + QString::number(relativeAddressRange.endAddress, 16).toUpper());
|
||||||
this->endAddressInput->setText("0x" + QString::number(addressRange.endAddress, 16).toUpper());
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this->addressTypeInput->setCurrentText(RegionItem::addressRangeTypeOptionsByName.at("absolute").text);
|
this->addressTypeInput->setCurrentText(RegionItem::addressRangeTypeOptionsByName.at("absolute").text);
|
||||||
|
|
||||||
auto addressRange = region.getAbsoluteAddressRange();
|
this->startAddressInput->setText("0x" + QString::number(region.addressRange.startAddress, 16).toUpper());
|
||||||
this->startAddressInput->setText("0x" + QString::number(addressRange.startAddress, 16).toUpper());
|
this->endAddressInput->setText("0x" + QString::number(region.addressRange.endAddress, 16).toUpper());
|
||||||
this->endAddressInput->setText("0x" + QString::number(addressRange.endAddress, 16).toUpper());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject::connect(this->startAddressInput, &QLineEdit::textEdited, this, &RegionItem::onAddressRangeInputChange);
|
QObject::connect(this->startAddressInput, &QLineEdit::textEdited, this, &RegionItem::onAddressRangeInputChange);
|
||||||
@@ -173,6 +172,24 @@ MemoryRegionAddressType RegionItem::getSelectedAddressType() const {
|
|||||||
return MemoryRegionAddressType::ABSOLUTE;
|
return MemoryRegionAddressType::ABSOLUTE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TargetMemoryAddressRange RegionItem::convertAbsoluteToRelativeAddressRange(
|
||||||
|
const TargetMemoryAddressRange& absoluteAddressRange
|
||||||
|
) const {
|
||||||
|
return TargetMemoryAddressRange(
|
||||||
|
absoluteAddressRange.startAddress - this->memoryDescriptor.addressRange.startAddress,
|
||||||
|
absoluteAddressRange.endAddress - this->memoryDescriptor.addressRange.startAddress
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetMemoryAddressRange RegionItem::convertRelativeToAbsoluteAddressRange(
|
||||||
|
const TargetMemoryAddressRange& relativeAddressRange
|
||||||
|
) const {
|
||||||
|
return TargetMemoryAddressRange(
|
||||||
|
relativeAddressRange.startAddress + this->memoryDescriptor.addressRange.startAddress,
|
||||||
|
relativeAddressRange.endAddress + this->memoryDescriptor.addressRange.startAddress
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void RegionItem::onAddressRangeInputChange() {
|
void RegionItem::onAddressRangeInputChange() {
|
||||||
bool startAddressConversionOk = false;
|
bool startAddressConversionOk = false;
|
||||||
bool endAddressConversionOk = false;
|
bool endAddressConversionOk = false;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TextInput.hpp"
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TextInput.hpp"
|
||||||
|
|
||||||
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp"
|
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/MemoryRegion.hpp"
|
||||||
|
#include "src/Targets/TargetMemory.hpp"
|
||||||
|
|
||||||
namespace Bloom::Widgets
|
namespace Bloom::Widgets
|
||||||
{
|
{
|
||||||
@@ -28,7 +29,11 @@ namespace Bloom::Widgets
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RegionItem(const MemoryRegion& region, QWidget *parent);
|
RegionItem(
|
||||||
|
const MemoryRegion& region,
|
||||||
|
const Targets::TargetMemoryDescriptor& memoryDescriptor,
|
||||||
|
QWidget *parent
|
||||||
|
);
|
||||||
void setSelected(bool selected);
|
void setSelected(bool selected);
|
||||||
|
|
||||||
[[nodiscard]] QWidget* getFormWidget() const {
|
[[nodiscard]] QWidget* getFormWidget() const {
|
||||||
@@ -48,6 +53,8 @@ namespace Bloom::Widgets
|
|||||||
protected:
|
protected:
|
||||||
static constexpr int NAME_LABEL_MAX_LENGTH = 34;
|
static constexpr int NAME_LABEL_MAX_LENGTH = 34;
|
||||||
|
|
||||||
|
const Targets::TargetMemoryDescriptor& memoryDescriptor;
|
||||||
|
|
||||||
QWidget* formWidget = nullptr;
|
QWidget* formWidget = nullptr;
|
||||||
TextInput* nameInput = nullptr;
|
TextInput* nameInput = nullptr;
|
||||||
QComboBox* addressTypeInput = nullptr;
|
QComboBox* addressTypeInput = nullptr;
|
||||||
@@ -58,6 +65,14 @@ namespace Bloom::Widgets
|
|||||||
virtual void initFormInputs();
|
virtual void initFormInputs();
|
||||||
[[nodiscard]] MemoryRegionAddressType getSelectedAddressType() const;
|
[[nodiscard]] MemoryRegionAddressType getSelectedAddressType() const;
|
||||||
|
|
||||||
|
Targets::TargetMemoryAddressRange convertAbsoluteToRelativeAddressRange(
|
||||||
|
const Targets::TargetMemoryAddressRange& absoluteAddressRange
|
||||||
|
) const;
|
||||||
|
|
||||||
|
Targets::TargetMemoryAddressRange convertRelativeToAbsoluteAddressRange(
|
||||||
|
const Targets::TargetMemoryAddressRange& relativeAddressRange
|
||||||
|
) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||||
QLabel* nameLabel = new QLabel(this);
|
QLabel* nameLabel = new QLabel(this);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ using Bloom::Targets::TargetMemoryType;
|
|||||||
|
|
||||||
TargetMemoryInspectionPane::TargetMemoryInspectionPane(
|
TargetMemoryInspectionPane::TargetMemoryInspectionPane(
|
||||||
const TargetMemoryDescriptor& targetMemoryDescriptor,
|
const TargetMemoryDescriptor& targetMemoryDescriptor,
|
||||||
const TargetMemoryInspectionPaneSettings& settings,
|
TargetMemoryInspectionPaneSettings& settings,
|
||||||
InsightWorker& insightWorker,
|
InsightWorker& insightWorker,
|
||||||
PanelWidget* parent
|
PanelWidget* parent
|
||||||
):
|
):
|
||||||
@@ -104,8 +104,8 @@ void TargetMemoryInspectionPane::refreshMemoryValues(std::optional<std::function
|
|||||||
this->settings.excludedMemoryRegions.begin(),
|
this->settings.excludedMemoryRegions.begin(),
|
||||||
this->settings.excludedMemoryRegions.end(),
|
this->settings.excludedMemoryRegions.end(),
|
||||||
std::inserter(excludedAddressRanges, excludedAddressRanges.begin()),
|
std::inserter(excludedAddressRanges, excludedAddressRanges.begin()),
|
||||||
[] (const ExcludedMemoryRegion& excludedRegion) {
|
[this] (const ExcludedMemoryRegion& excludedRegion) {
|
||||||
return excludedRegion.getAbsoluteAddressRange();
|
return excludedRegion.addressRange;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ void TargetMemoryInspectionPane::sanitiseSettings() {
|
|||||||
this->settings.focusedMemoryRegions.begin(),
|
this->settings.focusedMemoryRegions.begin(),
|
||||||
this->settings.focusedMemoryRegions.end(),
|
this->settings.focusedMemoryRegions.end(),
|
||||||
[this] (const FocusedMemoryRegion& region) {
|
[this] (const FocusedMemoryRegion& region) {
|
||||||
return region.memoryDescriptor != this->targetMemoryDescriptor;
|
return !this->targetMemoryDescriptor.addressRange.contains(region.addressRange);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
this->settings.focusedMemoryRegions.end()
|
this->settings.focusedMemoryRegions.end()
|
||||||
@@ -210,7 +210,7 @@ void TargetMemoryInspectionPane::sanitiseSettings() {
|
|||||||
this->settings.excludedMemoryRegions.begin(),
|
this->settings.excludedMemoryRegions.begin(),
|
||||||
this->settings.excludedMemoryRegions.end(),
|
this->settings.excludedMemoryRegions.end(),
|
||||||
[this] (const ExcludedMemoryRegion& region) {
|
[this] (const ExcludedMemoryRegion& region) {
|
||||||
return region.memoryDescriptor != this->targetMemoryDescriptor;
|
return !this->targetMemoryDescriptor.addressRange.contains(region.addressRange);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
this->settings.excludedMemoryRegions.end()
|
this->settings.excludedMemoryRegions.end()
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ namespace Bloom::Targets
|
|||||||
[[nodiscard]] bool contains(std::uint32_t address) const {
|
[[nodiscard]] bool contains(std::uint32_t address) const {
|
||||||
return address >= this->startAddress && address <= this->endAddress;
|
return address >= this->startAddress && address <= this->endAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool contains(const TargetMemoryAddressRange& addressRange) const {
|
||||||
|
return this->startAddress <= addressRange.startAddress && this->endAddress >= addressRange.endAddress;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TargetMemoryDescriptor
|
struct TargetMemoryDescriptor
|
||||||
|
|||||||
Reference in New Issue
Block a user