StackFrame objects now own ValueObjects for any frame variables (locals, args,
function statics, file globals and static variables) that a frame contains. 
The StackFrame objects can give out ValueObjects instances for
each variable which allows us to track when a variable changes and doesn't
depend on variable names when getting value objects.

StackFrame::GetVariableList now takes a boolean to indicate if we want to
get the frame compile unit globals and static variables.

The value objects in the stack frames can now correctly track when they have
been modified. There are a few more tweaks needed to complete this work. The
biggest issue is when stepping creates partial stacks (just frame zero usually)
and causes previous stack frames not to match up with the current stack frames
because the previous frames only has frame zero. We don't really want to 
require that all previous frames be complete since stepping often must check
stack frames to complete their jobs. I will fix this issue tomorrow.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@112800 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/lldb/API/SBValue.h b/include/lldb/API/SBValue.h
index b5ac5ef..032f1db 100644
--- a/include/lldb/API/SBValue.h
+++ b/include/lldb/API/SBValue.h
@@ -45,7 +45,7 @@
     GetValue (const lldb::SBFrame &frame);
 
     bool
-    GetValueDidChange ();
+    GetValueDidChange (const lldb::SBFrame &frame);
 
     const char *
     GetSummary (const lldb::SBFrame &frame);
diff --git a/include/lldb/Core/ValueObject.h b/include/lldb/Core/ValueObject.h
index 75ae31b..0e805f4 100644
--- a/include/lldb/Core/ValueObject.h
+++ b/include/lldb/Core/ValueObject.h
@@ -145,10 +145,10 @@
     GetUpdateID() const;
 
     bool
-    GetValueIsValid ();
+    GetValueIsValid () const;
 
     bool
-    GetValueDidChange () const;
+    GetValueDidChange (ExecutionContextScope *exe_scope);
 
     bool
     UpdateValueIfNeeded (ExecutionContextScope *exe_scope);
@@ -173,11 +173,6 @@
     GetSyntheticArrayMemberFromPointer (int32_t index, bool can_create);
 
 protected:
-    enum {
-        eValueChanged = (1 << 0),
-        eNumChildrenHasBeenSet = (1 << 1),
-        eValueIsValid = (1 << 2)
-    };
     //------------------------------------------------------------------
     // Classes that inherit from ValueObject can see and modify these
     //------------------------------------------------------------------
@@ -191,12 +186,17 @@
     DataExtractor       m_data;         // A data extractor that can be used to extract the value.
     Value               m_value;
     Error               m_error;        // An error object that can describe any errors that occur when updating values.
-    Flags               m_flags;        // A boolean that indicates this value has changed
     std::string         m_value_str;    // Cached value string that will get cleared if/when the value is updated.
+    std::string         m_old_value_str;// Cached old value string from the last time the value was gotten
     std::string         m_location_str; // Cached location string that will get cleared if/when the value is updated.
     std::string         m_summary_str;  // Cached summary string that will get cleared if/when the value is updated.
     std::vector<lldb::ValueObjectSP> m_children;
     std::map<ConstString, lldb::ValueObjectSP> m_synthetic_children;
+    bool                m_value_is_valid:1,
+                        m_value_did_change:1,
+                        m_children_count_valid:1,
+                        m_old_value_valid:1;
+                        
     //------------------------------------------------------------------
     // Constructors and Destructors
     //------------------------------------------------------------------
diff --git a/include/lldb/Core/ValueObjectList.h b/include/lldb/Core/ValueObjectList.h
index 1b31028..9c5cde6 100644
--- a/include/lldb/Core/ValueObjectList.h
+++ b/include/lldb/Core/ValueObjectList.h
@@ -48,11 +48,18 @@
     FindValueObjectByPointer (ValueObject *valobj);
 
     uint32_t
-    GetSize() const;
+    GetSize () const;
+    
+    void
+    Resize (uint32_t size);
 
     lldb::ValueObjectSP
-    GetValueObjectAtIndex (uint32_t);
+    GetValueObjectAtIndex (uint32_t idx);
 
+    void
+    SetValueObjectAtIndex (uint32_t idx, 
+                           const lldb::ValueObjectSP &valobj_sp);
+    
     lldb::ValueObjectSP
     FindValueObjectByValueName (const char *name);
 
