Start to clean up the process of defining command arguments. (#83097)

Partly, there's just a lot of unnecessary boiler plate. It's also
possible to define combinations of arguments that make no sense (e.g.
eArgRepeatPlus followed by eArgRepeatPlain...) but these are never
checked since we just push_back directly into the argument definitions.

This commit is step 1 of this cleanup - do the obvious stuff. In it, all
the simple homogenous argument lists and the breakpoint/watchpoint
ID/Range types, are set with common functions. This is an NFC change, it
just centralizes boiler plate. There's no checking yet because you can't
get a single argument wrong.

The end goal is that all argument definition goes through functions and
m_arguments is hidden so that you can't define inconsistent argument
sets.
This commit is contained in:
jimingham
2024-02-27 10:34:01 -08:00
committed by GitHub
parent abc693fb40
commit 2d704f4bf2
28 changed files with 162 additions and 987 deletions

View File

@@ -126,19 +126,7 @@ public:
LLDB_OPT_SET_ALL);
m_all_options.Finalize();
CommandArgumentEntry arg;
CommandArgumentData run_args_arg;
// Define the first (and only) variant of this arg.
run_args_arg.arg_type = eArgTypeRunArgs;
run_args_arg.arg_repetition = eArgRepeatOptional;
// There is only one variant this argument could be; put it into the
// argument entry.
arg.push_back(run_args_arg);
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back(arg);
AddSimpleArgumentList(eArgTypeRunArgs, eArgRepeatOptional);
}
~CommandObjectProcessLaunch() override = default;
@@ -870,8 +858,7 @@ public:
: CommandObjectParsed(interpreter, "process connect",
"Connect to a remote debug service.",
"process connect <remote-url>", 0) {
CommandArgumentData connect_arg{eArgTypeConnectURL, eArgRepeatPlain};
m_arguments.push_back({connect_arg});
AddSimpleArgumentList(eArgTypeConnectURL);
}
~CommandObjectProcessConnect() override = default;
@@ -996,8 +983,7 @@ public:
eCommandRequiresProcess | eCommandTryTargetAPILock |
eCommandProcessMustBeLaunched |
eCommandProcessMustBePaused) {
CommandArgumentData file_arg{eArgTypePath, eArgRepeatPlus};
m_arguments.push_back({file_arg});
AddSimpleArgumentList(eArgTypePath, eArgRepeatPlus);
}
~CommandObjectProcessLoad() override = default;
@@ -1070,8 +1056,7 @@ public:
"process unload <index>",
eCommandRequiresProcess | eCommandTryTargetAPILock |
eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {
CommandArgumentData load_idx_arg{eArgTypeUnsignedInteger, eArgRepeatPlain};
m_arguments.push_back({load_idx_arg});
AddSimpleArgumentList(eArgTypeUnsignedInteger);
}
~CommandObjectProcessUnload() override = default;
@@ -1131,19 +1116,7 @@ public:
interpreter, "process signal",
"Send a UNIX signal to the current target process.", nullptr,
eCommandRequiresProcess | eCommandTryTargetAPILock) {
CommandArgumentEntry arg;
CommandArgumentData signal_arg;
// Define the first (and only) variant of this arg.
signal_arg.arg_type = eArgTypeUnixSignal;
signal_arg.arg_repetition = eArgRepeatPlain;
// There is only one variant this argument could be; put it into the
// argument entry.
arg.push_back(signal_arg);
// Push the data for the first argument into the m_arguments vector.
m_arguments.push_back(arg);
AddSimpleArgumentList(eArgTypeUnixSignal);
}
~CommandObjectProcessSignal() override = default;
@@ -1274,8 +1247,7 @@ public:
"process save-core [-s corefile-style -p plugin-name] FILE",
eCommandRequiresProcess | eCommandTryTargetAPILock |
eCommandProcessMustBeLaunched) {
CommandArgumentData file_arg{eArgTypePath, eArgRepeatPlain};
m_arguments.push_back({file_arg});
AddSimpleArgumentList(eArgTypePath);
}
~CommandObjectProcessSaveCore() override = default;
@@ -1559,15 +1531,7 @@ public:
"by passing the -t option."
"\nYou can also clear the target modification for a signal"
"by passing the -c option");
CommandArgumentEntry arg;
CommandArgumentData signal_arg;
signal_arg.arg_type = eArgTypeUnixSignal;
signal_arg.arg_repetition = eArgRepeatStar;
arg.push_back(signal_arg);
m_arguments.push_back(arg);
AddSimpleArgumentList(eArgTypeUnixSignal, eArgRepeatStar);
}
~CommandObjectProcessHandle() override = default;