[Lldb-commits] [lldb] r136745 - in /lldb/trunk: include/lldb/Target/StackFrame.h source/Target/StackFrame.cpp

Greg Clayton gclayton at apple.com
Tue Aug 2 16:35:43 PDT 2011


Author: gclayton
Date: Tue Aug  2 18:35:43 2011
New Revision: 136745

URL: http://llvm.org/viewvc/llvm-project?rev=136745&view=rev
Log:
Fixed an issue where StackFrame::GetValueForVariableExpressionPath(...)
was previously using the entire frame variable list instead of using the
in scope variable list. I added a new function to a stack frame:

	lldb::VariableListSP
	StackFrame::GetInScopeVariableList (bool get_file_globals);

This gets only variables that are in scope and they will be ordered such
that the variables from the current scope are first.


Modified:
    lldb/trunk/include/lldb/Target/StackFrame.h
    lldb/trunk/source/Target/StackFrame.cpp

Modified: lldb/trunk/include/lldb/Target/StackFrame.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=136745&r1=136744&r2=136745&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/StackFrame.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrame.h Tue Aug  2 18:35:43 2011
@@ -101,6 +101,9 @@
     VariableList *
     GetVariableList (bool get_file_globals);
 
+    lldb::VariableListSP
+    GetInScopeVariableList (bool get_file_globals);
+
     // See ExpressionPathOption enumeration for "options" values
     lldb::ValueObjectSP
     GetValueForVariableExpressionPath (const char *var_expr, 

Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=136745&r1=136744&r2=136745&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Tue Aug  2 18:35:43 2011
@@ -485,6 +485,34 @@
     return m_variable_list_sp.get();
 }
 
+VariableListSP
+StackFrame::GetInScopeVariableList (bool get_file_globals)
+{
+    VariableListSP var_list_sp(new VariableList);
+    GetSymbolContext (eSymbolContextCompUnit | eSymbolContextBlock);
+
+    if (m_sc.block)
+    {
+        const bool can_create = true;
+        const bool get_parent_variables = true;
+        const bool stop_if_block_is_inlined_function = true;
+        m_sc.block->AppendVariables (can_create, 
+                                     get_parent_variables,
+                                     stop_if_block_is_inlined_function,
+                                     var_list_sp.get());
+    }
+                     
+    if (m_sc.comp_unit)
+    {
+        VariableListSP global_variable_list_sp (m_sc.comp_unit->GetVariableList(true));
+        if (global_variable_list_sp)
+            var_list_sp->AddVariables (global_variable_list_sp.get());
+    }
+    
+    return var_list_sp;
+}
+
+
 ValueObjectSP
 StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, 
                                                lldb::DynamicValueType use_dynamic,
@@ -502,7 +530,10 @@
         bool address_of = false;
         ValueObjectSP valobj_sp;
         const bool get_file_globals = true;
-        VariableList *variable_list = GetVariableList (get_file_globals);
+        // When looking up a variable for an expression, we need only consider the
+        // variables that are in scope.
+        VariableListSP var_list_sp (GetInScopeVariableList (get_file_globals));
+        VariableList *variable_list = var_list_sp.get();
         
         if (variable_list)
         {





More information about the lldb-commits mailing list