[Lldb-commits] [lldb] r113290 - in /lldb/trunk/source/Expression: ClangExpressionDeclMap.cpp IRForTarget.cpp

Sean Callanan scallanan at apple.com
Tue Sep 7 14:49:41 PDT 2010


Author: spyffe
Date: Tue Sep  7 16:49:41 2010
New Revision: 113290

URL: http://llvm.org/viewvc/llvm-project?rev=113290&view=rev
Log:
Improved function lookup to avoid conflicts between
symbols with the same name and no debug information.
Also improved the way functions are called so we
don't automatically define them as variadic functions
in the IR.

Modified:
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Expression/IRForTarget.cpp

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=113290&r1=113289&r2=113290&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Sep  7 16:49:41 2010
@@ -734,6 +734,9 @@
     
     m_sym_ctx->FindFunctionsByName(name_cs, false, sym_ctxs);
     
+    bool found_generic = false;
+    bool found_specific = false;
+    
     for (uint32_t index = 0, num_indices = sym_ctxs.GetSize();
          index < num_indices;
          ++index)
@@ -742,9 +745,21 @@
         sym_ctxs.GetContextAtIndex(index, sym_ctx);
         
         if (sym_ctx.function)
-            AddOneFunction(context, sym_ctx.function, NULL);
+        {
+            // TODO only do this if it's a C function; C++ functions may be
+            // overloaded
+            if (!found_specific)
+                AddOneFunction(context, sym_ctx.function, NULL);
+            found_specific = true;
+        }
         else if(sym_ctx.symbol)
-            AddOneFunction(context, NULL, sym_ctx.symbol);
+        {
+            if (!found_generic && !found_specific)
+            {
+                AddOneFunction(context, NULL, sym_ctx.symbol);
+                found_generic = true;
+            }
+        }
     }
     
     Variable *var = FindVariableInScope(*m_sym_ctx, name);
@@ -993,7 +1008,7 @@
     entity.m_parser_vars->m_lldb_value  = fun_location.release();
         
     if (log)
-        log->Printf("Found function %s, returned (NamedDecl)%p", context.Name.getAsString().c_str(), fun_decl);    
+        log->Printf("Found %s function %s, returned (NamedDecl)%p", (fun ? "specific" : "generic"), context.Name.getAsString().c_str(), fun_decl);    
 }
 
 void 

Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=113290&r1=113289&r2=113290&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Sep  7 16:49:41 2010
@@ -558,9 +558,15 @@
     {
         if (!m_decl_map->GetFunctionInfo(fun_decl, fun_value_ptr, fun_addr)) 
         {
-            if (log)
-                log->Printf("Function %s had no address", fun_decl->getNameAsCString());
-            return false;
+            fun_value_ptr = NULL;
+            
+            if (!m_decl_map->GetFunctionAddress(fun->getName().str().c_str(), fun_addr))
+            {
+                if (log)
+                    log->Printf("Function %s had no address", fun->getName().str().c_str());
+                
+                return false;
+            }
         }
     }
     else 
@@ -580,12 +586,9 @@
             
     if (!fun_value_ptr || !*fun_value_ptr)
     {
-        std::vector<const Type*> params;
-        
         const IntegerType *intptr_ty = Type::getIntNTy(M.getContext(),
                                                        (M.getPointerSize() == Module::Pointer64) ? 64 : 32);
-        
-        FunctionType *fun_ty = FunctionType::get(intptr_ty, params, true);
+        const FunctionType *fun_ty = fun->getFunctionType();
         PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty);
         Constant *fun_addr_int = ConstantInt::get(intptr_ty, fun_addr, false);
         fun_addr_ptr = ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty);





More information about the lldb-commits mailing list