Add dump support for half float
This commit is contained in:
parent
66ddb4198e
commit
f2ee27b732
|
@ -3,6 +3,7 @@
|
|||
#include "Bridge.h"
|
||||
#include "StringUtil.h"
|
||||
#include <QMessageBox>
|
||||
#include <QFloat16>
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
#include <QStringDecoder>
|
||||
|
@ -1083,6 +1084,12 @@ void HexDump::wordToString(duint rva, uint16_t word, WordViewMode mode, RichText
|
|||
}
|
||||
break;
|
||||
|
||||
case HalfFloatWord:
|
||||
{
|
||||
str = ToFloatingString<qfloat16>(&word, 3);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
|
||||
|
@ -1319,6 +1326,12 @@ static int wordStringMaxLength(HexDump::WordViewMode mode)
|
|||
}
|
||||
break;
|
||||
|
||||
case HexDump::HalfFloatWord:
|
||||
{
|
||||
length = 9;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ public:
|
|||
HexWord,
|
||||
UnicodeWord,
|
||||
SignedDecWord,
|
||||
UnsignedDecWord
|
||||
UnsignedDecWord,
|
||||
HalfFloatWord //half precision floatint point
|
||||
};
|
||||
|
||||
enum DwordViewMode
|
||||
|
|
|
@ -239,6 +239,7 @@ void CPUDump::setupContextMenu()
|
|||
floatMenu->addAction(makeAction(DIcon("32bit-float"), tr("&Float (32-bit)"), SLOT(floatFloatSlot())));
|
||||
floatMenu->addAction(makeAction(DIcon("64bit-float"), tr("&Double (64-bit)"), SLOT(floatDoubleSlot())));
|
||||
floatMenu->addAction(makeAction(DIcon("80bit-float"), tr("&Long double (80-bit)"), SLOT(floatLongDoubleSlot())));
|
||||
floatMenu->addAction(makeAction(DIcon("word"), tr("&Half float (16-bit)"), SLOT(floatHalfSlot())));
|
||||
mMenuBuilder->addMenu(makeMenu(DIcon("float"), tr("&Float")), floatMenu);
|
||||
|
||||
mMenuBuilder->addAction(makeAction(DIcon("address"), tr("&Address"), SLOT(addressAsciiSlot())));
|
||||
|
@ -1208,6 +1209,31 @@ void CPUDump::floatLongDoubleSlot()
|
|||
reloadData();
|
||||
}
|
||||
|
||||
void CPUDump::floatHalfSlot()
|
||||
{
|
||||
Config()->setUint("HexDump", "DefaultView", (duint)ViewFloatHalf);
|
||||
int charwidth = getCharWidth();
|
||||
ColumnDescriptor colDesc;
|
||||
DataDescriptor dDesc;
|
||||
|
||||
colDesc.isData = true; //float half
|
||||
colDesc.itemCount = 4;
|
||||
colDesc.separator = 0;
|
||||
colDesc.data.itemSize = Word;
|
||||
colDesc.data.wordMode = HalfFloatWord;
|
||||
appendResetDescriptor(8 + charwidth * 40, tr("Half float (16-bit)"), false, colDesc);
|
||||
|
||||
colDesc.isData = false; //empty column
|
||||
colDesc.itemCount = 0;
|
||||
colDesc.separator = 0;
|
||||
dDesc.itemSize = Byte;
|
||||
dDesc.byteMode = AsciiByte;
|
||||
colDesc.data = dDesc;
|
||||
appendDescriptor(0, "", false, colDesc);
|
||||
|
||||
reloadData();
|
||||
}
|
||||
|
||||
void CPUDump::addressAsciiSlot()
|
||||
{
|
||||
Config()->setUint("HexDump", "DefaultView", (duint)ViewAddressAscii);
|
||||
|
|
|
@ -59,6 +59,7 @@ public slots:
|
|||
void floatFloatSlot();
|
||||
void floatDoubleSlot();
|
||||
void floatLongDoubleSlot();
|
||||
void floatHalfSlot();
|
||||
|
||||
void addressUnicodeSlot();
|
||||
void addressAsciiSlot();
|
||||
|
@ -122,7 +123,8 @@ private:
|
|||
ViewAddressAscii,
|
||||
ViewAddressUnicode,
|
||||
ViewHexCodepage,
|
||||
ViewTextCodepage
|
||||
ViewTextCodepage,
|
||||
ViewFloatHalf
|
||||
};
|
||||
|
||||
void setView(ViewEnum_t view);
|
||||
|
|
|
@ -159,6 +159,7 @@ void TraceDump::setupContextMenu()
|
|||
wFloatMenu->addAction(makeAction(DIcon("32bit-float"), tr("&Float (32-bit)"), SLOT(floatFloatSlot())));
|
||||
wFloatMenu->addAction(makeAction(DIcon("64bit-float"), tr("&Double (64-bit)"), SLOT(floatDoubleSlot())));
|
||||
wFloatMenu->addAction(makeAction(DIcon("80bit-float"), tr("&Long double (80-bit)"), SLOT(floatLongDoubleSlot())));
|
||||
wFloatMenu->addAction(makeAction(DIcon("word"), tr("&Half float (16-bit)"), SLOT(floatHalfSlot())));
|
||||
mMenuBuilder->addMenu(makeMenu(DIcon("float"), tr("&Float")), wFloatMenu);
|
||||
|
||||
mMenuBuilder->addAction(makeAction(DIcon("address"), tr("&Address"), SLOT(addressAsciiSlot())));
|
||||
|
@ -992,6 +993,31 @@ void TraceDump::floatLongDoubleSlot()
|
|||
reloadData();
|
||||
}
|
||||
|
||||
void TraceDump::floatHalfSlot()
|
||||
{
|
||||
Config()->setUint("HexDump", "DefaultView", (duint)ViewFloatHalf);
|
||||
int charwidth = getCharWidth();
|
||||
ColumnDescriptor colDesc;
|
||||
DataDescriptor dDesc;
|
||||
|
||||
colDesc.isData = true; //float half
|
||||
colDesc.itemCount = 4;
|
||||
colDesc.separator = 0;
|
||||
colDesc.data.itemSize = Word;
|
||||
colDesc.data.wordMode = HalfFloatWord;
|
||||
appendResetDescriptor(8 + charwidth * 40, tr("Half float (16-bit)"), false, colDesc);
|
||||
|
||||
colDesc.isData = false; //empty column
|
||||
colDesc.itemCount = 0;
|
||||
colDesc.separator = 0;
|
||||
dDesc.itemSize = Byte;
|
||||
dDesc.byteMode = AsciiByte;
|
||||
colDesc.data = dDesc;
|
||||
appendDescriptor(0, "", false, colDesc);
|
||||
|
||||
reloadData();
|
||||
}
|
||||
|
||||
void TraceDump::addressAsciiSlot()
|
||||
{
|
||||
Config()->setUint("HexDump", "DefaultView", (duint)ViewAddressAscii);
|
||||
|
|
|
@ -63,6 +63,7 @@ public slots:
|
|||
void floatFloatSlot();
|
||||
void floatDoubleSlot();
|
||||
void floatLongDoubleSlot();
|
||||
void floatHalfSlot();
|
||||
|
||||
void addressUnicodeSlot();
|
||||
void addressAsciiSlot();
|
||||
|
@ -123,7 +124,8 @@ private:
|
|||
ViewAddressAscii,
|
||||
ViewAddressUnicode,
|
||||
ViewHexCodepage,
|
||||
ViewTextCodepage
|
||||
ViewTextCodepage,
|
||||
ViewFloatHalf
|
||||
};
|
||||
|
||||
void setView(ViewEnum_t view);
|
||||
|
|
Loading…
Reference in New Issue