Debugger: Cleanups.
- Factor out RegistersView's SIMD output formatting functions into UiUtils helpers. Adjust RegistersView accordingly. - Adjust DebugReportGenerator to detect SIMD registers and format them appropriately for report output using the aforementioned helpers.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2014, Rene Gollent, [email protected].
|
* Copyright 2012-2015, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -589,9 +589,16 @@ DebugReportGenerator::_DumpDebuggedThreadInfo(BFile& _output,
|
|||||||
reg = fArchitecture->Registers() + i;
|
reg = fArchitecture->Registers() + i;
|
||||||
state->GetRegisterValue(reg, value);
|
state->GetRegisterValue(reg, value);
|
||||||
|
|
||||||
|
if (reg->Format() == REGISTER_FORMAT_SIMD) {
|
||||||
|
data.SetToFormat("\t\t\t%5s:\t%s\n", reg->Name(),
|
||||||
|
UiUtils::FormatSIMDValue(value, reg->BitSize(),
|
||||||
|
SIMD_RENDER_FORMAT_INT16, data).String());
|
||||||
|
} else {
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
data.SetToFormat("\t\t\t%5s:\t%s\n", reg->Name(),
|
data.SetToFormat("\t\t\t%5s:\t%s\n", reg->Name(),
|
||||||
UiUtils::VariantToString(value, buffer, sizeof(buffer)));
|
UiUtils::VariantToString(value, buffer, sizeof(buffer)));
|
||||||
|
}
|
||||||
|
|
||||||
WRITE_AND_CHECK(_output, data);
|
WRITE_AND_CHECK(_output, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,16 +31,6 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum {
|
|
||||||
SIMD_RENDER_FORMAT_INT8 = 0,
|
|
||||||
SIMD_RENDER_FORMAT_INT16,
|
|
||||||
SIMD_RENDER_FORMAT_INT32,
|
|
||||||
SIMD_RENDER_FORMAT_INT64,
|
|
||||||
SIMD_RENDER_FORMAT_FLOAT,
|
|
||||||
SIMD_RENDER_FORMAT_DOUBLE
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static const char*
|
static const char*
|
||||||
GetLabelForSIMDFormat(int format)
|
GetLabelForSIMDFormat(int format)
|
||||||
{
|
{
|
||||||
@@ -176,8 +166,11 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
if (!fCpuState->GetRegisterValue(reg, value))
|
if (!fCpuState->GetRegisterValue(reg, value))
|
||||||
value.SetTo("?", B_VARIANT_DONT_COPY_DATA);
|
value.SetTo("?", B_VARIANT_DONT_COPY_DATA);
|
||||||
else if (reg->Format() == REGISTER_FORMAT_SIMD)
|
else if (reg->Format() == REGISTER_FORMAT_SIMD) {
|
||||||
_FormatSIMDValue(reg, value);
|
BString output;
|
||||||
|
value.SetTo(UiUtils::FormatSIMDValue(value,
|
||||||
|
reg->BitSize(),fSIMDFormat, output));
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@@ -193,74 +186,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _FormatSIMDValue(const Register* reg, BVariant& _value)
|
|
||||||
{
|
|
||||||
BString temp("{");
|
|
||||||
char* data = (char*)_value.ToPointer();
|
|
||||||
uint32 count = reg->BitSize() / (_GetSIMDFormatByteSize() * 8);
|
|
||||||
for (uint32 i = 0; i < count; i ++) {
|
|
||||||
BString format;
|
|
||||||
switch (fSIMDFormat) {
|
|
||||||
case SIMD_RENDER_FORMAT_INT8:
|
|
||||||
format.SetToFormat("%#" B_PRIx8,
|
|
||||||
_GetSIMDValueAtOffset<uint8>(data, i));
|
|
||||||
break;
|
|
||||||
case SIMD_RENDER_FORMAT_INT16:
|
|
||||||
format.SetToFormat("%#" B_PRIx16,
|
|
||||||
_GetSIMDValueAtOffset<uint16>(data, i));
|
|
||||||
break;
|
|
||||||
case SIMD_RENDER_FORMAT_INT32:
|
|
||||||
format.SetToFormat("%#" B_PRIx32,
|
|
||||||
_GetSIMDValueAtOffset<uint32>(data, i));
|
|
||||||
break;
|
|
||||||
case SIMD_RENDER_FORMAT_INT64:
|
|
||||||
format.SetToFormat("%#" B_PRIx64,
|
|
||||||
_GetSIMDValueAtOffset<uint64>(data, i));
|
|
||||||
break;
|
|
||||||
case SIMD_RENDER_FORMAT_FLOAT:
|
|
||||||
format.SetToFormat("%.3g",
|
|
||||||
(double)_GetSIMDValueAtOffset<float>(data, i));
|
|
||||||
break;
|
|
||||||
case SIMD_RENDER_FORMAT_DOUBLE:
|
|
||||||
format.SetToFormat("%.3g",
|
|
||||||
_GetSIMDValueAtOffset<double>(data, i));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
temp += format;
|
|
||||||
if (i < count - 1)
|
|
||||||
temp += ", ";
|
|
||||||
}
|
|
||||||
temp += "}";
|
|
||||||
|
|
||||||
_value.SetTo(temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
T _GetSIMDValueAtOffset(char* data, int32 index)
|
|
||||||
{
|
|
||||||
return ((T*)data)[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 _GetSIMDFormatByteSize() const
|
|
||||||
{
|
|
||||||
switch (fSIMDFormat) {
|
|
||||||
case SIMD_RENDER_FORMAT_INT8:
|
|
||||||
return sizeof(char);
|
|
||||||
case SIMD_RENDER_FORMAT_INT16:
|
|
||||||
return sizeof(int16);
|
|
||||||
case SIMD_RENDER_FORMAT_INT32:
|
|
||||||
return sizeof(int32);
|
|
||||||
case SIMD_RENDER_FORMAT_INT64:
|
|
||||||
return sizeof(int64);
|
|
||||||
case SIMD_RENDER_FORMAT_FLOAT:
|
|
||||||
return sizeof(float);
|
|
||||||
case SIMD_RENDER_FORMAT_DOUBLE:
|
|
||||||
return sizeof(double);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Architecture* fArchitecture;
|
Architecture* fArchitecture;
|
||||||
CpuState* fCpuState;
|
CpuState* fCpuState;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012, Ingo Weinhold, [email protected].
|
* Copyright 2012, Ingo Weinhold, [email protected].
|
||||||
* Copyright 2012-2014, Rene Gollent, [email protected].
|
* Copyright 2012-2015, Rene Gollent, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -485,3 +485,77 @@ UiUtils::TypeCodeToString(type_code type)
|
|||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T GetSIMDValueAtOffset(char* data, int32 index)
|
||||||
|
{
|
||||||
|
return ((T*)data)[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int32 GetSIMDFormatByteSize(uint32 format)
|
||||||
|
{
|
||||||
|
switch (format) {
|
||||||
|
case SIMD_RENDER_FORMAT_INT8:
|
||||||
|
return sizeof(char);
|
||||||
|
case SIMD_RENDER_FORMAT_INT16:
|
||||||
|
return sizeof(int16);
|
||||||
|
case SIMD_RENDER_FORMAT_INT32:
|
||||||
|
return sizeof(int32);
|
||||||
|
case SIMD_RENDER_FORMAT_INT64:
|
||||||
|
return sizeof(int64);
|
||||||
|
case SIMD_RENDER_FORMAT_FLOAT:
|
||||||
|
return sizeof(float);
|
||||||
|
case SIMD_RENDER_FORMAT_DOUBLE:
|
||||||
|
return sizeof(double);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*static*/
|
||||||
|
const BString&
|
||||||
|
UiUtils::FormatSIMDValue(const BVariant& value, uint32 bitSize,
|
||||||
|
uint32 format, BString& _output)
|
||||||
|
{
|
||||||
|
_output.SetTo("{");
|
||||||
|
char* data = (char*)value.ToPointer();
|
||||||
|
uint32 count = bitSize / (GetSIMDFormatByteSize(format) * 8);
|
||||||
|
for (uint32 i = 0; i < count; i ++) {
|
||||||
|
BString temp;
|
||||||
|
switch (format) {
|
||||||
|
case SIMD_RENDER_FORMAT_INT8:
|
||||||
|
temp.SetToFormat("%#" B_PRIx8,
|
||||||
|
GetSIMDValueAtOffset<uint8>(data, i));
|
||||||
|
break;
|
||||||
|
case SIMD_RENDER_FORMAT_INT16:
|
||||||
|
temp.SetToFormat("%#" B_PRIx16,
|
||||||
|
GetSIMDValueAtOffset<uint16>(data, i));
|
||||||
|
break;
|
||||||
|
case SIMD_RENDER_FORMAT_INT32:
|
||||||
|
temp.SetToFormat("%#" B_PRIx32,
|
||||||
|
GetSIMDValueAtOffset<uint32>(data, i));
|
||||||
|
break;
|
||||||
|
case SIMD_RENDER_FORMAT_INT64:
|
||||||
|
temp.SetToFormat("%#" B_PRIx64,
|
||||||
|
GetSIMDValueAtOffset<uint64>(data, i));
|
||||||
|
break;
|
||||||
|
case SIMD_RENDER_FORMAT_FLOAT:
|
||||||
|
temp.SetToFormat("%.3g",
|
||||||
|
(double)GetSIMDValueAtOffset<float>(data, i));
|
||||||
|
break;
|
||||||
|
case SIMD_RENDER_FORMAT_DOUBLE:
|
||||||
|
temp.SetToFormat("%.3g",
|
||||||
|
GetSIMDValueAtOffset<double>(data, i));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
_output += temp;
|
||||||
|
if (i < count - 1)
|
||||||
|
_output += ", ";
|
||||||
|
}
|
||||||
|
_output += "}";
|
||||||
|
|
||||||
|
return _output;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2014, Rene Gollent, [email protected].
|
* Copyright 2014-2015, Rene Gollent, [email protected].
|
||||||
* Copyright 2012, Ingo Weinhold, [email protected].
|
* Copyright 2012, Ingo Weinhold, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
@@ -22,6 +22,16 @@ class TeamMemoryBlock;
|
|||||||
class ValueNodeChild;
|
class ValueNodeChild;
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SIMD_RENDER_FORMAT_INT8 = 0,
|
||||||
|
SIMD_RENDER_FORMAT_INT16,
|
||||||
|
SIMD_RENDER_FORMAT_INT32,
|
||||||
|
SIMD_RENDER_FORMAT_INT64,
|
||||||
|
SIMD_RENDER_FORMAT_FLOAT,
|
||||||
|
SIMD_RENDER_FORMAT_DOUBLE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class UiUtils {
|
class UiUtils {
|
||||||
public:
|
public:
|
||||||
static const char* ThreadStateToString(int state,
|
static const char* ThreadStateToString(int state,
|
||||||
@@ -60,6 +70,10 @@ public:
|
|||||||
RangeList& _output);
|
RangeList& _output);
|
||||||
|
|
||||||
static const char* TypeCodeToString(type_code type);
|
static const char* TypeCodeToString(type_code type);
|
||||||
|
|
||||||
|
static const BString& FormatSIMDValue(const BVariant& value,
|
||||||
|
uint32 bitSize, uint32 format,
|
||||||
|
BString& _output);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user