diff options
Diffstat (limited to 'lldb/source/Core')
-rw-r--r-- | lldb/source/Core/AddressResolverName.cpp | 16 | ||||
-rw-r--r-- | lldb/source/Core/Disassembler.cpp | 53 | ||||
-rw-r--r-- | lldb/source/Core/Module.cpp | 79 | ||||
-rw-r--r-- | lldb/source/Core/ModuleList.cpp | 22 |
4 files changed, 130 insertions, 40 deletions
diff --git a/lldb/source/Core/AddressResolverName.cpp b/lldb/source/Core/AddressResolverName.cpp index d5bdd89b607..040a8621855 100644 --- a/lldb/source/Core/AddressResolverName.cpp +++ b/lldb/source/Core/AddressResolverName.cpp @@ -102,9 +102,11 @@ AddressResolverName::SearchCallback return Searcher::eCallbackReturnStop; } + const bool include_symbols = false; + const bool append = false; switch (m_match_type) { - case AddressResolver::Exact: + case AddressResolver::Exact: if (context.module_sp) { context.module_sp->FindSymbolsWithNameAndType (m_func_name, @@ -112,22 +114,26 @@ AddressResolverName::SearchCallback sym_list); context.module_sp->FindFunctions (m_func_name, eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeMethod | eFunctionNameTypeSelector, - false, + include_symbols, + append, func_list); } break; - case AddressResolver::Regexp: + + case AddressResolver::Regexp: if (context.module_sp) { context.module_sp->FindSymbolsMatchingRegExAndType (m_regex, eSymbolTypeCode, sym_list); context.module_sp->FindFunctions (m_regex, - true, + include_symbols, + append, func_list); } break; - case AddressResolver::Glob: + + case AddressResolver::Glob: if (log) log->Warning ("glob is not supported yet."); break; diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp index e6fe1b018a5..64a4c2c762b 100644 --- a/lldb/source/Core/Disassembler.cpp +++ b/lldb/source/Core/Disassembler.cpp @@ -99,39 +99,44 @@ Disassembler::Disassemble Stream &strm ) { - if (exe_ctx.target == NULL && name) - return false; - SymbolContextList sc_list; - - if (module) - { - if (!module->FindFunctions (name, - eFunctionNameTypeBase | - eFunctionNameTypeFull | - eFunctionNameTypeMethod | - eFunctionNameTypeSelector, - true, - sc_list)) - return false; - } - else + if (name) { - if (exe_ctx.target->GetImages().FindFunctions (name, + const bool include_symbols = true; + if (module) + { + module->FindFunctions (name, + eFunctionNameTypeBase | + eFunctionNameTypeFull | + eFunctionNameTypeMethod | + eFunctionNameTypeSelector, + include_symbols, + true, + sc_list); + } + else if (exe_ctx.target) + { + exe_ctx.target->GetImages().FindFunctions (name, eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeMethod | eFunctionNameTypeSelector, + include_symbols, false, - sc_list)) - { - return Disassemble (debugger, arch, exe_ctx, sc_list, num_mixed_context_lines, show_bytes, strm); - } - else if (exe_ctx.target->GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list)) - { - return Disassemble (debugger, arch, exe_ctx, sc_list, num_mixed_context_lines, show_bytes, strm); + sc_list); } } + + if (sc_list.GetSize ()) + { + return Disassemble (debugger, + arch, + exe_ctx, + sc_list, + num_mixed_context_lines, + show_bytes, + strm); + } return false; } diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 6226fb26f2a..ef8e3938a6e 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -321,21 +321,88 @@ Module::FindGlobalVariables(const RegularExpression& regex, bool append, uint32_ } uint32_t -Module::FindFunctions(const ConstString &name, uint32_t name_type_mask, bool append, SymbolContextList& sc_list) +Module::FindFunctions (const ConstString &name, + uint32_t name_type_mask, + bool include_symbols, + bool append, + SymbolContextList& sc_list) { + if (!append) + sc_list.Clear(); + + const uint32_t start_size = sc_list.GetSize(); + + // Find all the functions (not symbols, but debug information functions... SymbolVendor *symbols = GetSymbolVendor (); if (symbols) - return symbols->FindFunctions(name, name_type_mask, append, sc_list); - return 0; + symbols->FindFunctions(name, name_type_mask, append, sc_list); + + // Now check our symbol table for symbols that are code symbols if requested + if (include_symbols) + { + ObjectFile *objfile = GetObjectFile(); + if (objfile) + { + Symtab *symtab = objfile->GetSymtab(); + if (symtab) + { + std::vector<uint32_t> symbol_indexes; + symtab->FindAllSymbolsWithNameAndType (name, eSymbolTypeCode, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes); + const uint32_t num_matches = symbol_indexes.size(); + if (num_matches) + { + SymbolContext sc(this); + for (uint32_t i=0; i<num_matches; i++) + { + sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]); + sc_list.AppendIfUnique (sc); + } + } + } + } + } + return sc_list.GetSize() - start_size; } uint32_t -Module::FindFunctions(const RegularExpression& regex, bool append, SymbolContextList& sc_list) -{ +Module::FindFunctions (const RegularExpression& regex, + bool include_symbols, + bool append, + SymbolContextList& sc_list) +{ + if (!append) + sc_list.Clear(); + + const uint32_t start_size = sc_list.GetSize(); + SymbolVendor *symbols = GetSymbolVendor (); if (symbols) return symbols->FindFunctions(regex, append, sc_list); - return 0; + // Now check our symbol table for symbols that are code symbols if requested + if (include_symbols) + { + ObjectFile *objfile = GetObjectFile(); + if (objfile) + { + Symtab *symtab = objfile->GetSymtab(); + if (symtab) + { + std::vector<uint32_t> symbol_indexes; + symtab->AppendSymbolIndexesMatchingRegExAndType (regex, eSymbolTypeCode, Symtab::eDebugAny, Symtab::eVisibilityAny, symbol_indexes); + const uint32_t num_matches = symbol_indexes.size(); + if (num_matches) + { + SymbolContext sc(this); + for (uint32_t i=0; i<num_matches; i++) + { + sc.symbol = symtab->SymbolAtIndex(symbol_indexes[i]); + sc_list.AppendIfUnique (sc); + } + } + } + } + } + return sc_list.GetSize() - start_size; } uint32_t diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index dea3ac03bf8..7b448d4dd6d 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -141,7 +141,11 @@ ModuleList::GetModuleAtIndex(uint32_t idx) } size_t -ModuleList::FindFunctions (const ConstString &name, uint32_t name_type_mask, bool append, SymbolContextList &sc_list) +ModuleList::FindFunctions (const ConstString &name, + uint32_t name_type_mask, + bool include_symbols, + bool append, + SymbolContextList &sc_list) { if (!append) sc_list.Clear(); @@ -150,14 +154,17 @@ ModuleList::FindFunctions (const ConstString &name, uint32_t name_type_mask, boo collection::const_iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) { - (*pos)->FindFunctions (name, name_type_mask, true, sc_list); + (*pos)->FindFunctions (name, name_type_mask, include_symbols, true, sc_list); } return sc_list.GetSize(); } uint32_t -ModuleList::FindGlobalVariables (const ConstString &name, bool append, uint32_t max_matches, VariableList& variable_list) +ModuleList::FindGlobalVariables (const ConstString &name, + bool append, + uint32_t max_matches, + VariableList& variable_list) { size_t initial_size = variable_list.GetSize(); Mutex::Locker locker(m_modules_mutex); @@ -171,7 +178,10 @@ ModuleList::FindGlobalVariables (const ConstString &name, bool append, uint32_t uint32_t -ModuleList::FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variable_list) +ModuleList::FindGlobalVariables (const RegularExpression& regex, + bool append, + uint32_t max_matches, + VariableList& variable_list) { size_t initial_size = variable_list.GetSize(); Mutex::Locker locker(m_modules_mutex); @@ -185,7 +195,9 @@ ModuleList::FindGlobalVariables (const RegularExpression& regex, bool append, ui size_t -ModuleList::FindSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, SymbolContextList &sc_list) +ModuleList::FindSymbolsWithNameAndType (const ConstString &name, + SymbolType symbol_type, + SymbolContextList &sc_list) { Mutex::Locker locker(m_modules_mutex); sc_list.Clear(); |