diff --git a/include/lldb/Core/ValueObjectVariable.h b/include/lldb/Core/ValueObjectVariable.h
index 80e0d05..f3d91dd 100644
--- a/include/lldb/Core/ValueObjectVariable.h
+++ b/include/lldb/Core/ValueObjectVariable.h
@@ -25,7 +25,7 @@
 class ValueObjectVariable : public ValueObject
 {
 public:
-    ValueObjectVariable (lldb::VariableSP &var_sp);
+    ValueObjectVariable (const lldb::VariableSP &var_sp);
 
     virtual
     ~ValueObjectVariable();
diff --git a/include/lldb/Symbol/VariableList.h b/include/lldb/Symbol/VariableList.h
index 53d21e6..cadd218 100644
--- a/include/lldb/Symbol/VariableList.h
+++ b/include/lldb/Symbol/VariableList.h
@@ -27,7 +27,7 @@
     virtual ~VariableList();
 
     void
-    AddVariable (lldb::VariableSP &var_sp);
+    AddVariable (const lldb::VariableSP &var_sp);
 
     void
     AddVariables(VariableList *variable_list);
@@ -42,14 +42,11 @@
     GetVariableAtIndex(uint32_t idx);
 
     lldb::VariableSP
-    FindVariable(const ConstString& name);
+    FindVariable (const ConstString& name);
 
-//  const SymbolContext&
-//  GetSymbolContext() const
-//  {
-//      return m_symbol_context;
-//  }
-//
+    uint32_t
+    FindIndexForVariable (Variable* variable);
+
     size_t
     MemorySize() const;
 
diff --git a/include/lldb/Target/StackFrame.h b/include/lldb/Target/StackFrame.h
index 2732708..c8b482a 100644
--- a/include/lldb/Target/StackFrame.h
+++ b/include/lldb/Target/StackFrame.h
@@ -91,14 +91,11 @@
     }
 
     VariableList *
-    GetVariableList ();
+    GetVariableList (bool get_file_globals);
 
     bool
     HasDebugInformation ();
 
-    ValueObjectList &
-    GetValueObjectList();
-
     const char *
     Disassemble ();
 
@@ -120,6 +117,12 @@
         return m_unwind_frame_index;
     }
     
+    lldb::ValueObjectSP
+    GetValueObjectForFrameVariable (const lldb::VariableSP &variable_sp);
+
+    lldb::ValueObjectSP
+    TrackGlobalVariable (const lldb::VariableSP &variable_sp);
+    
     //------------------------------------------------------------------
     // lldb::ExecutionContextScope pure virtual functions
     //------------------------------------------------------------------
@@ -165,7 +168,7 @@
     Scalar m_frame_base;
     Error m_frame_base_error;
     lldb::VariableListSP m_variable_list_sp;
-    ValueObjectList m_value_object_list;
+    ValueObjectList m_variable_list_value_objects;  // Value objects for each variable in m_variable_list_sp
     StreamString m_disassembly;
     DISALLOW_COPY_AND_ASSIGN (StackFrame);
 };
diff --git a/include/lldb/lldb-forward-rtti.h b/include/lldb/lldb-forward-rtti.h
index 8841322..aca620c 100644
--- a/include/lldb/lldb-forward-rtti.h
+++ b/include/lldb/lldb-forward-rtti.h
@@ -62,6 +62,7 @@
     typedef SharedPtr<lldb_private::ValueObject>::Type ValueObjectSP;
     typedef SharedPtr<lldb_private::Variable>::Type VariableSP;
     typedef SharedPtr<lldb_private::VariableList>::Type VariableListSP;
+    typedef SharedPtr<lldb_private::ValueObjectList>::Type ValueObjectListSP;
 
 } // namespace lldb
 
diff --git a/lldb.xcodeproj/project.pbxproj b/lldb.xcodeproj/project.pbxproj
index 6c23d00..71c4d6e 100644
--- a/lldb.xcodeproj/project.pbxproj
+++ b/lldb.xcodeproj/project.pbxproj
@@ -2310,6 +2310,7 @@
 			isa = PBXProject;
 			buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
 			compatibilityVersion = "Xcode 3.1";
+			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				en,
diff --git a/source/API/SBFrame.cpp b/source/API/SBFrame.cpp
index b2d591d..ce294ca 100644
--- a/source/API/SBFrame.cpp
+++ b/source/API/SBFrame.cpp
@@ -304,7 +304,7 @@
     if (m_opaque_sp)
     {
         size_t i;
-        VariableList *variable_list = m_opaque_sp->GetVariableList();
+        VariableList *variable_list = m_opaque_sp->GetVariableList(true);
         if (variable_list)
         {
             const size_t num_variables = variable_list->GetSize();
@@ -339,38 +339,12 @@
                             if (in_scope_only && !variable_sp->IsInScope(m_opaque_sp.get()))
                                 continue;
 
-                            value_list.Append(ValueObjectSP (new ValueObjectVariable (variable_sp)));
+                            value_list.Append(m_opaque_sp->GetValueObjectForFrameVariable (variable_sp));
                         }
                     }
                 }
             }
