summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Commands/CommandObjectFrame.cpp2
-rw-r--r--lldb/source/Commands/CommandObjectType.cpp436
-rw-r--r--lldb/source/Commands/CommandObjectType.h11
-rw-r--r--lldb/source/Core/Debugger.cpp190
-rw-r--r--lldb/source/Core/FormatManager.cpp22
-rw-r--r--lldb/source/Core/ValueObject.cpp13
6 files changed, 445 insertions, 229 deletions
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index e99c1e09fd0..12670a1e9e5 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -442,7 +442,7 @@ public:
SummaryFormatSP summary_format_sp;
if (!m_option_variable.summary.empty())
- Debugger::NamedSummaryFormats::Get(ConstString(m_option_variable.summary.c_str()), summary_format_sp);
+ Debugger::Formatting::NamedSummaryFormats::Get(ConstString(m_option_variable.summary.c_str()), summary_format_sp);
if (variable_list)
{
diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp
index d408a603e85..8db88e759ed 100644
--- a/lldb/source/Commands/CommandObjectType.cpp
+++ b/lldb/source/Commands/CommandObjectType.cpp
@@ -196,7 +196,7 @@ public:
const char* typeA = command.GetArgumentAtIndex(i);
ConstString typeCS(typeA);
if (typeCS)
- Debugger::ValueFormats::Add(typeCS, entry);
+ Debugger::Formatting::ValueFormats::Add(typeCS, entry);
else
{
result.AppendError("empty typenames not allowed");
@@ -273,7 +273,7 @@ public:
}
- if (Debugger::ValueFormats::Delete(typeCS))
+ if (Debugger::Formatting::ValueFormats::Delete(typeCS))
{
result.SetStatus(eReturnStatusSuccessFinishNoResult);
return result.Succeeded();
@@ -311,7 +311,7 @@ public:
bool
Execute (Args& command, CommandReturnObject &result)
{
- Debugger::ValueFormats::Clear();
+ Debugger::Formatting::ValueFormats::Clear();
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
}
@@ -372,7 +372,7 @@ public:
}
else
param = new CommandObjectTypeFormatList_LoopCallbackParam(this,&result);
- Debugger::ValueFormats::LoopThrough(CommandObjectTypeFormatList_LoopCallback, param);
+ Debugger::Formatting::ValueFormats::LoopThrough(CommandObjectTypeFormatList_LoopCallback, param);
delete param;
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
@@ -549,7 +549,7 @@ public:
CommandObjectTypeSummaryAdd::AddSummary(ConstString(type_name),
script_format,
(options->m_regex ? CommandObjectTypeSummaryAdd::eRegexSummary : CommandObjectTypeSummaryAdd::eRegularSummary),
- options->m_is_system,
+ options->m_category,
&error);
if (error.Fail())
{
@@ -566,7 +566,7 @@ public:
CommandObjectTypeSummaryAdd::AddSummary(*(options->m_name),
script_format,
CommandObjectTypeSummaryAdd::eNamedSummary,
- options->m_is_system,
+ options->m_category,
&error);
if (error.Fail())
{
@@ -635,7 +635,7 @@ CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue (uint32_t option_idx
m_is_add_script = true;
break;
case 'w':
- m_is_system = true;
+ m_category = ConstString(option_arg).GetCString();
break;
default:
error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
@@ -660,6 +660,7 @@ CommandObjectTypeSummaryAdd::CommandOptions::OptionParsingStarting ()
m_python_function = "";
m_is_add_script = false;
m_is_system = false;
+ m_category = NULL;
}
void
@@ -786,7 +787,8 @@ CommandObjectTypeSummaryAdd::Execute_ScriptSummary (Args& command, CommandReturn
m_options.m_one_liner,
m_options.m_regex,
m_options.m_is_system,
- m_options.m_name);
+ m_options.m_name,
+ m_options.m_category);
for(int i = 0; i < argc; i++) {
const char* typeA = command.GetArgumentAtIndex(i);
@@ -815,7 +817,7 @@ CommandObjectTypeSummaryAdd::Execute_ScriptSummary (Args& command, CommandReturn
CommandObjectTypeSummaryAdd::AddSummary(ConstString(type_name),
script_format,
(m_options.m_regex ? eRegexSummary : eRegularSummary),
- m_options.m_is_system,
+ m_options.m_category,
&error);
if (error.Fail())
{
@@ -829,7 +831,7 @@ CommandObjectTypeSummaryAdd::Execute_ScriptSummary (Args& command, CommandReturn
{
if ( (bool)(*(m_options.m_name)) )
{
- AddSummary(*(m_options.m_name), script_format, eNamedSummary, m_options.m_is_system, &error);
+ AddSummary(*(m_options.m_name), script_format, eNamedSummary, m_options.m_category, &error);
if (error.Fail())
{
result.AppendError(error.AsCString());
@@ -903,7 +905,7 @@ CommandObjectTypeSummaryAdd::Execute_StringSummary (Args& command, CommandReturn
AddSummary(typeCS,
entry,
(m_options.m_regex ? eRegexSummary : eRegularSummary),
- m_options.m_is_system,
+ m_options.m_category,
&error);
if (error.Fail())
@@ -918,7 +920,7 @@ CommandObjectTypeSummaryAdd::Execute_StringSummary (Args& command, CommandReturn
{
if ( (bool)(*(m_options.m_name)) )
{
- AddSummary(*(m_options.m_name), entry, eNamedSummary, m_options.m_is_system, &error);
+ AddSummary(*(m_options.m_name), entry, eNamedSummary, m_options.m_category, &error);
if (error.Fail())
{
result.AppendError(error.AsCString());
@@ -1037,7 +1039,7 @@ bool
CommandObjectTypeSummaryAdd::AddSummary(const ConstString& type_name,
SummaryFormatSP entry,
SummaryFormatType type,
- bool is_system,
+ const char* category,
Error* error)
{
if (type == eRegexSummary)
@@ -1050,30 +1052,20 @@ CommandObjectTypeSummaryAdd::AddSummary(const ConstString& type_name,
return false;
}
- if (!is_system)
- {
- Debugger::RegexSummaryFormats::Delete(type_name);
- Debugger::RegexSummaryFormats::Add(typeRX, entry);
- }
- else
- {
- Debugger::SystemRegexSummaryFormats::Delete(type_name);
- Debugger::SystemRegexSummaryFormats::Add(typeRX, entry);
- }
+ Debugger::Formatting::SummaryFormats(category)->RegexSummary()->Delete(type_name.GetCString());
+ Debugger::Formatting::SummaryFormats(category)->RegexSummary()->Add(typeRX, entry);
+
return true;
}
else if (type == eNamedSummary)
{
// system named summaries do not exist (yet?)
- Debugger::NamedSummaryFormats::Add(type_name,entry);
+ Debugger::Formatting::NamedSummaryFormats::Add(type_name,entry);
return true;
}
else
{
- if (!is_system)
- Debugger::SummaryFormats::Add(type_name,entry);
- else
- Debugger::SystemSummaryFormats::Add(type_name,entry);
+ Debugger::Formatting::SummaryFormats(category)->Summary()->Add(type_name.GetCString(), entry);
return true;
}
}
@@ -1081,7 +1073,7 @@ CommandObjectTypeSummaryAdd::AddSummary(const ConstString& type_name,
OptionDefinition
CommandObjectTypeSummaryAdd::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "system", 'w', no_argument, NULL, 0, eArgTypeBoolean, "This is a system summary (makes it harder to delete it by accident)."},
+ { LLDB_OPT_SET_ALL, false, "category", 'w', required_argument, NULL, 0, eArgTypeName, "Add this to the given category instead of the default one."},
{ LLDB_OPT_SET_ALL, false, "cascade", 'C', required_argument, NULL, 0, eArgTypeBoolean, "If true, cascade to derived typedefs."},
{ LLDB_OPT_SET_ALL, false, "no-value", 'v', no_argument, NULL, 0, eArgTypeBoolean, "Don't show the value, just show the summary, for this type."},
{ LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', no_argument, NULL, 0, eArgTypeBoolean, "Don't use this format for pointers-to-type objects."},
@@ -1126,7 +1118,10 @@ private:
switch (short_option)
{
case 'a':
- m_delete_system = true;
+ m_delete_all = true;
+ break;
+ case 'w':
+ m_category = ConstString(option_arg).GetCString();
break;
default:
error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
@@ -1139,7 +1134,8 @@ private:
void
OptionParsingStarting ()
{
- m_delete_system = false;
+ m_delete_all = false;
+ m_category = NULL;
}
const OptionDefinition*
@@ -1154,7 +1150,9 @@ private:
// Instance variables to hold the values for command options.
- bool m_delete_system;
+ bool m_delete_all;
+ const char* m_category;
+
};
CommandOptions m_options;
@@ -1164,6 +1162,17 @@ private:
{
return &m_options;
}
+
+ static bool
+ PerCategoryCallback(void* param,
+ const char* cate_name,
+ const FormatCategory::SharedPointer& cate)
+ {
+ const char* name = (const char*)param;
+ cate->Summary()->Delete(name);
+ cate->RegexSummary()->Delete(name);
+ return true;
+ }
public:
CommandObjectTypeSummaryDelete (CommandInterpreter &interpreter) :
@@ -1210,13 +1219,17 @@ public:
return false;
}
- bool delete_summary = Debugger::SummaryFormats::Delete(typeCS);
- bool delete_regex = Debugger::RegexSummaryFormats::Delete(typeCS);
- bool delete_named = Debugger::NamedSummaryFormats::Delete(typeCS);
- bool delete_sys = m_options.m_delete_system ? Debugger::SystemSummaryFormats::Delete(typeCS) : false;
- bool delete_sys_regex = m_options.m_delete_system ? Debugger::SystemRegexSummaryFormats::Delete(typeCS) : false;
+ if (m_options.m_delete_all)
+ {
+ Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, (void*)typeCS.GetCString());
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return result.Succeeded();
+ }
- if (delete_summary || delete_regex || delete_named || delete_sys || delete_sys_regex)
+ bool delete_category = Debugger::Formatting::SummaryFormats(m_options.m_category)->Delete(typeCS.GetCString());
+ bool delete_named = Debugger::Formatting::NamedSummaryFormats::Delete(typeCS);
+
+ if (delete_category || delete_named)
{
result.SetStatus(eReturnStatusSuccessFinishNoResult);
return result.Succeeded();
@@ -1234,14 +1247,11 @@ public:
OptionDefinition
CommandObjectTypeSummaryDelete::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "all", 'a', no_argument, NULL, 0, eArgTypeBoolean, "Also delete system summaries (not recommended)."},
+ { LLDB_OPT_SET_1, false, "all", 'a', no_argument, NULL, 0, eArgTypeBoolean, "Delete from every category."},
+ { LLDB_OPT_SET_2, false, "category", 'w', required_argument, NULL, 0, eArgTypeName, "Delete from given category."},
{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
};
-//-------------------------------------------------------------------------
-// CommandObjectTypeSummaryClear
-//-------------------------------------------------------------------------
-
class CommandObjectTypeSummaryClear : public CommandObject
{
private:
@@ -1267,7 +1277,7 @@ private:
switch (short_option)
{
case 'a':
- m_delete_system = true;
+ m_delete_all = true;
break;
default:
error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
@@ -1280,7 +1290,7 @@ private:
void
OptionParsingStarting ()
{
- m_delete_system = false;
+ m_delete_all = false;
}
const OptionDefinition*
@@ -1295,7 +1305,8 @@ private:
// Instance variables to hold the values for command options.
- bool m_delete_system;
+ bool m_delete_all;
+ bool m_delete_named;
};
CommandOptions m_options;
@@ -1305,7 +1316,18 @@ private:
{
return &m_options;
}
-
+
+ static bool
+ PerCategoryCallback(void* param,
+ const char* cate_name,
+ const FormatCategory::SharedPointer& cate)
+ {
+ cate->Summary()->Clear();
+ cate->RegexSummary()->Clear();
+ return true;
+
+ }
+
public:
CommandObjectTypeSummaryClear (CommandInterpreter &interpreter) :
CommandObject (interpreter,
@@ -1322,15 +1344,19 @@ public:
bool
Execute (Args& command, CommandReturnObject &result)
{
- Debugger::SummaryFormats::Clear();
- Debugger::RegexSummaryFormats::Clear();
- Debugger::NamedSummaryFormats::Clear();
- if (m_options.m_delete_system)
+ if (m_options.m_delete_all)
+ Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, NULL);
+ else if (command.GetArgumentCount() > 0)
{
- Debugger::SystemSummaryFormats::Clear();
- Debugger::SystemRegexSummaryFormats::Clear();
+ const char* cat_name = command.GetArgumentAtIndex(0);
+ ConstString cat_nameCS(cat_name);
+ Debugger::Formatting::SummaryFormats(cat_nameCS.GetCString())->Clear();
}
+ else
+ Debugger::Formatting::SummaryFormats()->Clear();
+
+ Debugger::Formatting::NamedSummaryFormats::Clear();
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
@@ -1341,7 +1367,7 @@ public:
OptionDefinition
CommandObjectTypeSummaryClear::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "all", 'a', no_argument, NULL, 0, eArgTypeBoolean, "Also clear system summaries (not recommended)."},
+ { LLDB_OPT_SET_ALL, false, "all", 'a', no_argument, NULL, 0, eArgTypeBoolean, "Clear every category."},
{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
};
@@ -1362,14 +1388,6 @@ struct CommandObjectTypeSummaryList_LoopCallbackParam {
RegularExpression* X = NULL) : self(S), result(R), regex(X) {}
};
-struct CommandObjectTypeRXSummaryList_LoopCallbackParam {
- CommandObjectTypeSummaryList* self;
- CommandReturnObject* result;
- RegularExpression* regex;
- CommandObjectTypeRXSummaryList_LoopCallbackParam(CommandObjectTypeSummaryList* S, CommandReturnObject* R,
- RegularExpression* X = NULL) : self(S), result(R), regex(X) {}
-};
-
class CommandObjectTypeSummaryList : public CommandObject
{
public:
@@ -1400,7 +1418,6 @@ public:
const size_t argc = command.GetArgumentCount();
CommandObjectTypeSummaryList_LoopCallbackParam *param;
- CommandObjectTypeRXSummaryList_LoopCallbackParam *rxparam;
if (argc == 1) {
RegularExpression* regex = new RegularExpression(command.GetArgumentAtIndex(0));
@@ -1409,26 +1426,10 @@ public:
}
else
param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result);
- Debugger::SummaryFormats::LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param);
- Debugger::SystemSummaryFormats::LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param);
- delete param;
-
- if (Debugger::RegexSummaryFormats::GetCount() > 0 || Debugger::SystemRegexSummaryFormats::GetCount() > 0 )
- {
- 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);
- Debugger::SystemRegexSummaryFormats::LoopThrough(CommandObjectTypeRXSummaryList_LoopCallback, rxparam);
- delete rxparam;
- }
- if (Debugger::NamedSummaryFormats::GetCount() > 0)
+ Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback,param);
+
+ if (Debugger::Formatting::NamedSummaryFormats::GetCount() > 0)
{
result.GetOutputStream().Printf("Named summaries:\n");
if (argc == 1) {
@@ -1438,7 +1439,7 @@ public:
}
else
param = new CommandObjectTypeSummaryList_LoopCallbackParam(this,&result);
- Debugger::NamedSummaryFormats::LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param);
+ Debugger::Formatting::NamedSummaryFormats::LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param);
delete param;
}
@@ -1448,6 +1449,28 @@ public:
private:
+ static bool
+ PerCategoryCallback(void* param,
+ const char* cate_name,
+ const FormatCategory::SharedPointer& cate)
+ {
+
+ CommandReturnObject* result = ((CommandObjectTypeSummaryList_LoopCallbackParam*)param)->result;
+
+ result->GetOutputStream().Printf("-----------------------\nCategory: %s (%s)\n-----------------------\n",
+ cate_name,
+ (cate->IsEnabled() ? "enabled" : "disabled"));
+
+ cate->Summary()->LoopThrough(CommandObjectTypeSummaryList_LoopCallback, param);
+
+ if (cate->RegexSummary()->GetCount() > 0)
+ {
+ result->GetOutputStream().Printf("Regex-based summaries (slower):\n");
+ cate->RegexSummary()->LoopThrough(CommandObjectTypeRXSummaryList_LoopCallback, param);
+ }
+ return true;
+ }
+
bool
LoopCallback (const char* type,
const SummaryFormat::SharedPointer& entry,
@@ -1479,10 +1502,233 @@ CommandObjectTypeRXSummaryList_LoopCallback (
lldb::RegularExpressionSP regex,
const SummaryFormat::SharedPointer& entry)
{
- CommandObjectTypeRXSummaryList_LoopCallbackParam* param = (CommandObjectTypeRXSummaryList_LoopCallbackParam*)pt2self;
+ CommandObjectTypeSummaryList_LoopCallbackParam* param = (CommandObjectTypeSummaryList_LoopCallbackParam*)pt2self;
return param->self->LoopCallback(regex->GetText(), entry, param->regex, param->result);
}
+//-------------------------------------------------------------------------
+// CommandObjectTypeCategoryEnable
+//-------------------------------------------------------------------------
+
+class CommandObjectTypeCategoryEnable : public CommandObject
+{
+public:
+ CommandObjectTypeCategoryEnable (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "type category enable",
+ "Enable a category as a source of summaries.",
+ NULL)
+ {
+ CommandArgumentEntry type_arg;
+ CommandArgumentData type_style_arg;
+
+ type_style_arg.arg_type = eArgTypeName;
+ type_style_arg.arg_repetition = eArgRepeatPlain;
+
+ type_arg.push_back (type_style_arg);
+
+ m_arguments.push_back (type_arg);
+
+ }
+
+ ~CommandObjectTypeCategoryEnable ()
+ {
+ }
+
+ bool
+ Execute (Args& command, CommandReturnObject &result)
+ {
+ const size_t argc = command.GetArgumentCount();
+
+ if (argc != 1)
+ {
+ result.AppendErrorWithFormat ("%s takes 1 arg.\n", m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ const char* typeA = command.GetArgumentAtIndex(0);
+ ConstString typeCS(typeA);
+
+ if (!typeCS)
+ {
+ result.AppendError("empty category name not allowed");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ Debugger::Formatting::Categories::Enable(typeCS);
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return result.Succeeded();
+ }
+
+};
+
+//-------------------------------------------------------------------------
+// CommandObjectTypeCategoryDelete
+//-------------------------------------------------------------------------
+
+class CommandObjectTypeCategoryDelete : public CommandObject
+{
+public:
+ CommandObjectTypeCategoryDelete (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "type category delete",
+ "Delete a category and all associated summaries.",
+ NULL)
+ {
+ CommandArgumentEntry type_arg;
+ CommandArgumentData type_style_arg;
+
+ type_style_arg.arg_type = eArgTypeName;
+ type_style_arg.arg_repetition = eArgRepeatPlain;
+
+ type_arg.push_back (type_style_arg);
+
+ m_arguments.push_back (type_arg);
+
+ }
+
+ ~CommandObjectTypeCategoryDelete ()
+ {
+ }
+
+ bool
+ Execute (Args& command, CommandReturnObject &result)
+ {
+ const size_t argc = command.GetArgumentCount();
+
+ if (argc != 1)
+ {
+ result.AppendErrorWithFormat ("%s takes 1 arg.\n", m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ const char* typeA = command.GetArgumentAtIndex(0);
+ ConstString typeCS(typeA);
+
+ if (!typeCS)
+ {
+ result.AppendError("empty category name not allowed");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ if (Debugger::Formatting::Categories::Delete(typeCS))
+ {
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return result.Succeeded();
+ }
+ else
+ {
+ result.AppendErrorWithFormat ("cannot delete category %s.\n", typeA);
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+ }
+
+};
+
+//-------------------------------------------------------------------------
+// CommandObjectTypeCategoryDisable
+//-------------------------------------------------------------------------
+
+class CommandObjectTypeCategoryDisable : public CommandObject
+{
+public:
+ CommandObjectTypeCategoryDisable (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "type category disable",
+ "Disable a category as a source of summaries.",
+ NULL)
+ {
+ CommandArgumentEntry type_arg;
+ CommandArgumentData type_style_arg;
+
+ type_style_arg.arg_type = eArgTypeName;
+ type_style_arg.arg_repetition = eArgRepeatPlain;
+
+ type_arg.push_back (type_style_arg);
+
+ m_arguments.push_back (type_arg);
+
+ }
+
+ ~CommandObjectTypeCategoryDisable ()
+ {
+ }
+
+ bool
+ Execute (Args& command, CommandReturnObject &result)
+ {
+ const size_t argc = command.GetArgumentCount();
+
+ if (argc != 1)
+ {
+ result.AppendErrorWithFormat ("%s takes 1 arg.\n", m_cmd_name.c_str());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ const char* typeA = command.GetArgumentAtIndex(0);
+ ConstString typeCS(typeA);
+
+ if (!typeCS)
+ {
+ result.AppendError("empty category name not allowed");
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ Debugger::Formatting::Categories::Disable(typeCS);
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return result.Succeeded();
+ }
+
+};
+
+//-------------------------------------------------------------------------
+// CommandObjectTypeCategoryList
+//-------------------------------------------------------------------------
+
+class CommandObjectTypeCategoryList : public CommandObject
+{
+private:
+ static bool
+ PerCategoryCallback(void* param,
+ const char* cate_name,
+ const FormatCategory::SharedPointer& cate)
+ {
+ CommandReturnObject* result = (CommandReturnObject*)param;
+ result->GetOutputStream().Printf("Category %s is%s enabled\n",
+ cate_name,
+ (cate->IsEnabled() ? "" : " not"));
+ return true;
+ }
+public:
+ CommandObjectTypeCategoryList (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "type category list",
+ "Provide a list of all existing categories.",
+ NULL)
+ {
+ }
+
+ ~CommandObjectTypeCategoryList ()
+ {
+ }
+
+ bool
+ Execute (Args& command, CommandReturnObject &result)
+ {
+ Debugger::Formatting::Categories::LoopThrough(PerCategoryCallback, (void*)&result);
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return result.Succeeded();
+ }
+
+};
+
class CommandObjectTypeFormat : public CommandObjectMultiword
{
public:
@@ -1504,6 +1750,27 @@ public:
}
};
+class CommandObjectTypeCategory : public CommandObjectMultiword
+{
+public:
+ CommandObjectTypeCategory (CommandInterpreter &interpreter) :
+ CommandObjectMultiword (interpreter,
+ "type category",
+ "A set of commands for operating on categories",
+ "type category [<sub-command-options>] ")
+ {
+ LoadSubCommand ("enable", CommandObjectSP (new CommandObjectTypeCategoryEnable (interpreter)));
+ LoadSubCommand ("disable", CommandObjectSP (new CommandObjectTypeCategoryDisable (interpreter)));
+ LoadSubCommand ("delete", CommandObjectSP (new CommandObjectTypeCategoryDelete (interpreter)));
+ LoadSubCommand ("list", CommandObjectSP (new CommandObjectTypeCategoryList (interpreter)));
+ }
+
+
+ ~CommandObjectTypeCategory ()
+ {
+ }
+};
+
class CommandObjectTypeSummary : public CommandObjectMultiword
{
public:
@@ -1535,6 +1802,7 @@ CommandObjectType::CommandObjectType (CommandInterpreter &interpreter) :
"A set of commands for operating on the type system",
"type [<sub-command-options>]")
{
+ LoadSubCommand ("category", CommandObjectSP (new CommandObjectTypeCategory (interpreter)));
LoadSubCommand ("format", CommandObjectSP (new CommandObjectTypeFormat (interpreter)));
LoadSubCommand ("summary", CommandObjectSP (new CommandObjectTypeSummary (interpreter)));
}
diff --git a/lldb/source/Commands/CommandObjectType.h b/lldb/source/Commands/CommandObjectType.h
index 0c453785e41..d9242879bea 100644
--- a/lldb/source/Commands/CommandObjectType.h
+++ b/lldb/source/Commands/CommandObjectType.h
@@ -43,6 +43,8 @@ public:
ConstString* m_name;
+ const char* m_category;
+
ScriptAddOptions(bool sptr,
bool sref,
bool casc,
@@ -51,7 +53,8 @@ public:
bool onel,
bool regx,
bool syst,
- ConstString* name) :
+ ConstString* name,
+ const char* catg) :
m_skip_pointers(sptr),
m_skip_references(sref),
m_cascade(casc),
@@ -62,7 +65,8 @@ public:
m_one_liner(onel),
m_regex(regx),
m_is_system(syst),
- m_name(name)
+ m_name(name),
+ m_category(catg)
{
}
@@ -127,6 +131,7 @@ private:
std::string m_python_function;
bool m_is_add_script;
bool m_is_system;
+ const char* m_category;
};
CommandOptions m_options;
@@ -169,7 +174,7 @@ public:
AddSummary(const ConstString& type_name,
lldb::SummaryFormatSP entry,
SummaryFormatType type,
- bool is_system,
+ const char* category,
Error* error = NULL);
};
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index cde5da77d05..1c62a8cb46f 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -1714,253 +1714,175 @@ GetFormatManager() {
}
bool
-Debugger::ValueFormats::Get(ValueObject& vobj, ValueFormat::SharedPointer &entry)
+Debugger::Formatting::ValueFormats::Get(ValueObject& vobj, ValueFormat::SharedPointer &entry)
{
return GetFormatManager().Value().Get(vobj,entry);
}
void
-Debugger::ValueFormats::Add(const ConstString &type, const ValueFormat::SharedPointer &entry)
+Debugger::Formatting::ValueFormats::Add(const ConstString &type, const ValueFormat::SharedPointer &entry)
{
GetFormatManager().Value().Add(type.AsCString(),entry);
}
bool
-Debugger::ValueFormats::Delete(const ConstString &type)
+Debugger::Formatting::ValueFormats::Delete(const ConstString &type)
{
return GetFormatManager().Value().Delete(type.AsCString());
}
void
-Debugger::ValueFormats::Clear()
+Debugger::Formatting::ValueFormats::Clear()
{
GetFormatManager().Value().Clear();
}
void
-Debugger::ValueFormats::LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton)
+Debugger::Formatting::ValueFormats::LoopThrough(ValueFormat::ValueCallback callback, void* callback_baton)
{
GetFormatManager().Value().LoopThrough(callback, callback_baton);
}
uint32_t
-Debugger::ValueFormats::GetCurrentRevision()
+Debugger::Formatting::ValueFormats::GetCurrentRevision()
{
return GetFormatManager().GetCurrentRevision();
}
uint32_t
-Debugger::ValueFormats::GetCount()
+Debugger::Formatting::ValueFormats::GetCount()
{
return GetFormatManager().Value().GetCount();
}
-bool
-Debugger::SummaryFormats::Get(ValueObject& vobj, SummaryFormat::SharedPointer &entry)
-{
- return GetFormatManager().Summary().Get(vobj,entry);
-}
-
-void
-Debugger::SummaryFormats::Add(const ConstString &type, const SummaryFormat::SharedPointer &entry)
-{
- GetFormatManager().Summary().Add(type.AsCString(),entry);
-}
-
-bool
-Debugger::SummaryFormats::Delete(const ConstString &type)
-{
- return GetFormatManager().Summary().Delete(type.AsCString());
-}
-
-void
-Debugger::SummaryFormats::Clear()
-{
- GetFormatManager().Summary().Clear();
-}
-
-void
-Debugger::SummaryFormats::LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton)
-{
- GetFormatManager().Summary().LoopThrough(callback, callback_baton);
-}
-
-uint32_t
-Debugger::SummaryFormats::GetCurrentRevision()
-{
- return GetFormatManager().GetCurrentRevision();
-}
-
-uint32_t
-Debugger::SummaryFormats::GetCount()
+lldb::FormatCategorySP
+Debugger::Formatting::SummaryFormats(const char* category_name)
{
- return GetFormatManager().Summary().GetCount();
+ return GetFormatManager().Category(category_name);
}
bool
-Debugger::SystemSummaryFormats::Get(ValueObject& vobj, SummaryFormat::SharedPointer &entry)
-{
- return GetFormatManager().SystemSummary().Get(vobj,entry);
-}
-
-void
-Debugger::SystemSummaryFormats::Add(const ConstString &type, const SummaryFormat::SharedPointer &entry)
-{
- GetFormatManager().SystemSummary().Add(type.AsCString(),entry);
-}
-
-bool
-Debugger::SystemSummaryFormats::Delete(const ConstString &type)
-{
- return GetFormatManager().SystemSummary().Delete(type.AsCString());
-}
-
-void
-Debugger::SystemSummaryFormats::Clear()
+Debugger::Formatting::GetSummaryFormat(ValueObject& vobj,
+ lldb::SummaryFormatSP& entry)
{
- GetFormatManager().SystemSummary().Clear();
-}
-
-void
-Debugger::SystemSummaryFormats::LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton)
-{
- GetFormatManager().SystemSummary().LoopThrough(callback, callback_baton);
-}
-
-uint32_t
-Debugger::SystemSummaryFormats::GetCurrentRevision()
-{
- return GetFormatManager().GetCurrentRevision();
-}
-
-uint32_t
-Debugger::SystemSummaryFormats::GetCount()
-{
- return GetFormatManager().SystemSummary().GetCount();
+ return GetFormatManager().Get(vobj, entry);
}
bool
-Debugger::RegexSummaryFormats::Get(ValueObject& vobj, SummaryFormat::SharedPointer &entry)
+Debugger::Formatting::Categories::Get(const ConstString &category, lldb::FormatCategorySP &entry)
{
- return GetFormatManager().RegexSummary().Get(vobj,entry);
+ entry = GetFormatManager().Category(category.GetCString());
+ return true;
}
void
-Debugger::RegexSummaryFormats::Add(const lldb::RegularExpressionSP &type, const SummaryFormat::SharedPointer &entry)
+Debugger::Formatting::Categories::Add(const ConstString &category)
{
- GetFormatManager().RegexSummary().Add(type,entry);
+ GetFormatManager().Category(category.GetCString());
}
bool
-Debugger::RegexSummaryFormats::Delete(const ConstString &type)
+Debugger::Formatting::Categories::Delete(const ConstString &category)
{
- return GetFormatManager().RegexSummary().Delete(type.AsCString());
+ GetFormatManager().DisableCategory(category.GetCString());
+ return GetFormatManager().Categories().Delete(category.GetCString());
}
void
-Debugger::RegexSummaryFormats::Clear()
+Debugger::Formatting::Categories::Clear()
{
- GetFormatManager().RegexSummary().Clear();
+ GetFormatManager().Categories().Clear();
}
void
-Debugger::RegexSummaryFormats::LoopThrough(SummaryFormat::RegexSummaryCallback callback, void* callback_baton)
-{
- GetFormatManager().RegexSummary().LoopThrough(callback, callback_baton);
-}
-
-uint32_t
-Debugger::RegexSummaryFormats::GetCurrentRevision()
-{
- return GetFormatManager().GetCurrentRevision();
-}
-
-uint32_t
-Debugger::RegexSummaryFormats::GetCount()
-{
- return GetFormatManager().RegexSummary().GetCount();
-}
-
-bool
-Debugger::SystemRegexSummaryFormats::Get(ValueObject& vobj, SummaryFormat::SharedPointer &entry)
+Debugger::Formatting::Categories::Clear(ConstString &category)
{
- return GetFormatManager().SystemRegexSummary().Get(vobj,entry);
+ GetFormatManager().Category(category.GetCString())->Clear();
}
void
-Debugger::SystemRegexSummaryFormats::Add(const lldb::RegularExpressionSP &type, const SummaryFormat::SharedPointer &entry)
+Debugger::Formatting::Categories::Enable(ConstString& category)
{
- GetFormatManager().SystemRegexSummary().Add(type,entry);
-}
-
-bool
-Debugger::SystemRegexSummaryFormats::Delete(const ConstString &type)
-{
- return GetFormatManager().SystemRegexSummary().Delete(type.AsCString());
+ if (GetFormatManager().Category(category.GetCString())->IsEnabled() == false)
+ {
+ //GetFormatManager().Category(category.GetCString())->Enable();
+ GetFormatManager().EnableCategory(category.GetCString());
+ }
+ else
+ {
+ //GetFormatManager().Category(category.GetCString())->Disable();
+ GetFormatManager().DisableCategory(category.GetCString());
+ //GetFormatManager().Category(category.GetCString())->Enable();
+ GetFormatManager().EnableCategory(category.GetCString());
+ }
}
void
-Debugger::SystemRegexSummaryFormats::Clear()
+Debugger::Formatting::Categories::Disable(ConstString& category)
{
- GetFormatManager().SystemRegexSummary().Clear();
+ if (GetFormatManager().Category(category.GetCString())->IsEnabled() == true)
+ {
+ //GetFormatManager().Category(category.GetCString())->Disable();
+ GetFormatManager().DisableCategory(category.GetCString());
+ }
}
void
-Debugger::SystemRegexSummaryFormats::LoopThrough(SummaryFormat::RegexSummaryCallback callback, void* callback_baton)
+Debugger::Formatting::Categories::LoopThrough(FormatManager::CategoryCallback callback, void* callback_baton)
{
- GetFormatManager().SystemRegexSummary().LoopThrough(callback, callback_baton);
+ GetFormatManager().LoopThroughCategories(callback, callback_baton);
}
uint32_t
-Debugger::SystemRegexSummaryFormats::GetCurrentRevision()
+Debugger::Formatting::Categories::GetCurrentRevision()
{
return GetFormatManager().GetCurrentRevision();
}
uint32_t
-Debugger::SystemRegexSummaryFormats::GetCount()
+Debugger::Formatting::Categories::GetCount()
{
- return GetFormatManager().SystemRegexSummary().GetCount();
+ return GetFormatManager().Categories().GetCount();
}
bool
-Debugger::NamedSummaryFormats::Get(const ConstString &type, SummaryFormat::SharedPointer &entry)
+Debugger::Formatting::NamedSummaryFormats::Get(const ConstString &type, SummaryFormat::SharedPointer &entry)
{
return GetFormatManager().NamedSummary().Get(type.AsCString(),entry);
}
void
-Debugger::NamedSummaryFormats::Add(const ConstString &type, const SummaryFormat::SharedPointer &entry)
+Debugger::Formatting::NamedSummaryFormats::Add(const ConstString &type, const SummaryFormat::SharedPointer &entry)
{
GetFormatManager().NamedSummary().Add(type.AsCString(),entry);
}
bool
-Debugger::NamedSummaryFormats::Delete(const ConstString &type)
+Debugger::Formatting::NamedSummaryFormats::Delete(const ConstString &type)
{
return GetFormatManager().NamedSummary().Delete(type.AsCString());
}
void
-Debugger::NamedSummaryFormats::Clear()
+Debugger::Formatting::NamedSummaryFormats::Clear()
{
GetFormatManager().NamedSummary().Clear();
}
void
-Debugger::NamedSummaryFormats::LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton)
+Debugger::Formatting::NamedSummaryFormats::LoopThrough(SummaryFormat::SummaryCallback callback, void* callback_baton)
{
GetFormatManager().NamedSummary().LoopThrough(callback, callback_baton);
}
uint32_t
-Debugger::NamedSummaryFormats::GetCurrentRevision()
+Debugger::Formatting::NamedSummaryFormats::GetCurrentRevision()
{
return GetFormatManager().GetCurrentRevision();
}
uint32_t
-Debugger::NamedSummaryFormats::GetCount()
+Debugger::Formatting::NamedSummaryFormats::GetCount()
{
return GetFormatManager().NamedSummary().GetCount();
}
diff --git a/lldb/source/Core/FormatManager.cpp b/lldb/source/Core/FormatManager.cpp
index 7be3791adbb..2ce91aed8fd 100644
--- a/lldb/source/Core/FormatManager.cpp
+++ b/lldb/source/Core/FormatManager.cpp
@@ -184,6 +184,8 @@ FormatNavigator<lldb::RegularExpressionSP, SummaryFormat>::Delete(const char* ty
if ( ::strcmp(type,regex->GetText()) == 0)
{
m_format_map.map().erase(pos);
+ if(m_format_map.listener)
+ m_format_map.listener->Changed();
return true;
}
}
@@ -270,3 +272,23 @@ StringSummaryFormat::FormatObject(lldb::ValueObjectSP object)
}
}
+void
+FormatCategory::ChooseAsPreferential(const char* name)
+{
+ Mutex::Locker(m_mutex);
+ lldb::SummaryFormatSP format;
+
+ uint32_t revision = Debugger::Formatting::ValueFormats::GetCurrentRevision();
+
+ if ( Summary()->Get(name, format) )
+ format->SetPriority(revision);
+
+ format.reset();
+
+ if ( RegexSummary()->Get(name, format) )
+ format->SetPriority(revision);
+
+ if(m_change_listener)
+ m_change_listener->Changed();
+
+}
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 4f0c8dc9069..fc89f0fd4a4 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -202,22 +202,21 @@ ValueObject::UpdateFormatsIfNeeded()
ClearCustomSummaryFormat();
m_summary_str.clear();
}
- if (m_last_format_mgr_revision != Debugger::ValueFormats::GetCurrentRevision())
+ if (m_last_format_mgr_revision != Debugger::Formatting::ValueFormats::GetCurrentRevision())
{
if (m_last_summary_format.get())
m_last_summary_format.reset((StringSummaryFormat*)NULL);
if (m_last_value_format.get())
m_last_value_format.reset((ValueFormat*)NULL);
- Debugger::ValueFormats::Get(*this, m_last_value_format);
+ Debugger::Formatting::ValueFormats::Get(*this, m_last_value_format);
// to find a summary we look for a direct summary, then if there is none
// we look for a regex summary. if there is none we look for a system
// summary (direct), and if also that fails, we look for a system
// regex summary
- if (!Debugger::SummaryFormats::Get(*this, m_last_summary_format))
- if (!Debugger::RegexSummaryFormats::Get(*this, m_last_summary_format))
- if (!Debugger::SystemSummaryFormats::Get(*this, m_last_summary_format))
- Debugger::SystemRegexSummaryFormats::Get(*this, m_last_summary_format);
- m_last_format_mgr_revision = Debugger::ValueFormats::GetCurrentRevision();
+
+ Debugger::Formatting::GetSummaryFormat(*this, m_last_summary_format);
+
+ m_last_format_mgr_revision = Debugger::Formatting::ValueFormats::GetCurrentRevision();
ClearUserVisibleData();
}
OpenPOWER on IntegriCloud