[Lldb-commits] [lldb] r163913 - /lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp

Sean Callanan scallanan at apple.com
Fri Sep 14 10:20:18 PDT 2012


Author: spyffe
Date: Fri Sep 14 12:20:18 2012
New Revision: 163913

URL: http://llvm.org/viewvc/llvm-project?rev=163913&view=rev
Log:
Extended the "watchpoint set variable" code to
support watchpoints on globals.

<rdar://problem/12297238>

Modified:
    lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp

Modified: lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp?rev=163913&r1=163912&r2=163913&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectWatchpoint.cpp Fri Sep 14 12:20:18 2012
@@ -970,6 +970,21 @@
     }
 
 protected:
+    static uint32_t GetVariableCallback (void *baton,
+                                         const char *name,
+                                         VariableList &variable_list)
+    {
+        Target *target = static_cast<Target *>(baton);
+        if (target)
+        {
+            return target->GetImages().FindGlobalVariables (ConstString(name),
+                                                            true,
+                                                            UINT32_MAX,
+                                                            variable_list);
+        }
+        return 0;
+    }
+    
     virtual bool
     DoExecute (Args& command,
              CommandReturnObject &result)
@@ -1023,6 +1038,24 @@
                                                               expr_path_options,
                                                               var_sp,
                                                               error);
+        
+        if (!valobj_sp) {
+            // Not in the frame; let's check the globals.
+            
+            VariableList variable_list;
+            ValueObjectList valobj_list;
+            
+            Error error (Variable::GetValuesForVariableExpressionPath (command.GetArgumentAtIndex(0),
+                                                                       exe_ctx.GetBestExecutionContextScope(),
+                                                                       GetVariableCallback,
+                                                                       target,
+                                                                       variable_list,
+                                                                       valobj_list));
+            
+            if (valobj_list.GetSize())
+                valobj_sp = valobj_list.GetValueObjectAtIndex(0);
+        }
+        
         if (valobj_sp) {
             AddressType addr_type;
             addr = valobj_sp->GetAddressOf(false, &addr_type);





More information about the lldb-commits mailing list