Made symbol lookup in the expression parser more

robust:

- Now a client can specify what kind of symbols
  are needed; notably, this allows looking up
  Objective-C class symbols specifically.

- In the class of symbols being looked up, if
  one is non-NULL and others are NULL, LLDB now
  prefers the non-NULL one.

llvm-svn: 145554
This commit is contained in:
Sean Callanan 2011-12-01 02:04:16 +00:00
parent c1870b2633
commit 947ccc7396
3 changed files with 12 additions and 10 deletions

View File

@ -336,10 +336,12 @@ public:
//------------------------------------------------------------------
lldb::addr_t
GetSymbolAddress (Target &target,
const ConstString &name);
const ConstString &name,
lldb::SymbolType symbol_type);
lldb::addr_t
GetSymbolAddress (const ConstString &name);
GetSymbolAddress (const ConstString &name,
lldb::SymbolType symbol_type);
//------------------------------------------------------------------
/// [Used by IRInterpreter] Get basic target information.

View File

@ -718,16 +718,16 @@ ClangExpressionDeclMap::GetFunctionAddress
}
addr_t
ClangExpressionDeclMap::GetSymbolAddress (Target &target, const ConstString &name)
ClangExpressionDeclMap::GetSymbolAddress (Target &target, const ConstString &name, lldb::SymbolType symbol_type)
{
SymbolContextList sc_list;
target.GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list);
target.GetImages().FindSymbolsWithNameAndType(name, symbol_type, sc_list);
const uint32_t num_matches = sc_list.GetSize();
addr_t symbol_load_addr = LLDB_INVALID_ADDRESS;
for (uint32_t i=0; i<num_matches && symbol_load_addr == LLDB_INVALID_ADDRESS; i++)
for (uint32_t i=0; i<num_matches && (symbol_load_addr == 0 || symbol_load_addr == LLDB_INVALID_ADDRESS); i++)
{
SymbolContext sym_ctx;
sc_list.GetContextAtIndex(i, sym_ctx);
@ -778,7 +778,7 @@ ClangExpressionDeclMap::GetSymbolAddress (Target &target, const ConstString &nam
}
addr_t
ClangExpressionDeclMap::GetSymbolAddress (const ConstString &name)
ClangExpressionDeclMap::GetSymbolAddress (const ConstString &name, lldb::SymbolType symbol_type)
{
assert (m_parser_vars.get());
@ -786,7 +786,7 @@ ClangExpressionDeclMap::GetSymbolAddress (const ConstString &name)
!m_parser_vars->m_exe_ctx->GetTargetPtr())
return false;
return GetSymbolAddress(m_parser_vars->m_exe_ctx->GetTargetRef(), name);
return GetSymbolAddress(m_parser_vars->m_exe_ctx->GetTargetRef(), name, symbol_type);
}
// Interface for IRInterpreter
@ -1741,7 +1741,7 @@ ClangExpressionDeclMap::DoMaterializeOneVariable
}
else if (sym)
{
addr_t location_load_addr = GetSymbolAddress(*target, name);
addr_t location_load_addr = GetSymbolAddress(*target, name, lldb::eSymbolTypeAny);
if (location_load_addr == LLDB_INVALID_ADDRESS)
{

View File

@ -1676,7 +1676,7 @@ IRForTarget::HandleSymbol (Value *symbol)
lldb_private::ConstString name(symbol->getName().str().c_str());
lldb::addr_t symbol_addr = m_decl_map->GetSymbolAddress (name);
lldb::addr_t symbol_addr = m_decl_map->GetSymbolAddress (name, lldb::eSymbolTypeAny);
if (symbol_addr == LLDB_INVALID_ADDRESS)
{
@ -1748,7 +1748,7 @@ IRForTarget::HandleObjCClass(Value *classlist_reference)
StringRef name(initializer->getName());
lldb_private::ConstString name_cstr(name.str().c_str());
lldb::addr_t class_ptr = m_decl_map->GetSymbolAddress(name_cstr);
lldb::addr_t class_ptr = m_decl_map->GetSymbolAddress(name_cstr, lldb::eSymbolTypeRuntime);
if (log)
log->Printf("Found reference to Objective-C class %s (0x%llx)", name_cstr.AsCString(), (unsigned long long)class_ptr);