summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2015-09-09 01:10:46 +0000
committerEnrico Granata <egranata@apple.com>2015-09-09 01:10:46 +0000
commitd3233c1ed78fca9640cbfa145c19fe073c63eab3 (patch)
tree5ca32c49fe4bd1d925d8f227e8ae1884c679c6e1 /lldb/source
parent1ef6e4c870fcd434846423ea0019e1d2007aa494 (diff)
downloadbcm5719-llvm-d3233c1ed78fca9640cbfa145c19fe073c63eab3.tar.gz
bcm5719-llvm-d3233c1ed78fca9640cbfa145c19fe073c63eab3.zip
Data formatter candidate matches can be generated in a number of ways; language-based dynamic type discovery being one of them (for instance, this is what takes an 'id' and discovers that it truly is an __NSArrayI, so it should probably use the NSArray formatter)
This used to be hardcoded in the FormatManager, but in a pluginized world that is not the right way to go So, move this step to the Language plugin such that appropriate language plugins for a type get a say about adding candidates to the formatters lookup tables llvm-svn: 247112
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/DataFormatters/FormatManager.cpp43
-rw-r--r--lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp37
-rw-r--r--lldb/source/Plugins/Language/ObjC/ObjCLanguage.h9
-rw-r--r--lldb/source/Target/Language.cpp6
4 files changed, 61 insertions, 34 deletions
diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp
index 65b175392da..bc8e8e7c063 100644
--- a/lldb/source/DataFormatters/FormatManager.cpp
+++ b/lldb/source/DataFormatters/FormatManager.cpp
@@ -270,41 +270,22 @@ FormatManager::GetPossibleMatches (ValueObject& valobj,
true); // this is not exactly the usual meaning of stripping typedefs
}
}
- bool canBeObjCDynamic = clang_type.IsPossibleDynamicType (NULL,
- false, // no C
- true); // yes ObjC
- if (canBeObjCDynamic)
+ for (lldb::LanguageType language_type : GetCandidateLanguages(valobj))
{
- if (use_dynamic != lldb::eNoDynamicValues)
+ if (Language* language = Language::FindPlugin(language_type))
{
- do
+ for (ConstString candidate : language->GetPossibleFormattersMatches(valobj, use_dynamic))
{
- lldb::ProcessSP process_sp = valobj.GetProcessSP();
- if (!process_sp)
- break;
- 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);
+ entries.push_back({candidate,
+ reason | lldb_private::eFormatterChoiceCriterionLanguagePlugin,
+ did_strip_ptr,
+ did_strip_ref,
+ did_strip_typedef});
+ }
}
-
- CompilerType 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())
{
@@ -666,8 +647,8 @@ FormatManager::GetTypeForCache (ValueObject& valobj,
return ConstString();
}
-static std::vector<lldb::LanguageType>
-GetCandidateLanguages (ValueObject& valobj)
+std::vector<lldb::LanguageType>
+FormatManager::GetCandidateLanguages (ValueObject& valobj)
{
lldb::LanguageType lang_type = valobj.GetObjectRuntimeLanguage();
switch (lang_type)
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index 3f3705095d4..d6a68af5705 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -12,6 +12,9 @@
#include "lldb/Core/ConstString.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamString.h"
+#include "lldb/Core/ValueObject.h"
+#include "lldb/Symbol/CompilerType.h"
+#include "lldb/Target/ObjCLanguageRuntime.h"
using namespace lldb;
using namespace lldb_private;
@@ -298,3 +301,37 @@ ObjCLanguage::MethodName::GetFullNames (std::vector<ConstString> &names, bool ap
}
return names.size();
}
+
+std::vector<ConstString>
+ObjCLanguage::GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
+{
+ std::vector<ConstString> result;
+
+ if (use_dynamic == lldb::eNoDynamicValues)
+ return result;
+
+ CompilerType compiler_type(valobj.GetCompilerType());
+
+ const bool check_cpp = false;
+ const bool check_objc = true;
+ bool canBeObjCDynamic = compiler_type.IsPossibleDynamicType(nullptr, check_cpp, check_objc);
+
+ if (canBeObjCDynamic)
+ {
+ do {
+ lldb::ProcessSP process_sp = valobj.GetProcessSP();
+ if (!process_sp)
+ break;
+ ObjCLanguageRuntime* runtime = process_sp->GetObjCLanguageRuntime();
+ if (runtime == nullptr)
+ break;
+ ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp (runtime->GetClassDescriptor(valobj));
+ if (!objc_class_sp)
+ break;
+ if (ConstString name = objc_class_sp->GetClassName())
+ result.push_back(name);
+ } while (false);
+ }
+
+ return result;
+}
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
index 9c69fbf75a9..3850c2167a0 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -135,11 +135,14 @@ public:
ObjCLanguage () = default;
lldb::LanguageType
- GetLanguageType () const
+ GetLanguageType () const override
{
return lldb::eLanguageTypeObjC;
}
+ std::vector<ConstString>
+ GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic) override;
+
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
@@ -183,10 +186,10 @@ public:
// PluginInterface protocol
//------------------------------------------------------------------
virtual ConstString
- GetPluginName();
+ GetPluginName() override;
virtual uint32_t
- GetPluginVersion();
+ GetPluginVersion() override;
};
} // namespace lldb_private
diff --git a/lldb/source/Target/Language.cpp b/lldb/source/Target/Language.cpp
index e41d7b864ab..b4e6a5c31e3 100644
--- a/lldb/source/Target/Language.cpp
+++ b/lldb/source/Target/Language.cpp
@@ -94,6 +94,12 @@ Language::GetFormatters ()
return nullptr;
}
+std::vector<ConstString>
+Language::GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic)
+{
+ return {};
+}
+
struct language_name_pair {
const char *name;
LanguageType type;
OpenPOWER on IntegriCloud