1 //===-- CommandObjectProcess.cpp --------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "CommandObjectProcess.h"
10 #include "lldb/Breakpoint/Breakpoint.h"
11 #include "lldb/Breakpoint/BreakpointLocation.h"
12 #include "lldb/Breakpoint/BreakpointSite.h"
13 #include "lldb/Core/Module.h"
14 #include "lldb/Core/PluginManager.h"
15 #include "lldb/Host/Host.h"
16 #include "lldb/Host/OptionParser.h"
17 #include "lldb/Host/StringConvert.h"
18 #include "lldb/Interpreter/CommandInterpreter.h"
19 #include "lldb/Interpreter/CommandReturnObject.h"
20 #include "lldb/Interpreter/OptionArgParser.h"
21 #include "lldb/Interpreter/Options.h"
22 #include "lldb/Target/Platform.h"
23 #include "lldb/Target/Process.h"
24 #include "lldb/Target/StopInfo.h"
25 #include "lldb/Target/Target.h"
26 #include "lldb/Target/Thread.h"
27 #include "lldb/Target/UnixSignals.h"
28 #include "lldb/Utility/Args.h"
29 #include "lldb/Utility/State.h"
32 using namespace lldb_private;
34 class CommandObjectProcessLaunchOrAttach : public CommandObjectParsed {
36 CommandObjectProcessLaunchOrAttach(CommandInterpreter &interpreter,
37 const char *name, const char *help,
38 const char *syntax, uint32_t flags,
39 const char *new_process_action)
40 : CommandObjectParsed(interpreter, name, help, syntax, flags),
41 m_new_process_action(new_process_action) {}
43 ~CommandObjectProcessLaunchOrAttach() override = default;
46 bool StopProcessIfNecessary(Process *process, StateType &state,
47 CommandReturnObject &result) {
48 state = eStateInvalid;
50 state = process->GetState();
52 if (process->IsAlive() && state != eStateConnected) {
54 if (process->GetState() == eStateAttaching)
55 ::snprintf(message, sizeof(message),
56 "There is a pending attach, abort it and %s?",
57 m_new_process_action.c_str());
58 else if (process->GetShouldDetach())
59 ::snprintf(message, sizeof(message),
60 "There is a running process, detach from it and %s?",
61 m_new_process_action.c_str());
63 ::snprintf(message, sizeof(message),
64 "There is a running process, kill it and %s?",
65 m_new_process_action.c_str());
67 if (!m_interpreter.Confirm(message, true)) {
68 result.SetStatus(eReturnStatusFailed);
71 if (process->GetShouldDetach()) {
72 bool keep_stopped = false;
73 Status detach_error(process->Detach(keep_stopped));
74 if (detach_error.Success()) {
75 result.SetStatus(eReturnStatusSuccessFinishResult);
78 result.AppendErrorWithFormat(
79 "Failed to detach from process: %s\n",
80 detach_error.AsCString());
81 result.SetStatus(eReturnStatusFailed);
84 Status destroy_error(process->Destroy(false));
85 if (destroy_error.Success()) {
86 result.SetStatus(eReturnStatusSuccessFinishResult);
89 result.AppendErrorWithFormat("Failed to kill process: %s\n",
90 destroy_error.AsCString());
91 result.SetStatus(eReturnStatusFailed);
97 return result.Succeeded();
100 std::string m_new_process_action;
103 // CommandObjectProcessLaunch
104 #pragma mark CommandObjectProcessLaunch
105 class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach {
107 CommandObjectProcessLaunch(CommandInterpreter &interpreter)
108 : CommandObjectProcessLaunchOrAttach(
109 interpreter, "process launch",
110 "Launch the executable in the debugger.", nullptr,
111 eCommandRequiresTarget, "restart"),
113 CommandArgumentEntry arg;
114 CommandArgumentData run_args_arg;
116 // Define the first (and only) variant of this arg.
117 run_args_arg.arg_type = eArgTypeRunArgs;
118 run_args_arg.arg_repetition = eArgRepeatOptional;
120 // There is only one variant this argument could be; put it into the
122 arg.push_back(run_args_arg);
124 // Push the data for the first argument into the m_arguments vector.
125 m_arguments.push_back(arg);
128 ~CommandObjectProcessLaunch() override = default;
130 int HandleArgumentCompletion(
131 CompletionRequest &request,
132 OptionElementVector &opt_element_vector) override {
134 CommandCompletions::InvokeCommonCompletionCallbacks(
135 GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
137 return request.GetNumberOfMatches();
140 Options *GetOptions() override { return &m_options; }
142 const char *GetRepeatCommand(Args ¤t_command_args,
143 uint32_t index) override {
144 // No repeat for "process launch"...
149 bool DoExecute(Args &launch_args, CommandReturnObject &result) override {
150 Debugger &debugger = GetDebugger();
151 Target *target = debugger.GetSelectedTarget().get();
152 // If our listener is nullptr, users aren't allows to launch
153 ModuleSP exe_module_sp = target->GetExecutableModule();
155 if (exe_module_sp == nullptr) {
156 result.AppendError("no file in target, create a debug target using the "
157 "'target create' command");
158 result.SetStatus(eReturnStatusFailed);
162 StateType state = eStateInvalid;
164 if (!StopProcessIfNecessary(m_exe_ctx.GetProcessPtr(), state, result))
167 llvm::StringRef target_settings_argv0 = target->GetArg0();
169 // Determine whether we will disable ASLR or leave it in the default state
170 // (i.e. enabled if the platform supports it). First check if the process
171 // launch options explicitly turn on/off
172 // disabling ASLR. If so, use that setting;
173 // otherwise, use the 'settings target.disable-aslr' setting.
174 bool disable_aslr = false;
175 if (m_options.disable_aslr != eLazyBoolCalculate) {
176 // The user specified an explicit setting on the process launch line.
178 disable_aslr = (m_options.disable_aslr == eLazyBoolYes);
180 // The user did not explicitly specify whether to disable ASLR. Fall
181 // back to the target.disable-aslr setting.
182 disable_aslr = target->GetDisableASLR();
186 m_options.launch_info.GetFlags().Set(eLaunchFlagDisableASLR);
188 m_options.launch_info.GetFlags().Clear(eLaunchFlagDisableASLR);
190 if (target->GetDetachOnError())
191 m_options.launch_info.GetFlags().Set(eLaunchFlagDetachOnError);
193 if (target->GetDisableSTDIO())
194 m_options.launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO);
196 // Merge the launch info environment with the target environment.
197 Environment target_env = target->GetEnvironment();
198 m_options.launch_info.GetEnvironment().insert(target_env.begin(),
201 if (!target_settings_argv0.empty()) {
202 m_options.launch_info.GetArguments().AppendArgument(
203 target_settings_argv0);
204 m_options.launch_info.SetExecutableFile(
205 exe_module_sp->GetPlatformFileSpec(), false);
207 m_options.launch_info.SetExecutableFile(
208 exe_module_sp->GetPlatformFileSpec(), true);
211 if (launch_args.GetArgumentCount() == 0) {
212 m_options.launch_info.GetArguments().AppendArguments(
213 target->GetProcessLaunchInfo().GetArguments());
215 m_options.launch_info.GetArguments().AppendArguments(launch_args);
216 // Save the arguments for subsequent runs in the current target.
217 target->SetRunArguments(launch_args);
221 Status error = target->Launch(m_options.launch_info, &stream);
223 if (error.Success()) {
224 ProcessSP process_sp(target->GetProcessSP());
226 // There is a race condition where this thread will return up the call
227 // stack to the main command handler and show an (lldb) prompt before
228 // HandlePrivateEvent (from PrivateStateThread) has a chance to call
229 // PushProcessIOHandler().
230 process_sp->SyncIOHandler(0, std::chrono::seconds(2));
232 llvm::StringRef data = stream.GetString();
234 result.AppendMessage(data);
235 const char *archname =
236 exe_module_sp->GetArchitecture().GetArchitectureName();
237 result.AppendMessageWithFormat(
238 "Process %" PRIu64 " launched: '%s' (%s)\n", process_sp->GetID(),
239 exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
240 result.SetStatus(eReturnStatusSuccessFinishResult);
241 result.SetDidChangeProcessState(true);
244 "no error returned from Target::Launch, and target has no process");
245 result.SetStatus(eReturnStatusFailed);
248 result.AppendError(error.AsCString());
249 result.SetStatus(eReturnStatusFailed);
251 return result.Succeeded();
255 ProcessLaunchCommandOptions m_options;
258 static constexpr OptionDefinition g_process_attach_options[] = {
260 { LLDB_OPT_SET_ALL, false, "continue", 'c', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Immediately continue the process once attached." },
261 { LLDB_OPT_SET_ALL, false, "plugin", 'P', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePlugin, "Name of the process plugin you want to use." },
262 { LLDB_OPT_SET_1, false, "pid", 'p', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePid, "The process ID of an existing process to attach to." },
263 { LLDB_OPT_SET_2, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeProcessName, "The name of the process to attach to." },
264 { LLDB_OPT_SET_2, false, "include-existing", 'i', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Include existing processes when doing attach -w." },
265 { LLDB_OPT_SET_2, false, "waitfor", 'w', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Wait for the process with <process-name> to launch." },
269 #pragma mark CommandObjectProcessAttach
270 class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach {
272 class CommandOptions : public Options {
274 CommandOptions() : Options() {
275 // Keep default values of all options in one place: OptionParsingStarting
277 OptionParsingStarting(nullptr);
280 ~CommandOptions() override = default;
282 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
283 ExecutionContext *execution_context) override {
285 const int short_option = m_getopt_table[option_idx].val;
286 switch (short_option) {
288 attach_info.SetContinueOnceAttached(true);
293 if (option_arg.getAsInteger(0, pid)) {
294 error.SetErrorStringWithFormat("invalid process ID '%s'",
295 option_arg.str().c_str());
297 attach_info.SetProcessID(pid);
302 attach_info.SetProcessPluginName(option_arg);
306 attach_info.GetExecutableFile().SetFile(option_arg,
307 FileSpec::Style::native);
311 attach_info.SetWaitForLaunch(true);
315 attach_info.SetIgnoreExisting(false);
319 error.SetErrorStringWithFormat("invalid short option character '%c'",
326 void OptionParsingStarting(ExecutionContext *execution_context) override {
330 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
331 return llvm::makeArrayRef(g_process_attach_options);
334 bool HandleOptionArgumentCompletion(
335 CompletionRequest &request, OptionElementVector &opt_element_vector,
336 int opt_element_index, CommandInterpreter &interpreter) override {
337 int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos;
338 int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index;
340 // We are only completing the name option for now...
342 if (GetDefinitions()[opt_defs_index].short_option == 'n') {
343 // Are we in the name?
345 // Look to see if there is a -P argument provided, and if so use that
346 // plugin, otherwise use the default plugin.
348 const char *partial_name = nullptr;
349 partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos);
351 PlatformSP platform_sp(interpreter.GetPlatform(true));
353 ProcessInstanceInfoList process_infos;
354 ProcessInstanceInfoMatch match_info;
356 match_info.GetProcessInfo().GetExecutableFile().SetFile(
357 partial_name, FileSpec::Style::native);
358 match_info.SetNameMatchType(NameMatch::StartsWith);
360 platform_sp->FindProcesses(match_info, process_infos);
361 const size_t num_matches = process_infos.GetSize();
362 if (num_matches > 0) {
363 for (size_t i = 0; i < num_matches; ++i) {
364 request.AddCompletion(llvm::StringRef(
365 process_infos.GetProcessNameAtIndex(i),
366 process_infos.GetProcessNameLengthAtIndex(i)));
375 // Instance variables to hold the values for command options.
377 ProcessAttachInfo attach_info;
380 CommandObjectProcessAttach(CommandInterpreter &interpreter)
381 : CommandObjectProcessLaunchOrAttach(
382 interpreter, "process attach", "Attach to a process.",
383 "process attach <cmd-options>", 0, "attach"),
386 ~CommandObjectProcessAttach() override = default;
388 Options *GetOptions() override { return &m_options; }
391 bool DoExecute(Args &command, CommandReturnObject &result) override {
392 PlatformSP platform_sp(
393 GetDebugger().GetPlatformList().GetSelectedPlatform());
395 Target *target = GetDebugger().GetSelectedTarget().get();
396 // N.B. The attach should be synchronous. It doesn't help much to get the
397 // prompt back between initiating the attach and the target actually
398 // stopping. So even if the interpreter is set to be asynchronous, we wait
399 // for the stop ourselves here.
401 StateType state = eStateInvalid;
402 Process *process = m_exe_ctx.GetProcessPtr();
404 if (!StopProcessIfNecessary(process, state, result))
407 if (target == nullptr) {
408 // If there isn't a current target create one.
409 TargetSP new_target_sp;
412 error = GetDebugger().GetTargetList().CreateTarget(
413 GetDebugger(), "", "", eLoadDependentsNo,
414 nullptr, // No platform options
416 target = new_target_sp.get();
417 if (target == nullptr || error.Fail()) {
418 result.AppendError(error.AsCString("Error creating target"));
421 GetDebugger().GetTargetList().SetSelectedTarget(target);
424 // Record the old executable module, we want to issue a warning if the
425 // process of attaching changed the current executable (like somebody said
426 // "file foo" then attached to a PID whose executable was bar.)
428 ModuleSP old_exec_module_sp = target->GetExecutableModule();
429 ArchSpec old_arch_spec = target->GetArchitecture();
431 if (command.GetArgumentCount()) {
432 result.AppendErrorWithFormat("Invalid arguments for '%s'.\nUsage: %s\n",
433 m_cmd_name.c_str(), m_cmd_syntax.c_str());
434 result.SetStatus(eReturnStatusFailed);
438 m_interpreter.UpdateExecutionContext(nullptr);
440 const auto error = target->Attach(m_options.attach_info, &stream);
441 if (error.Success()) {
442 ProcessSP process_sp(target->GetProcessSP());
444 result.AppendMessage(stream.GetString());
445 result.SetStatus(eReturnStatusSuccessFinishNoResult);
446 result.SetDidChangeProcessState(true);
447 result.SetAbnormalStopWasExpected(true);
450 "no error returned from Target::Attach, and target has no process");
451 result.SetStatus(eReturnStatusFailed);
454 result.AppendErrorWithFormat("attach failed: %s\n", error.AsCString());
455 result.SetStatus(eReturnStatusFailed);
458 if (!result.Succeeded())
461 // Okay, we're done. Last step is to warn if the executable module has
463 char new_path[PATH_MAX];
464 ModuleSP new_exec_module_sp(target->GetExecutableModule());
465 if (!old_exec_module_sp) {
466 // We might not have a module if we attached to a raw pid...
467 if (new_exec_module_sp) {
468 new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);
469 result.AppendMessageWithFormat("Executable module set to \"%s\".\n",
472 } else if (old_exec_module_sp->GetFileSpec() !=
473 new_exec_module_sp->GetFileSpec()) {
474 char old_path[PATH_MAX];
476 old_exec_module_sp->GetFileSpec().GetPath(old_path, PATH_MAX);
477 new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);
479 result.AppendWarningWithFormat(
480 "Executable module changed from \"%s\" to \"%s\".\n", old_path,
484 if (!old_arch_spec.IsValid()) {
485 result.AppendMessageWithFormat(
486 "Architecture set to: %s.\n",
487 target->GetArchitecture().GetTriple().getTriple().c_str());
488 } else if (!old_arch_spec.IsExactMatch(target->GetArchitecture())) {
489 result.AppendWarningWithFormat(
490 "Architecture changed from %s to %s.\n",
491 old_arch_spec.GetTriple().getTriple().c_str(),
492 target->GetArchitecture().GetTriple().getTriple().c_str());
495 // This supports the use-case scenario of immediately continuing the
496 // process once attached.
497 if (m_options.attach_info.GetContinueOnceAttached())
498 m_interpreter.HandleCommand("process continue", eLazyBoolNo, result);
500 return result.Succeeded();
503 CommandOptions m_options;
506 // CommandObjectProcessContinue
508 static constexpr OptionDefinition g_process_continue_options[] = {
510 { LLDB_OPT_SET_ALL, false, "ignore-count",'i', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Ignore <N> crossings of the breakpoint (if it exists) for the currently selected thread." }
514 #pragma mark CommandObjectProcessContinue
516 class CommandObjectProcessContinue : public CommandObjectParsed {
518 CommandObjectProcessContinue(CommandInterpreter &interpreter)
519 : CommandObjectParsed(
520 interpreter, "process continue",
521 "Continue execution of all threads in the current process.",
523 eCommandRequiresProcess | eCommandTryTargetAPILock |
524 eCommandProcessMustBeLaunched | eCommandProcessMustBePaused),
527 ~CommandObjectProcessContinue() override = default;
530 class CommandOptions : public Options {
532 CommandOptions() : Options() {
533 // Keep default values of all options in one place: OptionParsingStarting
535 OptionParsingStarting(nullptr);
538 ~CommandOptions() override = default;
540 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
541 ExecutionContext *execution_context) override {
543 const int short_option = m_getopt_table[option_idx].val;
544 switch (short_option) {
546 if (option_arg.getAsInteger(0, m_ignore))
547 error.SetErrorStringWithFormat(
548 "invalid value for ignore option: \"%s\", should be a number.",
549 option_arg.str().c_str());
553 error.SetErrorStringWithFormat("invalid short option character '%c'",
560 void OptionParsingStarting(ExecutionContext *execution_context) override {
564 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
565 return llvm::makeArrayRef(g_process_continue_options);
571 bool DoExecute(Args &command, CommandReturnObject &result) override {
572 Process *process = m_exe_ctx.GetProcessPtr();
573 bool synchronous_execution = m_interpreter.GetSynchronous();
574 StateType state = process->GetState();
575 if (state == eStateStopped) {
576 if (command.GetArgumentCount() != 0) {
577 result.AppendErrorWithFormat(
578 "The '%s' command does not take any arguments.\n",
580 result.SetStatus(eReturnStatusFailed);
584 if (m_options.m_ignore > 0) {
585 ThreadSP sel_thread_sp(GetDefaultThread()->shared_from_this());
587 StopInfoSP stop_info_sp = sel_thread_sp->GetStopInfo();
589 stop_info_sp->GetStopReason() == eStopReasonBreakpoint) {
590 lldb::break_id_t bp_site_id =
591 (lldb::break_id_t)stop_info_sp->GetValue();
592 BreakpointSiteSP bp_site_sp(
593 process->GetBreakpointSiteList().FindByID(bp_site_id));
595 const size_t num_owners = bp_site_sp->GetNumberOfOwners();
596 for (size_t i = 0; i < num_owners; i++) {
598 bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
599 if (!bp_ref.IsInternal()) {
600 bp_ref.SetIgnoreCount(m_options.m_ignore);
608 { // Scope for thread list mutex:
609 std::lock_guard<std::recursive_mutex> guard(
610 process->GetThreadList().GetMutex());
611 const uint32_t num_threads = process->GetThreadList().GetSize();
613 // Set the actions that the threads should each take when resuming
614 for (uint32_t idx = 0; idx < num_threads; ++idx) {
615 const bool override_suspend = false;
616 process->GetThreadList().GetThreadAtIndex(idx)->SetResumeState(
617 eStateRunning, override_suspend);
621 const uint32_t iohandler_id = process->GetIOHandlerID();
625 if (synchronous_execution)
626 error = process->ResumeSynchronous(&stream);
628 error = process->Resume();
630 if (error.Success()) {
631 // There is a race condition where this thread will return up the call
632 // stack to the main command handler and show an (lldb) prompt before
633 // HandlePrivateEvent (from PrivateStateThread) has a chance to call
634 // PushProcessIOHandler().
635 process->SyncIOHandler(iohandler_id, std::chrono::seconds(2));
637 result.AppendMessageWithFormat("Process %" PRIu64 " resuming\n",
639 if (synchronous_execution) {
640 // If any state changed events had anything to say, add that to the
642 result.AppendMessage(stream.GetString());
644 result.SetDidChangeProcessState(true);
645 result.SetStatus(eReturnStatusSuccessFinishNoResult);
647 result.SetStatus(eReturnStatusSuccessContinuingNoResult);
650 result.AppendErrorWithFormat("Failed to resume process: %s.\n",
652 result.SetStatus(eReturnStatusFailed);
655 result.AppendErrorWithFormat(
656 "Process cannot be continued from its current state (%s).\n",
657 StateAsCString(state));
658 result.SetStatus(eReturnStatusFailed);
660 return result.Succeeded();
663 Options *GetOptions() override { return &m_options; }
665 CommandOptions m_options;
668 // CommandObjectProcessDetach
669 static constexpr OptionDefinition g_process_detach_options[] = {
671 { LLDB_OPT_SET_1, false, "keep-stopped", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." },
675 #pragma mark CommandObjectProcessDetach
677 class CommandObjectProcessDetach : public CommandObjectParsed {
679 class CommandOptions : public Options {
681 CommandOptions() : Options() { OptionParsingStarting(nullptr); }
683 ~CommandOptions() override = default;
685 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
686 ExecutionContext *execution_context) override {
688 const int short_option = m_getopt_table[option_idx].val;
690 switch (short_option) {
694 tmp_result = OptionArgParser::ToBoolean(option_arg, false, &success);
696 error.SetErrorStringWithFormat("invalid boolean option: \"%s\"",
697 option_arg.str().c_str());
700 m_keep_stopped = eLazyBoolYes;
702 m_keep_stopped = eLazyBoolNo;
706 error.SetErrorStringWithFormat("invalid short option character '%c'",
713 void OptionParsingStarting(ExecutionContext *execution_context) override {
714 m_keep_stopped = eLazyBoolCalculate;
717 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
718 return llvm::makeArrayRef(g_process_detach_options);
721 // Instance variables to hold the values for command options.
722 LazyBool m_keep_stopped;
725 CommandObjectProcessDetach(CommandInterpreter &interpreter)
726 : CommandObjectParsed(interpreter, "process detach",
727 "Detach from the current target process.",
729 eCommandRequiresProcess | eCommandTryTargetAPILock |
730 eCommandProcessMustBeLaunched),
733 ~CommandObjectProcessDetach() override = default;
735 Options *GetOptions() override { return &m_options; }
738 bool DoExecute(Args &command, CommandReturnObject &result) override {
739 Process *process = m_exe_ctx.GetProcessPtr();
740 // FIXME: This will be a Command Option:
742 if (m_options.m_keep_stopped == eLazyBoolCalculate) {
743 // Check the process default:
744 keep_stopped = process->GetDetachKeepsStopped();
745 } else if (m_options.m_keep_stopped == eLazyBoolYes)
748 keep_stopped = false;
750 Status error(process->Detach(keep_stopped));
751 if (error.Success()) {
752 result.SetStatus(eReturnStatusSuccessFinishResult);
754 result.AppendErrorWithFormat("Detach failed: %s\n", error.AsCString());
755 result.SetStatus(eReturnStatusFailed);
758 return result.Succeeded();
761 CommandOptions m_options;
764 // CommandObjectProcessConnect
766 static constexpr OptionDefinition g_process_connect_options[] = {
768 { LLDB_OPT_SET_ALL, false, "plugin", 'p', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePlugin, "Name of the process plugin you want to use." },
772 #pragma mark CommandObjectProcessConnect
774 class CommandObjectProcessConnect : public CommandObjectParsed {
776 class CommandOptions : public Options {
778 CommandOptions() : Options() {
779 // Keep default values of all options in one place: OptionParsingStarting
781 OptionParsingStarting(nullptr);
784 ~CommandOptions() override = default;
786 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
787 ExecutionContext *execution_context) override {
789 const int short_option = m_getopt_table[option_idx].val;
791 switch (short_option) {
793 plugin_name.assign(option_arg);
797 error.SetErrorStringWithFormat("invalid short option character '%c'",
804 void OptionParsingStarting(ExecutionContext *execution_context) override {
808 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
809 return llvm::makeArrayRef(g_process_connect_options);
812 // Instance variables to hold the values for command options.
814 std::string plugin_name;
817 CommandObjectProcessConnect(CommandInterpreter &interpreter)
818 : CommandObjectParsed(interpreter, "process connect",
819 "Connect to a remote debug service.",
820 "process connect <remote-url>", 0),
823 ~CommandObjectProcessConnect() override = default;
825 Options *GetOptions() override { return &m_options; }
828 bool DoExecute(Args &command, CommandReturnObject &result) override {
829 if (command.GetArgumentCount() != 1) {
830 result.AppendErrorWithFormat(
831 "'%s' takes exactly one argument:\nUsage: %s\n", m_cmd_name.c_str(),
832 m_cmd_syntax.c_str());
833 result.SetStatus(eReturnStatusFailed);
837 Process *process = m_exe_ctx.GetProcessPtr();
838 if (process && process->IsAlive()) {
839 result.AppendErrorWithFormat(
841 " is currently being debugged, kill the process before connecting.\n",
843 result.SetStatus(eReturnStatusFailed);
847 const char *plugin_name = nullptr;
848 if (!m_options.plugin_name.empty())
849 plugin_name = m_options.plugin_name.c_str();
852 Debugger &debugger = GetDebugger();
853 PlatformSP platform_sp = m_interpreter.GetPlatform(true);
854 ProcessSP process_sp = platform_sp->ConnectProcess(
855 command.GetArgumentAtIndex(0), plugin_name, debugger,
856 debugger.GetSelectedTarget().get(), error);
857 if (error.Fail() || process_sp == nullptr) {
858 result.AppendError(error.AsCString("Error connecting to the process"));
859 result.SetStatus(eReturnStatusFailed);
865 CommandOptions m_options;
868 // CommandObjectProcessPlugin
869 #pragma mark CommandObjectProcessPlugin
871 class CommandObjectProcessPlugin : public CommandObjectProxy {
873 CommandObjectProcessPlugin(CommandInterpreter &interpreter)
874 : CommandObjectProxy(
875 interpreter, "process plugin",
876 "Send a custom command to the current target process plug-in.",
877 "process plugin <args>", 0) {}
879 ~CommandObjectProcessPlugin() override = default;
881 CommandObject *GetProxyCommandObject() override {
882 Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
884 return process->GetPluginCommandObject();
889 // CommandObjectProcessLoad
891 static constexpr OptionDefinition g_process_load_options[] = {
893 { LLDB_OPT_SET_ALL, false, "install", 'i', OptionParser::eOptionalArgument, 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." },
897 #pragma mark CommandObjectProcessLoad
899 class CommandObjectProcessLoad : public CommandObjectParsed {
901 class CommandOptions : public Options {
903 CommandOptions() : Options() {
904 // Keep default values of all options in one place: OptionParsingStarting
906 OptionParsingStarting(nullptr);
909 ~CommandOptions() override = default;
911 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
912 ExecutionContext *execution_context) override {
914 const int short_option = m_getopt_table[option_idx].val;
915 switch (short_option) {
918 if (!option_arg.empty())
919 install_path.SetFile(option_arg, FileSpec::Style::native);
922 error.SetErrorStringWithFormat("invalid short option character '%c'",
929 void OptionParsingStarting(ExecutionContext *execution_context) override {
931 install_path.Clear();
934 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
935 return llvm::makeArrayRef(g_process_load_options);
938 // Instance variables to hold the values for command options.
940 FileSpec install_path;
943 CommandObjectProcessLoad(CommandInterpreter &interpreter)
944 : CommandObjectParsed(interpreter, "process load",
945 "Load a shared library into the current process.",
946 "process load <filename> [<filename> ...]",
947 eCommandRequiresProcess | eCommandTryTargetAPILock |
948 eCommandProcessMustBeLaunched |
949 eCommandProcessMustBePaused),
952 ~CommandObjectProcessLoad() override = default;
954 Options *GetOptions() override { return &m_options; }
957 bool DoExecute(Args &command, CommandReturnObject &result) override {
958 Process *process = m_exe_ctx.GetProcessPtr();
960 for (auto &entry : command.entries()) {
962 PlatformSP platform = process->GetTarget().GetPlatform();
963 llvm::StringRef image_path = entry.ref;
964 uint32_t image_token = LLDB_INVALID_IMAGE_TOKEN;
966 if (!m_options.do_install) {
967 FileSpec image_spec(image_path);
968 platform->ResolveRemotePath(image_spec, image_spec);
970 platform->LoadImage(process, FileSpec(), image_spec, error);
971 } else if (m_options.install_path) {
972 FileSpec image_spec(image_path);
973 FileSystem::Instance().Resolve(image_spec);
974 platform->ResolveRemotePath(m_options.install_path,
975 m_options.install_path);
976 image_token = platform->LoadImage(process, image_spec,
977 m_options.install_path, error);
979 FileSpec image_spec(image_path);
980 FileSystem::Instance().Resolve(image_spec);
982 platform->LoadImage(process, image_spec, FileSpec(), error);
985 if (image_token != LLDB_INVALID_IMAGE_TOKEN) {
986 result.AppendMessageWithFormat(
987 "Loading \"%s\"...ok\nImage %u loaded.\n", image_path.str().c_str(),
989 result.SetStatus(eReturnStatusSuccessFinishResult);
991 result.AppendErrorWithFormat("failed to load '%s': %s",
992 image_path.str().c_str(),
994 result.SetStatus(eReturnStatusFailed);
997 return result.Succeeded();
1000 CommandOptions m_options;
1003 // CommandObjectProcessUnload
1004 #pragma mark CommandObjectProcessUnload
1006 class CommandObjectProcessUnload : public CommandObjectParsed {
1008 CommandObjectProcessUnload(CommandInterpreter &interpreter)
1009 : CommandObjectParsed(
1010 interpreter, "process unload",
1011 "Unload a shared library from the current process using the index "
1012 "returned by a previous call to \"process load\".",
1013 "process unload <index>",
1014 eCommandRequiresProcess | eCommandTryTargetAPILock |
1015 eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {}
1017 ~CommandObjectProcessUnload() override = default;
1020 bool DoExecute(Args &command, CommandReturnObject &result) override {
1021 Process *process = m_exe_ctx.GetProcessPtr();
1023 for (auto &entry : command.entries()) {
1024 uint32_t image_token;
1025 if (entry.ref.getAsInteger(0, image_token)) {
1026 result.AppendErrorWithFormat("invalid image index argument '%s'",
1027 entry.ref.str().c_str());
1028 result.SetStatus(eReturnStatusFailed);
1031 Status error(process->GetTarget().GetPlatform()->UnloadImage(
1032 process, image_token));
1033 if (error.Success()) {
1034 result.AppendMessageWithFormat(
1035 "Unloading shared library with index %u...ok\n", image_token);
1036 result.SetStatus(eReturnStatusSuccessFinishResult);
1038 result.AppendErrorWithFormat("failed to unload image: %s",
1040 result.SetStatus(eReturnStatusFailed);
1045 return result.Succeeded();
1049 // CommandObjectProcessSignal
1050 #pragma mark CommandObjectProcessSignal
1052 class CommandObjectProcessSignal : public CommandObjectParsed {
1054 CommandObjectProcessSignal(CommandInterpreter &interpreter)
1055 : CommandObjectParsed(interpreter, "process signal",
1056 "Send a UNIX signal to the current target process.",
1057 nullptr, eCommandRequiresProcess |
1058 eCommandTryTargetAPILock) {
1059 CommandArgumentEntry arg;
1060 CommandArgumentData signal_arg;
1062 // Define the first (and only) variant of this arg.
1063 signal_arg.arg_type = eArgTypeUnixSignal;
1064 signal_arg.arg_repetition = eArgRepeatPlain;
1066 // There is only one variant this argument could be; put it into the
1068 arg.push_back(signal_arg);
1070 // Push the data for the first argument into the m_arguments vector.
1071 m_arguments.push_back(arg);
1074 ~CommandObjectProcessSignal() override = default;
1077 bool DoExecute(Args &command, CommandReturnObject &result) override {
1078 Process *process = m_exe_ctx.GetProcessPtr();
1080 if (command.GetArgumentCount() == 1) {
1081 int signo = LLDB_INVALID_SIGNAL_NUMBER;
1083 const char *signal_name = command.GetArgumentAtIndex(0);
1084 if (::isxdigit(signal_name[0]))
1086 StringConvert::ToSInt32(signal_name, LLDB_INVALID_SIGNAL_NUMBER, 0);
1088 signo = process->GetUnixSignals()->GetSignalNumberFromName(signal_name);
1090 if (signo == LLDB_INVALID_SIGNAL_NUMBER) {
1091 result.AppendErrorWithFormat("Invalid signal argument '%s'.\n",
1092 command.GetArgumentAtIndex(0));
1093 result.SetStatus(eReturnStatusFailed);
1095 Status error(process->Signal(signo));
1096 if (error.Success()) {
1097 result.SetStatus(eReturnStatusSuccessFinishResult);
1099 result.AppendErrorWithFormat("Failed to send signal %i: %s\n", signo,
1101 result.SetStatus(eReturnStatusFailed);
1105 result.AppendErrorWithFormat(
1106 "'%s' takes exactly one signal number argument:\nUsage: %s\n",
1107 m_cmd_name.c_str(), m_cmd_syntax.c_str());
1108 result.SetStatus(eReturnStatusFailed);
1110 return result.Succeeded();
1114 // CommandObjectProcessInterrupt
1115 #pragma mark CommandObjectProcessInterrupt
1117 class CommandObjectProcessInterrupt : public CommandObjectParsed {
1119 CommandObjectProcessInterrupt(CommandInterpreter &interpreter)
1120 : CommandObjectParsed(interpreter, "process interrupt",
1121 "Interrupt the current target process.",
1122 "process interrupt",
1123 eCommandRequiresProcess | eCommandTryTargetAPILock |
1124 eCommandProcessMustBeLaunched) {}
1126 ~CommandObjectProcessInterrupt() override = default;
1129 bool DoExecute(Args &command, CommandReturnObject &result) override {
1130 Process *process = m_exe_ctx.GetProcessPtr();
1131 if (process == nullptr) {
1132 result.AppendError("no process to halt");
1133 result.SetStatus(eReturnStatusFailed);
1137 if (command.GetArgumentCount() == 0) {
1138 bool clear_thread_plans = true;
1139 Status error(process->Halt(clear_thread_plans));
1140 if (error.Success()) {
1141 result.SetStatus(eReturnStatusSuccessFinishResult);
1143 result.AppendErrorWithFormat("Failed to halt process: %s\n",
1145 result.SetStatus(eReturnStatusFailed);
1148 result.AppendErrorWithFormat("'%s' takes no arguments:\nUsage: %s\n",
1149 m_cmd_name.c_str(), m_cmd_syntax.c_str());
1150 result.SetStatus(eReturnStatusFailed);
1152 return result.Succeeded();
1156 // CommandObjectProcessKill
1157 #pragma mark CommandObjectProcessKill
1159 class CommandObjectProcessKill : public CommandObjectParsed {
1161 CommandObjectProcessKill(CommandInterpreter &interpreter)
1162 : CommandObjectParsed(interpreter, "process kill",
1163 "Terminate the current target process.",
1165 eCommandRequiresProcess | eCommandTryTargetAPILock |
1166 eCommandProcessMustBeLaunched) {}
1168 ~CommandObjectProcessKill() override = default;
1171 bool DoExecute(Args &command, CommandReturnObject &result) override {
1172 Process *process = m_exe_ctx.GetProcessPtr();
1173 if (process == nullptr) {
1174 result.AppendError("no process to kill");
1175 result.SetStatus(eReturnStatusFailed);
1179 if (command.GetArgumentCount() == 0) {
1180 Status error(process->Destroy(true));
1181 if (error.Success()) {
1182 result.SetStatus(eReturnStatusSuccessFinishResult);
1184 result.AppendErrorWithFormat("Failed to kill process: %s\n",
1186 result.SetStatus(eReturnStatusFailed);
1189 result.AppendErrorWithFormat("'%s' takes no arguments:\nUsage: %s\n",
1190 m_cmd_name.c_str(), m_cmd_syntax.c_str());
1191 result.SetStatus(eReturnStatusFailed);
1193 return result.Succeeded();
1197 // CommandObjectProcessSaveCore
1198 #pragma mark CommandObjectProcessSaveCore
1200 class CommandObjectProcessSaveCore : public CommandObjectParsed {
1202 CommandObjectProcessSaveCore(CommandInterpreter &interpreter)
1203 : CommandObjectParsed(interpreter, "process save-core",
1204 "Save the current process as a core file using an "
1205 "appropriate file type.",
1206 "process save-core FILE",
1207 eCommandRequiresProcess | eCommandTryTargetAPILock |
1208 eCommandProcessMustBeLaunched) {}
1210 ~CommandObjectProcessSaveCore() override = default;
1213 bool DoExecute(Args &command, CommandReturnObject &result) override {
1214 ProcessSP process_sp = m_exe_ctx.GetProcessSP();
1216 if (command.GetArgumentCount() == 1) {
1217 FileSpec output_file(command.GetArgumentAtIndex(0));
1218 Status error = PluginManager::SaveCore(process_sp, output_file);
1219 if (error.Success()) {
1220 result.SetStatus(eReturnStatusSuccessFinishResult);
1222 result.AppendErrorWithFormat(
1223 "Failed to save core file for process: %s\n", error.AsCString());
1224 result.SetStatus(eReturnStatusFailed);
1227 result.AppendErrorWithFormat("'%s' takes one arguments:\nUsage: %s\n",
1228 m_cmd_name.c_str(), m_cmd_syntax.c_str());
1229 result.SetStatus(eReturnStatusFailed);
1232 result.AppendError("invalid process");
1233 result.SetStatus(eReturnStatusFailed);
1237 return result.Succeeded();
1241 // CommandObjectProcessStatus
1242 #pragma mark CommandObjectProcessStatus
1244 class CommandObjectProcessStatus : public CommandObjectParsed {
1246 CommandObjectProcessStatus(CommandInterpreter &interpreter)
1247 : CommandObjectParsed(
1248 interpreter, "process status",
1249 "Show status and stop location for the current target process.",
1251 eCommandRequiresProcess | eCommandTryTargetAPILock) {}
1253 ~CommandObjectProcessStatus() override = default;
1255 bool DoExecute(Args &command, CommandReturnObject &result) override {
1256 Stream &strm = result.GetOutputStream();
1257 result.SetStatus(eReturnStatusSuccessFinishNoResult);
1258 // No need to check "process" for validity as eCommandRequiresProcess
1259 // ensures it is valid
1260 Process *process = m_exe_ctx.GetProcessPtr();
1261 const bool only_threads_with_stop_reason = true;
1262 const uint32_t start_frame = 0;
1263 const uint32_t num_frames = 1;
1264 const uint32_t num_frames_with_source = 1;
1265 const bool stop_format = true;
1266 process->GetStatus(strm);
1267 process->GetThreadStatus(strm, only_threads_with_stop_reason, start_frame,
1268 num_frames, num_frames_with_source, stop_format);
1269 return result.Succeeded();
1273 // CommandObjectProcessHandle
1275 static constexpr OptionDefinition g_process_handle_options[] = {
1277 { LLDB_OPT_SET_1, false, "stop", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Whether or not the process should be stopped if the signal is received." },
1278 { LLDB_OPT_SET_1, false, "notify", 'n', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Whether or not the debugger should notify the user if the signal is received." },
1279 { LLDB_OPT_SET_1, false, "pass", 'p', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Whether or not the signal should be passed to the process." }
1283 #pragma mark CommandObjectProcessHandle
1285 class CommandObjectProcessHandle : public CommandObjectParsed {
1287 class CommandOptions : public Options {
1289 CommandOptions() : Options() { OptionParsingStarting(nullptr); }
1291 ~CommandOptions() override = default;
1293 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1294 ExecutionContext *execution_context) override {
1296 const int short_option = m_getopt_table[option_idx].val;
1298 switch (short_option) {
1303 notify = option_arg;
1309 error.SetErrorStringWithFormat("invalid short option character '%c'",
1316 void OptionParsingStarting(ExecutionContext *execution_context) override {
1322 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1323 return llvm::makeArrayRef(g_process_handle_options);
1326 // Instance variables to hold the values for command options.
1333 CommandObjectProcessHandle(CommandInterpreter &interpreter)
1334 : CommandObjectParsed(interpreter, "process handle",
1335 "Manage LLDB handling of OS signals for the "
1336 "current target process. Defaults to showing "
1340 SetHelpLong("\nIf no signals are specified, update them all. If no update "
1341 "option is specified, list the current values.");
1342 CommandArgumentEntry arg;
1343 CommandArgumentData signal_arg;
1345 signal_arg.arg_type = eArgTypeUnixSignal;
1346 signal_arg.arg_repetition = eArgRepeatStar;
1348 arg.push_back(signal_arg);
1350 m_arguments.push_back(arg);
1353 ~CommandObjectProcessHandle() override = default;
1355 Options *GetOptions() override { return &m_options; }
1357 bool VerifyCommandOptionValue(const std::string &option, int &real_value) {
1359 bool success = false;
1360 bool tmp_value = OptionArgParser::ToBoolean(option, false, &success);
1362 if (success && tmp_value)
1364 else if (success && !tmp_value)
1367 // If the value isn't 'true' or 'false', it had better be 0 or 1.
1368 real_value = StringConvert::ToUInt32(option.c_str(), 3);
1369 if (real_value != 0 && real_value != 1)
1376 void PrintSignalHeader(Stream &str) {
1377 str.Printf("NAME PASS STOP NOTIFY\n");
1378 str.Printf("=========== ===== ===== ======\n");
1381 void PrintSignal(Stream &str, int32_t signo, const char *sig_name,
1382 const UnixSignalsSP &signals_sp) {
1387 str.Printf("%-11s ", sig_name);
1388 if (signals_sp->GetSignalInfo(signo, suppress, stop, notify)) {
1389 bool pass = !suppress;
1390 str.Printf("%s %s %s", (pass ? "true " : "false"),
1391 (stop ? "true " : "false"), (notify ? "true " : "false"));
1396 void PrintSignalInformation(Stream &str, Args &signal_args,
1397 int num_valid_signals,
1398 const UnixSignalsSP &signals_sp) {
1399 PrintSignalHeader(str);
1401 if (num_valid_signals > 0) {
1402 size_t num_args = signal_args.GetArgumentCount();
1403 for (size_t i = 0; i < num_args; ++i) {
1404 int32_t signo = signals_sp->GetSignalNumberFromName(
1405 signal_args.GetArgumentAtIndex(i));
1406 if (signo != LLDB_INVALID_SIGNAL_NUMBER)
1407 PrintSignal(str, signo, signal_args.GetArgumentAtIndex(i),
1410 } else // Print info for ALL signals
1412 int32_t signo = signals_sp->GetFirstSignalNumber();
1413 while (signo != LLDB_INVALID_SIGNAL_NUMBER) {
1414 PrintSignal(str, signo, signals_sp->GetSignalAsCString(signo),
1416 signo = signals_sp->GetNextSignalNumber(signo);
1422 bool DoExecute(Args &signal_args, CommandReturnObject &result) override {
1423 TargetSP target_sp = GetDebugger().GetSelectedTarget();
1426 result.AppendError("No current target;"
1427 " cannot handle signals until you have a valid target "
1429 result.SetStatus(eReturnStatusFailed);
1433 ProcessSP process_sp = target_sp->GetProcessSP();
1436 result.AppendError("No current process; cannot handle signals until you "
1437 "have a valid process.\n");
1438 result.SetStatus(eReturnStatusFailed);
1442 int stop_action = -1; // -1 means leave the current setting alone
1443 int pass_action = -1; // -1 means leave the current setting alone
1444 int notify_action = -1; // -1 means leave the current setting alone
1446 if (!m_options.stop.empty() &&
1447 !VerifyCommandOptionValue(m_options.stop, stop_action)) {
1448 result.AppendError("Invalid argument for command option --stop; must be "
1449 "true or false.\n");
1450 result.SetStatus(eReturnStatusFailed);
1454 if (!m_options.notify.empty() &&
1455 !VerifyCommandOptionValue(m_options.notify, notify_action)) {
1456 result.AppendError("Invalid argument for command option --notify; must "
1457 "be true or false.\n");
1458 result.SetStatus(eReturnStatusFailed);
1462 if (!m_options.pass.empty() &&
1463 !VerifyCommandOptionValue(m_options.pass, pass_action)) {
1464 result.AppendError("Invalid argument for command option --pass; must be "
1465 "true or false.\n");
1466 result.SetStatus(eReturnStatusFailed);
1470 size_t num_args = signal_args.GetArgumentCount();
1471 UnixSignalsSP signals_sp = process_sp->GetUnixSignals();
1472 int num_signals_set = 0;
1475 for (const auto &arg : signal_args) {
1476 int32_t signo = signals_sp->GetSignalNumberFromName(arg.c_str());
1477 if (signo != LLDB_INVALID_SIGNAL_NUMBER) {
1478 // Casting the actions as bools here should be okay, because
1479 // VerifyCommandOptionValue guarantees the value is either 0 or 1.
1480 if (stop_action != -1)
1481 signals_sp->SetShouldStop(signo, stop_action);
1482 if (pass_action != -1) {
1483 bool suppress = !pass_action;
1484 signals_sp->SetShouldSuppress(signo, suppress);
1486 if (notify_action != -1)
1487 signals_sp->SetShouldNotify(signo, notify_action);
1490 result.AppendErrorWithFormat("Invalid signal name '%s'\n",
1495 // No signal specified, if any command options were specified, update ALL
1497 if ((notify_action != -1) || (stop_action != -1) || (pass_action != -1)) {
1498 if (m_interpreter.Confirm(
1499 "Do you really want to update all the signals?", false)) {
1500 int32_t signo = signals_sp->GetFirstSignalNumber();
1501 while (signo != LLDB_INVALID_SIGNAL_NUMBER) {
1502 if (notify_action != -1)
1503 signals_sp->SetShouldNotify(signo, notify_action);
1504 if (stop_action != -1)
1505 signals_sp->SetShouldStop(signo, stop_action);
1506 if (pass_action != -1) {
1507 bool suppress = !pass_action;
1508 signals_sp->SetShouldSuppress(signo, suppress);
1510 signo = signals_sp->GetNextSignalNumber(signo);
1516 PrintSignalInformation(result.GetOutputStream(), signal_args,
1517 num_signals_set, signals_sp);
1519 if (num_signals_set > 0)
1520 result.SetStatus(eReturnStatusSuccessFinishNoResult);
1522 result.SetStatus(eReturnStatusFailed);
1524 return result.Succeeded();
1527 CommandOptions m_options;
1530 // CommandObjectMultiwordProcess
1532 CommandObjectMultiwordProcess::CommandObjectMultiwordProcess(
1533 CommandInterpreter &interpreter)
1534 : CommandObjectMultiword(
1535 interpreter, "process",
1536 "Commands for interacting with processes on the current platform.",
1537 "process <subcommand> [<subcommand-options>]") {
1538 LoadSubCommand("attach",
1539 CommandObjectSP(new CommandObjectProcessAttach(interpreter)));
1540 LoadSubCommand("launch",
1541 CommandObjectSP(new CommandObjectProcessLaunch(interpreter)));
1542 LoadSubCommand("continue", CommandObjectSP(new CommandObjectProcessContinue(
1544 LoadSubCommand("connect",
1545 CommandObjectSP(new CommandObjectProcessConnect(interpreter)));
1546 LoadSubCommand("detach",
1547 CommandObjectSP(new CommandObjectProcessDetach(interpreter)));
1548 LoadSubCommand("load",
1549 CommandObjectSP(new CommandObjectProcessLoad(interpreter)));
1550 LoadSubCommand("unload",
1551 CommandObjectSP(new CommandObjectProcessUnload(interpreter)));
1552 LoadSubCommand("signal",
1553 CommandObjectSP(new CommandObjectProcessSignal(interpreter)));
1554 LoadSubCommand("handle",
1555 CommandObjectSP(new CommandObjectProcessHandle(interpreter)));
1556 LoadSubCommand("status",
1557 CommandObjectSP(new CommandObjectProcessStatus(interpreter)));
1558 LoadSubCommand("interrupt", CommandObjectSP(new CommandObjectProcessInterrupt(
1560 LoadSubCommand("kill",
1561 CommandObjectSP(new CommandObjectProcessKill(interpreter)));
1562 LoadSubCommand("plugin",
1563 CommandObjectSP(new CommandObjectProcessPlugin(interpreter)));
1564 LoadSubCommand("save-core", CommandObjectSP(new CommandObjectProcessSaveCore(
1568 CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess() = default;