summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/SymbolFile/Symtab
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2011-11-30 22:11:59 +0000
committerSean Callanan <scallanan@apple.com>2011-11-30 22:11:59 +0000
commit09ab4b777cdb7ec45e8a8e4181b1d2ab2de3909f (patch)
treef01460199e269f935d50beb0b3ba05f7b1a15ca9 /lldb/source/Plugins/SymbolFile/Symtab
parent9430e284a9007154fac11ba832064ed6a6afbac2 (diff)
downloadbcm5719-llvm-09ab4b777cdb7ec45e8a8e4181b1d2ab2de3909f.tar.gz
bcm5719-llvm-09ab4b777cdb7ec45e8a8e4181b1d2ab2de3909f.zip
Added support to the Objective-C language runtime
to find Objective-C class types by looking in the symbol tables for the individual object files. I did this as follows: - I added code to SymbolFileSymtab that vends Clang types for symbols matching the pattern "_OBJC_CLASS_$_NSMyClassName," making them appear as Objective-C classes. This only occurs in modules that do not have debug information, since otherwise SymbolFileDWARF would be in charge of looking up types. - I made a new SymbolVendor subclass for the Apple Objective-C runtime that is in charge of making global lookups of Objective-C types. It currently just sends out type lookup requests to the appropriate SymbolFiles, but in the future we will probably extend it to query the runtime more completely. I also modified a testcase whose behavior is changed by the fact that we now actually return an Objective-C type for __NSCFString. llvm-svn: 145526
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/Symtab')
-rw-r--r--lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp65
-rw-r--r--lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h7
2 files changed, 71 insertions, 1 deletions
diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
index c3e02d7573f..a824267487d 100644
--- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -63,7 +63,8 @@ SymbolFileSymtab::SymbolFileSymtab(ObjectFile* obj_file) :
m_func_indexes(),
m_code_indexes(),
m_data_indexes(),
- m_addr_indexes()
+ m_addr_indexes(),
+ m_has_objc_symbols(eLazyBoolCalculate)
{
}
@@ -71,6 +72,27 @@ SymbolFileSymtab::~SymbolFileSymtab()
{
}
+ClangASTContext &
+SymbolFileSymtab::GetClangASTContext ()
+{
+ ClangASTContext &ast = m_obj_file->GetModule()->GetClangASTContext();
+
+ return ast;
+}
+
+bool
+SymbolFileSymtab::HasObjCSymbols ()
+{
+ if (m_has_objc_symbols == eLazyBoolCalculate)
+ {
+ if (m_obj_file->GetSectionList()->FindSectionByName(ConstString("__objc_data")))
+ m_has_objc_symbols = eLazyBoolYes;
+ else
+ m_has_objc_symbols = eLazyBoolNo;
+ }
+
+ return m_has_objc_symbols == eLazyBoolYes;
+}
uint32_t
SymbolFileSymtab::GetAbilities ()
@@ -113,6 +135,11 @@ SymbolFileSymtab::GetAbilities ()
symtab->SortSymbolIndexesByValue(m_data_indexes, true);
abilities |= GlobalVariables;
}
+
+ if (HasObjCSymbols())
+ {
+ abilities |= RuntimeTypes;
+ }
}
}
return abilities;
@@ -352,6 +379,42 @@ SymbolFileSymtab::FindTypes (const lldb_private::SymbolContext& sc, const lldb_p
{
if (!append)
types.Clear();
+
+ if (HasObjCSymbols())
+ {
+ std::string symbol_name("OBJC_CLASS_$_");
+ symbol_name.append(name.AsCString());
+ ConstString symbol_const_string(symbol_name.c_str());
+
+ std::vector<uint32_t> indices;
+
+ if (m_obj_file->GetSymtab()->FindAllSymbolsWithNameAndType(symbol_const_string, lldb::eSymbolTypeRuntime, indices) == 0)
+ return 0;
+
+ const bool isForwardDecl = false;
+ const bool isInternal = true;
+
+ ClangASTContext &clang_ast_ctx = GetClangASTContext();
+
+ lldb::clang_type_t objc_object_type = clang_ast_ctx.CreateObjCClass(name.AsCString(), clang_ast_ctx.GetTranslationUnitDecl(), isForwardDecl, isInternal);
+
+ Declaration decl;
+
+ lldb::TypeSP type(new Type (indices[0],
+ this,
+ name,
+ 0 /*byte_size*/,
+ NULL /*SymbolContextScope*/,
+ 0 /*encoding_uid*/,
+ Type::eEncodingInvalid,
+ decl,
+ objc_object_type,
+ Type::eResolveStateForward));
+
+ types.Insert(type);
+
+ return 1;
+ }
return 0;
}
diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
index ba43a30424e..d7e58af1182 100644
--- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
+++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
@@ -119,12 +119,19 @@ public:
GetPluginVersion();
protected:
+ lldb_private::LazyBool m_has_objc_symbols;
std::vector<uint32_t> m_source_indexes;
std::vector<uint32_t> m_func_indexes;
std::vector<uint32_t> m_code_indexes;
std::vector<uint32_t> m_data_indexes;
std::vector<uint32_t> m_addr_indexes; // Anything that needs to go into an search by address
+ bool
+ HasObjCSymbols ();
+
+ lldb_private::ClangASTContext &
+ GetClangASTContext ();
+
private:
DISALLOW_COPY_AND_ASSIGN (SymbolFileSymtab);
};
OpenPOWER on IntegriCloud