[Lldb-commits] [lldb] r231420 - When we have a symbol, like "NSLog" that we try to call in an expression, make sure we prioritize the external symbols over the internal one.
Greg Clayton
gclayton at apple.com
Thu Mar 5 15:12:02 PST 2015
Author: gclayton
Date: Thu Mar 5 17:12:02 2015
New Revision: 231420
URL: http://llvm.org/viewvc/llvm-project?rev=231420&view=rev
Log:
When we have a symbol, like "NSLog" that we try to call in an expression, make sure we prioritize the external symbols over the internal one.
This is a temporary fix until a more comprehensive fix can be made for finding functions that we call in expressions.
We find "NSLog" in ClangExpressionDeclMap::FindExternalVisibleDecls() in after a call to target->GetImages().FindFunctions(...). Note that there are two symbols: NSLog from CFNetwork which is not external, and NSLog from Foundation which _is_ external. We do something with the external symbol with:
if (extern_symbol)
{
AddOneFunction (context, NULL, extern_symbol, current_id);
context.m_found.function = true;
}
Then later we try to lookup the _Z5NSLogP8NSStringz name and we don't find it so we call ClangExpressionDeclMap::GetFunctionAddress() with "_Z5NSLogP8NSStringz" as the name and the sc_list_size is zero at the "if" statement at line 568 because we don't find the mangled name and we extract the basename "NSLog" and call:
FindCodeSymbolInContext(ConstString(basename), m_parser_vars->m_sym_ctx, sc_list);
sc_list_size = sc_list.GetSize();
and we get a list size of two again, and we proceed to search for the symbol again, this time ignoring the external vs non-external-ness of the symbols that we find. This fix ensures we prioritize the external symbol until we get a real fix from Sean Callanan when he gets back to make sure we don't do multiple lookups for the same symbol we already resolved.
<rdar://problem/19879282>
Modified:
lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=231420&r1=231419&r2=231420&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Mar 5 17:12:02 2015
@@ -585,11 +585,14 @@ ClangExpressionDeclMap::GetFunctionAddre
}
}
+ lldb::addr_t intern_callable_load_addr = LLDB_INVALID_ADDRESS;
+
for (uint32_t i=0; i<sc_list_size; ++i)
{
SymbolContext sym_ctx;
sc_list.GetContextAtIndex(i, sym_ctx);
+
lldb::addr_t callable_load_addr = LLDB_INVALID_ADDRESS;
if (sym_ctx.function)
@@ -602,7 +605,13 @@ ClangExpressionDeclMap::GetFunctionAddre
}
else if (sym_ctx.symbol)
{
- callable_load_addr = sym_ctx.symbol->ResolveCallableAddress(*target);
+ if (sym_ctx.symbol->IsExternal())
+ callable_load_addr = sym_ctx.symbol->ResolveCallableAddress(*target);
+ else
+ {
+ if (intern_callable_load_addr == LLDB_INVALID_ADDRESS)
+ intern_callable_load_addr = sym_ctx.symbol->ResolveCallableAddress(*target);
+ }
}
if (callable_load_addr != LLDB_INVALID_ADDRESS)
@@ -611,6 +620,14 @@ ClangExpressionDeclMap::GetFunctionAddre
return true;
}
}
+
+ // See if we found an internal symbol
+ if (intern_callable_load_addr != LLDB_INVALID_ADDRESS)
+ {
+ func_addr = intern_callable_load_addr;
+ return true;
+ }
+
return false;
}
More information about the lldb-commits
mailing list