diff options
-rw-r--r-- | lldb/include/lldb/API/SBValue.h | 6 | ||||
-rw-r--r-- | lldb/include/lldb/Core/ValueObject.h | 2 | ||||
-rw-r--r-- | lldb/include/lldb/lldb-enumerations.h | 1 | ||||
-rw-r--r-- | lldb/source/API/SBValue.cpp | 16 | ||||
-rw-r--r-- | lldb/source/Core/DataExtractor.cpp | 97 | ||||
-rw-r--r-- | lldb/source/Symbol/ClangASTType.cpp | 120 |
6 files changed, 185 insertions, 57 deletions
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 76a4dbfa422..f5e1fc6f81c 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -48,6 +48,12 @@ public: bool IsInScope (const lldb::SBFrame &frame); + lldb::Format + GetFormat () const; + + void + SetFormat (lldb::Format format); + const char * GetValue (const lldb::SBFrame &frame); diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index dad51a51b7c..0ad0a82487d 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -260,6 +260,8 @@ public: void SetFormat (lldb::Format format) { + if (format != m_format) + m_value_str.clear(); m_format = format; } diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index c3b8bf75a76..29abd99f536 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -155,6 +155,7 @@ typedef enum Format eFormatHex, eFormatFloat, eFormatOctal, + eFormatOSType, // OS character codes encoded into an integer 'PICT' 'text' etc... eFormatUnicode16, eFormatUnicode32, eFormatUnsigned, diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 8161c95ee58..ffc5084f336 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -489,3 +489,19 @@ SBValue::GetDescription (SBStream &description) return true; } + +lldb::Format +SBValue::GetFormat () const +{ + if (m_opaque_sp) + return m_opaque_sp->GetFormat(); + return eFormatDefault; +} + +void +SBValue::SetFormat (lldb::Format format) +{ + if (m_opaque_sp) + m_opaque_sp->SetFormat(format); +} + diff --git a/lldb/source/Core/DataExtractor.cpp b/lldb/source/Core/DataExtractor.cpp index e75a1c6738b..a5acf73cc2b 100644 --- a/lldb/source/Core/DataExtractor.cpp +++ b/lldb/source/Core/DataExtractor.cpp @@ -1210,6 +1210,9 @@ DataExtractor::Dump if (item_byte_size != 4 && item_byte_size != 8) item_byte_size = s->GetAddressByteSize(); } + + if (item_format == eFormatOSType && item_byte_size > 8) + item_format = eFormatHex; for (offset = start_offset, line_start_offset = start_offset, count = 0; ValidOffset(offset) && count < item_count; ++count) { @@ -1280,7 +1283,7 @@ DataExtractor::Dump if (item_count == 1 && item_format == eFormatChar) s->PutChar('\''); - uint8_t ch = GetU8(&offset); + uint32_t ch = GetMaxU64(&offset, item_byte_size); if (isprint(ch)) s->Printf ("%c", ch); else if (item_format == eFormatChar) @@ -1296,7 +1299,12 @@ DataExtractor::Dump case '\t': s->Printf ("\\t", ch); break; case '\v': s->Printf ("\\v", ch); break; case '\0': s->Printf ("\\0", ch); break; - default: s->Printf ("\\x%2.2x", ch); break; + default: + if (item_byte_size == 1) + s->Printf ("\\x%2.2x", ch); + else + s->Printf ("\\u%x", ch); + break; } } else @@ -1310,29 +1318,6 @@ DataExtractor::Dump } break; - case eFormatComplex: - if (sizeof(float) * 2 == item_byte_size) - { - uint32_t a32 = GetU32(&offset); - uint32_t b32 = GetU32(&offset); - - s->Printf ("%g + %gi", a32, b32); - } - else if (sizeof(double) * 2 == item_byte_size) - { - uint64_t a64 = GetU64(&offset); - uint64_t b64 = GetU64(&offset); - - s->Printf ("%lg + %lgi", a64, b64); - } - else if (sizeof(long double) * 2 == item_byte_size && sizeof(long double) <= sizeof(uint64_t)) - { - uint64_t a64 = GetU64(&offset); - uint64_t b64 = GetU64(&offset); - s->Printf ("%Lg + %Lgi", a64, b64); - } - break; - case eFormatDecimal: if (item_byte_size <= 8) s->Printf ("%lld", GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset)); @@ -1348,6 +1333,40 @@ DataExtractor::Dump s->Printf ("0%llo", GetMaxS64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset)); break; + case eFormatOSType: + { + uint64_t uval64 = GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset); + s->PutChar('\''); + for (i=0; i<item_byte_size; ++i) + { + uint8_t ch; + if (i > 0) + ch = (uint8_t)(uval64 >> ((item_byte_size - i - 1) * 8)); + else + ch = (uint8_t)uval64; + if (isprint(ch)) + s->Printf ("%c", ch); + else + { + switch (ch) + { + case '\e': s->Printf ("\\e", (uint8_t)ch); break; + case '\a': s->Printf ("\\a", ch); break; + case '\b': s->Printf ("\\b", ch); break; + case '\f': s->Printf ("\\f", ch); break; + case '\n': s->Printf ("\\n", ch); break; + case '\r': s->Printf ("\\r", ch); break; + case '\t': s->Printf ("\\t", ch); break; + case '\v': s->Printf ("\\v", ch); break; + case '\0': s->Printf ("\\0", ch); break; + default: s->Printf ("\\x%2.2x", ch); break; + } + } + } + s->PutChar('\''); + } + 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)); @@ -1371,6 +1390,34 @@ DataExtractor::Dump s->Address(GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset), sizeof (addr_t)); break; + case eFormatComplex: + if (sizeof(float) * 2 == item_byte_size) + { + float f32_1 = GetFloat (&offset); + float f32_2 = GetFloat (&offset); + + s->Printf ("%g + %gi", f32_1, f32_2); + break; + } + else if (sizeof(double) * 2 == item_byte_size) + { + double d64_1 = GetDouble (&offset); + double d64_2 = GetDouble (&offset); + + s->Printf ("%lg + %lgi", d64_1, d64_2); + break; + } + else if (sizeof(long double) * 2 == item_byte_size) + { + long double ld64_1 = GetLongDouble (&offset); + long double ld64_2 = GetLongDouble (&offset); + s->Printf ("%Lg + %Lgi", ld64_1, ld64_2); + break; + } + + // Fall through to hex for any other sizes + item_format = eFormatHex; + default: case eFormatDefault: case eFormatHex: diff --git a/lldb/source/Symbol/ClangASTType.cpp b/lldb/source/Symbol/ClangASTType.cpp index c144ff35f99..5540bf4fe30 100644 --- a/lldb/source/Symbol/ClangASTType.cpp +++ b/lldb/source/Symbol/ClangASTType.cpp @@ -646,9 +646,33 @@ ClangASTType::DumpTypeValue else { const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) { + case clang::Type::Typedef: + { + clang::QualType typedef_qual_type = cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType(); + if (format == eFormatDefault) + format = ClangASTType::GetFormat(typedef_qual_type.getAsOpaquePtr()); + std::pair<uint64_t, unsigned> typedef_type_info = ast_context->getTypeInfo(typedef_qual_type); + uint64_t typedef_byte_size = typedef_type_info.first / 8; + + return ClangASTType::DumpTypeValue (ast_context, // The clang AST context for this type + typedef_qual_type.getAsOpaquePtr(), // The clang type we want to dump + s, + format, // The format with which to display the element + data, // Data buffer containing all bytes for this type + byte_offset, // Offset into "data" where to grab value from + typedef_byte_size, // Size of this type in bytes + bitfield_bit_size, // Size in bits of a bitfield value, if zero don't treat as a bitfield + bitfield_bit_offset); // Offset in bits of a bitfield value if bitfield_bit_size != 0 + } + break; + case clang::Type::Enum: + // If our format is enum or default, show the enumeration value as + // its enumeration string value, else just display it as requested. + if (format == eFormatEnum || format == eFormatDefault) { const clang::EnumType *enum_type = cast<clang::EnumType>(qual_type.getTypePtr()); const clang::EnumDecl *enum_decl = enum_type->getDecl(); @@ -666,43 +690,75 @@ ClangASTType::DumpTypeValue } // If we have gotten here we didn't get find the enumerator in the // enum decl, so just print the integer. - + s->Printf("%lli", enum_value); return true; } - break; - - case clang::Type::Typedef: - { - clang::QualType typedef_qual_type = cast<clang::TypedefType>(qual_type)->getDecl()->getUnderlyingType(); - lldb::Format typedef_format = ClangASTType::GetFormat(typedef_qual_type.getAsOpaquePtr()); - std::pair<uint64_t, unsigned> typedef_type_info = ast_context->getTypeInfo(typedef_qual_type); - uint64_t typedef_byte_size = typedef_type_info.first / 8; - - return ClangASTType::DumpTypeValue( - ast_context, // The clang AST context for this type - typedef_qual_type.getAsOpaquePtr(), // The clang type we want to dump - s, - typedef_format, // The format with which to display the element - data, // Data buffer containing all bytes for this type - byte_offset, // Offset into "data" where to grab value from - typedef_byte_size, // Size of this type in bytes - bitfield_bit_size, // Size in bits of a bitfield value, if zero don't treat as a bitfield - bitfield_bit_offset); // Offset in bits of a bitfield value if bitfield_bit_size != 0 - } - break; - + // format was not enum, just fall through and dump the value as requested.... + default: // We are down the a scalar type that we just need to display. - return data.Dump(s, - byte_offset, - format, - byte_size, - 1, - UINT32_MAX, - LLDB_INVALID_ADDRESS, - bitfield_bit_size, - bitfield_bit_offset); + { + uint32_t item_count = 1; + // A few formats, we might need to modify our size and count for depending + // on how we are trying to display the value... + switch (format) + { + default: + case eFormatBoolean: + case eFormatBinary: + case eFormatComplex: + case eFormatCString: // NULL terminated C strings + case eFormatDecimal: + case eFormatEnum: + case eFormatHex: + case eFormatFloat: + case eFormatOctal: + case eFormatOSType: + case eFormatUnsigned: + case eFormatPointer: + case eFormatVectorOfChar: + case eFormatVectorOfSInt8: + case eFormatVectorOfUInt8: + case eFormatVectorOfSInt16: + case eFormatVectorOfUInt16: + case eFormatVectorOfSInt32: + case eFormatVectorOfUInt32: + case eFormatVectorOfSInt64: + case eFormatVectorOfUInt64: + case eFormatVectorOfFloat32: + case eFormatVectorOfFloat64: + case eFormatVectorOfUInt128: + break; + + case eFormatChar: + case eFormatCharPrintable: + case eFormatBytes: + case eFormatBytesWithASCII: + item_count = (byte_size * item_count); + byte_size = 1; + break; + + case eFormatUnicode16: + item_count = (byte_size * item_count) / 2; + byte_size = 2; + break; + + case eFormatUnicode32: + item_count = (byte_size * item_count) / 4; + byte_size = 4; + break; + } + return data.Dump (s, + byte_offset, + format, + byte_size, + item_count, + UINT32_MAX, + LLDB_INVALID_ADDRESS, + bitfield_bit_size, + bitfield_bit_offset); + } break; } } |