1 //===-- CommandObjectProcess.cpp --------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/lldb-python.h"
12 #include "CommandObjectProcess.h"
16 // Other libraries and framework includes
18 #include "lldb/Breakpoint/Breakpoint.h"
19 #include "lldb/Breakpoint/BreakpointLocation.h"
20 #include "lldb/Breakpoint/BreakpointSite.h"
21 #include "lldb/Core/State.h"
22 #include "lldb/Core/Module.h"
23 #include "lldb/Host/Host.h"
24 #include "lldb/Interpreter/Args.h"
25 #include "lldb/Interpreter/Options.h"
26 #include "lldb/Interpreter/CommandInterpreter.h"
27 #include "lldb/Interpreter/CommandReturnObject.h"
28 #include "lldb/Target/Platform.h"
29 #include "lldb/Target/Process.h"
30 #include "lldb/Target/StopInfo.h"
31 #include "lldb/Target/Target.h"
32 #include "lldb/Target/Thread.h"
35 using namespace lldb_private;
37 class CommandObjectProcessLaunchOrAttach : public CommandObjectParsed
40 CommandObjectProcessLaunchOrAttach (CommandInterpreter &interpreter,
45 const char *new_process_action) :
46 CommandObjectParsed (interpreter, name, help, syntax, flags),
47 m_new_process_action (new_process_action) {}
49 virtual ~CommandObjectProcessLaunchOrAttach () {}
52 StopProcessIfNecessary (Process *&process, StateType &state, CommandReturnObject &result)
54 state = eStateInvalid;
57 state = process->GetState();
59 if (process->IsAlive() && state != eStateConnected)
62 if (process->GetState() == eStateAttaching)
63 ::snprintf (message, sizeof(message), "There is a pending attach, abort it and %s?", m_new_process_action.c_str());
64 else if (process->GetShouldDetach())
65 ::snprintf (message, sizeof(message), "There is a running process, detach from it and %s?", m_new_process_action.c_str());
67 ::snprintf (message, sizeof(message), "There is a running process, kill it and %s?", m_new_process_action.c_str());
69 if (!m_interpreter.Confirm (message, true))
71 result.SetStatus (eReturnStatusFailed);
76 if (process->GetShouldDetach())
78 bool keep_stopped = false;
79 Error detach_error (process->Detach(keep_stopped));
80 if (detach_error.Success())
82 result.SetStatus (eReturnStatusSuccessFinishResult);
87 result.AppendErrorWithFormat ("Failed to detach from process: %s\n", detach_error.AsCString());
88 result.SetStatus (eReturnStatusFailed);
93 Error destroy_error (process->Destroy());
94 if (destroy_error.Success())
96 result.SetStatus (eReturnStatusSuccessFinishResult);
101 result.AppendErrorWithFormat ("Failed to kill process: %s\n", destroy_error.AsCString());
102 result.SetStatus (eReturnStatusFailed);
108 return result.Succeeded();
110 std::string m_new_process_action;
112 //-------------------------------------------------------------------------
113 // CommandObjectProcessLaunch
114 //-------------------------------------------------------------------------
115 #pragma mark CommandObjectProcessLaunch
116 class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach
120 CommandObjectProcessLaunch (CommandInterpreter &interpreter) :
121 CommandObjectProcessLaunchOrAttach (interpreter,
123 "Launch the executable in the debugger.",
127 m_options (interpreter)
129 CommandArgumentEntry arg;
130 CommandArgumentData run_args_arg;
132 // Define the first (and only) variant of this arg.
133 run_args_arg.arg_type = eArgTypeRunArgs;
134 run_args_arg.arg_repetition = eArgRepeatOptional;
136 // There is only one variant this argument could be; put it into the argument entry.
137 arg.push_back (run_args_arg);
139 // Push the data for the first argument into the m_arguments vector.
140 m_arguments.push_back (arg);
144 ~CommandObjectProcessLaunch ()
149 HandleArgumentCompletion (Args &input,
151 int &cursor_char_position,
152 OptionElementVector &opt_element_vector,
153 int match_start_point,
154 int max_return_elements,
158 std::string completion_str (input.GetArgumentAtIndex(cursor_index));
159 completion_str.erase (cursor_char_position);
161 CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
162 CommandCompletions::eDiskFileCompletion,
163 completion_str.c_str(),
169 return matches.GetSize();
178 virtual const char *GetRepeatCommand (Args ¤t_command_args, uint32_t index)
180 // No repeat for "process launch"...
186 DoExecute (Args& launch_args, CommandReturnObject &result)
188 Debugger &debugger = m_interpreter.GetDebugger();
189 Target *target = debugger.GetSelectedTarget().get();
191 // If our listener is NULL, users aren't allows to launch
192 char filename[PATH_MAX];
193 const Module *exe_module = target->GetExecutableModulePointer();
195 if (exe_module == NULL)
197 result.AppendError ("no file in target, create a debug target using the 'target create' command");
198 result.SetStatus (eReturnStatusFailed);
202 StateType state = eStateInvalid;
203 Process *process = m_exe_ctx.GetProcessPtr();
205 if (!StopProcessIfNecessary(process, state, result))
208 const char *target_settings_argv0 = target->GetArg0();
210 exe_module->GetFileSpec().GetPath (filename, sizeof(filename));
212 if (target_settings_argv0)
214 m_options.launch_info.GetArguments().AppendArgument (target_settings_argv0);
215 m_options.launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), false);
219 m_options.launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
222 if (launch_args.GetArgumentCount() == 0)
224 Args target_setting_args;
225 if (target->GetRunArguments(target_setting_args))
226 m_options.launch_info.GetArguments().AppendArguments (target_setting_args);
230 m_options.launch_info.GetArguments().AppendArguments (launch_args);
232 // Save the arguments for subsequent runs in the current target.
233 target->SetRunArguments (launch_args);
236 if (target->GetDisableASLR())
237 m_options.launch_info.GetFlags().Set (eLaunchFlagDisableASLR);
239 if (target->GetDisableSTDIO())
240 m_options.launch_info.GetFlags().Set (eLaunchFlagDisableSTDIO);
242 m_options.launch_info.GetFlags().Set (eLaunchFlagDebug);
245 target->GetEnvironmentAsArgs (environment);
246 if (environment.GetArgumentCount() > 0)
247 m_options.launch_info.GetEnvironmentEntries ().AppendArguments (environment);
249 // Get the value of synchronous execution here. If you wait till after you have started to
250 // run, then you could have hit a breakpoint, whose command might switch the value, and
251 // then you'll pick up that incorrect value.
252 bool synchronous_execution = m_interpreter.GetSynchronous ();
254 // Finalize the file actions, and if none were given, default to opening
255 // up a pseudo terminal
256 const bool default_to_use_pty = true;
257 m_options.launch_info.FinalizeFileActions (target, default_to_use_pty);
259 if (state == eStateConnected)
261 if (m_options.launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY))
263 result.AppendWarning("can't launch in tty when launching through a remote connection");
264 m_options.launch_info.GetFlags().Clear (eLaunchFlagLaunchInTTY);
268 if (!m_options.launch_info.GetArchitecture().IsValid())
269 m_options.launch_info.GetArchitecture() = target->GetArchitecture();
271 PlatformSP platform_sp (target->GetPlatform());
273 if (platform_sp && platform_sp->CanDebugProcess ())
275 process = target->GetPlatform()->DebugProcess (m_options.launch_info,
278 debugger.GetListener(),
283 const char *plugin_name = m_options.launch_info.GetProcessPluginName();
284 process = target->CreateProcess (debugger.GetListener(), plugin_name, NULL).get();
286 error = process->Launch (m_options.launch_info);
291 result.SetError (error, "failed to launch or debug process");
298 const char *archname = exe_module->GetArchitecture().GetArchitectureName();
300 result.AppendMessageWithFormat ("Process %" PRIu64 " launched: '%s' (%s)\n", process->GetID(), filename, archname);
301 result.SetDidChangeProcessState (true);
302 if (m_options.launch_info.GetFlags().Test(eLaunchFlagStopAtEntry) == false)
304 result.SetStatus (eReturnStatusSuccessContinuingNoResult);
305 StateType state = process->WaitForProcessToStop (NULL);
307 if (state == eStateStopped)
309 error = process->Resume();
312 if (synchronous_execution)
314 state = process->WaitForProcessToStop (NULL);
315 const bool must_be_alive = true;
316 if (!StateIsStoppedState(state, must_be_alive))
318 result.AppendErrorWithFormat ("process isn't stopped: %s", StateAsCString(state));
320 result.SetDidChangeProcessState (true);
321 result.SetStatus (eReturnStatusSuccessFinishResult);
325 result.SetStatus (eReturnStatusSuccessContinuingNoResult);
330 result.AppendErrorWithFormat ("process resume at entry point failed: %s", error.AsCString());
331 result.SetStatus (eReturnStatusFailed);
336 result.AppendErrorWithFormat ("initial process state wasn't stopped: %s", StateAsCString(state));
337 result.SetStatus (eReturnStatusFailed);
343 result.AppendErrorWithFormat ("process launch failed: %s", error.AsCString());
344 result.SetStatus (eReturnStatusFailed);
347 return result.Succeeded();
351 ProcessLaunchCommandOptions m_options;
355 //#define SET1 LLDB_OPT_SET_1
356 //#define SET2 LLDB_OPT_SET_2
357 //#define SET3 LLDB_OPT_SET_3
360 //CommandObjectProcessLaunch::CommandOptions::g_option_table[] =
362 //{ SET1 | SET2 | SET3, false, "stop-at-entry", 's', no_argument, NULL, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."},
363 //{ SET1 , false, "stdin", 'i', required_argument, NULL, 0, eArgTypeDirectoryName, "Redirect stdin for the process to <path>."},
364 //{ SET1 , false, "stdout", 'o', required_argument, NULL, 0, eArgTypeDirectoryName, "Redirect stdout for the process to <path>."},
365 //{ SET1 , false, "stderr", 'e', required_argument, NULL, 0, eArgTypeDirectoryName, "Redirect stderr for the process to <path>."},
366 //{ SET1 | SET2 | SET3, false, "plugin", 'p', required_argument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
367 //{ SET2 , false, "tty", 't', optional_argument, NULL, 0, eArgTypeDirectoryName, "Start the process in a terminal. If <path> is specified, look for a terminal whose name contains <path>, else start the process in a new terminal."},
368 //{ SET3, false, "no-stdio", 'n', no_argument, NULL, 0, eArgTypeNone, "Do not set up for terminal I/O to go to running process."},
369 //{ SET1 | SET2 | SET3, false, "working-dir", 'w', required_argument, NULL, 0, eArgTypeDirectoryName, "Set the current working directory to <path> when running the inferior."},
370 //{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
377 //-------------------------------------------------------------------------
378 // CommandObjectProcessAttach
379 //-------------------------------------------------------------------------
380 #pragma mark CommandObjectProcessAttach
381 class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach
385 class CommandOptions : public Options
389 CommandOptions (CommandInterpreter &interpreter) :
392 // Keep default values of all options in one place: OptionParsingStarting ()
393 OptionParsingStarting ();
401 SetOptionValue (uint32_t option_idx, const char *option_arg)
404 const int short_option = m_getopt_table[option_idx].val;
405 bool success = false;
406 switch (short_option)
409 attach_info.SetContinueOnceAttached(true);
414 lldb::pid_t pid = Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
415 if (!success || pid == LLDB_INVALID_PROCESS_ID)
417 error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg);
421 attach_info.SetProcessID (pid);
427 attach_info.SetProcessPluginName (option_arg);
431 attach_info.GetExecutableFile().SetFile(option_arg, false);
435 attach_info.SetWaitForLaunch(true);
439 attach_info.SetIgnoreExisting(false);
443 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
450 OptionParsingStarting ()
455 const OptionDefinition*
458 return g_option_table;
462 HandleOptionArgumentCompletion (Args &input,
465 OptionElementVector &opt_element_vector,
466 int opt_element_index,
467 int match_start_point,
468 int max_return_elements,
472 int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos;
473 int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index;
475 // We are only completing the name option for now...
477 const OptionDefinition *opt_defs = GetDefinitions();
478 if (opt_defs[opt_defs_index].short_option == 'n')
480 // Are we in the name?
482 // Look to see if there is a -P argument provided, and if so use that plugin, otherwise
483 // use the default plugin.
485 const char *partial_name = NULL;
486 partial_name = input.GetArgumentAtIndex(opt_arg_pos);
488 PlatformSP platform_sp (m_interpreter.GetPlatform (true));
491 ProcessInstanceInfoList process_infos;
492 ProcessInstanceInfoMatch match_info;
495 match_info.GetProcessInfo().GetExecutableFile().SetFile(partial_name, false);
496 match_info.SetNameMatchType(eNameMatchStartsWith);
498 platform_sp->FindProcesses (match_info, process_infos);
499 const size_t num_matches = process_infos.GetSize();
502 for (size_t i=0; i<num_matches; ++i)
504 matches.AppendString (process_infos.GetProcessNameAtIndex(i),
505 process_infos.GetProcessNameLengthAtIndex(i));
514 // Options table: Required for subclasses of Options.
516 static OptionDefinition g_option_table[];
518 // Instance variables to hold the values for command options.
520 ProcessAttachInfo attach_info;
523 CommandObjectProcessAttach (CommandInterpreter &interpreter) :
524 CommandObjectProcessLaunchOrAttach (interpreter,
526 "Attach to a process.",
527 "process attach <cmd-options>",
530 m_options (interpreter)
534 ~CommandObjectProcessAttach ()
546 DoExecute (Args& command,
547 CommandReturnObject &result)
549 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
550 // N.B. The attach should be synchronous. It doesn't help much to get the prompt back between initiating the attach
551 // and the target actually stopping. So even if the interpreter is set to be asynchronous, we wait for the stop
554 StateType state = eStateInvalid;
555 Process *process = m_exe_ctx.GetProcessPtr();
557 if (!StopProcessIfNecessary (process, state, result))
562 // If there isn't a current target create one.
563 TargetSP new_target_sp;
566 error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(),
570 NULL, // No platform options
572 target = new_target_sp.get();
573 if (target == NULL || error.Fail())
575 result.AppendError(error.AsCString("Error creating target"));
578 m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target);
581 // Record the old executable module, we want to issue a warning if the process of attaching changed the
582 // current executable (like somebody said "file foo" then attached to a PID whose executable was bar.)
584 ModuleSP old_exec_module_sp = target->GetExecutableModule();
585 ArchSpec old_arch_spec = target->GetArchitecture();
587 if (command.GetArgumentCount())
589 result.AppendErrorWithFormat("Invalid arguments for '%s'.\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str());
590 result.SetStatus (eReturnStatusFailed);
594 if (state != eStateConnected)
596 const char *plugin_name = m_options.attach_info.GetProcessPluginName();
597 process = target->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name, NULL).get();
603 // If no process info was specified, then use the target executable
604 // name as the process to attach to by default
605 if (!m_options.attach_info.ProcessInfoSpecified ())
607 if (old_exec_module_sp)
608 m_options.attach_info.GetExecutableFile().GetFilename() = old_exec_module_sp->GetPlatformFileSpec().GetFilename();
610 if (!m_options.attach_info.ProcessInfoSpecified ())
612 error.SetErrorString ("no process specified, create a target with a file, or specify the --pid or --name command option");
618 error = process->Attach (m_options.attach_info);
622 result.SetStatus (eReturnStatusSuccessContinuingNoResult);
626 result.AppendErrorWithFormat ("attach failed: %s\n", error.AsCString());
627 result.SetStatus (eReturnStatusFailed);
630 // If we're synchronous, wait for the stopped event and report that.
631 // Otherwise just return.
632 // FIXME: in the async case it will now be possible to get to the command
633 // interpreter with a state eStateAttaching. Make sure we handle that correctly.
634 StateType state = process->WaitForProcessToStop (NULL);
636 result.SetDidChangeProcessState (true);
638 if (state == eStateStopped)
640 result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
641 result.SetStatus (eReturnStatusSuccessFinishNoResult);
645 result.AppendError ("attach failed: process did not stop (no such process or permission problem?)");
647 result.SetStatus (eReturnStatusFailed);
654 if (result.Succeeded())
656 // Okay, we're done. Last step is to warn if the executable module has changed:
657 char new_path[PATH_MAX];
658 ModuleSP new_exec_module_sp (target->GetExecutableModule());
659 if (!old_exec_module_sp)
661 // We might not have a module if we attached to a raw pid...
662 if (new_exec_module_sp)
664 new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);
665 result.AppendMessageWithFormat("Executable module set to \"%s\".\n", new_path);
668 else if (old_exec_module_sp->GetFileSpec() != new_exec_module_sp->GetFileSpec())
670 char old_path[PATH_MAX];
672 old_exec_module_sp->GetFileSpec().GetPath (old_path, PATH_MAX);
673 new_exec_module_sp->GetFileSpec().GetPath (new_path, PATH_MAX);
675 result.AppendWarningWithFormat("Executable module changed from \"%s\" to \"%s\".\n",
679 if (!old_arch_spec.IsValid())
681 result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().GetTriple().getTriple().c_str());
683 else if (!old_arch_spec.IsExactMatch(target->GetArchitecture()))
685 result.AppendWarningWithFormat("Architecture changed from %s to %s.\n",
686 old_arch_spec.GetTriple().getTriple().c_str(),
687 target->GetArchitecture().GetTriple().getTriple().c_str());
690 // This supports the use-case scenario of immediately continuing the process once attached.
691 if (m_options.attach_info.GetContinueOnceAttached())
692 m_interpreter.HandleCommand("process continue", eLazyBoolNo, result);
694 return result.Succeeded();
697 CommandOptions m_options;
702 CommandObjectProcessAttach::CommandOptions::g_option_table[] =
704 { LLDB_OPT_SET_ALL, false, "continue",'c', no_argument, NULL, 0, eArgTypeNone, "Immediately continue the process once attached."},
705 { LLDB_OPT_SET_ALL, false, "plugin", 'P', required_argument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
706 { LLDB_OPT_SET_1, false, "pid", 'p', required_argument, NULL, 0, eArgTypePid, "The process ID of an existing process to attach to."},
707 { LLDB_OPT_SET_2, false, "name", 'n', required_argument, NULL, 0, eArgTypeProcessName, "The name of the process to attach to."},
708 { LLDB_OPT_SET_2, false, "include-existing", 'i', no_argument, NULL, 0, eArgTypeNone, "Include existing processes when doing attach -w."},
709 { LLDB_OPT_SET_2, false, "waitfor", 'w', no_argument, NULL, 0, eArgTypeNone, "Wait for the process with <process-name> to launch."},
710 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
713 //-------------------------------------------------------------------------
714 // CommandObjectProcessContinue
715 //-------------------------------------------------------------------------
716 #pragma mark CommandObjectProcessContinue
718 class CommandObjectProcessContinue : public CommandObjectParsed
722 CommandObjectProcessContinue (CommandInterpreter &interpreter) :
723 CommandObjectParsed (interpreter,
725 "Continue execution of all threads in the current process.",
727 eFlagRequiresProcess |
728 eFlagTryTargetAPILock |
729 eFlagProcessMustBeLaunched |
730 eFlagProcessMustBePaused ),
731 m_options(interpreter)
736 ~CommandObjectProcessContinue ()
742 class CommandOptions : public Options
746 CommandOptions (CommandInterpreter &interpreter) :
749 // Keep default values of all options in one place: OptionParsingStarting ()
750 OptionParsingStarting ();
758 SetOptionValue (uint32_t option_idx, const char *option_arg)
761 const int short_option = m_getopt_table[option_idx].val;
762 bool success = false;
763 switch (short_option)
766 m_ignore = Args::StringToUInt32 (option_arg, 0, 0, &success);
768 error.SetErrorStringWithFormat ("invalid value for ignore option: \"%s\", should be a number.", option_arg);
772 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
779 OptionParsingStarting ()
784 const OptionDefinition*
787 return g_option_table;
790 // Options table: Required for subclasses of Options.
792 static OptionDefinition g_option_table[];
798 DoExecute (Args& command, CommandReturnObject &result)
800 Process *process = m_exe_ctx.GetProcessPtr();
801 bool synchronous_execution = m_interpreter.GetSynchronous ();
802 StateType state = process->GetState();
803 if (state == eStateStopped)
805 if (command.GetArgumentCount() != 0)
807 result.AppendErrorWithFormat ("The '%s' command does not take any arguments.\n", m_cmd_name.c_str());
808 result.SetStatus (eReturnStatusFailed);
812 if (m_options.m_ignore > 0)
814 ThreadSP sel_thread_sp(process->GetThreadList().GetSelectedThread());
817 StopInfoSP stop_info_sp = sel_thread_sp->GetStopInfo();
818 if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint)
820 lldb::break_id_t bp_site_id = (lldb::break_id_t)stop_info_sp->GetValue();
821 BreakpointSiteSP bp_site_sp(process->GetBreakpointSiteList().FindByID(bp_site_id));
824 const size_t num_owners = bp_site_sp->GetNumberOfOwners();
825 for (size_t i = 0; i < num_owners; i++)
827 Breakpoint &bp_ref = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
828 if (!bp_ref.IsInternal())
830 bp_ref.SetIgnoreCount(m_options.m_ignore);
838 { // Scope for thread list mutex:
839 Mutex::Locker locker (process->GetThreadList().GetMutex());
840 const uint32_t num_threads = process->GetThreadList().GetSize();
842 // Set the actions that the threads should each take when resuming
843 for (uint32_t idx=0; idx<num_threads; ++idx)
845 process->GetThreadList().GetThreadAtIndex(idx)->SetResumeState (eStateRunning);
849 Error error(process->Resume());
852 result.AppendMessageWithFormat ("Process %" PRIu64 " resuming\n", process->GetID());
853 if (synchronous_execution)
855 state = process->WaitForProcessToStop (NULL);
857 result.SetDidChangeProcessState (true);
858 result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
859 result.SetStatus (eReturnStatusSuccessFinishNoResult);
863 result.SetStatus (eReturnStatusSuccessContinuingNoResult);
868 result.AppendErrorWithFormat("Failed to resume process: %s.\n", error.AsCString());
869 result.SetStatus (eReturnStatusFailed);
874 result.AppendErrorWithFormat ("Process cannot be continued from its current state (%s).\n",
875 StateAsCString(state));
876 result.SetStatus (eReturnStatusFailed);
878 return result.Succeeded();
887 CommandOptions m_options;
892 CommandObjectProcessContinue::CommandOptions::g_option_table[] =
894 { LLDB_OPT_SET_ALL, false, "ignore-count",'i', required_argument, NULL, 0, eArgTypeUnsignedInteger,
895 "Ignore <N> crossings of the breakpoint (if it exists) for the currently selected thread."},
896 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
899 //-------------------------------------------------------------------------
900 // CommandObjectProcessDetach
901 //-------------------------------------------------------------------------
902 #pragma mark CommandObjectProcessDetach
904 class CommandObjectProcessDetach : public CommandObjectParsed
907 class CommandOptions : public Options
911 CommandOptions (CommandInterpreter &interpreter) :
912 Options (interpreter)
914 OptionParsingStarting ();
922 SetOptionValue (uint32_t option_idx, const char *option_arg)
925 const int short_option = m_getopt_table[option_idx].val;
927 switch (short_option)
932 tmp_result = Args::StringToBoolean(option_arg, false, &success);
934 error.SetErrorStringWithFormat("invalid boolean option: \"%s\"", option_arg);
938 m_keep_stopped = eLazyBoolYes;
940 m_keep_stopped = eLazyBoolNo;
944 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
951 OptionParsingStarting ()
953 m_keep_stopped = eLazyBoolCalculate;
956 const OptionDefinition*
959 return g_option_table;
962 // Options table: Required for subclasses of Options.
964 static OptionDefinition g_option_table[];
966 // Instance variables to hold the values for command options.
967 LazyBool m_keep_stopped;
970 CommandObjectProcessDetach (CommandInterpreter &interpreter) :
971 CommandObjectParsed (interpreter,
973 "Detach from the current process being debugged.",
975 eFlagRequiresProcess |
976 eFlagTryTargetAPILock |
977 eFlagProcessMustBeLaunched),
978 m_options(interpreter)
982 ~CommandObjectProcessDetach ()
995 DoExecute (Args& command, CommandReturnObject &result)
997 Process *process = m_exe_ctx.GetProcessPtr();
998 result.AppendMessageWithFormat ("Detaching from process %" PRIu64 "\n", process->GetID());
999 // FIXME: This will be a Command Option:
1001 if (m_options.m_keep_stopped == eLazyBoolCalculate)
1003 // Check the process default:
1004 if (process->GetDetachKeepsStopped())
1005 keep_stopped = true;
1007 keep_stopped = false;
1009 else if (m_options.m_keep_stopped == eLazyBoolYes)
1010 keep_stopped = true;
1012 keep_stopped = false;
1014 Error error (process->Detach(keep_stopped));
1015 if (error.Success())
1017 result.SetStatus (eReturnStatusSuccessFinishResult);
1021 result.AppendErrorWithFormat ("Detach failed: %s\n", error.AsCString());
1022 result.SetStatus (eReturnStatusFailed);
1025 return result.Succeeded();
1028 CommandOptions m_options;
1032 CommandObjectProcessDetach::CommandOptions::g_option_table[] =
1034 { LLDB_OPT_SET_1, false, "keep-stopped", 's', required_argument, NULL, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." },
1035 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
1038 //-------------------------------------------------------------------------
1039 // CommandObjectProcessConnect
1040 //-------------------------------------------------------------------------
1041 #pragma mark CommandObjectProcessConnect
1043 class CommandObjectProcessConnect : public CommandObjectParsed
1047 class CommandOptions : public Options
1051 CommandOptions (CommandInterpreter &interpreter) :
1052 Options(interpreter)
1054 // Keep default values of all options in one place: OptionParsingStarting ()
1055 OptionParsingStarting ();
1063 SetOptionValue (uint32_t option_idx, const char *option_arg)
1066 const int short_option = m_getopt_table[option_idx].val;
1068 switch (short_option)
1071 plugin_name.assign (option_arg);
1075 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
1082 OptionParsingStarting ()
1084 plugin_name.clear();
1087 const OptionDefinition*
1090 return g_option_table;
1093 // Options table: Required for subclasses of Options.
1095 static OptionDefinition g_option_table[];
1097 // Instance variables to hold the values for command options.
1099 std::string plugin_name;
1102 CommandObjectProcessConnect (CommandInterpreter &interpreter) :
1103 CommandObjectParsed (interpreter,
1105 "Connect to a remote debug service.",
1106 "process connect <remote-url>",
1108 m_options (interpreter)
1112 ~CommandObjectProcessConnect ()
1125 DoExecute (Args& command,
1126 CommandReturnObject &result)
1129 TargetSP target_sp (m_interpreter.GetDebugger().GetSelectedTarget());
1131 Process *process = m_exe_ctx.GetProcessPtr();
1134 if (process->IsAlive())
1136 result.AppendErrorWithFormat ("Process %" PRIu64 " is currently being debugged, kill the process before connecting.\n",
1138 result.SetStatus (eReturnStatusFailed);
1145 // If there isn't a current target create one.
1147 error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(),
1151 NULL, // No platform options
1153 if (!target_sp || error.Fail())
1155 result.AppendError(error.AsCString("Error creating target"));
1156 result.SetStatus (eReturnStatusFailed);
1159 m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target_sp.get());
1162 if (command.GetArgumentCount() == 1)
1164 const char *plugin_name = NULL;
1165 if (!m_options.plugin_name.empty())
1166 plugin_name = m_options.plugin_name.c_str();
1168 const char *remote_url = command.GetArgumentAtIndex(0);
1169 process = target_sp->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name, NULL).get();
1173 error = process->ConnectRemote (&process->GetTarget().GetDebugger().GetOutputStream(), remote_url);
1177 result.AppendError(error.AsCString("Remote connect failed"));
1178 result.SetStatus (eReturnStatusFailed);
1179 target_sp->DeleteCurrentProcess();
1185 result.AppendErrorWithFormat ("Unable to find process plug-in for remote URL '%s'.\nPlease specify a process plug-in name with the --plugin option, or specify an object file using the \"file\" command.\n",
1187 result.SetStatus (eReturnStatusFailed);
1192 result.AppendErrorWithFormat ("'%s' takes exactly one argument:\nUsage: %s\n",
1194 m_cmd_syntax.c_str());
1195 result.SetStatus (eReturnStatusFailed);
1197 return result.Succeeded();
1200 CommandOptions m_options;
1204 CommandObjectProcessConnect::CommandOptions::g_option_table[] =
1206 { LLDB_OPT_SET_ALL, false, "plugin", 'p', required_argument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
1207 { 0, false, NULL, 0 , 0, NULL, 0, eArgTypeNone, NULL }
1210 //-------------------------------------------------------------------------
1211 // CommandObjectProcessPlugin
1212 //-------------------------------------------------------------------------
1213 #pragma mark CommandObjectProcessPlugin
1215 class CommandObjectProcessPlugin : public CommandObjectProxy
1219 CommandObjectProcessPlugin (CommandInterpreter &interpreter) :
1220 CommandObjectProxy (interpreter,
1222 "Send a custom command to the current process plug-in.",
1223 "process plugin <args>",
1228 ~CommandObjectProcessPlugin ()
1232 virtual CommandObject *
1233 GetProxyCommandObject()
1235 Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
1237 return process->GetPluginCommandObject();
1243 //-------------------------------------------------------------------------
1244 // CommandObjectProcessLoad
1245 //-------------------------------------------------------------------------
1246 #pragma mark CommandObjectProcessLoad
1248 class CommandObjectProcessLoad : public CommandObjectParsed
1252 CommandObjectProcessLoad (CommandInterpreter &interpreter) :
1253 CommandObjectParsed (interpreter,
1255 "Load a shared library into the current process.",
1256 "process load <filename> [<filename> ...]",
1257 eFlagRequiresProcess |
1258 eFlagTryTargetAPILock |
1259 eFlagProcessMustBeLaunched |
1260 eFlagProcessMustBePaused )
1264 ~CommandObjectProcessLoad ()
1270 DoExecute (Args& command,
1271 CommandReturnObject &result)
1273 Process *process = m_exe_ctx.GetProcessPtr();
1275 const size_t argc = command.GetArgumentCount();
1277 for (uint32_t i=0; i<argc; ++i)
1280 const char *image_path = command.GetArgumentAtIndex(i);
1281 FileSpec image_spec (image_path, false);
1282 process->GetTarget().GetPlatform()->ResolveRemotePath(image_spec, image_spec);
1283 uint32_t image_token = process->LoadImage(image_spec, error);
1284 if (image_token != LLDB_INVALID_IMAGE_TOKEN)
1286 result.AppendMessageWithFormat ("Loading \"%s\"...ok\nImage %u loaded.\n", image_path, image_token);
1287 result.SetStatus (eReturnStatusSuccessFinishResult);
1291 result.AppendErrorWithFormat ("failed to load '%s': %s", image_path, error.AsCString());
1292 result.SetStatus (eReturnStatusFailed);
1295 return result.Succeeded();
1300 //-------------------------------------------------------------------------
1301 // CommandObjectProcessUnload
1302 //-------------------------------------------------------------------------
1303 #pragma mark CommandObjectProcessUnload
1305 class CommandObjectProcessUnload : public CommandObjectParsed
1309 CommandObjectProcessUnload (CommandInterpreter &interpreter) :
1310 CommandObjectParsed (interpreter,
1312 "Unload a shared library from the current process using the index returned by a previous call to \"process load\".",
1313 "process unload <index>",
1314 eFlagRequiresProcess |
1315 eFlagTryTargetAPILock |
1316 eFlagProcessMustBeLaunched |
1317 eFlagProcessMustBePaused )
1321 ~CommandObjectProcessUnload ()
1327 DoExecute (Args& command,
1328 CommandReturnObject &result)
1330 Process *process = m_exe_ctx.GetProcessPtr();
1332 const size_t argc = command.GetArgumentCount();
1334 for (uint32_t i=0; i<argc; ++i)
1336 const char *image_token_cstr = command.GetArgumentAtIndex(i);
1337 uint32_t image_token = Args::StringToUInt32(image_token_cstr, LLDB_INVALID_IMAGE_TOKEN, 0);
1338 if (image_token == LLDB_INVALID_IMAGE_TOKEN)
1340 result.AppendErrorWithFormat ("invalid image index argument '%s'", image_token_cstr);
1341 result.SetStatus (eReturnStatusFailed);
1346 Error error (process->UnloadImage(image_token));
1347 if (error.Success())
1349 result.AppendMessageWithFormat ("Unloading shared library with index %u...ok\n", image_token);
1350 result.SetStatus (eReturnStatusSuccessFinishResult);
1354 result.AppendErrorWithFormat ("failed to unload image: %s", error.AsCString());
1355 result.SetStatus (eReturnStatusFailed);
1360 return result.Succeeded();
1364 //-------------------------------------------------------------------------
1365 // CommandObjectProcessSignal
1366 //-------------------------------------------------------------------------
1367 #pragma mark CommandObjectProcessSignal
1369 class CommandObjectProcessSignal : public CommandObjectParsed
1373 CommandObjectProcessSignal (CommandInterpreter &interpreter) :
1374 CommandObjectParsed (interpreter,
1376 "Send a UNIX signal to the current process being debugged.",
1378 eFlagRequiresProcess | eFlagTryTargetAPILock)
1380 CommandArgumentEntry arg;
1381 CommandArgumentData signal_arg;
1383 // Define the first (and only) variant of this arg.
1384 signal_arg.arg_type = eArgTypeUnixSignal;
1385 signal_arg.arg_repetition = eArgRepeatPlain;
1387 // There is only one variant this argument could be; put it into the argument entry.
1388 arg.push_back (signal_arg);
1390 // Push the data for the first argument into the m_arguments vector.
1391 m_arguments.push_back (arg);
1394 ~CommandObjectProcessSignal ()
1400 DoExecute (Args& command,
1401 CommandReturnObject &result)
1403 Process *process = m_exe_ctx.GetProcessPtr();
1405 if (command.GetArgumentCount() == 1)
1407 int signo = LLDB_INVALID_SIGNAL_NUMBER;
1409 const char *signal_name = command.GetArgumentAtIndex(0);
1410 if (::isxdigit (signal_name[0]))
1411 signo = Args::StringToSInt32(signal_name, LLDB_INVALID_SIGNAL_NUMBER, 0);
1413 signo = process->GetUnixSignals().GetSignalNumberFromName (signal_name);
1415 if (signo == LLDB_INVALID_SIGNAL_NUMBER)
1417 result.AppendErrorWithFormat ("Invalid signal argument '%s'.\n", command.GetArgumentAtIndex(0));
1418 result.SetStatus (eReturnStatusFailed);
1422 Error error (process->Signal (signo));
1423 if (error.Success())
1425 result.SetStatus (eReturnStatusSuccessFinishResult);
1429 result.AppendErrorWithFormat ("Failed to send signal %i: %s\n", signo, error.AsCString());
1430 result.SetStatus (eReturnStatusFailed);
1436 result.AppendErrorWithFormat("'%s' takes exactly one signal number argument:\nUsage: %s\n", m_cmd_name.c_str(),
1437 m_cmd_syntax.c_str());
1438 result.SetStatus (eReturnStatusFailed);
1440 return result.Succeeded();
1445 //-------------------------------------------------------------------------
1446 // CommandObjectProcessInterrupt
1447 //-------------------------------------------------------------------------
1448 #pragma mark CommandObjectProcessInterrupt
1450 class CommandObjectProcessInterrupt : public CommandObjectParsed
1455 CommandObjectProcessInterrupt (CommandInterpreter &interpreter) :
1456 CommandObjectParsed (interpreter,
1457 "process interrupt",
1458 "Interrupt the current process being debugged.",
1459 "process interrupt",
1460 eFlagRequiresProcess |
1461 eFlagTryTargetAPILock |
1462 eFlagProcessMustBeLaunched)
1466 ~CommandObjectProcessInterrupt ()
1472 DoExecute (Args& command,
1473 CommandReturnObject &result)
1475 Process *process = m_exe_ctx.GetProcessPtr();
1476 if (process == NULL)
1478 result.AppendError ("no process to halt");
1479 result.SetStatus (eReturnStatusFailed);
1483 if (command.GetArgumentCount() == 0)
1485 bool clear_thread_plans = true;
1486 Error error(process->Halt (clear_thread_plans));
1487 if (error.Success())
1489 result.SetStatus (eReturnStatusSuccessFinishResult);
1493 result.AppendErrorWithFormat ("Failed to halt process: %s\n", error.AsCString());
1494 result.SetStatus (eReturnStatusFailed);
1499 result.AppendErrorWithFormat("'%s' takes no arguments:\nUsage: %s\n",
1501 m_cmd_syntax.c_str());
1502 result.SetStatus (eReturnStatusFailed);
1504 return result.Succeeded();
1508 //-------------------------------------------------------------------------
1509 // CommandObjectProcessKill
1510 //-------------------------------------------------------------------------
1511 #pragma mark CommandObjectProcessKill
1513 class CommandObjectProcessKill : public CommandObjectParsed
1517 CommandObjectProcessKill (CommandInterpreter &interpreter) :
1518 CommandObjectParsed (interpreter,
1520 "Terminate the current process being debugged.",
1522 eFlagRequiresProcess |
1523 eFlagTryTargetAPILock |
1524 eFlagProcessMustBeLaunched)
1528 ~CommandObjectProcessKill ()
1534 DoExecute (Args& command,
1535 CommandReturnObject &result)
1537 Process *process = m_exe_ctx.GetProcessPtr();
1538 if (process == NULL)
1540 result.AppendError ("no process to kill");
1541 result.SetStatus (eReturnStatusFailed);
1545 if (command.GetArgumentCount() == 0)
1547 Error error (process->Destroy());
1548 if (error.Success())
1550 result.SetStatus (eReturnStatusSuccessFinishResult);
1554 result.AppendErrorWithFormat ("Failed to kill process: %s\n", error.AsCString());
1555 result.SetStatus (eReturnStatusFailed);
1560 result.AppendErrorWithFormat("'%s' takes no arguments:\nUsage: %s\n",
1562 m_cmd_syntax.c_str());
1563 result.SetStatus (eReturnStatusFailed);
1565 return result.Succeeded();
1569 //-------------------------------------------------------------------------
1570 // CommandObjectProcessStatus
1571 //-------------------------------------------------------------------------
1572 #pragma mark CommandObjectProcessStatus
1574 class CommandObjectProcessStatus : public CommandObjectParsed
1577 CommandObjectProcessStatus (CommandInterpreter &interpreter) :
1578 CommandObjectParsed (interpreter,
1580 "Show the current status and location of executing process.",
1582 eFlagRequiresProcess | eFlagTryTargetAPILock)
1586 ~CommandObjectProcessStatus()
1592 DoExecute (Args& command, CommandReturnObject &result)
1594 Stream &strm = result.GetOutputStream();
1595 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1596 // No need to check "process" for validity as eFlagRequiresProcess ensures it is valid
1597 Process *process = m_exe_ctx.GetProcessPtr();
1598 const bool only_threads_with_stop_reason = true;
1599 const uint32_t start_frame = 0;
1600 const uint32_t num_frames = 1;
1601 const uint32_t num_frames_with_source = 1;
1602 process->GetStatus(strm);
1603 process->GetThreadStatus (strm,
1604 only_threads_with_stop_reason,
1607 num_frames_with_source);
1608 return result.Succeeded();
1612 //-------------------------------------------------------------------------
1613 // CommandObjectProcessHandle
1614 //-------------------------------------------------------------------------
1615 #pragma mark CommandObjectProcessHandle
1617 class CommandObjectProcessHandle : public CommandObjectParsed
1621 class CommandOptions : public Options
1625 CommandOptions (CommandInterpreter &interpreter) :
1626 Options (interpreter)
1628 OptionParsingStarting ();
1636 SetOptionValue (uint32_t option_idx, const char *option_arg)
1639 const int short_option = m_getopt_table[option_idx].val;
1641 switch (short_option)
1647 notify = option_arg;
1653 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
1660 OptionParsingStarting ()
1667 const OptionDefinition*
1670 return g_option_table;
1673 // Options table: Required for subclasses of Options.
1675 static OptionDefinition g_option_table[];
1677 // Instance variables to hold the values for command options.
1685 CommandObjectProcessHandle (CommandInterpreter &interpreter) :
1686 CommandObjectParsed (interpreter,
1688 "Show or update what the process and debugger should do with various signals received from the OS.",
1690 m_options (interpreter)
1692 SetHelpLong ("If no signals are specified, update them all. If no update option is specified, list the current values.\n");
1693 CommandArgumentEntry arg;
1694 CommandArgumentData signal_arg;
1696 signal_arg.arg_type = eArgTypeUnixSignal;
1697 signal_arg.arg_repetition = eArgRepeatStar;
1699 arg.push_back (signal_arg);
1701 m_arguments.push_back (arg);
1704 ~CommandObjectProcessHandle ()
1715 VerifyCommandOptionValue (const std::string &option, int &real_value)
1719 bool success = false;
1720 bool tmp_value = Args::StringToBoolean (option.c_str(), false, &success);
1722 if (success && tmp_value)
1724 else if (success && !tmp_value)
1728 // If the value isn't 'true' or 'false', it had better be 0 or 1.
1729 real_value = Args::StringToUInt32 (option.c_str(), 3);
1730 if (real_value != 0 && real_value != 1)
1738 PrintSignalHeader (Stream &str)
1740 str.Printf ("NAME PASS STOP NOTIFY\n");
1741 str.Printf ("========== ===== ===== ======\n");
1745 PrintSignal (Stream &str, int32_t signo, const char *sig_name, UnixSignals &signals)
1751 str.Printf ("%-10s ", sig_name);
1752 if (signals.GetSignalInfo (signo, suppress, stop, notify))
1754 bool pass = !suppress;
1755 str.Printf ("%s %s %s",
1756 (pass ? "true " : "false"),
1757 (stop ? "true " : "false"),
1758 (notify ? "true " : "false"));
1764 PrintSignalInformation (Stream &str, Args &signal_args, int num_valid_signals, UnixSignals &signals)
1766 PrintSignalHeader (str);
1768 if (num_valid_signals > 0)
1770 size_t num_args = signal_args.GetArgumentCount();
1771 for (size_t i = 0; i < num_args; ++i)
1773 int32_t signo = signals.GetSignalNumberFromName (signal_args.GetArgumentAtIndex (i));
1774 if (signo != LLDB_INVALID_SIGNAL_NUMBER)
1775 PrintSignal (str, signo, signal_args.GetArgumentAtIndex (i), signals);
1778 else // Print info for ALL signals
1780 int32_t signo = signals.GetFirstSignalNumber();
1781 while (signo != LLDB_INVALID_SIGNAL_NUMBER)
1783 PrintSignal (str, signo, signals.GetSignalAsCString (signo), signals);
1784 signo = signals.GetNextSignalNumber (signo);
1791 DoExecute (Args &signal_args, CommandReturnObject &result)
1793 TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget();
1797 result.AppendError ("No current target;"
1798 " cannot handle signals until you have a valid target and process.\n");
1799 result.SetStatus (eReturnStatusFailed);
1803 ProcessSP process_sp = target_sp->GetProcessSP();
1807 result.AppendError ("No current process; cannot handle signals until you have a valid process.\n");
1808 result.SetStatus (eReturnStatusFailed);
1812 int stop_action = -1; // -1 means leave the current setting alone
1813 int pass_action = -1; // -1 means leave the current setting alone
1814 int notify_action = -1; // -1 means leave the current setting alone
1816 if (! m_options.stop.empty()
1817 && ! VerifyCommandOptionValue (m_options.stop, stop_action))
1819 result.AppendError ("Invalid argument for command option --stop; must be true or false.\n");
1820 result.SetStatus (eReturnStatusFailed);
1824 if (! m_options.notify.empty()
1825 && ! VerifyCommandOptionValue (m_options.notify, notify_action))
1827 result.AppendError ("Invalid argument for command option --notify; must be true or false.\n");
1828 result.SetStatus (eReturnStatusFailed);
1832 if (! m_options.pass.empty()
1833 && ! VerifyCommandOptionValue (m_options.pass, pass_action))
1835 result.AppendError ("Invalid argument for command option --pass; must be true or false.\n");
1836 result.SetStatus (eReturnStatusFailed);
1840 size_t num_args = signal_args.GetArgumentCount();
1841 UnixSignals &signals = process_sp->GetUnixSignals();
1842 int num_signals_set = 0;
1846 for (size_t i = 0; i < num_args; ++i)
1848 int32_t signo = signals.GetSignalNumberFromName (signal_args.GetArgumentAtIndex (i));
1849 if (signo != LLDB_INVALID_SIGNAL_NUMBER)
1851 // Casting the actions as bools here should be okay, because VerifyCommandOptionValue guarantees
1852 // the value is either 0 or 1.
1853 if (stop_action != -1)
1854 signals.SetShouldStop (signo, (bool) stop_action);
1855 if (pass_action != -1)
1857 bool suppress = ! ((bool) pass_action);
1858 signals.SetShouldSuppress (signo, suppress);
1860 if (notify_action != -1)
1861 signals.SetShouldNotify (signo, (bool) notify_action);
1866 result.AppendErrorWithFormat ("Invalid signal name '%s'\n", signal_args.GetArgumentAtIndex (i));
1872 // No signal specified, if any command options were specified, update ALL signals.
1873 if ((notify_action != -1) || (stop_action != -1) || (pass_action != -1))
1875 if (m_interpreter.Confirm ("Do you really want to update all the signals?", false))
1877 int32_t signo = signals.GetFirstSignalNumber();
1878 while (signo != LLDB_INVALID_SIGNAL_NUMBER)
1880 if (notify_action != -1)
1881 signals.SetShouldNotify (signo, (bool) notify_action);
1882 if (stop_action != -1)
1883 signals.SetShouldStop (signo, (bool) stop_action);
1884 if (pass_action != -1)
1886 bool suppress = ! ((bool) pass_action);
1887 signals.SetShouldSuppress (signo, suppress);
1889 signo = signals.GetNextSignalNumber (signo);
1895 PrintSignalInformation (result.GetOutputStream(), signal_args, num_signals_set, signals);
1897 if (num_signals_set > 0)
1898 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1900 result.SetStatus (eReturnStatusFailed);
1902 return result.Succeeded();
1905 CommandOptions m_options;
1909 CommandObjectProcessHandle::CommandOptions::g_option_table[] =
1911 { LLDB_OPT_SET_1, false, "stop", 's', required_argument, NULL, 0, eArgTypeBoolean, "Whether or not the process should be stopped if the signal is received." },
1912 { LLDB_OPT_SET_1, false, "notify", 'n', required_argument, NULL, 0, eArgTypeBoolean, "Whether or not the debugger should notify the user if the signal is received." },
1913 { LLDB_OPT_SET_1, false, "pass", 'p', required_argument, NULL, 0, eArgTypeBoolean, "Whether or not the signal should be passed to the process." },
1914 { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
1917 //-------------------------------------------------------------------------
1918 // CommandObjectMultiwordProcess
1919 //-------------------------------------------------------------------------
1921 CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter &interpreter) :
1922 CommandObjectMultiword (interpreter,
1924 "A set of commands for operating on a process.",
1925 "process <subcommand> [<subcommand-options>]")
1927 LoadSubCommand ("attach", CommandObjectSP (new CommandObjectProcessAttach (interpreter)));
1928 LoadSubCommand ("launch", CommandObjectSP (new CommandObjectProcessLaunch (interpreter)));
1929 LoadSubCommand ("continue", CommandObjectSP (new CommandObjectProcessContinue (interpreter)));
1930 LoadSubCommand ("connect", CommandObjectSP (new CommandObjectProcessConnect (interpreter)));
1931 LoadSubCommand ("detach", CommandObjectSP (new CommandObjectProcessDetach (interpreter)));
1932 LoadSubCommand ("load", CommandObjectSP (new CommandObjectProcessLoad (interpreter)));
1933 LoadSubCommand ("unload", CommandObjectSP (new CommandObjectProcessUnload (interpreter)));
1934 LoadSubCommand ("signal", CommandObjectSP (new CommandObjectProcessSignal (interpreter)));
1935 LoadSubCommand ("handle", CommandObjectSP (new CommandObjectProcessHandle (interpreter)));
1936 LoadSubCommand ("status", CommandObjectSP (new CommandObjectProcessStatus (interpreter)));
1937 LoadSubCommand ("interrupt", CommandObjectSP (new CommandObjectProcessInterrupt (interpreter)));
1938 LoadSubCommand ("kill", CommandObjectSP (new CommandObjectProcessKill (interpreter)));
1939 LoadSubCommand ("plugin", CommandObjectSP (new CommandObjectProcessPlugin (interpreter)));
1942 CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess ()