Made endianness of focused memory regions configurable
This commit is contained in:
@@ -18,6 +18,7 @@ namespace Bloom
|
||||
{
|
||||
public:
|
||||
MemoryRegionDataType dataType = MemoryRegionDataType::UNKNOWN;
|
||||
Targets::TargetMemoryEndianness endianness = Targets::TargetMemoryEndianness::LITTLE;
|
||||
|
||||
explicit FocusedMemoryRegion(
|
||||
const QString& name,
|
||||
|
||||
@@ -5,12 +5,20 @@
|
||||
using namespace Bloom::Widgets;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void ValueAnnotationItem::setValue(const Targets::TargetMemoryBuffer& value) {
|
||||
this->value = value;
|
||||
|
||||
if (this->endianness == Targets::TargetMemoryEndianness::LITTLE) {
|
||||
std::reverse(this->value.begin(), this->value.end());
|
||||
}
|
||||
|
||||
this->refreshLabelText();
|
||||
this->setToolTip(this->labelText);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace Bloom::Widgets
|
||||
|
||||
FocusedMemoryRegion focusedMemoryRegion;
|
||||
Targets::TargetMemoryBuffer value;
|
||||
Targets::TargetMemoryEndianness endianness = Targets::TargetMemoryEndianness::LITTLE;
|
||||
|
||||
void refreshLabelText();
|
||||
};
|
||||
|
||||
@@ -41,13 +41,21 @@ void FocusedRegionItem::applyChanges() {
|
||||
this->endAddressInput->text().toUInt(nullptr, 16)
|
||||
);
|
||||
this->memoryRegion.addressRangeInputType = this->getSelectedAddressInputType();
|
||||
this->memoryRegion.addressRange = this->memoryRegion.addressRangeInputType == MemoryRegionAddressInputType::RELATIVE ?
|
||||
this->convertRelativeToAbsoluteAddressRange(inputAddressRange) : inputAddressRange;
|
||||
this->memoryRegion.addressRange =
|
||||
this->memoryRegion.addressRangeInputType == MemoryRegionAddressInputType::RELATIVE ?
|
||||
this->convertRelativeToAbsoluteAddressRange(inputAddressRange) : inputAddressRange;
|
||||
|
||||
auto selectedDataTypeOptionName = this->dataTypeInput->currentData().toString();
|
||||
if (FocusedRegionItem::dataTypeOptionsByName.contains(selectedDataTypeOptionName)) {
|
||||
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() {
|
||||
@@ -55,11 +63,16 @@ void FocusedRegionItem::initFormInputs() {
|
||||
const auto& region = this->memoryRegion;
|
||||
|
||||
this->dataTypeInput = this->formWidget->findChild<QComboBox*>("data-type-input");
|
||||
this->endiannessInput = this->formWidget->findChild<QComboBox*>("endianness-input");
|
||||
|
||||
for (const auto& [optionName, option] : FocusedRegionItem::dataTypeOptionsByName) {
|
||||
this->dataTypeInput->addItem(option.text, optionName);
|
||||
}
|
||||
|
||||
for (const auto& [optionName, option] : FocusedRegionItem::endiannessOptionsByName) {
|
||||
this->endiannessInput->addItem(option.text, optionName);
|
||||
}
|
||||
|
||||
switch (region.dataType) {
|
||||
case MemoryRegionDataType::UNSIGNED_INTEGER: {
|
||||
this->dataTypeInput->setCurrentText(FocusedRegionItem::dataTypeOptionsByName.at("unsigned_integer").text);
|
||||
@@ -77,4 +90,15 @@ void FocusedRegionItem::initFormInputs() {
|
||||
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) {};
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -37,6 +46,7 @@ namespace Bloom::Widgets
|
||||
private:
|
||||
FocusedMemoryRegion memoryRegion;
|
||||
QComboBox* dataTypeInput = nullptr;
|
||||
QComboBox* endiannessInput = nullptr;
|
||||
|
||||
static inline const std::map<QString, DataTypeOption> dataTypeOptionsByName = std::map<
|
||||
QString, DataTypeOption
|
||||
@@ -45,6 +55,13 @@ namespace Bloom::Widgets
|
||||
{"unsigned_integer", DataTypeOption("Unsigned Integer", MemoryRegionDataType::UNSIGNED_INTEGER)},
|
||||
{"signed_integer", DataTypeOption("Signed Integer", MemoryRegionDataType::SIGNED_INTEGER)},
|
||||
{"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->setFixedSize(QSize(860, 470));
|
||||
this->setFixedSize(QSize(900, 520));
|
||||
|
||||
auto uiLoader = UiLoader(this);
|
||||
this->container = uiLoader.load(&windowUiFile, this);
|
||||
|
||||
@@ -109,6 +109,12 @@
|
||||
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 #value-annotations-description-label,
|
||||
#form-container #integer-width-notice-label {
|
||||
|
||||
@@ -379,7 +379,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -395,6 +395,31 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</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>
|
||||
<layout class="QHBoxLayout" name="data-type-row">
|
||||
<item alignment="Qt::AlignVCenter">
|
||||
@@ -459,17 +484,55 @@
|
||||
</spacer>
|
||||
</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>
|
||||
<layout class="QHBoxLayout" name="endianness-row">
|
||||
<item alignment="Qt::AlignVCenter">
|
||||
<widget class="QLabel" name="endianness-label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Endianness:</string>
|
||||
</property>
|
||||
</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>
|
||||
<spacer name="vertical-spacer">
|
||||
|
||||
Reference in New Issue
Block a user