diff options
-rw-r--r-- | lldb/include/lldb/API/SBType.h | 1 | ||||
-rw-r--r-- | lldb/include/lldb/Core/ValueObject.h | 17 | ||||
-rw-r--r-- | lldb/include/lldb/Core/ValueObjectChild.h | 10 | ||||
-rw-r--r-- | lldb/include/lldb/Symbol/ClangASTContext.h | 8 | ||||
-rw-r--r-- | lldb/include/lldb/Symbol/Type.h | 12 | ||||
-rw-r--r-- | lldb/source/API/SBType.cpp | 5 | ||||
-rw-r--r-- | lldb/source/Core/ValueObject.cpp | 117 | ||||
-rw-r--r-- | lldb/source/Core/ValueObjectChild.cpp | 6 | ||||
-rw-r--r-- | lldb/source/Symbol/ClangASTContext.cpp | 30 | ||||
-rw-r--r-- | lldb/source/Symbol/Type.cpp | 44 |
10 files changed, 145 insertions, 105 deletions
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h index 383a58a1b30..97af8d21336 100644 --- a/lldb/include/lldb/API/SBType.h +++ b/lldb/include/lldb/API/SBType.h @@ -128,6 +128,7 @@ protected: uint32_t m_bit_size; uint32_t m_bit_offset; bool m_is_base_class; + bool m_is_deref_of_paremt; }; diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h index 1aeadb2cd47..30e5d5741c7 100644 --- a/lldb/include/lldb/Core/ValueObject.h +++ b/lldb/include/lldb/Core/ValueObject.h @@ -86,6 +86,15 @@ public: { return false; } + + virtual bool + IsDereferenceOfParent () + { + return false; + } + + virtual bool + GetBaseClassPath (Stream &s); virtual void GetExpressionPath (Stream &s, bool qualify_cxx_base_classes); @@ -276,7 +285,10 @@ public: { return m_parent; } - + + ValueObject * + GetNonBaseClassParent(); + void SetPointersPointToLoadAddrs (bool b) { @@ -312,7 +324,8 @@ protected: m_value_did_change:1, m_children_count_valid:1, m_old_value_valid:1, - m_pointers_point_to_load_addrs:1; + m_pointers_point_to_load_addrs:1, + m_is_deref_of_parent:1; friend class CommandObjectExpression; friend class ClangExpressionVariable; diff --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h index d5a7c5234ba..ae32e3f0b92 100644 --- a/lldb/include/lldb/Core/ValueObjectChild.h +++ b/lldb/include/lldb/Core/ValueObjectChild.h @@ -32,7 +32,8 @@ public: int32_t byte_offset, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, - bool is_base_class); + bool is_base_class, + bool is_deref_of_parent); virtual ~ValueObjectChild(); @@ -94,6 +95,12 @@ public: return m_is_base_class; } + virtual bool + IsDereferenceOfParent () + { + return m_is_deref_of_parent; + } + protected: clang::ASTContext *m_clang_ast; // The clang AST that the clang type comes from void *m_clang_type; // The type of the child in question within the parent (m_parent_sp) @@ -103,6 +110,7 @@ protected: uint8_t m_bitfield_bit_size; uint8_t m_bitfield_bit_offset; bool m_is_base_class; + bool m_is_deref_of_parent; // // void diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 38ecddb9850..9fd48d7e9c9 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -393,8 +393,9 @@ public: int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, - bool &child_is_base_class); - + bool &child_is_base_class, + bool &child_is_deref_of_parent); + static lldb::clang_type_t GetChildClangTypeAtIndex (clang::ASTContext *ast, const char *parent_name, @@ -407,7 +408,8 @@ public: int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, - bool &child_is_base_class); + bool &child_is_base_class, + bool &child_is_deref_of_parent); // Lookup a child given a name. This function will match base class names // and member member names in "clang_type" only, not descendants. diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h index ef1322197e6..1270d65b958 100644 --- a/lldb/include/lldb/Symbol/Type.h +++ b/lldb/include/lldb/Symbol/Type.h @@ -202,18 +202,6 @@ public: ClangASTContext & GetClangASTContext (); - lldb::clang_type_t - GetChildClangTypeAtIndex (const char *parent_name, - uint32_t idx, - bool transparent_pointers, - bool omit_empty_base_classes, - ConstString& name, - uint32_t &child_byte_size, - int32_t &child_byte_offset, - uint32_t &child_bitfield_bit_size, - uint32_t &child_bitfield_bit_offset, - bool &child_is_base_class); - static int Compare(const Type &a, const Type &b); diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp index ca3fe6d9c9b..1a1beaeb501 100644 --- a/lldb/source/API/SBType.cpp +++ b/lldb/source/API/SBType.cpp @@ -113,6 +113,7 @@ SBType::GetChildAtIndex (bool omit_empty_base_classes, uint32_t idx, SBTypeMembe uint32_t child_bitfield_bit_size = 0; uint32_t child_bitfield_bit_offset = 0; bool child_is_base_class = false; + bool child_is_deref_of_parent = false; if (IsValid ()) { @@ -128,7 +129,8 @@ SBType::GetChildAtIndex (bool omit_empty_base_classes, uint32_t idx, SBTypeMembe child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, - child_is_base_class); + child_is_base_class, + child_is_deref_of_parent); } @@ -142,6 +144,7 @@ SBType::GetChildAtIndex (bool omit_empty_base_classes, uint32_t idx, SBTypeMembe member.m_bit_size = child_bitfield_bit_size; member.m_bit_offset = child_bitfield_bit_offset; member.m_is_base_class = child_is_base_class; + member.m_is_deref_of_paremt = child_is_deref_of_parent; } else { diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index a492b72d30c..89fc8b31786 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -64,7 +64,8 @@ ValueObject::ValueObject (ValueObject *parent) : m_value_did_change (false), m_children_count_valid (false), m_old_value_valid (false), - m_pointers_point_to_load_addrs (false) + m_pointers_point_to_load_addrs (false), + m_is_deref_of_parent (false) { } @@ -367,6 +368,8 @@ ValueObject::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int3 uint32_t child_bitfield_bit_size = 0; uint32_t child_bitfield_bit_offset = 0; bool child_is_base_class = false; + bool child_is_deref_of_parent = false; + const bool transparent_pointers = synthetic_array_member == false; clang::ASTContext *clang_ast = GetClangAST(); clang_type_t clang_type = GetClangType(); @@ -382,7 +385,8 @@ ValueObject::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int3 child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, - child_is_base_class); + child_is_base_class, + child_is_deref_of_parent); if (child_clang_type && child_byte_size) { if (synthetic_index) @@ -400,7 +404,8 @@ ValueObject::CreateChildAtIndex (uint32_t idx, bool synthetic_array_member, int3 child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, - child_is_base_class)); + child_is_base_class, + child_is_deref_of_parent)); if (m_pointers_point_to_load_addrs) valobj_sp->SetPointersPointToLoadAddrs (m_pointers_point_to_load_addrs); } @@ -931,47 +936,90 @@ ValueObject::SetDynamicValue () return true; } +bool +ValueObject::GetBaseClassPath (Stream &s) +{ + if (IsBaseClass()) + { + bool parent_had_base_class = m_parent && m_parent->GetBaseClassPath (s); + clang_type_t clang_type = GetClangType(); + std::string cxx_class_name; + bool this_had_base_class = ClangASTContext::GetCXXClassName (clang_type, cxx_class_name); + if (this_had_base_class) + { + if (parent_had_base_class) + s.PutCString("::"); + s.PutCString(cxx_class_name.c_str()); + } + return parent_had_base_class || this_had_base_class; + } + return false; +} + + +ValueObject * +ValueObject::GetNonBaseClassParent() +{ + if (m_parent) + { + if (m_parent->IsBaseClass()) + return m_parent->GetNonBaseClassParent(); + else + return m_parent; + } + return NULL; +} void ValueObject::GetExpressionPath (Stream &s, bool qualify_cxx_base_classes) { + const bool is_deref_of_parent = IsDereferenceOfParent (); + + if (is_deref_of_parent) + s.PutCString("*("); + if (m_parent) - { m_parent->GetExpressionPath (s, qualify_cxx_base_classes); - clang_type_t parent_clang_type = m_parent->GetClangType(); - if (parent_clang_type) + + if (!IsBaseClass()) + { + if (!is_deref_of_parent) { - if (ClangASTContext::IsPointerType(parent_clang_type)) + ValueObject *non_base_class_parent = GetNonBaseClassParent(); + if (non_base_class_parent) { - s.PutCString("->"); + clang_type_t non_base_class_parent_clang_type = non_base_class_parent->GetClangType(); + if (non_base_class_parent_clang_type) + { + const uint32_t non_base_class_parent_type_info = ClangASTContext::GetTypeInfo (non_base_class_parent_clang_type, NULL, NULL); + + if (non_base_class_parent_type_info & ClangASTContext::eTypeIsPointer) + { + s.PutCString("->"); + } + else if ((non_base_class_parent_type_info & ClangASTContext::eTypeHasChildren) && + !(non_base_class_parent_type_info & ClangASTContext::eTypeIsArray)) + { + s.PutChar('.'); + } + } } - else if (ClangASTContext::IsAggregateType (parent_clang_type)) + + const char *name = GetName().GetCString(); + if (name) { - if (ClangASTContext::IsArrayType (parent_clang_type) == false && - m_parent->IsBaseClass() == false) - s.PutChar('.'); + if (qualify_cxx_base_classes) + { + if (GetBaseClassPath (s)) + s.PutCString("::"); + } + s.PutCString(name); } } } - if (IsBaseClass()) - { - if (qualify_cxx_base_classes) - { - clang_type_t clang_type = GetClangType(); - std::string cxx_class_name; - if (ClangASTContext::GetCXXClassName (clang_type, cxx_class_name)) - { - s << cxx_class_name.c_str() << "::"; - } - } - } - else - { - const char *name = GetName().GetCString(); - if (name) - s.PutCString(name); - } + if (is_deref_of_parent) + s.PutChar(')'); } void @@ -1012,7 +1060,7 @@ ValueObject::DumpValueObject s.Indent(); // Always show the type for the top level items. - if (show_types || curr_depth == 0) + if (show_types || (curr_depth == 0 && !flat_output)) s.Printf("(%s) ", valobj->GetTypeName().AsCString("<invalid type>")); @@ -1223,6 +1271,7 @@ ValueObject::Dereference (Error &error) uint32_t child_bitfield_bit_size = 0; uint32_t child_bitfield_bit_offset = 0; bool child_is_base_class = false; + bool child_is_deref_of_parent = false; const bool transparent_pointers = false; clang::ASTContext *clang_ast = GetClangAST(); clang_type_t clang_type = GetClangType(); @@ -1238,7 +1287,8 @@ ValueObject::Dereference (Error &error) child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, - child_is_base_class); + child_is_base_class, + child_is_deref_of_parent); if (child_clang_type && child_byte_size) { ConstString child_name; @@ -1253,7 +1303,8 @@ ValueObject::Dereference (Error &error) child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, - child_is_base_class)); + child_is_base_class, + child_is_deref_of_parent)); } } diff --git a/lldb/source/Core/ValueObjectChild.cpp b/lldb/source/Core/ValueObjectChild.cpp index 09bae2fb314..bf896abe9ba 100644 --- a/lldb/source/Core/ValueObjectChild.cpp +++ b/lldb/source/Core/ValueObjectChild.cpp @@ -34,7 +34,8 @@ ValueObjectChild::ValueObjectChild int32_t byte_offset, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, - bool is_base_class + bool is_base_class, + bool is_deref_of_parent ) : ValueObject (parent), m_clang_ast (clang_ast), @@ -43,7 +44,8 @@ ValueObjectChild::ValueObjectChild m_byte_offset (byte_offset), m_bitfield_bit_size (bitfield_bit_size), m_bitfield_bit_offset (bitfield_bit_offset), - m_is_base_class (is_base_class) + m_is_base_class (is_base_class), + m_is_deref_of_parent (is_deref_of_parent) { m_name = name; } diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index b1cd6c5b783..9988d0860c9 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -2373,7 +2373,8 @@ ClangASTContext::GetChildClangTypeAtIndex int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, - bool &child_is_base_class + bool &child_is_base_class, + bool &child_is_deref_of_parent ) { if (parent_clang_type) @@ -2389,7 +2390,8 @@ ClangASTContext::GetChildClangTypeAtIndex child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, - child_is_base_class); + child_is_base_class, + child_is_deref_of_parent); return NULL; } @@ -2407,7 +2409,8 @@ ClangASTContext::GetChildClangTypeAtIndex int32_t &child_byte_offset, uint32_t &child_bitfield_bit_size, uint32_t &child_bitfield_bit_offset, - bool &child_is_base_class + bool &child_is_base_class, + bool &child_is_deref_of_parent ) { if (parent_clang_type == NULL) @@ -2612,6 +2615,8 @@ ClangASTContext::GetChildClangTypeAtIndex if (transparent_pointers && ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr())) { + child_is_deref_of_parent = false; + bool tmp_child_is_deref_of_parent = false; return GetChildClangTypeAtIndex (ast, parent_name, pointer_type->getPointeeType().getAsOpaquePtr(), @@ -2623,10 +2628,12 @@ ClangASTContext::GetChildClangTypeAtIndex child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, - child_is_base_class); + child_is_base_class, + tmp_child_is_deref_of_parent); } else { + child_is_deref_of_parent = true; if (parent_name) { child_name.assign(1, '*'); @@ -2681,6 +2688,8 @@ ClangASTContext::GetChildClangTypeAtIndex if (transparent_pointers && ClangASTContext::IsAggregateType (pointee_type.getAsOpaquePtr())) { + child_is_deref_of_parent = false; + bool tmp_child_is_deref_of_parent = false; return GetChildClangTypeAtIndex (ast, parent_name, pointer_type->getPointeeType().getAsOpaquePtr(), @@ -2692,10 +2701,13 @@ ClangASTContext::GetChildClangTypeAtIndex child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, - child_is_base_class); + child_is_base_class, + tmp_child_is_deref_of_parent); } else { + child_is_deref_of_parent = true; + if (parent_name) { child_name.assign(1, '*'); @@ -2723,6 +2735,8 @@ ClangASTContext::GetChildClangTypeAtIndex clang_type_t pointee_clang_type = pointee_type.getAsOpaquePtr(); if (transparent_pointers && ClangASTContext::IsAggregateType (pointee_clang_type)) { + child_is_deref_of_parent = false; + bool tmp_child_is_deref_of_parent = false; return GetChildClangTypeAtIndex (ast, parent_name, pointee_clang_type, @@ -2734,7 +2748,8 @@ ClangASTContext::GetChildClangTypeAtIndex child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, - child_is_base_class); + child_is_base_class, + tmp_child_is_deref_of_parent); } else { @@ -2769,7 +2784,8 @@ ClangASTContext::GetChildClangTypeAtIndex child_byte_offset, child_bitfield_bit_size, child_bitfield_bit_offset, - child_is_base_class); + child_is_base_class, + child_is_deref_of_parent); break; default: diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp index 2fca2adb92e..0590a1d033e 100644 --- a/lldb/source/Symbol/Type.cpp +++ b/lldb/source/Symbol/Type.cpp @@ -559,50 +559,6 @@ lldb_private::Type::ResolveClangType (ResolveState clang_type_resolve_state) } return m_clang_type != NULL; } - -clang_type_t -lldb_private::Type::GetChildClangTypeAtIndex -( - const char *parent_name, - uint32_t idx, - bool transparent_pointers, - bool omit_empty_base_classes, - ConstString& name, - uint32_t &child_byte_size, - int32_t &child_byte_offset, - uint32_t &child_bitfield_bit_size, - uint32_t &child_bitfield_bit_offset, - bool &child_is_base_class -) -{ - clang_type_t child_qual_type = NULL; - - if (GetClangType()) - { - std::string name_str; - child_qual_type = GetClangASTContext().GetChildClangTypeAtIndex (parent_name, - m_clang_type, - idx, - transparent_pointers, - omit_empty_base_classes, - name_str, - child_byte_size, - child_byte_offset, - child_bitfield_bit_size, - child_bitfield_bit_offset, - child_is_base_class); - - if (child_qual_type) - { - if (!name_str.empty()) - name.SetCString(name_str.c_str()); - else - name.Clear(); - } - } - return child_qual_type; -} - uint32_t lldb_private::Type::GetEncodingMask () { |