summaryrefslogtreecommitdiffstats
path: root/lldb/source/Commands/CommandObjectProcess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp152
1 files changed, 67 insertions, 85 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 26e7602493d..582e8983458 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -312,6 +312,18 @@ protected:
//-------------------------------------------------------------------------
// CommandObjectProcessAttach
//-------------------------------------------------------------------------
+
+static OptionDefinition g_process_attach_options[] = {
+ // clang-format off
+ { LLDB_OPT_SET_ALL, false, "continue", 'c', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Immediately continue the process once attached." },
+ { LLDB_OPT_SET_ALL, false, "plugin", 'P', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePlugin, "Name of the process plugin you want to use." },
+ { LLDB_OPT_SET_1, false, "pid", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePid, "The process ID of an existing process to attach to." },
+ { LLDB_OPT_SET_2, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeProcessName, "The name of the process to attach to." },
+ { LLDB_OPT_SET_2, false, "include-existing", 'i', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Include existing processes when doing attach -w." },
+ { LLDB_OPT_SET_2, false, "waitfor", 'w', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Wait for the process with <process-name> to launch." },
+ // clang-format on
+};
+
#pragma mark CommandObjectProcessAttach
class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach {
public:
@@ -373,7 +385,9 @@ public:
attach_info.Clear();
}
- const OptionDefinition *GetDefinitions() override { return g_option_table; }
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return g_process_attach_options;
+ }
bool HandleOptionArgumentCompletion(
Args &input, int cursor_index, int char_pos,
@@ -386,8 +400,7 @@ public:
// We are only completing the name option for now...
- const OptionDefinition *opt_defs = GetDefinitions();
- if (opt_defs[opt_defs_index].short_option == 'n') {
+ if (GetDefinitions()[opt_defs_index].short_option == 'n') {
// Are we in the name?
// Look to see if there is a -P argument provided, and if so use that
@@ -421,10 +434,6 @@ public:
return false;
}
- // Options table: Required for subclasses of Options.
-
- static OptionDefinition g_option_table[];
-
// Instance variables to hold the values for command options.
ProcessAttachInfo attach_info;
@@ -559,22 +568,16 @@ protected:
CommandOptions m_options;
};
-OptionDefinition CommandObjectProcessAttach::CommandOptions::g_option_table[] =
- {
- // clang-format off
- {LLDB_OPT_SET_ALL, false, "continue", 'c', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Immediately continue the process once attached."},
- {LLDB_OPT_SET_ALL, false, "plugin", 'P', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
- {LLDB_OPT_SET_1, false, "pid", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePid, "The process ID of an existing process to attach to."},
- {LLDB_OPT_SET_2, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeProcessName, "The name of the process to attach to."},
- {LLDB_OPT_SET_2, false, "include-existing", 'i', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Include existing processes when doing attach -w."},
- {LLDB_OPT_SET_2, false, "waitfor", 'w', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Wait for the process with <process-name> to launch."},
- {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr}
- // clang-format on
-};
-
//-------------------------------------------------------------------------
// CommandObjectProcessContinue
//-------------------------------------------------------------------------
+
+static OptionDefinition g_process_continue_options[] = {
+ // clang-format off
+ { LLDB_OPT_SET_ALL, false, "ignore-count",'i', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeUnsignedInteger, "Ignore <N> crossings of the breakpoint (if it exists) for the currently selected thread." }
+ // clang-format on
+};
+
#pragma mark CommandObjectProcessContinue
class CommandObjectProcessContinue : public CommandObjectParsed {
@@ -627,11 +630,9 @@ protected:
m_ignore = 0;
}
- const OptionDefinition *GetDefinitions() override { return g_option_table; }
-
- // Options table: Required for subclasses of Options.
-
- static OptionDefinition g_option_table[];
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return g_process_continue_options;
+ }
uint32_t m_ignore;
};
@@ -735,17 +736,15 @@ protected:
CommandOptions m_options;
};
-OptionDefinition
- CommandObjectProcessContinue::CommandOptions::g_option_table[] = {
- // clang-format off
- {LLDB_OPT_SET_ALL, false, "ignore-count",'i', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeUnsignedInteger, "Ignore <N> crossings of the breakpoint (if it exists) for the currently selected thread."},
- {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr}
- // clang-format on
-};
-
//-------------------------------------------------------------------------
// CommandObjectProcessDetach
//-------------------------------------------------------------------------
+static OptionDefinition g_process_detach_options[] = {
+ // clang-format off
+ { LLDB_OPT_SET_1, false, "keep-stopped", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." },
+ // clang-format on
+};
+
#pragma mark CommandObjectProcessDetach
class CommandObjectProcessDetach : public CommandObjectParsed {
@@ -789,11 +788,9 @@ public:
m_keep_stopped = eLazyBoolCalculate;
}
- const OptionDefinition *GetDefinitions() override { return g_option_table; }
-
- // Options table: Required for subclasses of Options.
-
- static OptionDefinition g_option_table[];
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return g_process_detach_options;
+ }
// Instance variables to hold the values for command options.
LazyBool m_keep_stopped;
@@ -838,17 +835,16 @@ protected:
CommandOptions m_options;
};
-OptionDefinition CommandObjectProcessDetach::CommandOptions::g_option_table[] =
- {
- // clang-format off
- {LLDB_OPT_SET_1, false, "keep-stopped", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)."},
- {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr}
- // clang-format on
-};
-
//-------------------------------------------------------------------------
// CommandObjectProcessConnect
//-------------------------------------------------------------------------
+
+static OptionDefinition g_process_connect_options[] = {
+ // clang-format off
+ { LLDB_OPT_SET_ALL, false, "plugin", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePlugin, "Name of the process plugin you want to use." },
+ // clang-format on
+};
+
#pragma mark CommandObjectProcessConnect
class CommandObjectProcessConnect : public CommandObjectParsed {
@@ -885,11 +881,9 @@ public:
plugin_name.clear();
}
- const OptionDefinition *GetDefinitions() override { return g_option_table; }
-
- // Options table: Required for subclasses of Options.
-
- static OptionDefinition g_option_table[];
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return g_process_connect_options;
+ }
// Instance variables to hold the values for command options.
@@ -947,14 +941,6 @@ protected:
CommandOptions m_options;
};
-OptionDefinition CommandObjectProcessConnect::CommandOptions::g_option_table[] =
- {
- // clang-format off
- {LLDB_OPT_SET_ALL, false, "plugin", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
- {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr}
- // clang-format on
-};
-
//-------------------------------------------------------------------------
// CommandObjectProcessPlugin
//-------------------------------------------------------------------------
@@ -981,6 +967,13 @@ public:
//-------------------------------------------------------------------------
// CommandObjectProcessLoad
//-------------------------------------------------------------------------
+
+static OptionDefinition g_process_load_options[] = {
+ // clang-format off
+ { LLDB_OPT_SET_ALL, false, "install", 'i', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypePath, "Install the shared library to the target. If specified without an argument then the library will installed in the current working directory." },
+ // clang-format on
+};
+
#pragma mark CommandObjectProcessLoad
class CommandObjectProcessLoad : public CommandObjectParsed {
@@ -1018,10 +1011,9 @@ public:
install_path.Clear();
}
- const OptionDefinition *GetDefinitions() override { return g_option_table; }
-
- // Options table: Required for subclasses of Options.
- static OptionDefinition g_option_table[];
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return g_process_load_options;
+ }
// Instance variables to hold the values for command options.
bool do_install;
@@ -1085,13 +1077,6 @@ protected:
CommandOptions m_options;
};
-OptionDefinition CommandObjectProcessLoad::CommandOptions::g_option_table[] = {
- // clang-format off
- {LLDB_OPT_SET_ALL, false, "install", 'i', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypePath, "Install the shared library to the target. If specified without an argument then the library will installed in the current working directory."},
- {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr}
- // clang-format on
-};
-
//-------------------------------------------------------------------------
// CommandObjectProcessUnload
//-------------------------------------------------------------------------
@@ -1380,6 +1365,15 @@ public:
//-------------------------------------------------------------------------
// CommandObjectProcessHandle
//-------------------------------------------------------------------------
+
+static OptionDefinition g_process_handle_options[] = {
+ // clang-format off
+ { LLDB_OPT_SET_1, false, "stop", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Whether or not the process should be stopped if the signal is received." },
+ { LLDB_OPT_SET_1, false, "notify", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Whether or not the debugger should notify the user if the signal is received." },
+ { LLDB_OPT_SET_1, false, "pass", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Whether or not the signal should be passed to the process." }
+ // clang-format on
+};
+
#pragma mark CommandObjectProcessHandle
class CommandObjectProcessHandle : public CommandObjectParsed {
@@ -1419,11 +1413,9 @@ public:
pass.clear();
}
- const OptionDefinition *GetDefinitions() override { return g_option_table; }
-
- // Options table: Required for subclasses of Options.
-
- static OptionDefinition g_option_table[];
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return g_process_handle_options;
+ }
// Instance variables to hold the values for command options.
@@ -1631,16 +1623,6 @@ protected:
CommandOptions m_options;
};
-OptionDefinition CommandObjectProcessHandle::CommandOptions::g_option_table[] =
- {
- // clang-format off
- {LLDB_OPT_SET_1, false, "stop", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Whether or not the process should be stopped if the signal is received."},
- {LLDB_OPT_SET_1, false, "notify", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Whether or not the debugger should notify the user if the signal is received."},
- {LLDB_OPT_SET_1, false, "pass", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Whether or not the signal should be passed to the process."},
- {0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr}
- // clang-format on
-};
-
//-------------------------------------------------------------------------
// CommandObjectMultiwordProcess
//-------------------------------------------------------------------------
OpenPOWER on IntegriCloud