[Lldb-commits] [lldb] r145758 - in /lldb/trunk: include/lldb/Symbol/SymbolFile.h source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
Sean Callanan
scallanan at apple.com
Fri Dec 2 20:38:43 PST 2011
Author: spyffe
Date: Fri Dec 2 22:38:43 2011
New Revision: 145758
URL: http://llvm.org/viewvc/llvm-project?rev=145758&view=rev
Log:
Testcase fixes with the new symbol lookup code for
Objective-C, making symbol lookups for various raw
Objective-C symbols work correctly. The IR interpreter
makes these lookups because Clang has emitted raw
symbol references for ivars and classes.
Also improved performance in SymbolFiles, caching the
result of asking for SymbolFile abilities.
Modified:
lldb/trunk/include/lldb/Symbol/SymbolFile.h
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=145758&r1=145757&r2=145758&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Fri Dec 2 22:38:43 2011
@@ -48,7 +48,9 @@
// Constructors and Destructors
//------------------------------------------------------------------
SymbolFile(ObjectFile* obj_file) :
- m_obj_file(obj_file)
+ m_obj_file(obj_file),
+ m_abilities(0),
+ m_calculated_abilities(false)
{
}
@@ -86,7 +88,18 @@
/// enumeration. Any bits that are set represent an ability that
/// this symbol plug-in can parse from the object file.
///------------------------------------------------------------------
- virtual uint32_t GetAbilities () = 0;
+ uint32_t GetAbilities ()
+ {
+ if (!m_calculated_abilities)
+ {
+ m_abilities = CalculateAbilities();
+ m_calculated_abilities = true;
+ }
+
+ return m_abilities;
+ }
+
+ virtual uint32_t CalculateAbilities() = 0;
//------------------------------------------------------------------
/// Initialize the SymbolFile object.
@@ -144,7 +157,8 @@
void ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
protected:
ObjectFile* m_obj_file; // The object file that symbols can be extracted from.
-
+ uint32_t m_abilities;
+ bool m_calculated_abilities;
private:
DISALLOW_COPY_AND_ASSIGN (SymbolFile);
};
Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=145758&r1=145757&r2=145758&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Dec 2 22:38:43 2011
@@ -1271,19 +1271,19 @@
static const llvm::StringRef g_objc_v2_prefix_ivar ("_OBJC_IVAR_$_");
if (symbol_name_ref.startswith(g_objc_v2_prefix_class))
{
- symbol_name_non_abi_mangled = symbol_name;
+ symbol_name_non_abi_mangled = symbol_name + 1;
symbol_name = symbol_name + g_objc_v2_prefix_class.size();
type = eSymbolTypeObjCClass;
}
else if (symbol_name_ref.startswith(g_objc_v2_prefix_metaclass))
{
- symbol_name_non_abi_mangled = symbol_name;
+ symbol_name_non_abi_mangled = symbol_name + 1;
symbol_name = symbol_name + g_objc_v2_prefix_metaclass.size();
type = eSymbolTypeObjCMetaClass;
}
else if (symbol_name_ref.startswith(g_objc_v2_prefix_ivar))
{
- symbol_name_non_abi_mangled = symbol_name;
+ symbol_name_non_abi_mangled = symbol_name + 1;
symbol_name = symbol_name + g_objc_v2_prefix_ivar.size();
type = eSymbolTypeObjCIVar;
}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=145758&r1=145757&r2=145758&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Dec 2 22:38:43 2011
@@ -307,7 +307,7 @@
}
uint32_t
-SymbolFileDWARF::GetAbilities ()
+SymbolFileDWARF::CalculateAbilities ()
{
uint32_t abilities = 0;
if (m_obj_file != NULL)
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=145758&r1=145757&r2=145758&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Dec 2 22:38:43 2011
@@ -84,7 +84,7 @@
SymbolFileDWARF(lldb_private::ObjectFile* ofile);
virtual ~SymbolFileDWARF();
- virtual uint32_t GetAbilities ();
+ virtual uint32_t CalculateAbilities ();
virtual void InitializeObject();
//------------------------------------------------------------------
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=145758&r1=145757&r2=145758&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Fri Dec 2 22:38:43 2011
@@ -419,7 +419,7 @@
}
uint32_t
-SymbolFileDWARFDebugMap::GetAbilities ()
+SymbolFileDWARFDebugMap::CalculateAbilities ()
{
// In order to get the abilities of this plug-in, we look at the list of
// N_OSO entries (object files) from the symbol table and make sure that
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=145758&r1=145757&r2=145758&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Fri Dec 2 22:38:43 2011
@@ -48,7 +48,7 @@
SymbolFileDWARFDebugMap (lldb_private::ObjectFile* ofile);
virtual ~ SymbolFileDWARFDebugMap ();
- virtual uint32_t GetAbilities ();
+ virtual uint32_t CalculateAbilities ();
virtual void InitializeObject();
Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=145758&r1=145757&r2=145758&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Fri Dec 2 22:38:43 2011
@@ -83,19 +83,11 @@
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;
+ return (m_abilities & RuntimeTypes) != 0;
}
uint32_t
-SymbolFileSymtab::GetAbilities ()
+SymbolFileSymtab::CalculateAbilities ()
{
uint32_t abilities = 0;
if (m_obj_file)
@@ -136,8 +128,11 @@
abilities |= GlobalVariables;
}
- if (HasObjCSymbols())
+ symtab->AppendSymbolIndexesWithType(eSymbolTypeObjCClass, m_objc_class_indexes);
+
+ if (!m_objc_class_indexes.empty())
{
+ symtab->SortSymbolIndexesByValue(m_objc_class_indexes, true);
abilities |= RuntimeTypes;
}
}
@@ -403,14 +398,10 @@
types.Insert(iter->second);
return 1;
}
-
- 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)
+ /*const ConstString &name, SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector<uint32_t>& symbol_indexes*/
+ if (m_obj_file->GetSymtab()->FindAllSymbolsWithNameAndType(name, lldb::eSymbolTypeAny, Symtab::eDebugNo, Symtab::eVisibilityAny, m_objc_class_indexes) == 0)
return 0;
const bool isForwardDecl = false;
Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h?rev=145758&r1=145757&r2=145758&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Fri Dec 2 22:38:43 2011
@@ -42,7 +42,7 @@
virtual
~SymbolFileSymtab();
- virtual uint32_t GetAbilities ();
+ virtual uint32_t CalculateAbilities ();
//------------------------------------------------------------------
// Compile Unit function calls
@@ -119,12 +119,14 @@
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
+ std::vector<uint32_t> m_objc_class_indexes;
+
+ lldb_private::LazyBool m_has_objc_symbols;
typedef std::map<lldb_private::ConstString, lldb::TypeSP> TypeMap;
More information about the lldb-commits
mailing list