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

llvm-svn: 232767
This commit is contained in:
Chaoren Lin 2015-03-19 22:00:13 +00:00
parent a7f8c46439
commit 0efb51a072
1 changed files with 18 additions and 20 deletions

View File

@ -870,32 +870,30 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy
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;