<rdar://problem/13621080>

This commit changes the ${function.name-with-args} prompt keyword to also tackle structs
Previously, since aggregates have no values, this would show up as foo=(null)
This checkin changes that to instead print foo=(Foo at 0x123) (i.e. typename at address)
There are other potential choices here (summary, one-liner printout of all members, ...) and I would love to hear feedback about better options, if any

llvm-svn: 181462
This commit is contained in:
Enrico Granata 2013-05-08 20:27:37 +00:00
parent e1432cfe4c
commit cc7f9bf51e
3 changed files with 33 additions and 11 deletions

View File

@ -62,6 +62,11 @@ public:
AppendVariablesIfUnique (const RegularExpression& regex,
VariableList &var_list,
size_t& total_matches);
size_t
AppendVariablesWithScope (lldb::ValueType type,
VariableList &var_list,
bool if_unique = true);
uint32_t
FindIndexForVariable (Variable* variable);

View File

@ -2251,16 +2251,7 @@ Debugger::FormatPrompt
VariableList args;
if (variable_list_sp)
{
const size_t num_variables = variable_list_sp->GetSize();
for (size_t var_idx = 0; var_idx < num_variables; ++var_idx)
{
VariableSP var_sp (variable_list_sp->GetVariableAtIndex(var_idx));
if (var_sp->GetScope() == eValueTypeVariableArgument)
args.AddVariable (var_sp);
}
}
variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, args);
if (args.GetSize() > 0)
{
const char *open_paren = strchr (cstr, '(');
@ -2294,7 +2285,12 @@ Debugger::FormatPrompt
if (arg_idx > 0)
s.PutCString (", ");
if (var_value_sp->GetError().Success())
s.Printf ("%s=%s", var_name, var_value);
{
if (var_value)
s.Printf ("%s=%s", var_name, var_value);
else
s.Printf ("%s=%s at %s", var_name, var_value_sp->GetTypeName().GetCString(), var_value_sp->GetLocationAsCString());
}
else
s.Printf ("%s=<unavailable>", var_name);
}

View File

@ -134,6 +134,27 @@ VariableList::AppendVariablesIfUnique (const RegularExpression& regex, VariableL
return var_list.GetSize() - initial_size;
}
size_t
VariableList::AppendVariablesWithScope (lldb::ValueType type,
VariableList &var_list,
bool if_unique)
{
const size_t initial_size = var_list.GetSize();
iterator pos, end = m_variables.end();
for (pos = m_variables.begin(); pos != end; ++pos)
{
if ((*pos)->GetScope() == type)
{
if (if_unique)
var_list.AddVariableIfUnique (*pos);
else
var_list.AddVariable(*pos);
}
}
// Return the number of new unique variables added to "var_list"
return var_list.GetSize() - initial_size;
}
uint32_t
VariableList::FindIndexForVariable (Variable* variable)
{