diff options
-rw-r--r-- | lldb/source/Core/DataExtractor.cpp | 36 | ||||
-rw-r--r-- | lldb/source/Core/ValueObject.cpp | 36 |
2 files changed, 43 insertions, 29 deletions
diff --git a/lldb/source/Core/DataExtractor.cpp b/lldb/source/Core/DataExtractor.cpp index 0b409451d99..da52be8d865 100644 --- a/lldb/source/Core/DataExtractor.cpp +++ b/lldb/source/Core/DataExtractor.cpp @@ -1422,7 +1422,13 @@ DataExtractor::Dump (Stream *s, switch (item_format) { case eFormatBoolean: - s->Printf ("%s", GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset) ? "true" : "false"); + if (item_byte_size <= 8) + s->Printf ("%s", GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset) ? "true" : "false"); + else + { + s->Printf("error: unsupported byte size (%u) for boolean format", item_byte_size); + return offset; + } break; case eFormatBinary: @@ -1505,6 +1511,7 @@ DataExtractor::Dump (Stream *s, } break; + case eFormatEnum: // Print enum value as a signed integer when we don't get the enum type case eFormatDecimal: if (item_byte_size <= 8) s->Printf ("%lld", GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset)); @@ -1568,11 +1575,6 @@ DataExtractor::Dump (Stream *s, } break; - case eFormatEnum: - // Print enum value as a signed integer when we don't get the enum type - s->Printf ("%lld", GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset)); - break; - case eFormatCString: { const char *cstr = GetCStr(&offset); @@ -1631,6 +1633,11 @@ DataExtractor::Dump (Stream *s, s->Printf("%llu", GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0)); s->Printf(" + %llui", GetMaxU64Bitfield(&offset, complex_int_byte_size, 0, 0)); } + else + { + s->Printf("error: unsupported byte size (%u) for complex integer format", item_byte_size); + return offset; + } } break; @@ -1660,8 +1667,8 @@ DataExtractor::Dump (Stream *s, } else { - s->Printf ("unsupported complex float byte size %u", item_byte_size); - return start_offset; + s->Printf("error: unsupported byte size (%u) for complex float format", item_byte_size); + return offset; } break; @@ -1707,14 +1714,19 @@ DataExtractor::Dump (Stream *s, { s->Printf ("%Lg", GetLongDouble(&offset)); } + else + { + s->Printf("error: unsupported byte size (%u) for float format", item_byte_size); + return offset; + } break; case eFormatUnicode16: - s->Printf("0x%4.4x", GetU16 (&offset)); + s->Printf("U+%4.4x", GetU16 (&offset)); break; case eFormatUnicode32: - s->Printf("0x%8.8x", GetU32 (&offset)); + s->Printf("U+0x%8.8x", GetU32 (&offset)); break; case eFormatAddressInfo: @@ -1757,8 +1769,8 @@ DataExtractor::Dump (Stream *s, } else { - s->Printf ("unsupported hex float byte size %u", item_byte_size); - return start_offset; + s->Printf("error: unsupported byte size (%u) for hex float format", item_byte_size); + return offset; } break; diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 7c8cd7f62ed..023234cf99f 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -1135,24 +1135,26 @@ ValueObject::GetValueAsCString () } StreamString sstr; ExecutionContext exe_ctx (GetExecutionContextRef()); - if (ClangASTType::DumpTypeValue (GetClangAST(), // The clang AST - clang_type, // The clang type to display - &sstr, - my_format, // Format to display this type with - m_data, // Data to extract from - 0, // Byte offset into "m_data" - GetByteSize(), // Byte size of item in "m_data" - GetBitfieldBitSize(), // Bitfield bit size - GetBitfieldBitOffset(), - exe_ctx.GetBestExecutionContextScope())) // Bitfield bit offset - m_value_str.swap(sstr.GetString()); - else - { - m_error.SetErrorStringWithFormat ("unsufficient data for value (only %lu of %lu bytes available)", - m_data.GetByteSize(), - GetByteSize()); + ClangASTType::DumpTypeValue (GetClangAST(), // The clang AST + clang_type, // The clang type to display + &sstr, + my_format, // Format to display this type with + m_data, // Data to extract from + 0, // Byte offset into "m_data" + GetByteSize(), // Byte size of item in "m_data" + GetBitfieldBitSize(), // Bitfield bit size + GetBitfieldBitOffset(), // Bitfield bit offset + exe_ctx.GetBestExecutionContextScope()); + // Don't set the m_error to anything here otherwise + // we won't be able to re-format as anything else. The + // code for ClangASTType::DumpTypeValue() should always + // return something, even if that something contains + // an error messsage. "m_error" is used to detect errors + // when reading the valid object, not for formatting errors. + if (sstr.GetString().empty()) m_value_str.clear(); - } + else + m_value_str.swap(sstr.GetString()); } } break; |