aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectBreakpoint.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/CommandObjectBreakpoint.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/CommandObjectBreakpoint.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectBreakpoint.cpp72
1 files changed, 9 insertions, 63 deletions
diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp
index cfb0b87..fbece86 100644
--- a/lldb/source/Commands/CommandObjectBreakpoint.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp
@@ -813,12 +813,7 @@ public:
"With the exception of -e, -d and -i, passing an "
"empty argument clears the modification.",
nullptr) {
- CommandArgumentEntry arg;
- CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID,
- eArgTypeBreakpointIDRange);
- // Add the entry for the first argument for this command to the object's
- // arguments vector.
- m_arguments.push_back(arg);
+ CommandObject::AddIDsArgumentData(eBreakpointArgs);
m_options.Append(&m_bp_opts,
LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3,
@@ -890,12 +885,7 @@ public:
"Enable the specified disabled breakpoint(s). If "
"no breakpoints are specified, enable all of them.",
nullptr) {
- CommandArgumentEntry arg;
- CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID,
- eArgTypeBreakpointIDRange);
- // Add the entry for the first argument for this command to the object's
- // arguments vector.
- m_arguments.push_back(arg);
+ CommandObject::AddIDsArgumentData(eBreakpointArgs);
}
~CommandObjectBreakpointEnable() override = default;
@@ -1002,12 +992,7 @@ execution will NOT stop at location 1.1. To achieve that, type:
"The first command disables all locations for breakpoint 1, \
the second re-enables the first location.");
- CommandArgumentEntry arg;
- CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID,
- eArgTypeBreakpointIDRange);
- // Add the entry for the first argument for this command to the object's
- // arguments vector.
- m_arguments.push_back(arg);
+ CommandObject::AddIDsArgumentData(eBreakpointArgs);
}
~CommandObjectBreakpointDisable() override = default;
@@ -1098,15 +1083,7 @@ public:
CommandArgumentData bp_id_arg;
// Define the first (and only) variant of this arg.
- bp_id_arg.arg_type = eArgTypeBreakpointID;
- bp_id_arg.arg_repetition = eArgRepeatOptional;
-
- // 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);
+ AddSimpleArgumentList(eArgTypeBreakpointID, eArgRepeatOptional);
}
~CommandObjectBreakpointList() override = default;
@@ -1372,12 +1349,7 @@ public:
"Delete the specified breakpoint(s). If no "
"breakpoints are specified, delete them all.",
nullptr) {
- CommandArgumentEntry arg;
- CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID,
- eArgTypeBreakpointIDRange);
- // Add the entry for the first argument for this command to the object's
- // arguments vector.
- m_arguments.push_back(arg);
+ CommandObject::AddIDsArgumentData(eBreakpointArgs);
}
~CommandObjectBreakpointDelete() override = default;
@@ -1677,14 +1649,7 @@ public:
"on the name.",
"breakpoint name configure <command-options> "
"<breakpoint-name-list>") {
- // Create the first variant for the first (and only) argument for this
- // command.
- CommandArgumentEntry arg1;
- CommandArgumentData id_arg;
- id_arg.arg_type = eArgTypeBreakpointName;
- id_arg.arg_repetition = eArgRepeatOptional;
- arg1.push_back(id_arg);
- m_arguments.push_back(arg1);
+ AddSimpleArgumentList(eArgTypeBreakpointName, eArgRepeatOptional);
m_option_group.Append(&m_bp_opts, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1);
m_option_group.Append(&m_access_options, LLDB_OPT_SET_ALL,
@@ -1770,14 +1735,7 @@ public:
: CommandObjectParsed(
interpreter, "add", "Add a name to the breakpoints provided.",
"breakpoint name add <command-options> <breakpoint-id-list>") {
- // Create the first variant for the first (and only) argument for this
- // command.
- CommandArgumentEntry arg1;
- CommandArgumentData id_arg;
- id_arg.arg_type = eArgTypeBreakpointID;
- id_arg.arg_repetition = eArgRepeatOptional;
- arg1.push_back(id_arg);
- m_arguments.push_back(arg1);
+ AddSimpleArgumentList(eArgTypeBreakpointID, eArgRepeatOptional);
m_option_group.Append(&m_name_options, LLDB_OPT_SET_1, LLDB_OPT_SET_ALL);
m_option_group.Finalize();
@@ -1851,14 +1809,7 @@ public:
interpreter, "delete",
"Delete a name from the breakpoints provided.",
"breakpoint name delete <command-options> <breakpoint-id-list>") {
- // Create the first variant for the first (and only) argument for this
- // command.
- CommandArgumentEntry arg1;
- CommandArgumentData id_arg;
- id_arg.arg_type = eArgTypeBreakpointID;
- id_arg.arg_repetition = eArgRepeatOptional;
- arg1.push_back(id_arg);
- m_arguments.push_back(arg1);
+ AddSimpleArgumentList(eArgTypeBreakpointID, eArgRepeatOptional);
m_option_group.Append(&m_name_options, LLDB_OPT_SET_1, LLDB_OPT_SET_ALL);
m_option_group.Finalize();
@@ -2308,12 +2259,7 @@ public:
"be read in with \"breakpoint read\". "
"If given no arguments, writes all breakpoints.",
nullptr) {
- CommandArgumentEntry arg;
- CommandObject::AddIDsArgumentData(arg, eArgTypeBreakpointID,
- eArgTypeBreakpointIDRange);
- // Add the entry for the first argument for this command to the object's
- // arguments vector.
- m_arguments.push_back(arg);
+ CommandObject::AddIDsArgumentData(eBreakpointArgs);
}
~CommandObjectBreakpointWrite() override = default;