diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h index 2cd9b4459a33..40173af93329 100644 --- a/lldb/include/lldb/API/SBType.h +++ b/lldb/include/lldb/API/SBType.h @@ -161,6 +161,9 @@ public: const char* GetName(); + const char * + GetDisplayTypeName (); + lldb::TypeClass GetTypeClass (); diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 2b9a344b9300..332ca50b85f4 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -50,6 +50,9 @@ public: const char * GetTypeName (); + + const char * + GetDisplayTypeName (); size_t GetByteSize (); diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 589b22f3a24a..0a525451898a 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -394,6 +394,9 @@ public: virtual ConstString GetTypeName(); + virtual ConstString + GetDisplayTypeName(); + virtual ConstString GetQualifiedTypeName(); diff --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h index 780529a4af11..40c406088876 100644 --- a/lldb/include/lldb/Core/ValueObjectChild.h +++ b/lldb/include/lldb/Core/ValueObjectChild.h @@ -62,6 +62,9 @@ public: virtual ConstString GetQualifiedTypeName(); + virtual ConstString + GetDisplayTypeName(); + virtual bool IsInScope (); diff --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h index 4964d0589a09..dd87fc848ae8 100644 --- a/lldb/include/lldb/Core/ValueObjectConstResult.h +++ b/lldb/include/lldb/Core/ValueObjectConstResult.h @@ -80,6 +80,9 @@ public: virtual ConstString GetTypeName(); + virtual ConstString + GetDisplayTypeName(); + virtual bool IsInScope (); diff --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h index 68f88c96e545..7607bd38137d 100644 --- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h +++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h @@ -37,6 +37,9 @@ public: virtual ConstString GetQualifiedTypeName(); + + virtual ConstString + GetDisplayTypeName(); virtual size_t CalculateNumChildren(); diff --git a/lldb/include/lldb/Core/ValueObjectMemory.h b/lldb/include/lldb/Core/ValueObjectMemory.h index 627d73eb4b27..41b43188a46a 100644 --- a/lldb/include/lldb/Core/ValueObjectMemory.h +++ b/lldb/include/lldb/Core/ValueObjectMemory.h @@ -47,6 +47,9 @@ public: virtual ConstString GetTypeName(); + virtual ConstString + GetDisplayTypeName(); + virtual size_t CalculateNumChildren(); diff --git a/lldb/include/lldb/Core/ValueObjectRegister.h b/lldb/include/lldb/Core/ValueObjectRegister.h index 6820629f08e1..f7c7683d60bc 100644 --- a/lldb/include/lldb/Core/ValueObjectRegister.h +++ b/lldb/include/lldb/Core/ValueObjectRegister.h @@ -45,6 +45,9 @@ public: virtual ConstString GetQualifiedTypeName(); + + virtual ConstString + GetDisplayTypeName(); virtual size_t CalculateNumChildren(); diff --git a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h index f1d8c885c255..e12698f49bb1 100644 --- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h +++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h @@ -41,6 +41,9 @@ public: virtual ConstString GetQualifiedTypeName(); + + virtual ConstString + GetDisplayTypeName(); virtual bool MightHaveChildren(); diff --git a/lldb/include/lldb/Core/ValueObjectVariable.h b/lldb/include/lldb/Core/ValueObjectVariable.h index 8a30b00f6bbd..0e32d09057dc 100644 --- a/lldb/include/lldb/Core/ValueObjectVariable.h +++ b/lldb/include/lldb/Core/ValueObjectVariable.h @@ -39,6 +39,9 @@ public: virtual ConstString GetQualifiedTypeName(); + + virtual ConstString + GetDisplayTypeName(); virtual size_t CalculateNumChildren(); diff --git a/lldb/include/lldb/Symbol/ClangASTType.h b/lldb/include/lldb/Symbol/ClangASTType.h index 0f2eb965ca67..7f136bd95738 100644 --- a/lldb/include/lldb/Symbol/ClangASTType.h +++ b/lldb/include/lldb/Symbol/ClangASTType.h @@ -264,6 +264,9 @@ public: ConstString GetTypeName () const; + ConstString + GetDisplayTypeName () const; + uint32_t GetTypeInfo (ClangASTType *pointee_or_element_clang_type = NULL) const; diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h index da327439936c..a1034044c0d2 100644 --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -368,6 +368,16 @@ public: return ConstString (); } + ConstString + GetDisplayTypeName () const + { + if (type_sp) + return type_sp->GetClangForwardType().GetDisplayTypeName(); + if (clang_type) + return clang_type.GetDisplayTypeName(); + return ConstString(); + } + void SetType (ClangASTType type) { @@ -511,6 +521,9 @@ public: ConstString GetName () const; + ConstString + GetDisplayTypeName () const; + TypeImpl GetPointerType () const; diff --git a/lldb/scripts/Python/interface/SBType.i b/lldb/scripts/Python/interface/SBType.i index 936bf2ccf277..8a0ad6e508be 100644 --- a/lldb/scripts/Python/interface/SBType.i +++ b/lldb/scripts/Python/interface/SBType.i @@ -27,7 +27,7 @@ public: const char * GetName (); - + lldb::SBType GetType (); @@ -216,6 +216,9 @@ public: const char* GetName(); + const char * + GetDisplayTypeName (); + lldb::TypeClass GetTypeClass (); diff --git a/lldb/scripts/Python/interface/SBValue.i b/lldb/scripts/Python/interface/SBValue.i index 4cfafa3f4d8b..78e7605224e1 100644 --- a/lldb/scripts/Python/interface/SBValue.i +++ b/lldb/scripts/Python/interface/SBValue.i @@ -81,6 +81,9 @@ public: const char * GetTypeName (); + + const char * + GetDisplayTypeName (); size_t GetByteSize (); diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp index 5ca7ddf3d813..1e04841bfadf 100644 --- a/lldb/source/API/SBType.cpp +++ b/lldb/source/API/SBType.cpp @@ -414,6 +414,14 @@ SBType::GetName() return m_opaque_sp->GetName().GetCString(); } +const char * +SBType::GetDisplayTypeName () +{ + if (!IsValid()) + return ""; + return m_opaque_sp->GetDisplayTypeName().GetCString(); +} + lldb::TypeClass SBType::GetTypeClass () { diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index f171d2399135..3a9621b1e3bc 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -378,6 +378,31 @@ SBValue::GetTypeName () return name; } +const char * +SBValue::GetDisplayTypeName () +{ + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + const char *name = NULL; + ValueLocker locker; + lldb::ValueObjectSP value_sp(GetSP(locker)); + if (value_sp) + { + name = value_sp->GetDisplayTypeName().GetCString(); + } + + if (log) + { + if (name) + log->Printf ("SBValue(%p)::GetTypeName () => \"%s\"", + static_cast(value_sp.get()), name); + else + log->Printf ("SBValue(%p)::GetTypeName () => NULL", + static_cast(value_sp.get())); + } + + return name; +} + size_t SBValue::GetByteSize () { diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index f6a3d53032b4..9fc4167f31ba 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -1952,6 +1952,12 @@ ValueObject::GetTypeName() return GetClangType().GetConstTypeName(); } +ConstString +ValueObject::GetDisplayTypeName() +{ + return GetTypeName(); +} + ConstString ValueObject::GetQualifiedTypeName() { diff --git a/lldb/source/Core/ValueObjectChild.cpp b/lldb/source/Core/ValueObjectChild.cpp index ccf87cd15b24..33b91f9e30d1 100644 --- a/lldb/source/Core/ValueObjectChild.cpp +++ b/lldb/source/Core/ValueObjectChild.cpp @@ -66,25 +66,29 @@ ValueObjectChild::CalculateNumChildren() return GetClangType().GetNumChildren (true); } +static void +AdjustForBitfieldness(ConstString& name, + uint8_t bitfield_bit_size) +{ + if (name && bitfield_bit_size) + { + const char *clang_type_name = name.AsCString(); + if (clang_type_name) + { + std::vector bitfield_type_name (strlen(clang_type_name) + 32, 0); + ::snprintf (&bitfield_type_name.front(), bitfield_type_name.size(), "%s:%u", clang_type_name, bitfield_bit_size); + name.SetCString(&bitfield_type_name.front()); + } + } +} + ConstString ValueObjectChild::GetTypeName() { if (m_type_name.IsEmpty()) { m_type_name = GetClangType().GetConstTypeName (); - if (m_type_name) - { - if (m_bitfield_bit_size > 0) - { - const char *clang_type_name = m_type_name.AsCString(); - if (clang_type_name) - { - std::vector bitfield_type_name (strlen(clang_type_name) + 32, 0); - ::snprintf (&bitfield_type_name.front(), bitfield_type_name.size(), "%s:%u", clang_type_name, m_bitfield_bit_size); - m_type_name.SetCString(&bitfield_type_name.front()); - } - } - } + AdjustForBitfieldness(m_type_name, m_bitfield_bit_size); } return m_type_name; } @@ -93,22 +97,18 @@ ConstString ValueObjectChild::GetQualifiedTypeName() { ConstString qualified_name = GetClangType().GetConstTypeName(); - if (qualified_name) - { - if (m_bitfield_bit_size > 0) - { - const char *clang_type_name = qualified_name.AsCString(); - if (clang_type_name) - { - std::vector bitfield_type_name (strlen(clang_type_name) + 32, 0); - ::snprintf (&bitfield_type_name.front(), bitfield_type_name.size(), "%s:%u", clang_type_name, m_bitfield_bit_size); - qualified_name.SetCString(&bitfield_type_name.front()); - } - } - } + AdjustForBitfieldness(qualified_name, m_bitfield_bit_size); return qualified_name; } +ConstString +ValueObjectChild::GetDisplayTypeName() +{ + ConstString display_name = GetClangType().GetDisplayTypeName(); + AdjustForBitfieldness(display_name, m_bitfield_bit_size); + return display_name; +} + bool ValueObjectChild::UpdateValue () { diff --git a/lldb/source/Core/ValueObjectConstResult.cpp b/lldb/source/Core/ValueObjectConstResult.cpp index d6d86381358d..387e171e3526 100644 --- a/lldb/source/Core/ValueObjectConstResult.cpp +++ b/lldb/source/Core/ValueObjectConstResult.cpp @@ -276,6 +276,12 @@ ValueObjectConstResult::GetTypeName() return m_type_name; } +ConstString +ValueObjectConstResult::GetDisplayTypeName() +{ + return GetClangType().GetDisplayTypeName(); +} + bool ValueObjectConstResult::UpdateValue () { diff --git a/lldb/source/Core/ValueObjectDynamicValue.cpp b/lldb/source/Core/ValueObjectDynamicValue.cpp index a9f2606212c1..a6fad7a9b1fd 100644 --- a/lldb/source/Core/ValueObjectDynamicValue.cpp +++ b/lldb/source/Core/ValueObjectDynamicValue.cpp @@ -71,8 +71,6 @@ ValueObjectDynamicValue::GetTypeName() { if (m_dynamic_type_info.HasName()) return m_dynamic_type_info.GetName(); - if (m_dynamic_type_info.HasType()) - return GetClangType().GetConstTypeName(); } return m_parent->GetTypeName(); } @@ -96,10 +94,22 @@ ValueObjectDynamicValue::GetQualifiedTypeName() { if (m_dynamic_type_info.HasName()) return m_dynamic_type_info.GetName(); - if (m_dynamic_type_info.HasType()) - return GetClangType().GetConstQualifiedTypeName (); } - return m_parent->GetTypeName(); + return m_parent->GetQualifiedTypeName(); +} + +ConstString +ValueObjectDynamicValue::GetDisplayTypeName() +{ + const bool success = UpdateValueIfNeeded(false); + if (success) + { + if (m_dynamic_type_info.HasType()) + return GetClangType().GetDisplayTypeName(); + if (m_dynamic_type_info.HasName()) + return m_dynamic_type_info.GetName(); + } + return m_parent->GetDisplayTypeName(); } size_t diff --git a/lldb/source/Core/ValueObjectMemory.cpp b/lldb/source/Core/ValueObjectMemory.cpp index 42fd0e8fffba..d2cbbfdda240 100644 --- a/lldb/source/Core/ValueObjectMemory.cpp +++ b/lldb/source/Core/ValueObjectMemory.cpp @@ -147,6 +147,14 @@ ValueObjectMemory::GetTypeName() return m_clang_type.GetConstTypeName(); } +ConstString +ValueObjectMemory::GetDisplayTypeName() +{ + if (m_type_sp) + return m_type_sp->GetClangForwardType().GetDisplayTypeName(); + return m_clang_type.GetDisplayTypeName(); +} + size_t ValueObjectMemory::CalculateNumChildren() { diff --git a/lldb/source/Core/ValueObjectRegister.cpp b/lldb/source/Core/ValueObjectRegister.cpp index 4f21457519ec..0db1f0cd45cf 100644 --- a/lldb/source/Core/ValueObjectRegister.cpp +++ b/lldb/source/Core/ValueObjectRegister.cpp @@ -54,6 +54,12 @@ ValueObjectRegisterContext::GetTypeName() return ConstString(); } +ConstString +ValueObjectRegisterContext::GetDisplayTypeName() +{ + return ConstString(); +} + ConstString ValueObjectRegisterContext::GetQualifiedTypeName() { diff --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp index a65b8f63e317..18d36164989a 100644 --- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp +++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp @@ -101,6 +101,12 @@ ValueObjectSynthetic::GetQualifiedTypeName() return m_parent->GetQualifiedTypeName(); } +ConstString +ValueObjectSynthetic::GetDisplayTypeName() +{ + return m_parent->GetDisplayTypeName(); +} + size_t ValueObjectSynthetic::CalculateNumChildren() { diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp index 2e5bb22a890c..225dc02c8add 100644 --- a/lldb/source/Core/ValueObjectVariable.cpp +++ b/lldb/source/Core/ValueObjectVariable.cpp @@ -72,6 +72,15 @@ ValueObjectVariable::GetTypeName() return ConstString(); } +ConstString +ValueObjectVariable::GetDisplayTypeName() +{ + Type * var_type = m_variable_sp->GetType(); + if (var_type) + return var_type->GetClangForwardType().GetDisplayTypeName(); + return ConstString(); +} + ConstString ValueObjectVariable::GetQualifiedTypeName() { diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index 9fe89b187bf8..f3146b99f0ca 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -185,7 +185,11 @@ FormatManager::GetPossibleMatches (ValueObject& valobj, reason |= lldb_private::eFormatterChoiceCriterionStrippedBitField; } entries.push_back({type_name,reason,did_strip_ptr,did_strip_ref,did_strip_typedef}); - + + ConstString display_type_name(clang_type.GetDisplayTypeName()); + if (display_type_name != type_name) + entries.push_back({display_type_name,reason,did_strip_ptr,did_strip_ref,did_strip_typedef}); + for (bool is_rvalue_ref = true, j = true; j && clang_type.IsReferenceType(nullptr, &is_rvalue_ref); j = false) { ClangASTType non_ref_type = clang_type.GetNonReferenceType(); diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp index 565d4d419da8..65e5e3f45823 100644 --- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp +++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp @@ -222,7 +222,11 @@ ValueObjectPrinter::PrintTypeIfNeeded () { // Some ValueObjects don't have types (like registers sets). Only print // the type if there is one to print - ConstString qualified_type_name(m_valobj->GetQualifiedTypeName()); + ConstString qualified_type_name; + if (options.m_be_raw) + qualified_type_name = m_valobj->GetQualifiedTypeName(); + else + qualified_type_name = m_valobj->GetDisplayTypeName(); if (qualified_type_name) m_stream->Printf("(%s) ", qualified_type_name.GetCString()); else diff --git a/lldb/source/Symbol/ClangASTType.cpp b/lldb/source/Symbol/ClangASTType.cpp index 20ac65fe3234..b864844625b4 100644 --- a/lldb/source/Symbol/ClangASTType.cpp +++ b/lldb/source/Symbol/ClangASTType.cpp @@ -1243,6 +1243,11 @@ ClangASTType::GetTypeName () const return ConstString(type_name); } +ConstString +ClangASTType::GetDisplayTypeName () const +{ + return GetTypeName(); +} uint32_t ClangASTType::GetTypeInfo (ClangASTType *pointee_or_element_clang_type) const diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp index cabdbbafa713..e58cbc19b369 100644 --- a/lldb/source/Symbol/Type.cpp +++ b/lldb/source/Symbol/Type.cpp @@ -1053,6 +1053,14 @@ TypeImpl::GetName () const return m_static_type.GetName (); } +ConstString +TypeImpl::GetDisplayTypeName () const +{ + if (m_dynamic_type) + return m_dynamic_type.GetDisplayTypeName(); + return m_static_type.GetDisplayTypeName(); +} + TypeImpl TypeImpl::GetPointerType () const {