[Lldb-commits] [lldb] r195395 - <rdar://problem/15530080>
Enrico Granata
egranata at apple.com
Thu Nov 21 16:02:14 PST 2013
Author: enrico
Date: Thu Nov 21 18:02:13 2013
New Revision: 195395
URL: http://llvm.org/viewvc/llvm-project?rev=195395&view=rev
Log:
<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
Modified:
lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h
lldb/trunk/include/lldb/DataFormatters/FormatCache.h
lldb/trunk/include/lldb/DataFormatters/FormatClasses.h
lldb/trunk/include/lldb/DataFormatters/FormatManager.h
lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h
lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp
lldb/trunk/source/DataFormatters/FormatClasses.cpp
lldb/trunk/source/DataFormatters/FormatManager.cpp
lldb/trunk/source/DataFormatters/TypeCategory.cpp
lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp
Modified: lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h?rev=195395&r1=195394&r2=195395&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/CXXFormatterFunctions.h Thu Nov 21 18:02:13 2013
@@ -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"
Modified: lldb/trunk/include/lldb/DataFormatters/FormatCache.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatCache.h?rev=195395&r1=195394&r2=195395&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatCache.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatCache.h Thu Nov 21 18:02:13 2013
@@ -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 {
Modified: lldb/trunk/include/lldb/DataFormatters/FormatClasses.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatClasses.h?rev=195395&r1=195394&r2=195395&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatClasses.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatClasses.h Thu Nov 21 18:02:13 2013
@@ -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:
Modified: lldb/trunk/include/lldb/DataFormatters/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatManager.h?rev=195395&r1=195394&r2=195395&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatManager.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatManager.h Thu Nov 21 18:02:13 2013
@@ -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;
Modified: lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h?rev=195395&r1=195394&r2=195395&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatNavigator.h Thu Nov 21 18:02:13 2013
@@ -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;
}
};
Modified: lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeCategory.h?rev=195395&r1=195394&r2=195395&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeCategory.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeCategory.h Thu Nov 21 18:02:13 2013
@@ -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
Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=195395&r1=195394&r2=195395&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Thu Nov 21 18:02:13 2013
@@ -97,6 +97,7 @@ class FileSpecList;
class Flags;
class TypeCategoryImpl;
class FormatManager;
+class FormattersMatchCandidate;
class FuncUnwinders;
class Function;
class FunctionInfo;
Modified: lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp?rev=195395&r1=195394&r2=195395&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectSyntheticFilter.cpp Thu Nov 21 18:02:13 2013
@@ -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;
Modified: lldb/trunk/source/DataFormatters/FormatClasses.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatClasses.cpp?rev=195395&r1=195394&r2=195395&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatClasses.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatClasses.cpp Thu Nov 21 18:02:13 2013
@@ -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;
Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=195395&r1=195394&r2=195395&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Thu Nov 21 18:02:13 2013
@@ -163,6 +163,139 @@ FormatManager::GetFormatAsCString (Forma
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)
{
Modified: lldb/trunk/source/DataFormatters/TypeCategory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeCategory.cpp?rev=195395&r1=195394&r2=195395&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeCategory.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeCategory.cpp Thu Nov 21 18:02:13 2013
@@ -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& valo
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& valob
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& valob
{
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
Modified: lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp?rev=195395&r1=195394&r2=195395&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp (original)
+++ lldb/trunk/source/DataFormatters/TypeCategoryMap.cpp Thu Nov 21 18:02:13 2013
@@ -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&
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 (Value
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 (V
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;
}
More information about the lldb-commits
mailing list