[Lldb-commits] [lldb] r120728 - /lldb/trunk/source/Expression/IRForTarget.cpp

Sean Callanan scallanan at apple.com
Thu Dec 2 11:47:57 PST 2010


Author: spyffe
Date: Thu Dec  2 13:47:57 2010
New Revision: 120728

URL: http://llvm.org/viewvc/llvm-project?rev=120728&view=rev
Log:
Fixed IRForTarget so that it errors out when function
pointers are used.  Previously, they caused a crash
in the JIT because we didn't resolve them correctly.

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

Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=120728&r1=120727&r2=120728&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Thu Dec  2 13:47:57 2010
@@ -844,6 +844,9 @@
 IRForTarget::MaybeHandleVariable (Module &llvm_module, Value *llvm_value_ptr)
 {
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    
+    if (log)
+        log->Printf("MaybeHandleVariable (%s)\n", PrintValue(llvm_value_ptr).c_str());
 
     if (ConstantExpr *constant_expr = dyn_cast<ConstantExpr>(llvm_value_ptr))
     {
@@ -854,7 +857,8 @@
         case Instruction::GetElementPtr:
         case Instruction::BitCast:
             Value *s = constant_expr->getOperand(0);
-            MaybeHandleVariable(llvm_module, s);
+            if (!MaybeHandleVariable(llvm_module, s))
+                return false;
         }
     }
     if (GlobalVariable *global_variable = dyn_cast<GlobalVariable>(llvm_value_ptr))
@@ -909,6 +913,13 @@
                                                         value_alignment))
             return false;
     }
+    else if (llvm::Function *function = dyn_cast<llvm::Function>(llvm_value_ptr))
+    {
+        if (log)
+            log->Printf("Function pointers aren't handled right now");
+        
+        return false;
+    }
     
     return true;
 }
@@ -916,7 +927,10 @@
 bool
 IRForTarget::MaybeHandleCallArguments (Module &llvm_module, CallInst *Old)
 {
-    // lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    
+    if (log)
+        log->Printf("MaybeHandleCallArguments(%s)", PrintValue(Old).c_str());
     
     for (unsigned op_index = 0, num_ops = Old->getNumArgOperands();
          op_index < num_ops;
@@ -945,11 +959,11 @@
             fun = dyn_cast<Function>(const_expr->getOperand(0));
             
             if (!fun)
-                return true;
+                return false;
         }
         else
         {
-            return true;
+            return false;
         }
     }
     
@@ -1065,6 +1079,9 @@
         
         if (call && !MaybeHandleCall(llvm_module, call))
             return false;
+        
+        if (call && !MaybeHandleCallArguments(llvm_module, call))
+            return false;
     }
     
     return true;





More information about the lldb-commits mailing list