[Lldb-commits] [lldb] r232767 - Fix SBFrame::FindValue for when only global variables exist.

Chaoren Lin chaorenl at google.com
Thu Mar 19 15:00:13 PDT 2015


Author: chaoren
Date: Thu Mar 19 17:00:13 2015
New Revision: 232767

URL: http://llvm.org/viewvc/llvm-project?rev=232767&view=rev
Log:
Fix SBFrame::FindValue for when only global variables exist.

Summary:
sc.block->AppendVariables(...) returns 0 if there are no arguments or local
variables, but we still need to check for global variables.

Test Plan:
```
$ cat test.cpp
int i;
int main() {
}
$ lldb test -o 'b main' -o r
(lldb) script
>>> print lldb.frame.FindValue('i', lldb.eValueTypeVariableGlobal)
(int) i = 0 # as opposed to "No value"
```

Reviewers: jingham, ovyalov, vharron, clayborg

Reviewed By: clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D8464

Modified:
    lldb/trunk/source/API/SBFrame.cpp

Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=232767&r1=232766&r2=232767&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Thu Mar 19 17:00:13 2015
@@ -870,32 +870,30 @@ SBFrame::FindValue (const char *name, Va
                 case eValueTypeVariableArgument:    // function argument variables
                 case eValueTypeVariableLocal:       // function local variables
                     {
-                        SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock));
+                        SymbolContext sc(frame->GetSymbolContext(eSymbolContextBlock));
 
                         const bool can_create = true;
                         const bool get_parent_variables = true;
                         const bool stop_if_block_is_inlined_function = true;
 
-                        if (sc.block && sc.block->AppendVariables (can_create, 
-                                                                   get_parent_variables,
-                                                                   stop_if_block_is_inlined_function,
-                                                                   &variable_list))
+                        if (sc.block)
+                            sc.block->AppendVariables(can_create,
+                                                      get_parent_variables,
+                                                      stop_if_block_is_inlined_function,
+                                                      &variable_list);
+                        if (value_type == eValueTypeVariableGlobal)
                         {
-                            if (value_type == eValueTypeVariableGlobal)
-                            {
-                                const bool get_file_globals = true;
-                                VariableList* frame_vars = frame->GetVariableList(get_file_globals);
-                                if (frame_vars)
-                                    frame_vars->AppendVariablesIfUnique(variable_list);
-                            }
-                            ConstString const_name(name);
-                            VariableSP variable_sp(variable_list.FindVariable(const_name,value_type));
-                            if (variable_sp)
-                            {
-                                value_sp = frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues);
-                                sb_value.SetSP (value_sp, use_dynamic);
-                                break;
-                            }
+                            const bool get_file_globals = true;
+                            VariableList *frame_vars = frame->GetVariableList(get_file_globals);
+                            if (frame_vars)
+                                frame_vars->AppendVariablesIfUnique(variable_list);
+                        }
+                        ConstString const_name(name);
+                        VariableSP variable_sp(variable_list.FindVariable(const_name, value_type));
+                        if (variable_sp)
+                        {
+                            value_sp = frame->GetValueObjectForFrameVariable(variable_sp, eNoDynamicValues);
+                            sb_value.SetSP(value_sp, use_dynamic);
                         }
                     }
                     break;





More information about the lldb-commits mailing list