diff --git a/src/apps/debugger/controllers/DebugReportGenerator.cpp b/src/apps/debugger/controllers/DebugReportGenerator.cpp index 3d05bd144c..6f40773c61 100644 --- a/src/apps/debugger/controllers/DebugReportGenerator.cpp +++ b/src/apps/debugger/controllers/DebugReportGenerator.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014, Rene Gollent, rene@gollent.com. + * Copyright 2012-2015, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -589,9 +589,16 @@ DebugReportGenerator::_DumpDebuggedThreadInfo(BFile& _output, reg = fArchitecture->Registers() + i; state->GetRegisterValue(reg, value); - char buffer[64]; - data.SetToFormat("\t\t\t%5s:\t%s\n", reg->Name(), - UiUtils::VariantToString(value, buffer, sizeof(buffer))); + 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]; + data.SetToFormat("\t\t\t%5s:\t%s\n", reg->Name(), + UiUtils::VariantToString(value, buffer, sizeof(buffer))); + } + WRITE_AND_CHECK(_output, data); } diff --git a/src/apps/debugger/user_interface/gui/team_window/RegistersView.cpp b/src/apps/debugger/user_interface/gui/team_window/RegistersView.cpp index f1a1be5a39..fea36d8888 100644 --- a/src/apps/debugger/user_interface/gui/team_window/RegistersView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/RegistersView.cpp @@ -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* GetLabelForSIMDFormat(int format) { @@ -176,8 +166,11 @@ public: return false; if (!fCpuState->GetRegisterValue(reg, value)) value.SetTo("?", B_VARIANT_DONT_COPY_DATA); - else if (reg->Format() == REGISTER_FORMAT_SIMD) - _FormatSIMDValue(reg, value); + else if (reg->Format() == REGISTER_FORMAT_SIMD) { + BString output; + value.SetTo(UiUtils::FormatSIMDValue(value, + reg->BitSize(),fSIMDFormat, output)); + } return true; default: return false; @@ -193,74 +186,6 @@ public: } 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(data, i)); - break; - case SIMD_RENDER_FORMAT_INT16: - format.SetToFormat("%#" B_PRIx16, - _GetSIMDValueAtOffset(data, i)); - break; - case SIMD_RENDER_FORMAT_INT32: - format.SetToFormat("%#" B_PRIx32, - _GetSIMDValueAtOffset(data, i)); - break; - case SIMD_RENDER_FORMAT_INT64: - format.SetToFormat("%#" B_PRIx64, - _GetSIMDValueAtOffset(data, i)); - break; - case SIMD_RENDER_FORMAT_FLOAT: - format.SetToFormat("%.3g", - (double)_GetSIMDValueAtOffset(data, i)); - break; - case SIMD_RENDER_FORMAT_DOUBLE: - format.SetToFormat("%.3g", - _GetSIMDValueAtOffset(data, i)); - break; - } - temp += format; - if (i < count - 1) - temp += ", "; - } - temp += "}"; - - _value.SetTo(temp); - } - - template - 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: Architecture* fArchitecture; CpuState* fCpuState; diff --git a/src/apps/debugger/user_interface/util/UiUtils.cpp b/src/apps/debugger/user_interface/util/UiUtils.cpp index 8c21e8c804..c2de82f67e 100644 --- a/src/apps/debugger/user_interface/util/UiUtils.cpp +++ b/src/apps/debugger/user_interface/util/UiUtils.cpp @@ -1,6 +1,6 @@ /* * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2012-2014, Rene Gollent, rene@gollent.com. + * Copyright 2012-2015, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -485,3 +485,77 @@ UiUtils::TypeCodeToString(type_code type) return "unknown"; } } + + +template +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(data, i)); + break; + case SIMD_RENDER_FORMAT_INT16: + temp.SetToFormat("%#" B_PRIx16, + GetSIMDValueAtOffset(data, i)); + break; + case SIMD_RENDER_FORMAT_INT32: + temp.SetToFormat("%#" B_PRIx32, + GetSIMDValueAtOffset(data, i)); + break; + case SIMD_RENDER_FORMAT_INT64: + temp.SetToFormat("%#" B_PRIx64, + GetSIMDValueAtOffset(data, i)); + break; + case SIMD_RENDER_FORMAT_FLOAT: + temp.SetToFormat("%.3g", + (double)GetSIMDValueAtOffset(data, i)); + break; + case SIMD_RENDER_FORMAT_DOUBLE: + temp.SetToFormat("%.3g", + GetSIMDValueAtOffset(data, i)); + break; + } + _output += temp; + if (i < count - 1) + _output += ", "; + } + _output += "}"; + + return _output; +} diff --git a/src/apps/debugger/user_interface/util/UiUtils.h b/src/apps/debugger/user_interface/util/UiUtils.h index 4d9cdb2c42..8f5af96ed1 100644 --- a/src/apps/debugger/user_interface/util/UiUtils.h +++ b/src/apps/debugger/user_interface/util/UiUtils.h @@ -1,5 +1,5 @@ /* - * Copyright 2014, Rene Gollent, rene@gollent.com. + * Copyright 2014-2015, Rene Gollent, rene@gollent.com. * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ @@ -22,6 +22,16 @@ class TeamMemoryBlock; 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 { public: static const char* ThreadStateToString(int state, @@ -60,6 +70,10 @@ public: RangeList& _output); static const char* TypeCodeToString(type_code type); + + static const BString& FormatSIMDValue(const BVariant& value, + uint32 bitSize, uint32 format, + BString& _output); };