aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectCommands.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Commands/CommandObjectCommands.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectCommands.cpp63
1 files changed, 33 insertions, 30 deletions
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 4b4932dd367b..39c7207bbdbe 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -56,9 +56,9 @@ public:
~CommandObjectCommandsSource() override = default;
- const char *GetRepeatCommand(Args &current_command_args,
- uint32_t index) override {
- return "";
+ llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
+ uint32_t index) override {
+ return std::string("");
}
void
@@ -206,7 +206,7 @@ class CommandObjectCommandsAlias : public CommandObjectRaw {
protected:
class CommandOptions : public OptionGroup {
public:
- CommandOptions() {}
+ CommandOptions() = default;
~CommandOptions() override = default;
@@ -824,6 +824,8 @@ a number follows 'f':"
R"(
(lldb) command regex f s/^$/finish/ 's/([0-9]+)/frame select %1/')");
+ CommandArgumentData thread_arg{eArgTypeSEDStylePair, eArgRepeatOptional};
+ m_arguments.push_back({thread_arg});
}
~CommandObjectCommandsAddRegex() override = default;
@@ -1022,7 +1024,7 @@ private:
class CommandOptions : public Options {
public:
- CommandOptions() {}
+ CommandOptions() = default;
~CommandOptions() override = default;
@@ -1076,7 +1078,7 @@ public:
std::string funct, std::string help,
ScriptedCommandSynchronicity synch)
: CommandObjectRaw(interpreter, name), m_function_name(funct),
- m_synchro(synch), m_fetched_help_long(false) {
+ m_synchro(synch) {
if (!help.empty())
SetHelp(help);
else {
@@ -1139,7 +1141,7 @@ protected:
private:
std::string m_function_name;
ScriptedCommandSynchronicity m_synchro;
- bool m_fetched_help_long;
+ bool m_fetched_help_long = false;
};
class CommandObjectScriptingObject : public CommandObjectRaw {
@@ -1267,7 +1269,7 @@ public:
protected:
class CommandOptions : public Options {
public:
- CommandOptions() {}
+ CommandOptions() = default;
~CommandOptions() override = default;
@@ -1422,7 +1424,7 @@ public:
protected:
class CommandOptions : public Options {
public:
- CommandOptions() {}
+ CommandOptions() = default;
~CommandOptions() override = default;
@@ -1445,7 +1447,7 @@ protected:
m_short_help = std::string(option_arg);
break;
case 'o':
- m_overwrite = true;
+ m_overwrite_lazy = eLazyBoolYes;
break;
case 's':
m_synchronicity =
@@ -1467,7 +1469,7 @@ protected:
m_class_name.clear();
m_funct_name.clear();
m_short_help.clear();
- m_overwrite = false;
+ m_overwrite_lazy = eLazyBoolCalculate;
m_synchronicity = eScriptedCommandSynchronicitySynchronous;
}
@@ -1480,7 +1482,7 @@ protected:
std::string m_class_name;
std::string m_funct_name;
std::string m_short_help;
- bool m_overwrite;
+ LazyBool m_overwrite_lazy = eLazyBoolCalculate;
ScriptedCommandSynchronicity m_synchronicity =
eScriptedCommandSynchronicitySynchronous;
};
@@ -1499,7 +1501,6 @@ protected:
ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter) {
-
StringList lines;
lines.SplitIntoLines(data);
if (lines.GetSize() > 0) {
@@ -1562,8 +1563,19 @@ protected:
result.AppendError("'command script add' requires at least one argument");
return false;
}
- // Store the options in case we get multi-line input
- m_overwrite = m_options.m_overwrite;
+ // Store the options in case we get multi-line input, also figure out the
+ // default if not user supplied:
+ switch (m_options.m_overwrite_lazy) {
+ case eLazyBoolCalculate:
+ m_overwrite = !GetDebugger().GetCommandInterpreter().GetRequireCommandOverwrite();
+ break;
+ case eLazyBoolYes:
+ m_overwrite = true;
+ break;
+ case eLazyBoolNo:
+ m_overwrite = false;
+ }
+
Status path_error;
m_container = GetCommandInterpreter().VerifyUserMultiwordCmdPath(
command, true, path_error);
@@ -1637,8 +1649,9 @@ protected:
std::string m_cmd_name;
CommandObjectMultiword *m_container = nullptr;
std::string m_short_help;
- bool m_overwrite;
- ScriptedCommandSynchronicity m_synchronicity;
+ bool m_overwrite = false;
+ ScriptedCommandSynchronicity m_synchronicity =
+ eScriptedCommandSynchronicitySynchronous;
};
// CommandObjectCommandsScriptList
@@ -1653,11 +1666,6 @@ public:
~CommandObjectCommandsScriptList() override = default;
bool DoExecute(Args &command, CommandReturnObject &result) override {
- if (command.GetArgumentCount() != 0) {
- result.AppendError("'command script list' doesn't take any arguments");
- return false;
- }
-
m_interpreter.GetHelp(result, CommandInterpreter::eCommandTypesUserDef);
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -1678,11 +1686,6 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- if (command.GetArgumentCount() != 0) {
- result.AppendError("'command script clear' doesn't take any arguments");
- return false;
- }
-
m_interpreter.RemoveAllUser();
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -1879,7 +1882,7 @@ public:
protected:
class CommandOptions : public Options {
public:
- CommandOptions() {}
+ CommandOptions() = default;
~CommandOptions() override = default;
@@ -2088,8 +2091,8 @@ public:
: CommandObjectMultiword(
interpreter, "command container",
"Commands for adding container commands to lldb. "
- "Container commands are containers for other commands. You can"
- "add nested container commands by specifying a command path, but "
+ "Container commands are containers for other commands. You can "
+ "add nested container commands by specifying a command path, "
"but you can't add commands into the built-in command hierarchy.",
"command container <subcommand> [<subcommand-options>]") {
LoadSubCommand("add", CommandObjectSP(new CommandObjectCommandsContainerAdd(