Made endianness of focused memory regions configurable
This commit is contained in:
@@ -18,6 +18,7 @@ namespace Bloom
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MemoryRegionDataType dataType = MemoryRegionDataType::UNKNOWN;
|
MemoryRegionDataType dataType = MemoryRegionDataType::UNKNOWN;
|
||||||
|
Targets::TargetMemoryEndianness endianness = Targets::TargetMemoryEndianness::LITTLE;
|
||||||
|
|
||||||
explicit FocusedMemoryRegion(
|
explicit FocusedMemoryRegion(
|
||||||
const QString& name,
|
const QString& name,
|
||||||
|
|||||||
@@ -5,12 +5,20 @@
|
|||||||
using namespace Bloom::Widgets;
|
using namespace Bloom::Widgets;
|
||||||
|
|
||||||
ValueAnnotationItem::ValueAnnotationItem(const FocusedMemoryRegion& focusedMemoryRegion)
|
ValueAnnotationItem::ValueAnnotationItem(const FocusedMemoryRegion& focusedMemoryRegion)
|
||||||
: AnnotationItem(focusedMemoryRegion, AnnotationItemPosition::TOP), focusedMemoryRegion(focusedMemoryRegion) {
|
: AnnotationItem(focusedMemoryRegion, AnnotationItemPosition::TOP)
|
||||||
|
, focusedMemoryRegion(focusedMemoryRegion)
|
||||||
|
, endianness(focusedMemoryRegion.endianness)
|
||||||
|
{
|
||||||
this->labelText = QString(ValueAnnotationItem::DEFAULT_LABEL_TEXT);
|
this->labelText = QString(ValueAnnotationItem::DEFAULT_LABEL_TEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValueAnnotationItem::setValue(const Targets::TargetMemoryBuffer& value) {
|
void ValueAnnotationItem::setValue(const Targets::TargetMemoryBuffer& value) {
|
||||||
this->value = value;
|
this->value = value;
|
||||||
|
|
||||||
|
if (this->endianness == Targets::TargetMemoryEndianness::LITTLE) {
|
||||||
|
std::reverse(this->value.begin(), this->value.end());
|
||||||
|
}
|
||||||
|
|
||||||
this->refreshLabelText();
|
this->refreshLabelText();
|
||||||
this->setToolTip(this->labelText);
|
this->setToolTip(this->labelText);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ namespace Bloom::Widgets
|
|||||||
|
|
||||||
FocusedMemoryRegion focusedMemoryRegion;
|
FocusedMemoryRegion focusedMemoryRegion;
|
||||||
Targets::TargetMemoryBuffer value;
|
Targets::TargetMemoryBuffer value;
|
||||||
|
Targets::TargetMemoryEndianness endianness = Targets::TargetMemoryEndianness::LITTLE;
|
||||||
|
|
||||||
void refreshLabelText();
|
void refreshLabelText();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -41,13 +41,21 @@ void FocusedRegionItem::applyChanges() {
|
|||||||
this->endAddressInput->text().toUInt(nullptr, 16)
|
this->endAddressInput->text().toUInt(nullptr, 16)
|
||||||
);
|
);
|
||||||
this->memoryRegion.addressRangeInputType = this->getSelectedAddressInputType();
|
this->memoryRegion.addressRangeInputType = this->getSelectedAddressInputType();
|
||||||
this->memoryRegion.addressRange = this->memoryRegion.addressRangeInputType == MemoryRegionAddressInputType::RELATIVE ?
|
this->memoryRegion.addressRange =
|
||||||
this->convertRelativeToAbsoluteAddressRange(inputAddressRange) : inputAddressRange;
|
this->memoryRegion.addressRangeInputType == MemoryRegionAddressInputType::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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto selectedEndiannessOptionName = this->endiannessInput->currentData().toString();
|
||||||
|
if (FocusedRegionItem::endiannessOptionsByName.contains(selectedEndiannessOptionName)) {
|
||||||
|
this->memoryRegion.endianness = FocusedRegionItem::endiannessOptionsByName.at(
|
||||||
|
selectedEndiannessOptionName
|
||||||
|
).endianness;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FocusedRegionItem::initFormInputs() {
|
void FocusedRegionItem::initFormInputs() {
|
||||||
@@ -55,11 +63,16 @@ void FocusedRegionItem::initFormInputs() {
|
|||||||
const auto& region = this->memoryRegion;
|
const auto& region = this->memoryRegion;
|
||||||
|
|
||||||
this->dataTypeInput = this->formWidget->findChild<QComboBox*>("data-type-input");
|
this->dataTypeInput = this->formWidget->findChild<QComboBox*>("data-type-input");
|
||||||
|
this->endiannessInput = this->formWidget->findChild<QComboBox*>("endianness-input");
|
||||||
|
|
||||||
for (const auto& [optionName, option] : FocusedRegionItem::dataTypeOptionsByName) {
|
for (const auto& [optionName, option] : FocusedRegionItem::dataTypeOptionsByName) {
|
||||||
this->dataTypeInput->addItem(option.text, optionName);
|
this->dataTypeInput->addItem(option.text, optionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto& [optionName, option] : FocusedRegionItem::endiannessOptionsByName) {
|
||||||
|
this->endiannessInput->addItem(option.text, optionName);
|
||||||
|
}
|
||||||
|
|
||||||
switch (region.dataType) {
|
switch (region.dataType) {
|
||||||
case MemoryRegionDataType::UNSIGNED_INTEGER: {
|
case MemoryRegionDataType::UNSIGNED_INTEGER: {
|
||||||
this->dataTypeInput->setCurrentText(FocusedRegionItem::dataTypeOptionsByName.at("unsigned_integer").text);
|
this->dataTypeInput->setCurrentText(FocusedRegionItem::dataTypeOptionsByName.at("unsigned_integer").text);
|
||||||
@@ -77,4 +90,15 @@ void FocusedRegionItem::initFormInputs() {
|
|||||||
this->dataTypeInput->setCurrentText(FocusedRegionItem::dataTypeOptionsByName.at("other").text);
|
this->dataTypeInput->setCurrentText(FocusedRegionItem::dataTypeOptionsByName.at("other").text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (region.endianness) {
|
||||||
|
case Targets::TargetMemoryEndianness::LITTLE: {
|
||||||
|
this->endiannessInput->setCurrentText(FocusedRegionItem::endiannessOptionsByName.at("little").text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Targets::TargetMemoryEndianness::BIG: {
|
||||||
|
this->endiannessInput->setCurrentText(FocusedRegionItem::endiannessOptionsByName.at("big").text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,15 @@ namespace Bloom::Widgets
|
|||||||
: text(text), dataType(dataType) {};
|
: text(text), dataType(dataType) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct EndiannessOption
|
||||||
|
{
|
||||||
|
QString text;
|
||||||
|
Targets::TargetMemoryEndianness endianness = Targets::TargetMemoryEndianness::LITTLE;
|
||||||
|
|
||||||
|
EndiannessOption(const QString& text, Targets::TargetMemoryEndianness endianness)
|
||||||
|
: text(text), endianness(endianness) {};
|
||||||
|
};
|
||||||
|
|
||||||
class FocusedRegionItem: public RegionItem
|
class FocusedRegionItem: public RegionItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -37,6 +46,7 @@ namespace Bloom::Widgets
|
|||||||
private:
|
private:
|
||||||
FocusedMemoryRegion memoryRegion;
|
FocusedMemoryRegion memoryRegion;
|
||||||
QComboBox* dataTypeInput = nullptr;
|
QComboBox* dataTypeInput = nullptr;
|
||||||
|
QComboBox* endiannessInput = nullptr;
|
||||||
|
|
||||||
static inline const std::map<QString, DataTypeOption> dataTypeOptionsByName = std::map<
|
static inline const std::map<QString, DataTypeOption> dataTypeOptionsByName = std::map<
|
||||||
QString, DataTypeOption
|
QString, DataTypeOption
|
||||||
@@ -45,6 +55,13 @@ namespace Bloom::Widgets
|
|||||||
{"unsigned_integer", DataTypeOption("Unsigned Integer", MemoryRegionDataType::UNSIGNED_INTEGER)},
|
{"unsigned_integer", DataTypeOption("Unsigned Integer", MemoryRegionDataType::UNSIGNED_INTEGER)},
|
||||||
{"signed_integer", DataTypeOption("Signed Integer", MemoryRegionDataType::SIGNED_INTEGER)},
|
{"signed_integer", DataTypeOption("Signed Integer", MemoryRegionDataType::SIGNED_INTEGER)},
|
||||||
{"ascii", DataTypeOption("ASCII String", MemoryRegionDataType::ASCII_STRING)},
|
{"ascii", DataTypeOption("ASCII String", MemoryRegionDataType::ASCII_STRING)},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
static inline const std::map<QString, EndiannessOption> endiannessOptionsByName = std::map<
|
||||||
|
QString, EndiannessOption
|
||||||
|
>({
|
||||||
|
{"little", EndiannessOption("Little-endian", Targets::TargetMemoryEndianness::LITTLE)},
|
||||||
|
{"big", EndiannessOption("Big-endian", Targets::TargetMemoryEndianness::BIG)},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ MemoryRegionManagerWindow::MemoryRegionManagerWindow(
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->setStyleSheet(windowStylesheet.readAll());
|
this->setStyleSheet(windowStylesheet.readAll());
|
||||||
this->setFixedSize(QSize(860, 470));
|
this->setFixedSize(QSize(900, 520));
|
||||||
|
|
||||||
auto uiLoader = UiLoader(this);
|
auto uiLoader = UiLoader(this);
|
||||||
this->container = uiLoader.load(&windowUiFile, this);
|
this->container = uiLoader.load(&windowUiFile, this);
|
||||||
|
|||||||
@@ -109,6 +109,12 @@
|
|||||||
max-width: 30px;
|
max-width: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#form-container #data-type-label,
|
||||||
|
#form-container #endianness-label {
|
||||||
|
min-width: 75px;
|
||||||
|
max-width: 75px;
|
||||||
|
}
|
||||||
|
|
||||||
#form-container #address-range-description-label,
|
#form-container #address-range-description-label,
|
||||||
#form-container #value-annotations-description-label,
|
#form-container #value-annotations-description-label,
|
||||||
#form-container #integer-width-notice-label {
|
#form-container #integer-width-notice-label {
|
||||||
|
|||||||
@@ -379,7 +379,7 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Specifying the type of data stored in this region will allow Bloom to present the current value of the data, in the form of a value annotation.</string>
|
<string>Specifying the type and endianness of the data stored in this region will allow Bloom to present the current value, in the form of a value annotation.</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -395,6 +395,31 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="integer-width-notice-label">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"/>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Maximum width for integer data types: 64 bits</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="vertical-spacer">
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<height>10</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="data-type-row">
|
<layout class="QHBoxLayout" name="data-type-row">
|
||||||
<item alignment="Qt::AlignVCenter">
|
<item alignment="Qt::AlignVCenter">
|
||||||
@@ -459,17 +484,55 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="integer-width-notice-label">
|
<layout class="QHBoxLayout" name="endianness-row">
|
||||||
<property name="sizePolicy">
|
<item alignment="Qt::AlignVCenter">
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"/>
|
<widget class="QLabel" name="endianness-label">
|
||||||
</property>
|
<property name="sizePolicy">
|
||||||
<property name="wordWrap">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"/>
|
||||||
<bool>true</bool>
|
</property>
|
||||||
</property>
|
<property name="text">
|
||||||
<property name="text">
|
<string>Endianness:</string>
|
||||||
<string>Maximum width for integer data types: 64 bits</string>
|
</property>
|
||||||
</property>
|
</widget>
|
||||||
</widget>
|
</item>
|
||||||
|
<item alignment="Qt::AlignVCenter">
|
||||||
|
<spacer name="horizontal-spacer">
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignVCenter">
|
||||||
|
<widget class="QComboBox" name="endianness-input">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"/>
|
||||||
|
</property>
|
||||||
|
<property name="minimumWidth">
|
||||||
|
<number>150</number>
|
||||||
|
</property>
|
||||||
|
<property name="frame">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignVCenter">
|
||||||
|
<spacer name="horizontal-spacer">
|
||||||
|
<property name="sizeHint">
|
||||||
|
<size>
|
||||||
|
<width>10</width>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="vertical-spacer">
|
<spacer name="vertical-spacer">
|
||||||
|
|||||||
@@ -122,6 +122,14 @@ InsightProjectSettings::InsightProjectSettings(const QJsonObject& jsonObject) {
|
|||||||
region.dataType = dataType.value();
|
region.dataType = dataType.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto endianness = InsightProjectSettings::regionEndiannessByName.valueAt(
|
||||||
|
regionObj.find("endianness")->toString()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (endianness.has_value()) {
|
||||||
|
region.endianness = endianness.value();
|
||||||
|
}
|
||||||
|
|
||||||
inspectionPaneSettings.focusedMemoryRegions.emplace_back(region);
|
inspectionPaneSettings.focusedMemoryRegions.emplace_back(region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -202,11 +210,13 @@ QJsonObject InsightProjectSettings::toJson() const {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const auto& regionDataTypesByName = InsightProjectSettings::regionDataTypesByName;
|
const auto& regionDataTypesByName = InsightProjectSettings::regionDataTypesByName;
|
||||||
|
const auto& regionEndiannessByName = InsightProjectSettings::regionEndiannessByName;
|
||||||
const auto& addressRangeInputTypesByName = InsightProjectSettings::addressRangeInputTypesByName;
|
const auto& addressRangeInputTypesByName = InsightProjectSettings::addressRangeInputTypesByName;
|
||||||
|
|
||||||
auto focusedRegions = QJsonArray();
|
auto focusedRegions = QJsonArray();
|
||||||
for (const auto& focusedRegion : inspectionPaneSettings.focusedMemoryRegions) {
|
for (const auto& focusedRegion : inspectionPaneSettings.focusedMemoryRegions) {
|
||||||
if (!regionDataTypesByName.contains(focusedRegion.dataType)
|
if (!regionDataTypesByName.contains(focusedRegion.dataType)
|
||||||
|
|| !regionEndiannessByName.contains(focusedRegion.endianness)
|
||||||
|| !addressRangeInputTypesByName.contains(focusedRegion.addressRangeInputType)
|
|| !addressRangeInputTypesByName.contains(focusedRegion.addressRangeInputType)
|
||||||
) {
|
) {
|
||||||
continue;
|
continue;
|
||||||
@@ -223,6 +233,7 @@ QJsonObject InsightProjectSettings::toJson() const {
|
|||||||
{"createdTimestamp", focusedRegion.createdDate.toSecsSinceEpoch()},
|
{"createdTimestamp", focusedRegion.createdDate.toSecsSinceEpoch()},
|
||||||
{"addressInputType", addressRangeInputTypesByName.at(focusedRegion.addressRangeInputType)},
|
{"addressInputType", addressRangeInputTypesByName.at(focusedRegion.addressRangeInputType)},
|
||||||
{"dataType", regionDataTypesByName.at(focusedRegion.dataType)},
|
{"dataType", regionDataTypesByName.at(focusedRegion.dataType)},
|
||||||
|
{"endianness", regionEndiannessByName.at(focusedRegion.endianness)},
|
||||||
});
|
});
|
||||||
|
|
||||||
focusedRegions.push_back(regionObj);
|
focusedRegions.push_back(regionObj);
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ namespace Bloom
|
|||||||
{MemoryRegionDataType::ASCII_STRING, "ascii_string"},
|
{MemoryRegionDataType::ASCII_STRING, "ascii_string"},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const inline BiMap<Targets::TargetMemoryEndianness, QString> regionEndiannessByName = {
|
||||||
|
{Targets::TargetMemoryEndianness::LITTLE, "little"},
|
||||||
|
{Targets::TargetMemoryEndianness::BIG, "big"},
|
||||||
|
};
|
||||||
|
|
||||||
static const inline BiMap<MemoryRegionAddressInputType, QString> addressRangeInputTypesByName = {
|
static const inline BiMap<MemoryRegionAddressInputType, QString> addressRangeInputTypesByName = {
|
||||||
{MemoryRegionAddressInputType::ABSOLUTE, "absolute"},
|
{MemoryRegionAddressInputType::ABSOLUTE, "absolute"},
|
||||||
{MemoryRegionAddressInputType::RELATIVE, "relative"},
|
{MemoryRegionAddressInputType::RELATIVE, "relative"},
|
||||||
|
|||||||
@@ -5,6 +5,12 @@
|
|||||||
|
|
||||||
namespace Bloom::Targets
|
namespace Bloom::Targets
|
||||||
{
|
{
|
||||||
|
enum class TargetMemoryEndianness: std::uint8_t
|
||||||
|
{
|
||||||
|
BIG,
|
||||||
|
LITTLE,
|
||||||
|
};
|
||||||
|
|
||||||
enum class TargetMemoryType: std::uint8_t
|
enum class TargetMemoryType: std::uint8_t
|
||||||
{
|
{
|
||||||
FLASH,
|
FLASH,
|
||||||
|
|||||||
Reference in New Issue
Block a user