diff options
| author | Mohit K. Bhakkad <mohit.bhakkad@gmail.com> | 2016-01-23 10:36:06 +0000 |
|---|---|---|
| committer | Mohit K. Bhakkad <mohit.bhakkad@gmail.com> | 2016-01-23 10:36:06 +0000 |
| commit | 0d9dd7df601a3a693f0a339b25ad4afa12a9e7da (patch) | |
| tree | 71581ae1563c4330933a49054fd234995ac37d76 /lldb/source | |
| parent | dd5e9d2159385e2f195c5977871ccae310f4a258 (diff) | |
| download | bcm5719-llvm-0d9dd7df601a3a693f0a339b25ad4afa12a9e7da.tar.gz bcm5719-llvm-0d9dd7df601a3a693f0a339b25ad4afa12a9e7da.zip | |
[LLDB] Consider only valid symbols while resolving by address
Reviewers: clayborg.
Subscribers: jaydeep, bhushan, sagar, nitesh.jain, lldb-commits.
Differential Revision: http://reviews.llvm.org/D16397
llvm-svn: 258621
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/Core/Module.cpp | 11 | ||||
| -rw-r--r-- | lldb/source/Symbol/Symtab.cpp | 20 |
2 files changed, 30 insertions, 1 deletions
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 833540e1a30..c4d90f53db0 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -559,7 +559,16 @@ Module::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve Symtab *symtab = sym_vendor->GetSymtab(); if (symtab && so_addr.IsSectionOffset()) { - sc.symbol = symtab->FindSymbolContainingFileAddress(so_addr.GetFileAddress()); + Symbol *matching_symbol = nullptr; + symtab->ForEachSymbolContainingFileAddresss (so_addr.GetFileAddress(), [&matching_symbol](Symbol *symbol) -> bool { + if (symbol->GetType() != eSymbolTypeInvalid) + { + matching_symbol = symbol; + return false; // Stop iterating + } + return true; // Keep iterating + }); + sc.symbol = matching_symbol; if (!sc.symbol && resolve_scope & eSymbolContextFunction && !(resolved_flags & eSymbolContextFunction)) { diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index 31db57289fd..61b8317fde1 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -1074,6 +1074,26 @@ Symtab::FindSymbolContainingFileAddress (addr_t file_addr) } void +Symtab::ForEachSymbolContainingFileAddresss (addr_t file_addr, std::function <bool(Symbol *)> const &callback) +{ + Mutex::Locker locker (m_mutex); + + if (!m_file_addr_to_index_computed) + InitAddressIndexes(); + + std::vector<uint32_t> all_addr_indexes; + + // Get all symbols with file_addr + const size_t addr_match_count = m_file_addr_to_index.FindEntryIndexesThatContains(file_addr, all_addr_indexes); + + for (size_t i=0; i<addr_match_count; ++i) + { + if (!callback(SymbolAtIndex(all_addr_indexes[i]))) + break; + } +} + +void Symtab::SymbolIndicesToSymbolContextList (std::vector<uint32_t> &symbol_indexes, SymbolContextList &sc_list) { // No need to protect this call using m_mutex all other method calls are |

