From f32db51c5014e4d27b1a003a00e090fde308fee7 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Wed, 30 Oct 2013 21:37:46 +0000 Subject: [PATCH] Fixed the expression parser to be able to iterate across all function name matches that it finds when it is looking for the address of a function that the IR is looking for. Also taught it to deal with reexported symbols. llvm-svn: 193716 --- .../Expression/ClangExpressionDeclMap.cpp | 63 ++++++++++++------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index 1944495591e1..4570e018619f 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -515,6 +515,7 @@ FindCodeSymbolInContext { case eSymbolTypeCode: case eSymbolTypeResolver: + case eSymbolTypeReExported: sc_list.Append(sym_ctx); break; @@ -547,7 +548,8 @@ ClangExpressionDeclMap::GetFunctionAddress FindCodeSymbolInContext(name, m_parser_vars->m_sym_ctx, sc_list); - if (!sc_list.GetSize()) + uint32_t sc_list_size = sc_list.GetSize(); + if (sc_list_size == 0) { // We occasionally get debug information in which a const function is reported // as non-const, so the mangled name is wrong. This is a hack to compensate. @@ -563,32 +565,49 @@ ClangExpressionDeclMap::GetFunctionAddress log->Printf("Failed to find symbols given non-const name %s; trying %s", name.GetCString(), fixed_name.GetCString()); FindCodeSymbolInContext(fixed_name, m_parser_vars->m_sym_ctx, sc_list); + sc_list_size = sc_list.GetSize(); } } - - if (!sc_list.GetSize()) - return false; - SymbolContext sym_ctx; - sc_list.GetContextAtIndex(0, sym_ctx); + for (uint32_t i=0; iGetAddressRange().GetBaseAddress(); + else if (sym_ctx.symbol) + { + if (sym_ctx.symbol->GetType() == eSymbolTypeReExported) + { + Symbol *reexported_symbol = sym_ctx.symbol->ResolveReExportedSymbol(*target); + if (reexported_symbol) + { + func_so_addr = &reexported_symbol->GetAddress(); + is_indirect_function = reexported_symbol->IsIndirect(); + } + } + else + { + func_so_addr = &sym_ctx.symbol->GetAddress(); + is_indirect_function = sym_ctx.symbol->IsIndirect(); + } + } - if (sym_ctx.function) - func_so_addr = &sym_ctx.function->GetAddressRange().GetBaseAddress(); - else if (sym_ctx.symbol) { - func_so_addr = &sym_ctx.symbol->GetAddress(); - is_indirect_function = sym_ctx.symbol->IsIndirect(); - } else - return false; - - if (!func_so_addr || !func_so_addr->IsValid()) - return false; - - func_addr = func_so_addr->GetCallableLoadAddress (target, is_indirect_function); - - return true; + if (func_so_addr && func_so_addr->IsValid()) + { + lldb::addr_t load_addr = func_so_addr->GetCallableLoadAddress (target, is_indirect_function); + + if (load_addr != LLDB_INVALID_ADDRESS) + { + func_addr = load_addr; + return true; + } + } + } + return false; } addr_t