diff options
| author | Greg Clayton <gclayton@apple.com> | 2015-02-25 22:41:34 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2015-02-25 22:41:34 +0000 |
| commit | bc63aaccf7df033abd1f1060c681fe4853433383 (patch) | |
| tree | e385259899e61666da36145e1ceb43d7b8b112a0 /lldb/source/Symbol/Symtab.cpp | |
| parent | 75dbd7ca3e20bf432a6b94e92df6c4537fa9f78f (diff) | |
| download | bcm5719-llvm-bc63aaccf7df033abd1f1060c681fe4853433383.tar.gz bcm5719-llvm-bc63aaccf7df033abd1f1060c681fe4853433383.zip | |
Optimize finding the Complete Definition of an ObjC class for debug with .o files with lots of .o files.
When we have a debug map we have an executable with a bunch of STAB symbols and each source file has a N_SO symbol which scopes a bunch of symbols inside of it. We can use this to our advantage here when looking for the complete definition of an objective C class by looking for a symbol whose name matches the class name and whose type is eSymbolTypeObjCClass. If we find one, that symbol will be contained within a N_SO symbol. This symbol gets turned into a symbol whose type is eSymbolTypeSourceFile and that symbol will contain the eSymbolTypeObjCClass which helps us to locate the correct .o file and allows us to only look in that file.
To further accelerate things, if we are looking for the implementation, we can avoid looking at all .o files if we don't find a matching symbol because we have a debug map, which means the objective C symbol for the class can't have been stripped, so we can safely not search all remaining .o files. This will save us lots of time when trying to look for "NSObject" and any other AppKit and Foundation classes that we never have implementation definitions for.
<rdar://problem/19234225>
llvm-svn: 230562
Diffstat (limited to 'lldb/source/Symbol/Symtab.cpp')
| -rw-r--r-- | lldb/source/Symbol/Symtab.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index 1f4afdfd6ac..e2bf984c5cc 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -14,6 +14,7 @@ #include "lldb/Core/Section.h" #include "lldb/Core/Timer.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Symbol/Symbol.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Symtab.h" #include "lldb/Target/CPPLanguageRuntime.h" @@ -546,9 +547,12 @@ Symtab::AppendSymbolIndexesWithType (SymbolType symbol_type, Debug symbol_debug_ uint32_t Symtab::GetIndexForSymbol (const Symbol *symbol) const { - const Symbol *first_symbol = &m_symbols[0]; - if (symbol >= first_symbol && symbol < first_symbol + m_symbols.size()) - return symbol - first_symbol; + if (!m_symbols.empty()) + { + const Symbol *first_symbol = &m_symbols[0]; + if (symbol >= first_symbol && symbol < first_symbol + m_symbols.size()) + return symbol - first_symbol; + } return UINT32_MAX; } @@ -1178,3 +1182,20 @@ Symtab::FindFunctionSymbols (const ConstString &name, return count; } + +const Symbol * +Symtab::GetParent (Symbol *child_symbol) const +{ + uint32_t child_idx = GetIndexForSymbol(child_symbol); + if (child_idx != UINT32_MAX && child_idx > 0) + { + for (uint32_t idx = child_idx - 1; idx != UINT32_MAX; --idx) + { + const Symbol *symbol = SymbolAtIndex (idx); + const uint32_t sibling_idx = symbol->GetSiblingIndex(); + if (sibling_idx != UINT32_MAX && sibling_idx > child_idx) + return symbol; + } + } + return NULL; +} |