-        }
-        
-        if (statics)
-        {
-            CompileUnit *frame_comp_unit = m_opaque_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit;
-            
-            if (frame_comp_unit)
-            {
-                variable_list = frame_comp_unit->GetVariableList(true).get();
-                
-                if (variable_list)
-                {
-                    const size_t num_variables = variable_list->GetSize();
-                    if (num_variables)
-                    {
-                        for (i = 0; i < num_variables; ++i)
-                        {
-                            VariableSP variable_sp (variable_list->GetVariableAtIndex(i));
-                            if (variable_sp)
-                            {
-                                value_list.Append(ValueObjectSP (new ValueObjectVariable (variable_sp)));
-                            }
-                        }
-                    }
-                }
-            }
-        }
+        }        
     }
     return value_list;
 }
diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp
index c7839cb..f92be9f 100644
--- a/source/API/SBValue.cpp
+++ b/source/API/SBValue.cpp
@@ -172,15 +172,15 @@
 {
     const char *value_string = NULL;
     if ( m_opaque_sp)
-        value_string = m_opaque_sp->GetValueAsCString(frame.get());
+        value_string = m_opaque_sp->GetValueAsCString (frame.get());
     return value_string;
 }
 
 bool
-SBValue::GetValueDidChange ()
+SBValue::GetValueDidChange (const SBFrame &frame)
 {
     if (IsValid())
-        return m_opaque_sp->GetValueDidChange();
+        return m_opaque_sp->GetValueDidChange (frame.get());
     return false;
 }
 
diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp
index f78f8cb..30287e2 100644
--- a/source/Commands/CommandObjectFrame.cpp
+++ b/source/Commands/CommandObjectFrame.cpp
@@ -584,13 +584,12 @@
                                 var_sp = global_var_list.GetVariableAtIndex(global_idx);
                                 if (var_sp)
                                 {
-                                    valobj_sp = exe_ctx.frame->GetValueObjectList().FindValueObjectByValueName (m_options.globals[idx].AsCString());
+                                    valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp);
                                     if (!valobj_sp)
-                                        valobj_sp.reset (new ValueObjectVariable (var_sp));
+                                        valobj_sp = exe_ctx.frame->TrackGlobalVariable (var_sp);
 
                                     if (valobj_sp)
                                     {
-                                        exe_ctx.frame->GetValueObjectList().Append (valobj_sp);
                                         DumpValueObject (result, exe_ctx.frame, valobj_sp.get(), name_cstr, m_options.ptr_depth, 0, m_options.max_depth, false);
                                         result.GetOutputStream().EOL();
                                     }
@@ -631,18 +630,7 @@
                     var_sp = variable_list.FindVariable(name_const_string);
                     if (var_sp)
                     {
-                        //DumpVariable (result, &exe_ctx, var_sp.get());
-                        // TODO: redo history variables using a different map
-//                        if (var_path[0] == '$')
-//                            valobj_sp = valobj_list.FindValueObjectByValueObjectName (name_const_string.GetCString());
-//                        else
-                            valobj_sp = exe_ctx.frame->GetValueObjectList().FindValueObjectByValueName (name_const_string.GetCString());
-
-                        if (!valobj_sp)
-                        {
-                            valobj_sp.reset (new ValueObjectVariable (var_sp));
-                            exe_ctx.frame->GetValueObjectList().Append (valobj_sp);
-                        }
+                        valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp);
 
                         var_path.erase (0, name_const_string.GetLength ());
                         // We are dumping at least one child
diff --git a/source/Core/ValueObject.cpp b/source/Core/ValueObject.cpp
index 9c70c3b..e14875b 100644
--- a/source/Core/ValueObject.cpp
+++ b/source/Core/ValueObject.cpp
@@ -44,12 +44,16 @@
     m_data (),
     m_value (),
     m_error (),
-    m_flags (),
-    m_value_str(),
-    m_location_str(),
-    m_summary_str(),
-    m_children(),
-    m_synthetic_children()
+    m_value_str (),
+    m_old_value_str (),
+    m_location_str (),
+    m_summary_str (),
+    m_children (),
+    m_synthetic_children (),
+    m_value_is_valid (false),
+    m_value_did_change (false),
+    m_children_count_valid (false),
+    m_old_value_valid (false)
 {
 }
 
