summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Language/ObjC
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2015-10-01 18:16:18 +0000
committerEnrico Granata <egranata@apple.com>2015-10-01 18:16:18 +0000
commit9b0af1b86f435fd490596af1b7812bd02565888a (patch)
tree5ad02c8a589de53388f900fd86db7fc849758c14 /lldb/source/Plugins/Language/ObjC
parent12629324a4e97e9619848826c80314a88f9eae85 (diff)
downloadbcm5719-llvm-9b0af1b86f435fd490596af1b7812bd02565888a.tar.gz
bcm5719-llvm-9b0af1b86f435fd490596af1b7812bd02565888a.zip
Add a 'type lookup' command. This command is meant to look up type information by name in a language-specific way.
Currently, it only supports Objective-C - C++ types can be looked up through debug info via 'image lookup -t', whereas ObjC types via this command are looked up by runtime introspection This behavior is in line with type lookup's behavior in Xcode 7, but I am definitely open to feedback as to what makes the most sense here llvm-svn: 249047
Diffstat (limited to 'lldb/source/Plugins/Language/ObjC')
-rw-r--r--lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp88
-rw-r--r--lldb/source/Plugins/Language/ObjC/ObjCLanguage.h3
2 files changed, 91 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index c7e024c66c7..6c1aee9be6d 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -656,3 +656,91 @@ ObjCLanguage::GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicVa
return result;
}
+
+std::unique_ptr<Language::TypeScavenger>
+ObjCLanguage::GetTypeScavenger ()
+{
+ class ObjCTypeScavenger : public Language::TypeScavenger
+ {
+ private:
+ class ObjCScavengerResult : public Language::TypeScavenger::Result
+ {
+ public:
+ ObjCScavengerResult (CompilerType type) :
+ Language::TypeScavenger::Result(),
+ m_compiler_type(type)
+ {
+ }
+
+ bool
+ IsValid () override
+ {
+ return m_compiler_type.IsValid();
+ }
+
+ bool
+ DumpToStream (Stream& stream,
+ bool print_help_if_available) override
+ {
+ if (IsValid())
+ {
+ m_compiler_type.DumpTypeDescription(&stream);
+ stream.EOL();
+ return true;
+ }
+ return false;
+ }
+
+ virtual ~ObjCScavengerResult() = default;
+ private:
+ CompilerType m_compiler_type;
+ };
+
+ protected:
+ ObjCTypeScavenger() = default;
+
+ virtual ~ObjCTypeScavenger() = default;
+
+ bool
+ Find_Impl (ExecutionContextScope *exe_scope,
+ const char *key,
+ ResultSet &results) override
+ {
+ bool result = false;
+
+ Process* process = exe_scope->CalculateProcess().get();
+ if (process)
+ {
+ const bool create_on_demand = false;
+ auto objc_runtime = process->GetObjCLanguageRuntime(create_on_demand);
+ if (objc_runtime)
+ {
+ auto decl_vendor = objc_runtime->GetDeclVendor();
+ if (decl_vendor)
+ {
+ std::vector<clang::NamedDecl *> decls;
+ ConstString name(key);
+ decl_vendor->FindDecls(name, true, UINT32_MAX, decls);
+ for (auto decl : decls)
+ {
+ if (decl)
+ {
+ if (CompilerType candidate = ClangASTContext::GetTypeForDecl(decl))
+ {
+ result = true;
+ std::unique_ptr<Language::TypeScavenger::Result> result(new ObjCScavengerResult(candidate));
+ results.insert(std::move(result));
+ }
+ }
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ friend class ObjCLanguage;
+ };
+
+ return std::unique_ptr<TypeScavenger>(new ObjCTypeScavenger());
+}
diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
index 0e3c45f0ff1..09ee55d274f 100644
--- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -146,6 +146,9 @@ public:
std::vector<ConstString>
GetPossibleFormattersMatches (ValueObject& valobj, lldb::DynamicValueType use_dynamic) override;
+ std::unique_ptr<TypeScavenger>
+ GetTypeScavenger () override;
+
//------------------------------------------------------------------
// Static Functions
//------------------------------------------------------------------
OpenPOWER on IntegriCloud