aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectProcess.cpp
diff options
context:
space:
mode:
authorjimingham <jingham@apple.com>2024-02-27 10:34:01 -0800
committerGitHub <noreply@github.com>2024-02-27 10:34:01 -0800
commit2d704f4bf2edb0f9343dac818ab4d29442be9968 (patch)
treeef20273e98e399b40906c2b36e8172d3ef36e2e8 /lldb/source/Commands/CommandObjectProcess.cpp
parentabc693fb4051dfb3a49ba2dcdbc2d164c53f2a51 (diff)
downloadllvm-2d704f4bf2edb0f9343dac818ab4d29442be9968.zip
llvm-2d704f4bf2edb0f9343dac818ab4d29442be9968.tar.gz
llvm-2d704f4bf2edb0f9343dac818ab4d29442be9968.tar.bz2
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.
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp50
1 files changed, 7 insertions, 43 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 7cd5ad6..9ac97eb 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -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;