@@ -77,10 +81,19 @@
             const user_id_t stop_id = process->GetStopID();
             if (m_update_id != stop_id)
             {
+                bool first_update = m_update_id == 0;
                 // Save the old value using swap to avoid a string copy which
                 // also will clear our m_value_str
-                std::string old_value_str;
-                old_value_str.swap (m_value_str);
+                if (m_value_str.empty())
+                {
+                    m_old_value_valid = false;
+                }
+                else
+                {
+                    m_old_value_valid = true;
+                    m_old_value_str.swap (m_value_str);
+                    m_value_str.clear();
+                }
                 m_location_str.clear();
                 m_summary_str.clear();
 
@@ -97,22 +110,14 @@
                 m_update_id = stop_id;
                 bool success = m_error.Success();
                 SetValueIsValid (success);
-                // If the variable hasn't already been marked as changed do it
-                // by comparing the old any new value
-                if (!GetValueDidChange())
+                
+                if (first_update)
+                    SetValueDidChange (false);
+                else if (!m_value_did_change && success == false)
                 {
-                    if (success)
-                    {
-                        // The value was gotten successfully, so we consider the
-                        // value as changed if the value string differs
-                        SetValueDidChange (old_value_str != m_value_str);
-                    }
-                    else
-                    {
-                        // The value wasn't gotten successfully, so we mark this
-                        // as changed if the value used to be valid and now isn't
-                        SetValueDidChange (value_was_valid);
-                    }
+                    // The value wasn't gotten successfully, so we mark this
+                    // as changed if the value used to be valid and now isn't
+                    SetValueDidChange (value_was_valid);
                 }
             }
         }
@@ -202,31 +207,29 @@
 }
 
 bool
-ValueObject::GetValueIsValid ()
+ValueObject::GetValueIsValid () const
 {
-    return m_flags.IsSet(eValueIsValid);
+    return m_value_is_valid;
 }
 
 
 void
 ValueObject::SetValueIsValid (bool b)
 {
-    if (b)
-        m_flags.Set(eValueIsValid);
-    else
-        m_flags.Clear(eValueIsValid);
+    m_value_is_valid = b;
 }
 
 bool
-ValueObject::GetValueDidChange () const
+ValueObject::GetValueDidChange (ExecutionContextScope *exe_scope)
 {
-    return m_flags.IsSet(eValueChanged);
+    GetValueAsCString (exe_scope);
+    return m_value_did_change;
 }
 
 void
 ValueObject::SetValueDidChange (bool value_changed)
 {
-    m_flags.Set(eValueChanged);
+    m_value_did_change = value_changed;
 }
 
 ValueObjectSP
@@ -301,7 +304,7 @@
 uint32_t
 ValueObject::GetNumChildren ()
 {
-    if (m_flags.IsClear(eNumChildrenHasBeenSet))
+    if (!m_children_count_valid)
     {
         SetNumChildren (CalculateNumChildren());
     }
@@ -310,7 +313,7 @@
 void
 ValueObject::SetNumChildren (uint32_t num_children)
 {
-    m_flags.Set(eNumChildrenHasBeenSet);
+    m_children_count_valid = true;
     m_children.resize(num_children);
 }
 
@@ -552,6 +555,13 @@
                     break;
                 }
             }
+            
+            if (!m_value_did_change && m_old_value_valid)
+            {
+                // The value was gotten successfully, so we consider the
+                // value as changed if the value string differs
+                SetValueDidChange (m_old_value_str != m_value_str);
+            }
         }
     }
     if (m_value_str.empty())
diff --git a/source/Core/ValueObjectList.cpp b/source/Core/ValueObjectList.cpp
index 5feeae7..8913d4d 100644
--- a/source/Core/ValueObjectList.cpp
+++ b/source/Core/ValueObjectList.cpp
@@ -57,6 +57,12 @@
     return m_value_objects.size();
 }
 
+void
+ValueObjectList::Resize (uint32_t size)
+{
+    m_value_objects.resize (size);
+}
+
 lldb::ValueObjectSP
 ValueObjectList::GetValueObjectAtIndex (uint32_t idx)
 {
@@ -66,6 +72,14 @@
     return valobj_sp;
 }
 
