Add infrastructure for standardizing arguments for commands and
command options; makes it easier to ensure that the same type of
argument will have the same name everywhere, hooks up help for command
arguments, so that users can ask for help when they are confused about
what an argument should be; puts in the beginnings of the ability to
do tab-completion for certain types of arguments, allows automatic
syntax help generation for commands with arguments, and adds command
arguments into command options help correctly.
Currently only the breakpoint-id and breakpoint-id-range arguments, in
the breakpoint commands, have been hooked up to use the new mechanism.
The next steps will be to fix the command options arguments to use
this mechanism, and to fix the rest of the regular command arguments
to use this mechanism. Most of the help text is currently missing or
dummy text; this will need to be filled in, and the existing argument
help text will need to be cleaned up a bit (it was thrown in quickly,
mostly for testing purposes).
Help command now works for all argument types, although the help may not
be very helpful yet.
Those commands that take "raw" command strings now indicate it in their
help text.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@115318 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectBreakpoint.cpp b/source/Commands/CommandObjectBreakpoint.cpp
index 2fc5f2b..6a8aabc 100644
--- a/source/Commands/CommandObjectBreakpoint.cpp
+++ b/source/Commands/CommandObjectBreakpoint.cpp
@@ -685,8 +685,20 @@
CommandObject (interpreter,
"breakpoint list",
"List some or all breakpoints at configurable levels of detail.",
- "breakpoint list [<breakpoint-id>]")
+ NULL)
{
+ CommandArgumentEntry arg;
+ CommandArgumentData bp_id_arg;
+
+ // Define the first (and only) variant of this arg.
+ bp_id_arg.arg_type = eArgTypeBreakpointID;
+ bp_id_arg.arg_repetition = eArgRepeatStar;
+
+ // There is only one variant this argument could be; put it into the argument entry.
+ arg.push_back (bp_id_arg);
+
+ // Push the data for the first argument into the m_arguments vector.
+ m_arguments.push_back (arg);
}
CommandObjectBreakpointList::~CommandObjectBreakpointList ()
@@ -774,14 +786,28 @@
CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) :
CommandObject (interpreter,
"enable",
- "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.",
- "breakpoint enable [<breakpoint-id> | <breakpoint-id-list>]")
+ "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.",
+ NULL)
{
- // This command object can either be called via 'enable' or 'breakpoint enable'. Because it has two different
- // potential invocation methods, we need to be a little tricky about generating the syntax string.
- //StreamString tmp_string;
- //tmp_string.Printf ("%s <breakpoint-id>", GetCommandName());
- //m_cmd_syntax.assign (tmp_string.GetData(), tmp_string.GetSize());
+ CommandArgumentEntry arg;
+ CommandArgumentData bp_id_arg;
+ CommandArgumentData bp_id_range_arg;
+
+ // Create the first variant for the first (and only) argument for this command.
+ bp_id_arg.arg_type = eArgTypeBreakpointID;
+ bp_id_arg.arg_repetition = eArgRepeatStar;
+
+ // Create the second variant for the first (and only) argument for this command.
+ bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange;
+ bp_id_range_arg.arg_repetition = eArgRepeatStar;
+
+ // The first (and only) argument for this command could be either a bp_id or a bp_id_range.
+ // Push both variants into the entry for the first argument for this command.
+ arg.push_back (bp_id_arg);
+ arg.push_back (bp_id_range_arg);
+
+ // Add the entry for the first argument for this command to the object's arguments vector.
+ m_arguments.push_back (arg);
}
@@ -875,15 +901,29 @@
CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) :
CommandObject (interpreter,
- "disable",
+ "breakpoint disable",
"Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.",
- "disable [<breakpoint-id> | <breakpoint-id-list>]")
+ NULL)
{
- // This command object can either be called via 'enable' or 'breakpoint enable'. Because it has two different
- // potential invocation methods, we need to be a little tricky about generating the syntax string.
- //StreamString tmp_string;
- //tmp_string.Printf ("%s <breakpoint-id>", GetCommandName());
- //m_cmd_syntax.assign(tmp_string.GetData(), tmp_string.GetSize());
+ CommandArgumentEntry arg;
+ CommandArgumentData bp_id_arg;
+ CommandArgumentData bp_id_range_arg;
+
+ // Create the first variant for the first (and only) argument for this command.
+ bp_id_arg.arg_type = eArgTypeBreakpointID;
+ bp_id_arg.arg_repetition = eArgRepeatStar;
+
+ // Create the second variant for the first (and only) argument for this command.
+ bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange;
+ bp_id_range_arg.arg_repetition = eArgRepeatStar;
+
+ // The first (and only) argument for this command could be either a bp_id or a bp_id_range.
+ // Push both variants into the entry for the first argument for this command.
+ arg.push_back (bp_id_arg);
+ arg.push_back (bp_id_range_arg);
+
+ // Add the entry for the first argument for this command to the object's arguments vector.
+ m_arguments.push_back (arg);
}
CommandObjectBreakpointDisable::~CommandObjectBreakpointDisable ()
@@ -977,8 +1017,27 @@
CommandObject (interpreter,
"breakpoint delete",
"Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.",
- "breakpoint delete [<breakpoint-id> | <breakpoint-id-list>]")
+ NULL)
{
+ CommandArgumentEntry arg;
+ CommandArgumentData bp_id_arg;
+ CommandArgumentData bp_id_range_arg;
+
+ // Create the first variant for the first (and only) argument for this command.
+ bp_id_arg.arg_type = eArgTypeBreakpointID;
+ bp_id_arg.arg_repetition = eArgRepeatStar;
+
+ // Create the second variant for the first (and only) argument for this command.
+ bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange;
+ bp_id_range_arg.arg_repetition = eArgRepeatStar;
+
+ // The first (and only) argument for this command could be either a bp_id or a bp_id_range.
+ // Push both variants into the entry for the first argument for this command.
+ arg.push_back (bp_id_arg);
+ arg.push_back (bp_id_range_arg);
+
+ // Add the entry for the first argument for this command to the object's arguments vector.
+ m_arguments.push_back (arg);
}
@@ -1198,8 +1257,27 @@
CommandObject (interpreter,
"breakpoint modify",
"Modify the options on a breakpoint or set of breakpoints in the executable.",
- "breakpoint modify <cmd-options> <breakpoint-id> [<breakpoint-id> ...]")
+ NULL)
{
+ CommandArgumentEntry arg;
+ CommandArgumentData bp_id_arg;
+ CommandArgumentData bp_id_range_arg;
+
+ // Create the first variant for the first (and only) argument for this command.
+ bp_id_arg.arg_type = eArgTypeBreakpointID;
+ bp_id_arg.arg_repetition = eArgRepeatPlus;
+
+ // Create the second variant for the first (and only) argument for this command.
+ bp_id_range_arg.arg_type = eArgTypeBreakpointIDRange;
+ bp_id_range_arg.arg_repetition = eArgRepeatPlus;
+
+ // The first (and only) argument for this command could be either a bp_id or a bp_id_range.
+ // Push both variants into the entry for the first argument for this command.
+ arg.push_back (bp_id_arg);
+ arg.push_back (bp_id_range_arg);
+
+ // Add the entry for the first argument for this command to the object's arguments vector.
+ m_arguments.push_back (arg);
}
CommandObjectBreakpointModify::~CommandObjectBreakpointModify ()
diff --git a/source/Commands/CommandObjectHelp.cpp b/source/Commands/CommandObjectHelp.cpp
index 2d4b9f2..4f8b752 100644
--- a/source/Commands/CommandObjectHelp.cpp
+++ b/source/Commands/CommandObjectHelp.cpp
@@ -95,7 +95,14 @@
Stream &output_strm = result.GetOutputStream();
if (sub_cmd_obj->GetOptions() != NULL)
{
- m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
+ if (sub_cmd_obj->WantsRawCommandString())
+ {
+ std::string help_text (sub_cmd_obj->GetHelp());
+ help_text.append (" This command takes 'raw' input (no need to quote stuff).");
+ m_interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1);
+ }
+ else
+ m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax());
sub_cmd_obj->GetOptions()->GenerateOptionUsage (m_interpreter, output_strm, sub_cmd_obj);
const char *long_help = sub_cmd_obj->GetHelpLong();
@@ -105,7 +112,14 @@
}
else if (sub_cmd_obj->IsMultiwordObject())
{
- m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
+ if (sub_cmd_obj->WantsRawCommandString())
+ {
+ std::string help_text (sub_cmd_obj->GetHelp());
+ help_text.append (" This command takes 'raw' input (no need to quote stuff).");
+ m_interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1);
+ }
+ else
+ m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (result);
}
else
@@ -114,6 +128,12 @@
if ((long_help != NULL)
&& (strlen (long_help) > 0))
output_strm.Printf ("\n%s", long_help);
+ else if (sub_cmd_obj->WantsRawCommandString())
+ {
+ std::string help_text (sub_cmd_obj->GetHelp());
+ help_text.append (" This command takes 'raw' input (no need to quote stuff).");
+ m_interpreter.OutputFormattedHelpText (output_strm, "", "", help_text.c_str(), 1);
+ }
else
m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1);
output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax());
@@ -132,10 +152,21 @@
}
else
{
- result.AppendErrorWithFormat
- ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n",
- command.GetArgumentAtIndex(0));
- result.SetStatus (eReturnStatusFailed);
+ // Maybe the user is asking for help about a command argument rather than a command.
+ const CommandArgumentType arg_type = CommandObject::LookupArgumentName (command.GetArgumentAtIndex (0));
+ if (arg_type != eArgTypeLastArg)
+ {
+ Stream &output_strm = result.GetOutputStream ();
+ CommandObject::GetArgumentHelp (output_strm, arg_type, m_interpreter);
+ result.SetStatus (eReturnStatusSuccessFinishNoResult);
+ }
+ else
+ {
+ result.AppendErrorWithFormat
+ ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n",
+ command.GetArgumentAtIndex(0));
+ result.SetStatus (eReturnStatusFailed);
+ }
}
}
diff --git a/source/Commands/CommandObjectMultiword.cpp b/source/Commands/CommandObjectMultiword.cpp
index 9530adf..aafd0f8 100644
--- a/source/Commands/CommandObjectMultiword.cpp
+++ b/source/Commands/CommandObjectMultiword.cpp
@@ -196,11 +196,22 @@
{
std::string indented_command (" ");
indented_command.append (pos->first);
- m_interpreter.OutputFormattedHelpText (result.GetOutputStream(),
- indented_command.c_str(),
- "--",
- pos->second->GetHelp(),
- max_len);
+ if (pos->second->WantsRawCommandString ())
+ {
+ std::string help_text (pos->second->GetHelp());
+ help_text.append (" This command takes 'raw' input (no need to quote stuff).");
+ m_interpreter.OutputFormattedHelpText (result.GetOutputStream(),
+ indented_command.c_str(),
+ "--",
+ help_text.c_str(),
+ max_len);
+ }
+ else
+ m_interpreter.OutputFormattedHelpText (result.GetOutputStream(),
+ indented_command.c_str(),
+ "--",
+ pos->second->GetHelp(),
+ max_len);
}
output_stream.PutCString ("\nFor more help on any particular subcommand, type 'help <command> <subcommand>'.\n");