Restore the ability of SBFrame::FindValue() to look for file global variables

This should clean up the new test failures caused by r201614

llvm-svn: 201710
This commit is contained in:
Enrico Granata 2014-02-19 19:35:13 +00:00
parent e3f902c32a
commit 8a2a0dfba5
3 changed files with 24 additions and 3 deletions

View File

@ -55,7 +55,10 @@ public:
uint32_t
FindVariableIndex (const lldb::VariableSP &var_sp);
size_t
AppendVariablesIfUnique(VariableList &var_list);
// Returns the actual number of unique variables that were added to the
// list. "total_matches" will get updated with the actualy number of
// matches that were found regardless of whether they were unique or not

View File

@ -845,6 +845,8 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy
frame = exe_ctx.GetFramePtr();
if (frame)
{
VariableList variable_list;
switch (value_type)
{
case eValueTypeVariableGlobal: // global variable
@ -852,8 +854,7 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy
case eValueTypeVariableArgument: // function argument variables
case eValueTypeVariableLocal: // function local variables
{
VariableList variable_list;
SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock));
const bool can_create = true;
@ -865,6 +866,13 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy
stop_if_block_is_inlined_function,
&variable_list))
{
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)

View File

@ -131,6 +131,16 @@ VariableList::FindVariable (const ConstString& name, lldb::ValueType value_type)
return var_sp;
}
size_t
VariableList::AppendVariablesIfUnique(VariableList &var_list)
{
const size_t initial_size = var_list.GetSize();
iterator pos, end = m_variables.end();
for (pos = m_variables.begin(); pos != end; ++pos)
var_list.AddVariableIfUnique(*pos);
return var_list.GetSize() - initial_size;
}
size_t
VariableList::AppendVariablesIfUnique (const RegularExpression& regex, VariableList &var_list, size_t& total_matches)
{