+void
+ValueObjectList::SetValueObjectAtIndex (uint32_t idx, const ValueObjectSP &valobj_sp)
+{
+    if (idx >= m_value_objects.size())
+        m_value_objects.resize (idx + 1);
+    m_value_objects[idx] = valobj_sp;
+}
+
 ValueObjectSP
 ValueObjectList::FindValueObjectByValueName (const char *name)
 {
@@ -74,7 +88,8 @@
     collection::iterator pos, end = m_value_objects.end();
     for (pos = m_value_objects.begin(); pos != end; ++pos)
     {
-        if ((*pos)->GetName() == name_const_str)
+        ValueObject *valobj = (*pos).get();
+        if (valobj && valobj->GetName() == name_const_str)
         {
             val_obj_sp = *pos;
             break;
@@ -91,7 +106,10 @@
 
     for (pos = m_value_objects.begin(); pos != end; ++pos)
     {
-        if ((*pos)->GetID() == uid)
+        // Watch out for NULL objects in our list as the list
+        // might get resized to a specific size and lazily filled in
+        ValueObject *valobj = (*pos).get();
+        if (valobj && valobj->GetID() == uid)
         {
             valobj_sp = *pos;
             break;
@@ -102,14 +120,15 @@
 
 
 ValueObjectSP
-ValueObjectList::FindValueObjectByPointer (ValueObject *valobj)
+ValueObjectList::FindValueObjectByPointer (ValueObject *find_valobj)
 {
     ValueObjectSP valobj_sp;
     collection::iterator pos, end = m_value_objects.end();
 
     for (pos = m_value_objects.begin(); pos != end; ++pos)
     {
-        if ((*pos).get() == valobj)
+        ValueObject *valobj = (*pos).get();
+        if (valobj && valobj == find_valobj)
         {
             valobj_sp = *pos;
             break;
diff --git a/source/Core/ValueObjectVariable.cpp b/source/Core/ValueObjectVariable.cpp
index c15bbef..cbd583f 100644
--- a/source/Core/ValueObjectVariable.cpp
+++ b/source/Core/ValueObjectVariable.cpp
@@ -32,7 +32,7 @@
 
 using namespace lldb_private;
 
-ValueObjectVariable::ValueObjectVariable (lldb::VariableSP &var_sp) :
+ValueObjectVariable::ValueObjectVariable (const lldb::VariableSP &var_sp) :
     ValueObject(),
     m_variable_sp(var_sp)
 {
diff --git a/source/Symbol/VariableList.cpp b/source/Symbol/VariableList.cpp
index 7f864f2..5ee5299 100644
--- a/source/Symbol/VariableList.cpp
+++ b/source/Symbol/VariableList.cpp
@@ -32,7 +32,7 @@
 
 
 void
-VariableList::AddVariable(VariableSP &variable_sp)
+VariableList::AddVariable(const VariableSP &variable_sp)
 {
     m_variables.push_back(variable_sp);
 }
@@ -82,6 +82,20 @@
     return var_sp;
 }
 
+uint32_t
+VariableList::FindIndexForVariable (Variable* variable)
+{
+    VariableSP var_sp;
+    iterator pos;
+    const iterator begin = m_variables.begin();
+    const iterator end = m_variables.end();
+    for (pos = m_variables.begin(); pos != end; ++pos)
+    {
+        if ((*pos).get() == variable)
+            return std::distance (begin, pos);
+    }
+    return UINT32_MAX;
+}
 
 size_t
 VariableList::MemorySize() const
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index 4aef251..f812285 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -16,7 +16,9 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Core/Disassembler.h"
 #include "lldb/Core/Value.h"
+#include "lldb/Core/ValueObjectVariable.h"
 #include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/RegisterContext.h"
@@ -55,7 +57,7 @@
     m_frame_base (),
     m_frame_base_error (),
     m_variable_list_sp (),
-    m_value_object_list ()
+    m_variable_list_value_objects ()
 {
     if (sc_ptr != NULL)
     {
@@ -85,7 +87,7 @@
     m_frame_base (),
     m_frame_base_error (),
     m_variable_list_sp (),
-    m_value_object_list ()
+    m_variable_list_value_objects ()
 {
     if (sc_ptr != NULL)
     {
@@ -121,7 +123,7 @@
     m_frame_base (),
     m_frame_base_error (),
     m_variable_list_sp (),
-    m_value_object_list ()
+    m_variable_list_value_objects ()
 {
     if (sc_ptr != NULL)
     {
@@ -450,18 +452,31 @@
 
 
 VariableList *
-StackFrame::GetVariableList ()
+StackFrame::GetVariableList (bool get_file_globals)
 {
     if (m_flags.IsClear(RESOLVED_VARIABLES))
     {
         m_flags.Set(RESOLVED_VARIABLES);
 
-        if (GetSymbolContext (eSymbolContextFunction).function)
+        GetSymbolContext (eSymbolContextCompUnit | 
+                          eSymbolContextFunction | 
+                          eSymbolContextBlock);
+
+        if (m_sc.block)
         {
             bool get_child_variables = true;
             bool can_create = true;
             m_variable_list_sp = m_sc.function->GetBlock (can_create).GetVariableList (get_child_variables, can_create);
         }
+        
+        if (get_file_globals && m_sc.comp_unit)
+        {
+            VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true));
+            if (m_variable_list_sp)
+                m_variable_list_sp->AddVariables (global_variable_list_sp.get());
+            else
+                m_variable_list_sp = global_variable_list_sp;
+        }
     }
     return m_variable_list_sp.get();
 }
@@ -521,10 +536,52 @@
     return m_sc.line_entry.IsValid();
 }
 
-ValueObjectList &
-StackFrame::GetValueObjectList()
+
+ValueObjectSP
+StackFrame::GetValueObjectForFrameVariable (const VariableSP &variable_sp)
 {
-    return m_value_object_list;
+    ValueObjectSP valobj_sp;
+    VariableList *var_list = GetVariableList (true);
+    if (var_list)
+    {
+        // Make sure the variable is a frame variable
+        const uint32_t var_idx = var_list->FindIndexForVariable (variable_sp.get());
+        const uint32_t num_variables = var_list->GetSize();
+        if (var_idx < num_variables)
+        {
+            valobj_sp = m_variable_list_value_objects.GetValueObjectAtIndex (var_idx);
+            if (valobj_sp.get() == NULL)
+            {
+                if (m_variable_list_value_objects.GetSize() < num_variables)
+                    m_variable_list_value_objects.Resize(num_variables);
+                valobj_sp.reset (new ValueObjectVariable (variable_sp));
+                m_variable_list_value_objects.SetValueObjectAtIndex (var_idx, valobj_sp);
+            }
+        }
+    }
+    return valobj_sp;
+}
+
+ValueObjectSP
+StackFrame::TrackGlobalVariable (const VariableSP &variable_sp)
+{
+    // Check to make sure we aren't already tracking this variable?
+    ValueObjectSP valobj_sp (GetValueObjectForFrameVariable (variable_sp));
+    if (!valobj_sp)
+    {
+        // We aren't already tracking this global
+        VariableList *var_list = GetVariableList (true);
+        // If this frame has no variables, create a new list
+        if (var_list == NULL)
+            m_variable_list_sp.reset (new VariableList());
+
+        // Add the global/static variable to this frame
+        m_variable_list_sp->AddVariable (variable_sp);
+
+        // Now make a value object for it so we can track its changes
+        valobj_sp = GetValueObjectForFrameVariable (variable_sp);
+    }
+    return valobj_sp;
 }
 
 bool
@@ -591,7 +648,7 @@
 {
     assert (GetStackID() == prev_frame.GetStackID());    // TODO: remove this after some testing
     m_variable_list_sp = prev_frame.m_variable_list_sp;
-    m_value_object_list.Swap (prev_frame.m_value_object_list);
+    m_variable_list_value_objects.Swap (prev_frame.m_variable_list_value_objects);
     if (!m_disassembly.GetString().empty())
         m_disassembly.GetString().swap (m_disassembly.GetString());
 }
@@ -610,7 +667,6 @@
     assert (m_sc.module_sp.get() == NULL || curr_frame.m_sc.module_sp.get() == NULL || m_sc.module_sp.get() == curr_frame.m_sc.module_sp.get());
     assert (m_sc.comp_unit == NULL || curr_frame.m_sc.comp_unit == NULL || m_sc.comp_unit == curr_frame.m_sc.comp_unit);
     assert (m_sc.function == NULL || curr_frame.m_sc.function == NULL || m_sc.function == curr_frame.m_sc.function);
-    assert (m_sc.symbol == NULL || curr_frame.m_sc.symbol == NULL || m_sc.symbol == curr_frame.m_sc.symbol);
     m_sc = curr_frame.m_sc;
     m_flags.Clear(GOT_FRAME_BASE | eSymbolContextEverything);
     m_flags.Set (m_sc.GetResolvedMask());