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

Sean Callanan scallanan at apple.com
Mon Aug 1 10:41:38 PDT 2011


Author: spyffe
Date: Mon Aug  1 12:41:38 2011
New Revision: 136629

URL: http://llvm.org/viewvc/llvm-project?rev=136629&view=rev
Log:
Fixed a bug where named constants were being
treated as externals, causing problems when we
tried to look their locations up in the debug
info.  For example:

expr char c[] = "foo"; c[0]

would terminate when trying to find c in the
debug information, despite the fact that c was
defined inside the expression.

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=136629&r1=136628&r2=136629&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Mon Aug  1 12:41:38 2011
@@ -1236,7 +1236,7 @@
     
     if (log)
         log->Printf("MaybeHandleVariable (%s)", PrintValue(llvm_value_ptr).c_str());
-
+        
     if (ConstantExpr *constant_expr = dyn_cast<ConstantExpr>(llvm_value_ptr))
     {
         switch (constant_expr->getOpcode())
@@ -1324,7 +1324,12 @@
                                                         llvm_value_ptr,
                                                         value_size, 
                                                         value_alignment))
-            return false;
+        {
+            if (!global_variable->hasExternalLinkage())
+                return true;
+            else
+                return false;
+        }
     }
     else if (dyn_cast<llvm::Function>(llvm_value_ptr))
     {
@@ -1403,6 +1408,9 @@
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
 
     Function *fun = llvm_call_inst->getCalledFunction();
+
+    // If the call is to something other than a plain llvm::Function, resolve which
+    // Function is meant or give up.
     
     if (fun == NULL)
     {
@@ -1440,6 +1448,9 @@
         }
     }
     
+    // Determine the name of the called function, which is needed to find the address.
+    // Intrinsics are special-cased.
+    
     lldb_private::ConstString str;
     
     if (fun->isIntrinsic())
@@ -1472,6 +1483,8 @@
         str.SetCStringWithLength (fun->getName().data(), fun->getName().size());
     }
     
+    // Find the address of the function, and the type if possible.
+    
     clang::NamedDecl *fun_decl = DeclForGlobal (fun);
     lldb::addr_t fun_addr = LLDB_INVALID_ADDRESS;
     Value **fun_value_ptr = NULL;
@@ -1511,6 +1524,8 @@
     if (log)
         log->Printf("Found \"%s\" at 0x%llx", str.GetCString(), fun_addr);
     
+    // Construct the typed pointer to the function.
+    
     Value *fun_addr_ptr = NULL;
             
     if (!fun_value_ptr || !*fun_value_ptr)





More information about the lldb-commits mailing list