[Lldb-commits] [lldb] r241282 - Make sure we can lookup re-exported symbols after recent changes to lldb_private::Symbol.

Greg Clayton gclayton at apple.com
Thu Jul 2 09:43:50 PDT 2015


Author: gclayton
Date: Thu Jul  2 11:43:49 2015
New Revision: 241282

URL: http://llvm.org/viewvc/llvm-project?rev=241282&view=rev
Log:
Make sure we can lookup re-exported symbols after recent changes to lldb_private::Symbol.

Recently lldb_private::Symbol was changed so the old code:

Address &Symbol::GetAddress();

Is now:

Address Symbol::GetAddress();

And the Address object that is returned will be invalid for non-address based symbols. When we have re-exported symbols this code would now fail:

    const Address sym_address = sym_ctx.symbol->GetAddress();

    if (!sym_address.IsValid())
        continue;

    symbol_load_addr = sym_ctx.symbol->ResolveCallableAddress(*target_sp);

    if (symbol_load_addr == LLDB_INVALID_ADDRESS)
    {
        symbol_load_addr = sym_address.GetLoadAddress(target_sp.get());
    }

It used to return an Address reference to the value of the re-exported symbol that contained no section and a zero value for Address.m_offset (since the original symbol in the symbol table had a value of zero). When a reference was returned, this meant the "sym_address.IsValid()" would return true because the Address.m_offset was not LLDB_INVALID_ADDRESS, it was zero. This was working by mistake.

The Symbol::ResolveCallableAddress(...) actually checks for reexported symbols and whole bunch of other cases and resolves the address correctly, so we should let it do its thing and not cut it off before it can resolve the address with the "if (!sym_address.IsValid()) continue;".


Modified:
    lldb/trunk/source/Expression/IRExecutionUnit.cpp

Modified: lldb/trunk/source/Expression/IRExecutionUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRExecutionUnit.cpp?rev=241282&r1=241281&r2=241282&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRExecutionUnit.cpp (original)
+++ lldb/trunk/source/Expression/IRExecutionUnit.cpp Thu Jul  2 11:43:49 2015
@@ -676,20 +676,10 @@ IRExecutionUnit::MemoryManager::getSymbo
         SymbolContext sym_ctx;
         sc_list.GetContextAtIndex(i, sym_ctx);
         
-        if (sym_ctx.symbol->GetType() == lldb::eSymbolTypeUndefined)
-            continue;
-        
-        const Address sym_address = sym_ctx.symbol->GetAddress();
-        
-        if (!sym_address.IsValid())
-            continue;
-
         symbol_load_addr = sym_ctx.symbol->ResolveCallableAddress(*target_sp);
-        
+
         if (symbol_load_addr == LLDB_INVALID_ADDRESS)
-        {
-            symbol_load_addr = sym_address.GetLoadAddress(target_sp.get());
-        }
+            symbol_load_addr = sym_ctx.symbol->GetAddress().GetLoadAddress(target_sp.get());
     }
     
     if (symbol_load_addr == LLDB_INVALID_ADDRESS && process_sp && name_cs)





More information about the lldb-commits mailing list