[Lldb-commits] [lldb] r193716 - <rdar://problem/14496092>

Greg Clayton gclayton at apple.com
Wed Oct 30 14:37:47 PDT 2013


Author: gclayton
Date: Wed Oct 30 16:37:46 2013
New Revision: 193716

URL: http://llvm.org/viewvc/llvm-project?rev=193716&view=rev
Log:
<rdar://problem/14496092>

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.


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=193716&r1=193715&r2=193716&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Oct 30 16:37:46 2013
@@ -515,6 +515,7 @@ FindCodeSymbolInContext
             {
                 case eSymbolTypeCode:
                 case eSymbolTypeResolver:
+                case eSymbolTypeReExported:
                     sc_list.Append(sym_ctx);
                     break;
 
@@ -547,7 +548,8 @@ ClangExpressionDeclMap::GetFunctionAddre
     
     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::GetFunctionAddre
                 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);
-
-    const Address *func_so_addr = NULL;
-    bool is_indirect_function = false;
-
-    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;
+    for (uint32_t i=0; i<sc_list_size; ++i)
+    {
+        SymbolContext sym_ctx;
+        sc_list.GetContextAtIndex(i, sym_ctx);
 
-    func_addr = func_so_addr->GetCallableLoadAddress (target, is_indirect_function);
+        const Address *func_so_addr = NULL;
+        bool is_indirect_function = false;
+        if (sym_ctx.function)
+            func_so_addr = &sym_ctx.function->GetAddressRange().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();
+            }
+        }
 
-    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





More information about the lldb-commits mailing list