From 58ea3e35d0139c3afd5a07a0ca9a7fcf70ac6eb2 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Mon, 9 Mar 2015 16:46:57 +0000 Subject: [PATCH] Fixed a bug where the expression parser relied on having symbols for things even if they were in the debug info. The issue can happen if you strip your main executable and then run an expression and it would fail to find the stripped symbol and it would then not be able to make the function call. The issue was fixed by doing our normal FindFunctions call. llvm-svn: 231667 --- lldb/source/Expression/ClangExpressionDeclMap.cpp | 55 ++++++++++++++++------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index 906065d..5b92e74 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -493,33 +493,56 @@ FindCodeSymbolInContext SymbolContextList &sc_list ) { + sc_list.Clear(); SymbolContextList temp_sc_list; if (sym_ctx.module_sp) - sym_ctx.module_sp->FindSymbolsWithNameAndType(name, eSymbolTypeAny, temp_sc_list); - - if (!sc_list.GetSize() && sym_ctx.target_sp) - sym_ctx.target_sp->GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeAny, temp_sc_list); + sym_ctx.module_sp->FindFunctions(name, + NULL, + eFunctionNameTypeAuto, + true, // include_symbols + false, // include_inlines + true, // append + temp_sc_list); + if (temp_sc_list.GetSize() == 0) + { + if (sym_ctx.target_sp) + sym_ctx.target_sp->GetImages().FindFunctions(name, + eFunctionNameTypeAuto, + true, // include_symbols + false, // include_inlines + true, // append + temp_sc_list); + } + SymbolContextList internal_symbol_sc_list; unsigned temp_sc_list_size = temp_sc_list.GetSize(); for (unsigned i = 0; i < temp_sc_list_size; i++) { - SymbolContext sym_ctx; - temp_sc_list.GetContextAtIndex(i, sym_ctx); - if (sym_ctx.symbol) + SymbolContext sc; + temp_sc_list.GetContextAtIndex(i, sc); + if (sc.function) { - switch (sym_ctx.symbol->GetType()) + sc_list.Append(sc); + } + else if (sc.symbol) + { + if (sc.symbol->IsExternal()) { - case eSymbolTypeCode: - case eSymbolTypeResolver: - case eSymbolTypeReExported: - sc_list.Append(sym_ctx); - break; - - default: - break; + sc_list.Append(sc); + } + else + { + internal_symbol_sc_list.Append(sc); } } } + + // If we had internal symbols and we didn't find any external symbols or + // functions in debug info, then fallback to the internal symbols + if (sc_list.GetSize() == 0 && internal_symbol_sc_list.GetSize()) + { + sc_list = internal_symbol_sc_list; + } } bool -- 2.7.4