named summaries:
- a new --name option for "type summary add" lets you give a name to a summary
- a new --summary option for "frame variable" lets you bind a named summary to one or more variables
${var%s} now works for printing the value of 0-terminated CStrings
type format test case now tests for cascading
- this is disabled on GCC because GCC may end up stripping typedef chains, basically breaking cascading
new design for the FormatNavigator class
new template class CleanUp2 meant to support cleanup routines with 1 additional parameter beyond resource handle
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@134943 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp
index f82c06b..9d8f429 100644
--- a/source/Commands/CommandObjectFrame.cpp
+++ b/source/Commands/CommandObjectFrame.cpp
@@ -439,6 +439,10 @@
const char *name_cstr = NULL;
size_t idx;
+
+ SummaryFormatSP summary_format_sp;
+ if (!m_option_variable.summary.empty())
+ Debugger::NamedSummaryFormats::Get(ConstString(m_option_variable.summary.c_str()), summary_format_sp);
if (variable_list)
{
@@ -484,7 +488,8 @@
if (var_sp->DumpDeclaration(&s, show_fullpaths, show_module))
s.PutCString (": ");
}
-
+ if (summary_format_sp)
+ valobj_sp->SetCustomSummaryFormat(summary_format_sp);
ValueObject::DumpValueObject (result.GetOutputStream(),
valobj_sp.get(),
var_sp->GetName().AsCString(),
@@ -534,6 +539,8 @@
var_sp->GetDeclaration ().DumpStopContext (&s, false);
s.PutCString (": ");
}
+ if (summary_format_sp)
+ valobj_sp->SetCustomSummaryFormat(summary_format_sp);
ValueObject::DumpValueObject (result.GetOutputStream(),
valobj_sp.get(),
valobj_sp->GetParent() ? name_cstr : NULL,
@@ -622,6 +629,8 @@
var_sp->GetDeclaration ().DumpStopContext (&s, false);
s.PutCString (": ");
}
+ if (summary_format_sp)
+ valobj_sp->SetCustomSummaryFormat(summary_format_sp);
ValueObject::DumpValueObject (result.GetOutputStream(),
valobj_sp.get(),
name_cstr,
diff --git a/source/Commands/CommandObjectType.cpp b/source/Commands/CommandObjectType.cpp
index 2e0aa5c..c0ffddb 100644
--- a/source/Commands/CommandObjectType.cpp
+++ b/source/Commands/CommandObjectType.cpp
@@ -468,6 +468,9 @@
case 'x':
m_regex = true;
break;
+ case 'n':
+ m_name = new ConstString(option_arg);
+ break;
default:
error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
break;
@@ -486,6 +489,7 @@
m_skip_references = false;
m_skip_pointers = false;
m_regex = false;
+ m_name = NULL;
}
const OptionDefinition*
@@ -508,6 +512,7 @@
bool m_skip_pointers;
bool m_regex;
std::string m_format_string;
+ ConstString* m_name;
};
CommandOptions m_options;
@@ -601,7 +606,7 @@
{
const size_t argc = command.GetArgumentCount();
- if (argc < 1)
+ if (argc < 1 && !m_options.m_name)
{
result.AppendErrorWithFormat ("%s takes one or more args.\n", m_cmd_name.c_str());
result.SetStatus(eReturnStatusFailed);
@@ -636,14 +641,14 @@
for(int i = 0; i < argc; i++) {
const char* typeA = command.GetArgumentAtIndex(i);
- if(!typeA || typeA[0] == '\0')
+ if (!typeA || typeA[0] == '\0')
{
result.AppendError("empty typenames not allowed");
result.SetStatus(eReturnStatusFailed);
return false;
}
ConstString typeCS(typeA);
- if(!m_options.m_regex)
+ if (!m_options.m_regex)
{
Debugger::SummaryFormats::Add(typeCS, entry);
}
@@ -660,6 +665,21 @@
Debugger::RegexSummaryFormats::Add(typeRX, entry);
}
}
+
+ if (m_options.m_name)
+ {
+ if( (bool)(*(m_options.m_name)) )
+ {
+ Debugger::NamedSummaryFormats::Add(*(m_options.m_name), entry);
+ }
+ else
+ {
+ result.AppendError("added to types, but not given a name");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ }
+
result.SetStatus(eReturnStatusSuccessFinishNoResult);
return result.Succeeded();
}
@@ -676,7 +696,8 @@
{ LLDB_OPT_SET_ALL, false, "regex", 'x', no_argument, NULL, 0, eArgTypeBoolean, "Type names are actually regular expressions."},
{ LLDB_OPT_SET_1 , true, "inline-children", 'c', no_argument, NULL, 0, eArgTypeBoolean, "If true, inline all child values into summary string."},
{ LLDB_OPT_SET_2 , true, "format-string", 'f', required_argument, NULL, 0, eArgTypeSummaryString, "Format string used to display text and object contents."},
- { LLDB_OPT_SET_2, false, "expand", 'e', no_argument, NULL, 0, eArgTypeBoolean, "Expand aggregate data types to show children on separate lines."},
+ { LLDB_OPT_SET_2, false, "expand", 'e', no_argument, NULL, 0, eArgTypeBoolean, "Expand aggregate data types to show children on separate lines."},
+ { LLDB_OPT_SET_2, false, "name", 'n', required_argument, NULL, 0, eArgTypeName, "A name for this summary string."},
{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
};
@@ -734,7 +755,9 @@
bool delete_summary = Debugger::SummaryFormats::Delete(typeCS);
bool delete_regex = Debugger::RegexSummaryFormats::Delete(typeCS);
- if (delete_summary || delete_regex)
+ bool delete_named = Debugger::NamedSummaryFormats::Delete(typeCS);
+
+ if (delete_summary || delete_regex || delete_named)
{
result.SetStatus(eReturnStatusSuccessFinishNoResult);
return result.Succeeded();
@@ -774,6 +797,7 @@
{
Debugger::SummaryFormats::Clear();
Debugger::RegexSummaryFormats::Clear();
+ Debugger::NamedSummaryFormats::Clear();
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
@@ -847,22 +871,33 @@
Debugger::SummaryFormats::LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param);
delete param;
- if(Debugger::RegexSummaryFormats::GetCount() == 0)
+ if(Debugger::RegexSummaryFormats::GetCount() > 0)
{
- result.SetStatus(eReturnStatusSuccessFinishResult);
- return result.Succeeded();
+ result.GetOutputStream().Printf("Regex-based summaries (slower):\n");
+ if (argc == 1) {
+ RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
+ regex->Compile(command.GetArgumentAtIndex(0));
+ rxparam = new CommandObjectTypeRXSummaryList_LoopCallbackParam(this,&result,regex);
+ }
+ else
+ rxparam = new CommandObjectTypeRXSummaryList_LoopCallbackParam(this,&result);
+ Debugger::RegexSummaryFormats::LoopThrough(CommandObjectTypeRXSummaryList_LoopCallback, rxparam);
+ delete rxparam;
}
- result.GetOutputStream().Printf("Regex-based summaries (slower):\n");
- if (argc == 1) {
- RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
- regex->Compile(command.GetArgumentAtIndex(0));
- rxparam = new CommandObjectTypeRXSummaryList_LoopCallbackParam(this,&result,regex);
+ if(Debugger::NamedSummaryFormats::GetCount() > 0)
+ {
+ result.GetOutputStream().Printf("Named summaries:\n");
+ if (argc == 1) {
+ RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
+ regex->Compile(command.GetArgumentAtIndex(0));
+ param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result,regex);
+ }
+ else
+ param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result);
+ Debugger::NamedSummaryFormats::LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param);
+ delete param;
}
- else
- rxparam = new CommandObjectTypeRXSummaryList_LoopCallbackParam(this,&result);
- Debugger::RegexSummaryFormats::LoopThrough(CommandObjectTypeRXSummaryList_LoopCallback, rxparam);
- delete rxparam;
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();