summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2013-11-22 00:02:13 +0000
committerEnrico Granata <egranata@apple.com>2013-11-22 00:02:13 +0000
commitde61cecd1ccfd4024ddf527bda37c12806296427 (patch)
treeaf56af873c9de6a2ff62bf49249427b44f1df192
parent340cdda2f69751b9140c844dfae6773e1439ab3e (diff)
downloadbcm5719-llvm-de61cecd1ccfd4024ddf527bda37c12806296427.tar.gz
bcm5719-llvm-de61cecd1ccfd4024ddf527bda37c12806296427.zip
<rdar://problem/15530080>
Rework data formatters matching algorithm What happens now is that, for each category, the FormatNavigator generates all possible matches, and checks them one by one Since the possible matches do not actually depend on the category (whether a match is accepted or not does, but that check can be shifted at a more convenient time), it is actually feasible to generate every possible match upfront and then let individual categories just scan through those This commit changes things by introducing a notion of formatters match candidate, and shifting responsibility for generating all of them given a (ValueObject,DynamicValueType) pair from the FormatNavigator back to the FormatManager A list of these candidates is then passed down to each category for matching Candidates also need to remember whether they were generated by stripping pointers, references, typedefs, since this is something that individual formatters can choose to reject This check, however, is conveniently only done once a "textual" match has been found, so that the list of candidates is truly category-independent While the performance benefit is small (mostly, due to caching), this is much cleaner from a design perspective llvm-svn: 195395
-rw-r--r--lldb/include/lldb/DataFormatters/CXXFormatterFunctions.h2
-rw-r--r--lldb/include/lldb/DataFormatters/FormatCache.h1
-rw-r--r--lldb/include/lldb/DataFormatters/FormatClasses.h84
-rw-r--r--lldb/include/lldb/DataFormatters/FormatManager.h30
-rw-r--r--lldb/include/lldb/DataFormatters/FormatNavigator.h226
-rw-r--r--lldb/include/lldb/DataFormatters/TypeCategory.h8
-rw-r--r--lldb/include/lldb/lldb-forward.h1
-rw-r--r--lldb/source/Core/ValueObjectSyntheticFilter.cpp2
-rw-r--r--lldb/source/DataFormatters/FormatClasses.cpp13
-rw-r--r--lldb/source/DataFormatters/FormatManager.cpp133
-rw-r--r--lldb/source/DataFormatters/TypeCategory.cpp35
-rw-r--r--lldb/source/DataFormatters/TypeCategoryMap.cpp15
12 files changed, 292 insertions, 258 deletions
diff --git a/lldb/include/lldb/DataFormatters/CXXFormatterFunctions.h b/lldb/include/lldb/DataFormatters/CXXFormatterFunctions.h
index 433c2a3c407..415ef9be59e 100644
--- a/lldb/include/lldb/DataFormatters/CXXFormatterFunctions.h
+++ b/lldb/include/lldb/DataFormatters/CXXFormatterFunctions.h
@@ -17,6 +17,8 @@
#include "lldb/Core/ConstString.h"
#include "lldb/DataFormatters/FormatClasses.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
+#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
#include "clang/AST/ASTContext.h"
diff --git a/lldb/include/lldb/DataFormatters/FormatCache.h b/lldb/include/lldb/DataFormatters/FormatCache.h
index bd9e20ccc9e..1505d7c4618 100644
--- a/lldb/include/lldb/DataFormatters/FormatCache.h
+++ b/lldb/include/lldb/DataFormatters/FormatCache.h
@@ -18,6 +18,7 @@
// Project includes
#include "lldb/lldb-public.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/Host/Mutex.h"
#include "lldb/DataFormatters/FormatClasses.h"
namespace lldb_private {
diff --git a/lldb/include/lldb/DataFormatters/FormatClasses.h b/lldb/include/lldb/DataFormatters/FormatClasses.h
index 6d9a50e8f2c..651160371c6 100644
--- a/lldb/include/lldb/DataFormatters/FormatClasses.h
+++ b/lldb/include/lldb/DataFormatters/FormatClasses.h
@@ -10,9 +10,6 @@
#ifndef lldb_FormatClasses_h_
#define lldb_FormatClasses_h_
-// C Includes
-#include <stdint.h>
-
// C++ Includes
#include <string>
#include <vector>
@@ -23,17 +20,86 @@
#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
-#include "lldb/Core/ValueObject.h"
-#include "lldb/Interpreter/ScriptInterpreterPython.h"
#include "lldb/Symbol/ClangASTType.h"
#include "lldb/Symbol/Type.h"
-#include "lldb/DataFormatters/TypeFormat.h"
-#include "lldb/DataFormatters/TypeSummary.h"
-#include "lldb/DataFormatters/TypeSynthetic.h"
-
namespace lldb_private {
+class FormattersMatchCandidate
+{
+public:
+
+ FormattersMatchCandidate (ConstString name,
+ uint32_t reason,
+ bool strip_ptr,
+ bool strip_ref,
+ bool strip_tydef) :
+ m_type_name(name),
+ m_reason(reason),
+ m_stripped_pointer(strip_ptr),
+ m_stripped_reference(strip_ref),
+ m_stripped_typedef(strip_tydef)
+ {
+ }
+
+ ~FormattersMatchCandidate ()
+ {}
+
+ ConstString
+ GetTypeName () const
+ {
+ return m_type_name;
+ }
+
+ uint32_t
+ GetReason () const
+ {
+ return m_reason;
+ }
+
+ bool
+ DidStripPointer () const
+ {
+ return m_stripped_pointer;
+ }
+
+ bool
+ DidStripReference () const
+ {
+ return m_stripped_reference;
+ }
+
+ bool
+ DidStripTypedef () const
+ {
+ return m_stripped_typedef;
+ }
+
+ template <class Formatter>
+ bool
+ IsMatch (const std::shared_ptr<Formatter>& formatter_sp) const
+ {
+ if (!formatter_sp)
+ return false;
+ if (formatter_sp->Cascades() == false && DidStripTypedef())
+ return false;
+ if (formatter_sp->SkipsPointers() && DidStripPointer())
+ return false;
+ if (formatter_sp->SkipsReferences() && DidStripReference())
+ return false;
+ return true;
+ }
+
+private:
+ ConstString m_type_name;
+ uint32_t m_reason;
+ bool m_stripped_pointer;
+ bool m_stripped_reference;
+ bool m_stripped_typedef;
+};
+
+typedef std::vector<FormattersMatchCandidate> FormattersMatchVector;
+
class TypeNameSpecifierImpl
{
public:
diff --git a/lldb/include/lldb/DataFormatters/FormatManager.h b/lldb/include/lldb/DataFormatters/FormatManager.h
index 3c90c993e0c..750e5300831 100644
--- a/lldb/include/lldb/DataFormatters/FormatManager.h
+++ b/lldb/include/lldb/DataFormatters/FormatManager.h
@@ -19,6 +19,7 @@
#include "lldb/lldb-enumerations.h"
#include "lldb/DataFormatters/FormatCache.h"
+#include "lldb/DataFormatters/FormatClasses.h"
#include "lldb/DataFormatters/FormatNavigator.h"
#include "lldb/DataFormatters/TypeCategory.h"
#include "lldb/DataFormatters/TypeCategoryMap.h"
@@ -213,7 +214,36 @@ public:
{
}
+ static FormattersMatchVector
+ GetPossibleMatches (ValueObject& valobj,
+ lldb::DynamicValueType use_dynamic)
+ {
+ FormattersMatchVector matches;
+ GetPossibleMatches (valobj,
+ valobj.GetClangType(),
+ lldb_private::eFormatterChoiceCriterionDirectChoice,
+ use_dynamic,
+ matches,
+ false,
+ false,
+ false,
+ true);
+ return matches;
+ }
+
private:
+
+ static void
+ GetPossibleMatches (ValueObject& valobj,
+ ClangASTType clang_type,
+ uint32_t reason,
+ lldb::DynamicValueType use_dynamic,
+ FormattersMatchVector& entries,
+ bool did_strip_ptr,
+ bool did_strip_ref,
+ bool did_strip_typedef,
+ bool root_level = false);
+
FormatCache m_format_cache;
NamedSummariesMap m_named_summaries_map;
std::atomic<uint32_t> m_last_revision;
diff --git a/lldb/include/lldb/DataFormatters/FormatNavigator.h b/lldb/include/lldb/DataFormatters/FormatNavigator.h
index cd5f6824e19..1b82776fb28 100644
--- a/lldb/include/lldb/DataFormatters/FormatNavigator.h
+++ b/lldb/include/lldb/DataFormatters/FormatNavigator.h
@@ -26,6 +26,9 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/FormatClasses.h"
+#include "lldb/DataFormatters/TypeFormat.h"
+#include "lldb/DataFormatters/TypeSummary.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangASTType.h"
@@ -459,228 +462,29 @@ protected:
}
return false;
}
-
- bool
- Get_BitfieldMatch (ValueObject& valobj,
- ConstString typeName,
- MapValueType& entry,
- uint32_t& reason)
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
- // for bitfields, append size to the typename so one can custom format them
- StreamString sstring;
- sstring.Printf("%s:%d",typeName.AsCString(),valobj.GetBitfieldBitSize());
- ConstString bitfieldname = ConstString(sstring.GetData());
- if (log)
- log->Printf("[Get_BitfieldMatch] appended bitfield info, final result is %s", bitfieldname.GetCString());
- if (Get(bitfieldname, entry))
- {
- if (log)
- log->Printf("[Get_BitfieldMatch] bitfield direct match found, returning");
- return true;
- }
- else
- {
- reason |= lldb_private::eFormatterChoiceCriterionStrippedBitField;
- if (log)
- log->Printf("[Get_BitfieldMatch] no bitfield direct match");
- return false;
- }
- }
-
- bool Get_ObjC (ValueObject& valobj,
- MapValueType& entry)
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
- lldb::ProcessSP process_sp = valobj.GetProcessSP();
- ObjCLanguageRuntime* runtime = process_sp->GetObjCLanguageRuntime();
- if (runtime == NULL)
- {
- if (log)
- log->Printf("[Get_ObjC] no valid ObjC runtime, skipping dynamic");
- return false;
- }
- ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp (runtime->GetClassDescriptor(valobj));
- if (!objc_class_sp)
- {
- if (log)
- log->Printf("[Get_ObjC] invalid ISA, skipping dynamic");
- return false;
- }
- ConstString name (objc_class_sp->GetClassName());
- if (log)
- log->Printf("[Get_ObjC] dynamic type inferred is %s - looking for direct dynamic match", name.GetCString());
- if (Get(name, entry))
- {
- if (log)
- log->Printf("[Get_ObjC] direct dynamic match found, returning");
- return true;
- }
- if (log)
- log->Printf("[Get_ObjC] no dynamic match");
- return false;
- }
-
+
bool
- Get_Impl (ValueObject& valobj,
- ClangASTType clang_type,
- MapValueType& entry,
- lldb::DynamicValueType use_dynamic,
- uint32_t& reason)
+ Get (const FormattersMatchVector& candidates,
+ MapValueType& entry,
+ uint32_t *reason)
{
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
-
- if (!clang_type.IsValid())
- {
- if (log)
- log->Printf("[Get_Impl] type is invalid, returning");
- return false;
- }
-
- clang_type = clang_type.RemoveFastQualifiers();
-
- ConstString typeName(clang_type.GetConstTypeName());
-
- if (valobj.GetBitfieldBitSize() > 0)
+ for (const FormattersMatchCandidate& candidate : candidates)
{
- if (Get_BitfieldMatch(valobj, typeName, entry, reason))
- return true;
- }
-
- if (log)
- log->Printf("[Get_Impl] trying to get %s for VO name %s of type %s",
- m_name.c_str(),
- valobj.GetName().AsCString(),
- typeName.AsCString());
-
- if (Get(typeName, entry))
- {
- if (log)
- log->Printf("[Get] direct match found, returning");
- return true;
- }
- if (log)
- log->Printf("[Get_Impl] no direct match");
-
- // strip pointers and references and see if that helps
- if (clang_type.IsReferenceType())
- {
- if (log)
- log->Printf("[Get_Impl] stripping reference");
- if (Get_Impl(valobj, clang_type.GetNonReferenceType(), entry, use_dynamic, reason) && !entry->SkipsReferences())
+ if (Get(candidate.GetTypeName(),entry))
{
- reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
- return true;
- }
- }
- else if (clang_type.IsPointerType())
- {
- if (log)
- log->Printf("[Get_Impl] stripping pointer");
- if (Get_Impl(valobj, clang_type.GetPointeeType(), entry, use_dynamic, reason) && !entry->SkipsPointers())
- {
- reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
- return true;
- }
- }
-
- bool canBeObjCDynamic = valobj.GetClangType().IsPossibleDynamicType (NULL,
- false, // no C++
- true); // yes ObjC
-
- if (canBeObjCDynamic)
- {
- if (use_dynamic != lldb::eNoDynamicValues)
- {
- if (log)
- log->Printf("[Get_Impl] allowed to figure out dynamic ObjC type");
- if (Get_ObjC(valobj,entry))
+ if (candidate.IsMatch(entry) == false)
{
- reason |= lldb_private::eFormatterChoiceCriterionDynamicObjCDiscovery;
- return true;
+ entry.reset();
+ continue;
}
- }
- if (log)
- log->Printf("[Get_Impl] dynamic disabled or failed - stripping ObjC pointer");
- if (Get_Impl(valobj, clang_type.GetPointeeType(), entry, use_dynamic, reason) && !entry->SkipsPointers())
- {
- reason |= lldb_private::eFormatterChoiceCriterionStrippedPointerReference;
- return true;
- }
- }
-
- // try to strip typedef chains
- if (clang_type.IsTypedefType())
- {
- if (log)
- log->Printf("[Get_Impl] stripping typedef");
- if ((Get_Impl(valobj, clang_type.GetTypedefedType(), entry, use_dynamic, reason)) && entry->Cascades())
- {
- reason |= lldb_private::eFormatterChoiceCriterionNavigatedTypedefs;
- return true;
- }
- }
-
- // out of luck here
- return false;
- }
-
- // we are separately passing in valobj and type because the valobj is fixed (and is used for ObjC discovery and bitfield size)
- // but the type can change (e.g. stripping pointers, ...)
- bool Get (ValueObject& valobj,
- ClangASTType clang_type,
- MapValueType& entry,
- lldb::DynamicValueType use_dynamic,
- uint32_t& reason)
- {
- Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
-
- if (Get_Impl (valobj, clang_type, entry, use_dynamic, reason))
- return true;
-
- // try going to the unqualified type
- do {
- if (log)
- log->Printf("[Get] trying the unqualified type");
- if (!clang_type.IsValid())
- break;
-
- ClangASTType unqual_clang_ast_type = clang_type.GetFullyUnqualifiedType();
- if (!unqual_clang_ast_type.IsValid())
- {
- if (log)
- log->Printf("[Get] could not get the unqual_clang_ast_type");
- break;
- }
- if (unqual_clang_ast_type.GetOpaqueQualType() != clang_type.GetOpaqueQualType())
- {
- if (log)
- log->Printf("[Get] unqualified type is there and is not the same, let's try");
- if (Get_Impl (valobj, unqual_clang_ast_type,entry, use_dynamic, reason))
- return true;
- }
- else if (log)
- log->Printf("[Get] unqualified type same as original type");
- } while(false);
-
- // if all else fails, go to static type
- if (valobj.IsDynamic())
- {
- if (log)
- log->Printf("[Get] going to static value");
- lldb::ValueObjectSP static_value_sp(valobj.GetStaticValue());
- if (static_value_sp)
- {
- if (log)
- log->Printf("[Get] has a static value - actually use it");
- if (Get(*static_value_sp.get(), static_value_sp->GetClangType(), entry, use_dynamic, reason))
+ else
{
- reason |= lldb_private::eFormatterChoiceCriterionWentToStaticValue;
+ if(reason)
+ *reason = candidate.GetReason();
return true;
}
}
}
-
return false;
}
};
diff --git a/lldb/include/lldb/DataFormatters/TypeCategory.h b/lldb/include/lldb/DataFormatters/TypeCategory.h
index 6461c4e97e4..082395a0461 100644
--- a/lldb/include/lldb/DataFormatters/TypeCategory.h
+++ b/lldb/include/lldb/DataFormatters/TypeCategory.h
@@ -18,6 +18,7 @@
#include "lldb/lldb-public.h"
#include "lldb/lldb-enumerations.h"
+#include "lldb/DataFormatters/FormatClasses.h"
#include "lldb/DataFormatters/FormatNavigator.h"
namespace lldb_private {
@@ -177,23 +178,22 @@ namespace lldb_private {
return m_enabled_position;
}
-
bool
Get (ValueObject& valobj,
+ const FormattersMatchVector& candidates,
lldb::TypeFormatImplSP& entry,
- lldb::DynamicValueType use_dynamic,
uint32_t* reason = NULL);
bool
Get (ValueObject& valobj,
+ const FormattersMatchVector& candidates,
lldb::TypeSummaryImplSP& entry,
- lldb::DynamicValueType use_dynamic,
uint32_t* reason = NULL);
bool
Get (ValueObject& valobj,
+ const FormattersMatchVector& candidates,
lldb::SyntheticChildrenSP& entry,
- lldb::DynamicValueType use_dynamic,
uint32_t* reason = NULL);
void
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index a72e2e9303c..68d85f081e2 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -97,6 +97,7 @@ class FileSpecList;
class Flags;
class TypeCategoryImpl;
class FormatManager;
+class FormattersMatchCandidate;
class FuncUnwinders;
class Function;
class FunctionInfo;
diff --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
index 5767466f509..a65b8f63e31 100644
--- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp
+++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
@@ -16,7 +16,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/ValueObject.h"
-#include "lldb/DataFormatters/FormatClasses.h"
+#include "lldb/DataFormatters/TypeSynthetic.h"
using namespace lldb_private;
diff --git a/lldb/source/DataFormatters/FormatClasses.cpp b/lldb/source/DataFormatters/FormatClasses.cpp
index c67f86a7493..f27b45b3049 100644
--- a/lldb/source/DataFormatters/FormatClasses.cpp
+++ b/lldb/source/DataFormatters/FormatClasses.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "lldb/lldb-python.h"
+#include "lldb/DataFormatters/FormatClasses.h"
// C Includes
@@ -16,17 +16,6 @@
// Other libraries and framework includes
// Project includes
-#include "lldb/lldb-public.h"
-#include "lldb/lldb-enumerations.h"
-
-#include "lldb/Core/Debugger.h"
-#include "lldb/Core/StreamString.h"
-#include "lldb/Core/Timer.h"
-#include "lldb/DataFormatters/FormatClasses.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Symbol/ClangASTType.h"
-#include "lldb/Target/StackFrame.h"
-#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp
index b4c4628b48a..bec2edf5d5c 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -163,6 +163,139 @@ FormatManager::GetFormatAsCString (Format format)
return NULL;
}
+void
+FormatManager::GetPossibleMatches (ValueObject& valobj,
+ ClangASTType clang_type,
+ uint32_t reason,
+ lldb::DynamicValueType use_dynamic,
+ FormattersMatchVector& entries,
+ bool did_strip_ptr,
+ bool did_strip_ref,
+ bool did_strip_typedef,
+ bool root_level)
+{
+ clang_type = clang_type.RemoveFastQualifiers();
+ ConstString type_name(clang_type.GetConstTypeName());
+ if (valobj.GetBitfieldBitSize() > 0)
+ {
+ StreamString sstring;
+ sstring.Printf("%s:%d",type_name.AsCString(),valobj.GetBitfieldBitSize());
+ ConstString bitfieldname = ConstString(sstring.GetData());
+ entries.push_back({bitfieldname,0,did_strip_ptr,did_strip_ref,did_strip_typedef});
+ reason |= lldb_private::eFormatterChoiceCriterionStrippedBitField;
+ }
+ entries.push_back({type_name,reason,did_strip_ptr,did_strip_ref,did_strip_typedef});
+
+ if (clang_type.IsReferenceType())
+ {
+ ClangASTType non_ref_type = clang_type.GetNonReferenceType();
+ GetPossibleMatches(valobj,
+ non_ref_type,
+ reason | lldb_private::eFormatterChoiceCriterionStrippedPointerReference,
+ use_dynamic,
+ entries,
+ did_strip_ptr,
+ true,
+ did_strip_typedef);
+ }
+ else if (clang_type.IsPointerType())
+ {
+ ClangASTType non_ptr_type = clang_type.GetPointeeType();
+ GetPossibleMatches(valobj,
+ non_ptr_type,
+ reason | lldb_private::eFormatterChoiceCriterionStrippedPointerReference,
+ use_dynamic,
+ entries,
+ true,
+ did_strip_ref,
+ did_strip_typedef);
+ }
+ bool canBeObjCDynamic = clang_type.IsPossibleDynamicType (NULL,
+ false, // no C
+ true); // yes ObjC
+
+ if (canBeObjCDynamic)
+ {
+ if (use_dynamic != lldb::eNoDynamicValues)
+ {
+ do
+ {
+ lldb::ProcessSP process_sp = valobj.GetProcessSP();
+ ObjCLanguageRuntime* runtime = process_sp->GetObjCLanguageRuntime();
+ if (runtime == nullptr)
+ break;
+ ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp (runtime->GetClassDescriptor(valobj));
+ if (!objc_class_sp)
+ break;
+ ConstString name (objc_class_sp->GetClassName());
+ entries.push_back({name,reason | lldb_private::eFormatterChoiceCriterionDynamicObjCDiscovery,did_strip_ptr,did_strip_ref,did_strip_typedef});
+ } while (false);
+ }
+
+ ClangASTType non_ptr_type = clang_type.GetPointeeType();
+ GetPossibleMatches(valobj,
+ non_ptr_type,
+ reason | lldb_private::eFormatterChoiceCriterionStrippedPointerReference,
+ use_dynamic,
+ entries,
+ true,
+ did_strip_ref,
+ did_strip_typedef);
+ }
+
+ // try to strip typedef chains
+ if (clang_type.IsTypedefType())
+ {
+ ClangASTType deffed_type = clang_type.GetTypedefedType();
+ GetPossibleMatches(valobj,
+ deffed_type,
+ reason | lldb_private::eFormatterChoiceCriterionNavigatedTypedefs,
+ use_dynamic,
+ entries,
+ did_strip_ptr,
+ did_strip_ref,
+ true);
+ }
+
+ if (root_level)
+ {
+ do {
+ if (!clang_type.IsValid())
+ break;
+
+ ClangASTType unqual_clang_ast_type = clang_type.GetFullyUnqualifiedType();
+ if (!unqual_clang_ast_type.IsValid())
+ break;
+ if (unqual_clang_ast_type.GetOpaqueQualType() != clang_type.GetOpaqueQualType())
+ GetPossibleMatches (valobj,
+ unqual_clang_ast_type,
+ reason,
+ use_dynamic,
+ entries,
+ did_strip_ptr,
+ did_strip_ref,
+ did_strip_typedef);
+ } while(false);
+
+
+ // if all else fails, go to static type
+ if (valobj.IsDynamic())
+ {
+ lldb::ValueObjectSP static_value_sp(valobj.GetStaticValue());
+ if (static_value_sp)
+ GetPossibleMatches(*static_value_sp.get(),
+ static_value_sp->GetClangType(),
+ reason | lldb_private::eFormatterChoiceCriterionWentToStaticValue,
+ use_dynamic,
+ entries,
+ did_strip_ptr,
+ did_strip_ref,
+ did_strip_typedef,
+ true);
+ }
+ }
+}
+
lldb::TypeFormatImplSP
FormatManager::GetFormatForType (lldb::TypeNameSpecifierImplSP type_sp)
{
diff --git a/lldb/source/DataFormatters/TypeCategory.cpp b/lldb/source/DataFormatters/TypeCategory.cpp
index 636000bb23e..a02560e7878 100644
--- a/lldb/source/DataFormatters/TypeCategory.cpp
+++ b/lldb/source/DataFormatters/TypeCategory.cpp
@@ -39,15 +39,15 @@ m_name(name)
bool
TypeCategoryImpl::Get (ValueObject& valobj,
+ const FormattersMatchVector& candidates,
lldb::TypeFormatImplSP& entry,
- lldb::DynamicValueType use_dynamic,
uint32_t* reason)
{
if (!IsEnabled())
return false;
- if (GetValueNavigator()->Get(valobj, entry, use_dynamic, reason))
+ if (GetValueNavigator()->Get(candidates, entry, reason))
return true;
- bool regex = GetRegexValueNavigator()->Get(valobj, entry, use_dynamic, reason);
+ bool regex = GetRegexValueNavigator()->Get(candidates, entry, reason);
if (regex && reason)
*reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionSummary;
return regex;
@@ -55,25 +55,25 @@ TypeCategoryImpl::Get (ValueObject& valobj,
bool
TypeCategoryImpl::Get (ValueObject& valobj,
+ const FormattersMatchVector& candidates,
lldb::TypeSummaryImplSP& entry,
- lldb::DynamicValueType use_dynamic,
uint32_t* reason)
{
if (!IsEnabled())
return false;
- if (GetSummaryNavigator()->Get(valobj, entry, use_dynamic, reason))
+ if (GetSummaryNavigator()->Get(candidates, entry, reason))
return true;
- bool regex = GetRegexSummaryNavigator()->Get(valobj, entry, use_dynamic, reason);
+ bool regex = GetRegexSummaryNavigator()->Get(candidates, entry, reason);
if (regex && reason)
*reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionSummary;
return regex;
}
bool
-TypeCategoryImpl::Get(ValueObject& valobj,
- lldb::SyntheticChildrenSP& entry_sp,
- lldb::DynamicValueType use_dynamic,
- uint32_t* reason)
+TypeCategoryImpl::Get (ValueObject& valobj,
+ const FormattersMatchVector& candidates,
+ lldb::SyntheticChildrenSP& entry,
+ uint32_t* reason)
{
if (!IsEnabled())
return false;
@@ -82,16 +82,16 @@ TypeCategoryImpl::Get(ValueObject& valobj,
bool regex_filter = false;
// first find both Filter and Synth, and then check which is most recent
- if (!GetFilterNavigator()->Get(valobj, filter_sp, use_dynamic, &reason_filter))
- regex_filter = GetRegexFilterNavigator()->Get (valobj, filter_sp, use_dynamic, &reason_filter);
+ if (!GetFilterNavigator()->Get(candidates, filter_sp, &reason_filter))
+ regex_filter = GetRegexFilterNavigator()->Get (candidates, filter_sp, &reason_filter);
#ifndef LLDB_DISABLE_PYTHON
bool regex_synth = false;
uint32_t reason_synth = 0;
bool pick_synth = false;
ScriptedSyntheticChildren::SharedPointer synth;
- if (!GetSyntheticNavigator()->Get(valobj, synth, use_dynamic, &reason_synth))
- regex_synth = GetRegexSyntheticNavigator()->Get (valobj, synth, use_dynamic, &reason_synth);
+ if (!GetSyntheticNavigator()->Get(candidates, synth, &reason_synth))
+ regex_synth = GetRegexSyntheticNavigator()->Get (candidates, synth, &reason_synth);
if (!filter_sp.get() && !synth.get())
return false;
else if (!filter_sp.get() && synth.get())
@@ -111,27 +111,26 @@ TypeCategoryImpl::Get(ValueObject& valobj,
{
if (regex_synth && reason)
*reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter;
- entry_sp = synth;
+ entry = synth;
return true;
}
else
{
if (regex_filter && reason)
*reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter;
- entry_sp = filter_sp;
+ entry = filter_sp;
return true;
}
#else
if (filter_sp)
{
- entry_sp = filter_sp;
+ entry = filter_sp;
return true;
}
#endif
return false;
-
}
void
diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp b/lldb/source/DataFormatters/TypeCategoryMap.cpp
index 621258806de..c6dba1b9f4b 100644
--- a/lldb/source/DataFormatters/TypeCategoryMap.cpp
+++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp
@@ -11,6 +11,9 @@
#include "lldb/DataFormatters/TypeCategoryMap.h"
+#include "lldb/DataFormatters/FormatClasses.h"
+#include "lldb/DataFormatters/FormatManager.h"
+
// C Includes
// C++ Includes
// Other libraries and framework includes
@@ -187,13 +190,15 @@ TypeCategoryMap::GetFormat (ValueObject& valobj,
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ FormattersMatchVector matches = FormatManager::GetPossibleMatches(valobj, use_dynamic);
+
for (begin = m_active_categories.begin(); begin != end; begin++)
{
lldb::TypeCategoryImplSP category_sp = *begin;
lldb::TypeFormatImplSP current_format;
if (log)
log->Printf("\n[TypeCategoryMap::GetFormat] Trying to use category %s", category_sp->GetName());
- if (!category_sp->Get(valobj, current_format, use_dynamic, &reason_why))
+ if (!category_sp->Get(valobj, matches, current_format, &reason_why))
continue;
return current_format;
}
@@ -213,13 +218,15 @@ TypeCategoryMap::GetSummaryFormat (ValueObject& valobj,
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ FormattersMatchVector matches = FormatManager::GetPossibleMatches(valobj, use_dynamic);
+
for (begin = m_active_categories.begin(); begin != end; begin++)
{
lldb::TypeCategoryImplSP category_sp = *begin;
lldb::TypeSummaryImplSP current_format;
if (log)
log->Printf("\n[CategoryMap::GetSummaryFormat] Trying to use category %s", category_sp->GetName());
- if (!category_sp->Get(valobj, current_format, use_dynamic, &reason_why))
+ if (!category_sp->Get(valobj, matches, current_format, &reason_why))
continue;
return current_format;
}
@@ -241,13 +248,15 @@ TypeCategoryMap::GetSyntheticChildren (ValueObject& valobj,
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
+ FormattersMatchVector matches = FormatManager::GetPossibleMatches(valobj, use_dynamic);
+
for (begin = m_active_categories.begin(); begin != end; begin++)
{
lldb::TypeCategoryImplSP category_sp = *begin;
lldb::SyntheticChildrenSP current_format;
if (log)
log->Printf("\n[CategoryMap::GetSyntheticChildren] Trying to use category %s", category_sp->GetName());
- if (!category_sp->Get(valobj, current_format, use_dynamic, &reason_why))
+ if (!category_sp->Get(valobj, matches, current_format, &reason_why))
continue;
return current_format;
}
OpenPOWER on IntegriCloud