blob: 4414bdf2a2c8a926b7d69da332f79c2a49f5da1d [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- CommandObjectProcess.cpp --------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "CommandObjectProcess.h"
11
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
Jim Ingham0e410842012-08-11 01:27:55 +000016#include "lldb/Breakpoint/Breakpoint.h"
17#include "lldb/Breakpoint/BreakpointLocation.h"
18#include "lldb/Breakpoint/BreakpointSite.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000019#include "lldb/Core/State.h"
Greg Clayton1f746072012-08-29 21:13:06 +000020#include "lldb/Core/Module.h"
Greg Claytona2715cf2014-06-13 00:54:12 +000021#include "lldb/Core/PluginManager.h"
Greg Clayton7260f622011-04-18 08:33:37 +000022#include "lldb/Host/Host.h"
Vince Harron5275aaa2015-01-15 20:08:35 +000023#include "lldb/Host/StringConvert.h"
Jim Ingham0e410842012-08-11 01:27:55 +000024#include "lldb/Interpreter/Args.h"
25#include "lldb/Interpreter/Options.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000026#include "lldb/Interpreter/CommandInterpreter.h"
27#include "lldb/Interpreter/CommandReturnObject.h"
Greg Claytone996fd32011-03-08 22:40:15 +000028#include "lldb/Target/Platform.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000029#include "lldb/Target/Process.h"
Jim Ingham0e410842012-08-11 01:27:55 +000030#include "lldb/Target/StopInfo.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000031#include "lldb/Target/Target.h"
32#include "lldb/Target/Thread.h"
Zachary Turner93749ab2015-03-03 21:51:25 +000033#include "lldb/Target/UnixSignals.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000034
35using namespace lldb;
36using namespace lldb_private;
37
Jim Inghamdcb1d852013-03-29 00:56:30 +000038class CommandObjectProcessLaunchOrAttach : public CommandObjectParsed
39{
40public:
41 CommandObjectProcessLaunchOrAttach (CommandInterpreter &interpreter,
42 const char *name,
43 const char *help,
44 const char *syntax,
45 uint32_t flags,
46 const char *new_process_action) :
47 CommandObjectParsed (interpreter, name, help, syntax, flags),
48 m_new_process_action (new_process_action) {}
49
50 virtual ~CommandObjectProcessLaunchOrAttach () {}
51protected:
52 bool
Greg Claytonb09c5382013-12-13 17:20:18 +000053 StopProcessIfNecessary (Process *process, StateType &state, CommandReturnObject &result)
Jim Inghamdcb1d852013-03-29 00:56:30 +000054 {
55 state = eStateInvalid;
56 if (process)
57 {
58 state = process->GetState();
59
60 if (process->IsAlive() && state != eStateConnected)
61 {
62 char message[1024];
63 if (process->GetState() == eStateAttaching)
64 ::snprintf (message, sizeof(message), "There is a pending attach, abort it and %s?", m_new_process_action.c_str());
65 else if (process->GetShouldDetach())
66 ::snprintf (message, sizeof(message), "There is a running process, detach from it and %s?", m_new_process_action.c_str());
67 else
68 ::snprintf (message, sizeof(message), "There is a running process, kill it and %s?", m_new_process_action.c_str());
69
70 if (!m_interpreter.Confirm (message, true))
71 {
72 result.SetStatus (eReturnStatusFailed);
73 return false;
74 }
75 else
76 {
77 if (process->GetShouldDetach())
78 {
Jim Inghamacff8952013-05-02 00:27:30 +000079 bool keep_stopped = false;
80 Error detach_error (process->Detach(keep_stopped));
Jim Inghamdcb1d852013-03-29 00:56:30 +000081 if (detach_error.Success())
82 {
83 result.SetStatus (eReturnStatusSuccessFinishResult);
84 process = NULL;
85 }
86 else
87 {
88 result.AppendErrorWithFormat ("Failed to detach from process: %s\n", detach_error.AsCString());
89 result.SetStatus (eReturnStatusFailed);
90 }
91 }
92 else
93 {
Jason Molendaede31932015-04-17 05:01:58 +000094 Error destroy_error (process->Destroy(false));
Jim Inghamdcb1d852013-03-29 00:56:30 +000095 if (destroy_error.Success())
96 {
97 result.SetStatus (eReturnStatusSuccessFinishResult);
98 process = NULL;
99 }
100 else
101 {
102 result.AppendErrorWithFormat ("Failed to kill process: %s\n", destroy_error.AsCString());
103 result.SetStatus (eReturnStatusFailed);
104 }
105 }
106 }
107 }
108 }
109 return result.Succeeded();
110 }
111 std::string m_new_process_action;
112};
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000113//-------------------------------------------------------------------------
114// CommandObjectProcessLaunch
115//-------------------------------------------------------------------------
Jim Ingham4bddaeb2012-02-16 06:50:00 +0000116#pragma mark CommandObjectProcessLaunch
Jim Inghamdcb1d852013-03-29 00:56:30 +0000117class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000118{
119public:
120
Greg Claytona7015092010-09-18 01:14:36 +0000121 CommandObjectProcessLaunch (CommandInterpreter &interpreter) :
Jim Inghamdcb1d852013-03-29 00:56:30 +0000122 CommandObjectProcessLaunchOrAttach (interpreter,
123 "process launch",
124 "Launch the executable in the debugger.",
125 NULL,
Enrico Granatae87764f2015-05-27 05:04:35 +0000126 eCommandRequiresTarget,
Jim Inghamdcb1d852013-03-29 00:56:30 +0000127 "restart"),
Greg Claytoneb0103f2011-04-07 22:46:35 +0000128 m_options (interpreter)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000129 {
Caroline Tice405fe672010-10-04 22:28:36 +0000130 CommandArgumentEntry arg;
131 CommandArgumentData run_args_arg;
132
133 // Define the first (and only) variant of this arg.
134 run_args_arg.arg_type = eArgTypeRunArgs;
135 run_args_arg.arg_repetition = eArgRepeatOptional;
136
137 // There is only one variant this argument could be; put it into the argument entry.
138 arg.push_back (run_args_arg);
139
140 // Push the data for the first argument into the m_arguments vector.
141 m_arguments.push_back (arg);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000142 }
143
144
145 ~CommandObjectProcessLaunch ()
146 {
147 }
148
Greg Claytonc7bece562013-01-25 18:06:21 +0000149 virtual int
Jim Inghame9ce62b2012-08-10 21:48:41 +0000150 HandleArgumentCompletion (Args &input,
151 int &cursor_index,
152 int &cursor_char_position,
153 OptionElementVector &opt_element_vector,
154 int match_start_point,
155 int max_return_elements,
156 bool &word_complete,
157 StringList &matches)
158 {
159 std::string completion_str (input.GetArgumentAtIndex(cursor_index));
160 completion_str.erase (cursor_char_position);
161
162 CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
163 CommandCompletions::eDiskFileCompletion,
164 completion_str.c_str(),
165 match_start_point,
166 max_return_elements,
167 NULL,
168 word_complete,
169 matches);
170 return matches.GetSize();
171 }
172
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000173 Options *
174 GetOptions ()
175 {
176 return &m_options;
177 }
178
Jim Ingham5a988412012-06-08 21:56:10 +0000179 virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index)
180 {
181 // No repeat for "process launch"...
182 return "";
183 }
184
185protected:
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000186 bool
Jim Ingham5a988412012-06-08 21:56:10 +0000187 DoExecute (Args& launch_args, CommandReturnObject &result)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000188 {
Greg Clayton1d885962011-11-08 02:43:13 +0000189 Debugger &debugger = m_interpreter.GetDebugger();
190 Target *target = debugger.GetSelectedTarget().get();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000191 // If our listener is NULL, users aren't allows to launch
Greg Claytonb09c5382013-12-13 17:20:18 +0000192 ModuleSP exe_module_sp = target->GetExecutableModule();
Greg Clayton71337622011-02-24 22:24:29 +0000193
Greg Claytonb09c5382013-12-13 17:20:18 +0000194 if (exe_module_sp == NULL)
Greg Clayton71337622011-02-24 22:24:29 +0000195 {
Greg Claytoneffe5c92011-05-03 22:09:39 +0000196 result.AppendError ("no file in target, create a debug target using the 'target create' command");
Greg Clayton71337622011-02-24 22:24:29 +0000197 result.SetStatus (eReturnStatusFailed);
198 return false;
199 }
200
Greg Clayton71337622011-02-24 22:24:29 +0000201 StateType state = eStateInvalid;
Greg Clayton71337622011-02-24 22:24:29 +0000202
Greg Claytonb09c5382013-12-13 17:20:18 +0000203 if (!StopProcessIfNecessary(m_exe_ctx.GetProcessPtr(), state, result))
Jim Inghamdcb1d852013-03-29 00:56:30 +0000204 return false;
Jim Inghambb9caf72010-12-09 18:58:16 +0000205
Greg Clayton45392552012-10-17 22:57:12 +0000206 const char *target_settings_argv0 = target->GetArg0();
207
Todd Fiala51637922014-08-19 17:40:43 +0000208 // Determine whether we will disable ASLR or leave it in the default state (i.e. enabled if the platform supports it).
209 // First check if the process launch options explicitly turn on/off disabling ASLR. If so, use that setting;
210 // otherwise, use the 'settings target.disable-aslr' setting.
211 bool disable_aslr = false;
212 if (m_options.disable_aslr != eLazyBoolCalculate)
213 {
214 // The user specified an explicit setting on the process launch line. Use it.
215 disable_aslr = (m_options.disable_aslr == eLazyBoolYes);
216 }
217 else
218 {
219 // The user did not explicitly specify whether to disable ASLR. Fall back to the target.disable-aslr setting.
220 disable_aslr = target->GetDisableASLR ();
221 }
222
223 if (disable_aslr)
Greg Claytonb09c5382013-12-13 17:20:18 +0000224 m_options.launch_info.GetFlags().Set (eLaunchFlagDisableASLR);
Todd Fiala51637922014-08-19 17:40:43 +0000225 else
226 m_options.launch_info.GetFlags().Clear (eLaunchFlagDisableASLR);
Greg Clayton45392552012-10-17 22:57:12 +0000227
Jim Ingham106d0282014-06-25 02:32:56 +0000228 if (target->GetDetachOnError())
229 m_options.launch_info.GetFlags().Set (eLaunchFlagDetachOnError);
230
Greg Claytonb09c5382013-12-13 17:20:18 +0000231 if (target->GetDisableSTDIO())
232 m_options.launch_info.GetFlags().Set (eLaunchFlagDisableSTDIO);
233
234 Args environment;
235 target->GetEnvironmentAsArgs (environment);
236 if (environment.GetArgumentCount() > 0)
237 m_options.launch_info.GetEnvironmentEntries ().AppendArguments (environment);
238
Greg Clayton45392552012-10-17 22:57:12 +0000239 if (target_settings_argv0)
240 {
241 m_options.launch_info.GetArguments().AppendArgument (target_settings_argv0);
Greg Claytonb09c5382013-12-13 17:20:18 +0000242 m_options.launch_info.SetExecutableFile(exe_module_sp->GetPlatformFileSpec(), false);
Greg Clayton45392552012-10-17 22:57:12 +0000243 }
244 else
245 {
Greg Claytonb09c5382013-12-13 17:20:18 +0000246 m_options.launch_info.SetExecutableFile(exe_module_sp->GetPlatformFileSpec(), true);
Greg Clayton45392552012-10-17 22:57:12 +0000247 }
248
Greg Clayton144f3a92011-11-15 03:53:30 +0000249 if (launch_args.GetArgumentCount() == 0)
250 {
Ilia Kcc39d3f2015-02-13 17:07:55 +0000251 m_options.launch_info.GetArguments().AppendArguments (target->GetProcessLaunchInfo().GetArguments());
Greg Clayton144f3a92011-11-15 03:53:30 +0000252 }
253 else
Greg Clayton1d885962011-11-08 02:43:13 +0000254 {
Greg Clayton45392552012-10-17 22:57:12 +0000255 m_options.launch_info.GetArguments().AppendArguments (launch_args);
Greg Clayton162b5972011-11-21 21:51:18 +0000256 // Save the arguments for subsequent runs in the current target.
257 target->SetRunArguments (launch_args);
Greg Clayton1d885962011-11-08 02:43:13 +0000258 }
Greg Claytondc6224e2014-10-21 01:00:42 +0000259
260 StreamString stream;
Greg Clayton8012cad2014-11-17 19:39:20 +0000261 Error error = target->Launch(m_options.launch_info, &stream);
Jim Inghamdcb1d852013-03-29 00:56:30 +0000262
Greg Claytona7015092010-09-18 01:14:36 +0000263 if (error.Success())
264 {
Greg Claytonb09c5382013-12-13 17:20:18 +0000265 ProcessSP process_sp (target->GetProcessSP());
266 if (process_sp)
Greg Claytona7015092010-09-18 01:14:36 +0000267 {
Ilia K8f0db3e2015-05-07 06:26:27 +0000268 // There is a race condition where this thread will return up the call stack to the main command
269 // handler and show an (lldb) prompt before HandlePrivateEvent (from PrivateStateThread) has
270 // a chance to call PushProcessIOHandler().
Pavel Labath44464872015-05-27 12:40:32 +0000271 process_sp->SyncIOHandler (0, 2000);
Ilia K8f0db3e2015-05-07 06:26:27 +0000272
Stephane Sezerf2ef94e2014-12-13 05:23:51 +0000273 const char *data = stream.GetData();
274 if (data && strlen(data) > 0)
Greg Claytondc6224e2014-10-21 01:00:42 +0000275 result.AppendMessage(stream.GetData());
Ilia K8f0db3e2015-05-07 06:26:27 +0000276 const char *archname = exe_module_sp->GetArchitecture().GetArchitectureName();
Greg Claytonb09c5382013-12-13 17:20:18 +0000277 result.AppendMessageWithFormat ("Process %" PRIu64 " launched: '%s' (%s)\n", process_sp->GetID(), exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
278 result.SetStatus (eReturnStatusSuccessFinishResult);
279 result.SetDidChangeProcessState (true);
280 }
281 else
282 {
283 result.AppendError("no error returned from Target::Launch, and target has no process");
284 result.SetStatus (eReturnStatusFailed);
Greg Claytona7015092010-09-18 01:14:36 +0000285 }
286 }
Greg Clayton514487e2011-02-15 21:59:32 +0000287 else
288 {
Greg Claytonb09c5382013-12-13 17:20:18 +0000289 result.AppendError(error.AsCString());
Greg Clayton514487e2011-02-15 21:59:32 +0000290 result.SetStatus (eReturnStatusFailed);
291 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000292 return result.Succeeded();
293 }
294
295protected:
Greg Clayton982c9762011-11-03 21:22:33 +0000296 ProcessLaunchCommandOptions m_options;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000297};
298
299
Greg Clayton982c9762011-11-03 21:22:33 +0000300//#define SET1 LLDB_OPT_SET_1
301//#define SET2 LLDB_OPT_SET_2
302//#define SET3 LLDB_OPT_SET_3
303//
304//OptionDefinition
305//CommandObjectProcessLaunch::CommandOptions::g_option_table[] =
306//{
Virgile Belloe2607b52013-09-05 16:42:23 +0000307//{ SET1 | SET2 | SET3, false, "stop-at-entry", 's', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."},
308//{ SET1 , false, "stdin", 'i', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stdin for the process to <path>."},
309//{ SET1 , false, "stdout", 'o', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stdout for the process to <path>."},
310//{ SET1 , false, "stderr", 'e', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stderr for the process to <path>."},
311//{ SET1 | SET2 | SET3, false, "plugin", 'p', OptionParser::eRequiredArgument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
312//{ SET2 , false, "tty", 't', OptionParser::eOptionalArgument, 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."},
313//{ SET3, false, "no-stdio", 'n', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Do not set up for terminal I/O to go to running process."},
314//{ SET1 | SET2 | SET3, false, "working-dir", 'w', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Set the current working directory to <path> when running the inferior."},
Greg Clayton982c9762011-11-03 21:22:33 +0000315//{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
316//};
317//
318//#undef SET1
319//#undef SET2
320//#undef SET3
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000321
322//-------------------------------------------------------------------------
323// CommandObjectProcessAttach
324//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +0000325#pragma mark CommandObjectProcessAttach
Jim Inghamdcb1d852013-03-29 00:56:30 +0000326class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000327{
328public:
329
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000330 class CommandOptions : public Options
331 {
332 public:
333
Greg Claytoneb0103f2011-04-07 22:46:35 +0000334 CommandOptions (CommandInterpreter &interpreter) :
335 Options(interpreter)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000336 {
Greg Claytonf6b8b582011-04-13 00:18:08 +0000337 // Keep default values of all options in one place: OptionParsingStarting ()
338 OptionParsingStarting ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000339 }
340
341 ~CommandOptions ()
342 {
343 }
344
345 Error
Greg Claytonf6b8b582011-04-13 00:18:08 +0000346 SetOptionValue (uint32_t option_idx, const char *option_arg)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000347 {
348 Error error;
Greg Clayton3bcdfc02012-12-04 00:32:51 +0000349 const int short_option = m_getopt_table[option_idx].val;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000350 bool success = false;
351 switch (short_option)
352 {
Johnny Chena95ce622012-05-24 00:43:00 +0000353 case 'c':
354 attach_info.SetContinueOnceAttached(true);
355 break;
356
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000357 case 'p':
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000358 {
Vince Harron5275aaa2015-01-15 20:08:35 +0000359 lldb::pid_t pid = StringConvert::ToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
Greg Clayton144f3a92011-11-15 03:53:30 +0000360 if (!success || pid == LLDB_INVALID_PROCESS_ID)
361 {
362 error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg);
363 }
364 else
365 {
366 attach_info.SetProcessID (pid);
367 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000368 }
369 break;
370
371 case 'P':
Greg Clayton144f3a92011-11-15 03:53:30 +0000372 attach_info.SetProcessPluginName (option_arg);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000373 break;
374
375 case 'n':
Greg Clayton144f3a92011-11-15 03:53:30 +0000376 attach_info.GetExecutableFile().SetFile(option_arg, false);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000377 break;
378
379 case 'w':
Greg Clayton144f3a92011-11-15 03:53:30 +0000380 attach_info.SetWaitForLaunch(true);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000381 break;
Jim Inghamcd16df92012-07-20 21:37:13 +0000382
383 case 'i':
384 attach_info.SetIgnoreExisting(false);
385 break;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000386
387 default:
Greg Clayton86edbf42011-10-26 00:56:27 +0000388 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000389 break;
390 }
391 return error;
392 }
393
394 void
Greg Claytonf6b8b582011-04-13 00:18:08 +0000395 OptionParsingStarting ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000396 {
Greg Clayton144f3a92011-11-15 03:53:30 +0000397 attach_info.Clear();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000398 }
399
Greg Claytone0d378b2011-03-24 21:19:54 +0000400 const OptionDefinition*
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000401 GetDefinitions ()
402 {
403 return g_option_table;
404 }
405
Jim Ingham5aee1622010-08-09 23:31:02 +0000406 virtual bool
Greg Claytoneb0103f2011-04-07 22:46:35 +0000407 HandleOptionArgumentCompletion (Args &input,
Jim Ingham5aee1622010-08-09 23:31:02 +0000408 int cursor_index,
409 int char_pos,
410 OptionElementVector &opt_element_vector,
411 int opt_element_index,
412 int match_start_point,
413 int max_return_elements,
414 bool &word_complete,
415 StringList &matches)
416 {
417 int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos;
418 int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index;
419
420 // We are only completing the name option for now...
421
Greg Claytone0d378b2011-03-24 21:19:54 +0000422 const OptionDefinition *opt_defs = GetDefinitions();
Jim Ingham5aee1622010-08-09 23:31:02 +0000423 if (opt_defs[opt_defs_index].short_option == 'n')
424 {
425 // Are we in the name?
426
427 // Look to see if there is a -P argument provided, and if so use that plugin, otherwise
428 // use the default plugin.
Jim Ingham5aee1622010-08-09 23:31:02 +0000429
430 const char *partial_name = NULL;
431 partial_name = input.GetArgumentAtIndex(opt_arg_pos);
Greg Claytone996fd32011-03-08 22:40:15 +0000432
Greg Clayton8b82f082011-04-12 05:54:46 +0000433 PlatformSP platform_sp (m_interpreter.GetPlatform (true));
Greg Claytone996fd32011-03-08 22:40:15 +0000434 if (platform_sp)
Jim Ingham5aee1622010-08-09 23:31:02 +0000435 {
Greg Clayton8b82f082011-04-12 05:54:46 +0000436 ProcessInstanceInfoList process_infos;
437 ProcessInstanceInfoMatch match_info;
Greg Clayton32e0a752011-03-30 18:16:51 +0000438 if (partial_name)
439 {
Greg Clayton144f3a92011-11-15 03:53:30 +0000440 match_info.GetProcessInfo().GetExecutableFile().SetFile(partial_name, false);
Greg Clayton32e0a752011-03-30 18:16:51 +0000441 match_info.SetNameMatchType(eNameMatchStartsWith);
442 }
443 platform_sp->FindProcesses (match_info, process_infos);
Greg Claytonc7bece562013-01-25 18:06:21 +0000444 const size_t num_matches = process_infos.GetSize();
Greg Claytone996fd32011-03-08 22:40:15 +0000445 if (num_matches > 0)
446 {
Greg Claytonc7bece562013-01-25 18:06:21 +0000447 for (size_t i=0; i<num_matches; ++i)
Greg Claytone996fd32011-03-08 22:40:15 +0000448 {
449 matches.AppendString (process_infos.GetProcessNameAtIndex(i),
450 process_infos.GetProcessNameLengthAtIndex(i));
451 }
452 }
Jim Ingham5aee1622010-08-09 23:31:02 +0000453 }
454 }
455
456 return false;
457 }
458
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000459 // Options table: Required for subclasses of Options.
460
Greg Claytone0d378b2011-03-24 21:19:54 +0000461 static OptionDefinition g_option_table[];
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000462
463 // Instance variables to hold the values for command options.
464
Greg Clayton144f3a92011-11-15 03:53:30 +0000465 ProcessAttachInfo attach_info;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000466 };
467
Greg Claytona7015092010-09-18 01:14:36 +0000468 CommandObjectProcessAttach (CommandInterpreter &interpreter) :
Jim Inghamdcb1d852013-03-29 00:56:30 +0000469 CommandObjectProcessLaunchOrAttach (interpreter,
470 "process attach",
471 "Attach to a process.",
472 "process attach <cmd-options>",
473 0,
474 "attach"),
Greg Claytoneb0103f2011-04-07 22:46:35 +0000475 m_options (interpreter)
Jim Ingham5aee1622010-08-09 23:31:02 +0000476 {
Jim Ingham5aee1622010-08-09 23:31:02 +0000477 }
478
479 ~CommandObjectProcessAttach ()
480 {
481 }
482
Jim Ingham5a988412012-06-08 21:56:10 +0000483 Options *
484 GetOptions ()
485 {
486 return &m_options;
487 }
488
489protected:
Jim Ingham5aee1622010-08-09 23:31:02 +0000490 bool
Jim Ingham5a988412012-06-08 21:56:10 +0000491 DoExecute (Args& command,
Jim Ingham5aee1622010-08-09 23:31:02 +0000492 CommandReturnObject &result)
493 {
Oleksiy Vyalov926af0c2015-02-03 00:04:35 +0000494 PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
495
Greg Claytona7015092010-09-18 01:14:36 +0000496 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Jim Ingham31412642011-09-15 01:08:57 +0000497 // N.B. The attach should be synchronous. It doesn't help much to get the prompt back between initiating the attach
498 // and the target actually stopping. So even if the interpreter is set to be asynchronous, we wait for the stop
499 // ourselves here.
Jim Inghambb3a2832011-01-29 01:49:25 +0000500
Greg Clayton71337622011-02-24 22:24:29 +0000501 StateType state = eStateInvalid;
Jim Inghamdcb1d852013-03-29 00:56:30 +0000502 Process *process = m_exe_ctx.GetProcessPtr();
503
504 if (!StopProcessIfNecessary (process, state, result))
505 return false;
506
Jim Ingham5aee1622010-08-09 23:31:02 +0000507 if (target == NULL)
508 {
509 // If there isn't a current target create one.
510 TargetSP new_target_sp;
Jim Ingham5aee1622010-08-09 23:31:02 +0000511 Error error;
512
Greg Claytona7015092010-09-18 01:14:36 +0000513 error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(),
Greg Claytona0ca6602012-10-18 16:33:33 +0000514 NULL,
Greg Claytoncac9c5f2011-09-24 00:52:29 +0000515 NULL,
Greg Claytona7015092010-09-18 01:14:36 +0000516 false,
Greg Claytoncac9c5f2011-09-24 00:52:29 +0000517 NULL, // No platform options
Greg Claytona7015092010-09-18 01:14:36 +0000518 new_target_sp);
Jim Ingham5aee1622010-08-09 23:31:02 +0000519 target = new_target_sp.get();
520 if (target == NULL || error.Fail())
521 {
Greg Claytonb766a732011-02-04 01:58:07 +0000522 result.AppendError(error.AsCString("Error creating target"));
Jim Ingham5aee1622010-08-09 23:31:02 +0000523 return false;
524 }
Greg Claytona7015092010-09-18 01:14:36 +0000525 m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target);
Jim Ingham5aee1622010-08-09 23:31:02 +0000526 }
527
528 // Record the old executable module, we want to issue a warning if the process of attaching changed the
529 // current executable (like somebody said "file foo" then attached to a PID whose executable was bar.)
530
531 ModuleSP old_exec_module_sp = target->GetExecutableModule();
532 ArchSpec old_arch_spec = target->GetArchitecture();
533
534 if (command.GetArgumentCount())
535 {
Jason Molendafd54b362011-09-20 21:44:10 +0000536 result.AppendErrorWithFormat("Invalid arguments for '%s'.\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str());
Jim Ingham5aee1622010-08-09 23:31:02 +0000537 result.SetStatus (eReturnStatusFailed);
Oleksiy Vyalov926af0c2015-02-03 00:04:35 +0000538 return false;
539 }
540
541 m_interpreter.UpdateExecutionContext(nullptr);
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000542 StreamString stream;
543 const auto error = target->Attach(m_options.attach_info, &stream);
Oleksiy Vyalov926af0c2015-02-03 00:04:35 +0000544 if (error.Success())
545 {
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000546 ProcessSP process_sp (target->GetProcessSP());
547 if (process_sp)
Oleksiy Vyalov926af0c2015-02-03 00:04:35 +0000548 {
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000549 if (stream.GetData())
550 result.AppendMessage(stream.GetData());
Oleksiy Vyalov926af0c2015-02-03 00:04:35 +0000551 result.SetStatus (eReturnStatusSuccessFinishNoResult);
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000552 result.SetDidChangeProcessState (true);
Oleksiy Vyalov926af0c2015-02-03 00:04:35 +0000553 }
554 else
555 {
Oleksiy Vyalov37386142015-02-10 22:49:57 +0000556 result.AppendError("no error returned from Target::Attach, and target has no process");
Oleksiy Vyalov926af0c2015-02-03 00:04:35 +0000557 result.SetStatus (eReturnStatusFailed);
558 }
Jim Ingham5aee1622010-08-09 23:31:02 +0000559 }
560 else
561 {
Oleksiy Vyalov926af0c2015-02-03 00:04:35 +0000562 result.AppendErrorWithFormat ("attach failed: %s\n", error.AsCString());
563 result.SetStatus (eReturnStatusFailed);
Jim Ingham5aee1622010-08-09 23:31:02 +0000564 }
Oleksiy Vyalov926af0c2015-02-03 00:04:35 +0000565
566 if (!result.Succeeded())
567 return false;
568
569 // Okay, we're done. Last step is to warn if the executable module has changed:
570 char new_path[PATH_MAX];
571 ModuleSP new_exec_module_sp (target->GetExecutableModule());
572 if (!old_exec_module_sp)
Jim Ingham5aee1622010-08-09 23:31:02 +0000573 {
Oleksiy Vyalov926af0c2015-02-03 00:04:35 +0000574 // We might not have a module if we attached to a raw pid...
575 if (new_exec_module_sp)
Jim Ingham5aee1622010-08-09 23:31:02 +0000576 {
Oleksiy Vyalov926af0c2015-02-03 00:04:35 +0000577 new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);
578 result.AppendMessageWithFormat("Executable module set to \"%s\".\n", new_path);
Jim Ingham5aee1622010-08-09 23:31:02 +0000579 }
Jim Ingham5aee1622010-08-09 23:31:02 +0000580 }
Oleksiy Vyalov926af0c2015-02-03 00:04:35 +0000581 else if (old_exec_module_sp->GetFileSpec() != new_exec_module_sp->GetFileSpec())
582 {
583 char old_path[PATH_MAX];
584
585 old_exec_module_sp->GetFileSpec().GetPath (old_path, PATH_MAX);
586 new_exec_module_sp->GetFileSpec().GetPath (new_path, PATH_MAX);
587
588 result.AppendWarningWithFormat("Executable module changed from \"%s\" to \"%s\".\n",
589 old_path, new_path);
590 }
591
592 if (!old_arch_spec.IsValid())
593 {
594 result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().GetTriple().getTriple().c_str());
595 }
596 else if (!old_arch_spec.IsExactMatch(target->GetArchitecture()))
597 {
598 result.AppendWarningWithFormat("Architecture changed from %s to %s.\n",
599 old_arch_spec.GetTriple().getTriple().c_str(),
600 target->GetArchitecture().GetTriple().getTriple().c_str());
601 }
602
603 // This supports the use-case scenario of immediately continuing the process once attached.
604 if (m_options.attach_info.GetContinueOnceAttached())
605 m_interpreter.HandleCommand("process continue", eLazyBoolNo, result);
606
Jim Ingham5aee1622010-08-09 23:31:02 +0000607 return result.Succeeded();
608 }
609
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000610 CommandOptions m_options;
611};
612
613
Greg Claytone0d378b2011-03-24 21:19:54 +0000614OptionDefinition
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000615CommandObjectProcessAttach::CommandOptions::g_option_table[] =
616{
Zachary Turnerd37221d2014-07-09 16:31:49 +0000617{ LLDB_OPT_SET_ALL, false, "continue",'c', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Immediately continue the process once attached."},
618{ LLDB_OPT_SET_ALL, false, "plugin", 'P', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
619{ LLDB_OPT_SET_1, false, "pid", 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePid, "The process ID of an existing process to attach to."},
620{ LLDB_OPT_SET_2, false, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeProcessName, "The name of the process to attach to."},
621{ LLDB_OPT_SET_2, false, "include-existing", 'i', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Include existing processes when doing attach -w."},
622{ LLDB_OPT_SET_2, false, "waitfor", 'w', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Wait for the process with <process-name> to launch."},
623{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000624};
625
626//-------------------------------------------------------------------------
627// CommandObjectProcessContinue
628//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +0000629#pragma mark CommandObjectProcessContinue
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000630
Jim Ingham5a988412012-06-08 21:56:10 +0000631class CommandObjectProcessContinue : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000632{
633public:
634
Greg Claytona7015092010-09-18 01:14:36 +0000635 CommandObjectProcessContinue (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +0000636 CommandObjectParsed (interpreter,
637 "process continue",
638 "Continue execution of all threads in the current process.",
639 "process continue",
Enrico Granatae87764f2015-05-27 05:04:35 +0000640 eCommandRequiresProcess |
641 eCommandTryTargetAPILock |
642 eCommandProcessMustBeLaunched |
643 eCommandProcessMustBePaused ),
Jim Ingham0e410842012-08-11 01:27:55 +0000644 m_options(interpreter)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000645 {
646 }
647
648
649 ~CommandObjectProcessContinue ()
650 {
651 }
652
Jim Ingham5a988412012-06-08 21:56:10 +0000653protected:
Jim Ingham0e410842012-08-11 01:27:55 +0000654
655 class CommandOptions : public Options
656 {
657 public:
658
659 CommandOptions (CommandInterpreter &interpreter) :
660 Options(interpreter)
661 {
662 // Keep default values of all options in one place: OptionParsingStarting ()
663 OptionParsingStarting ();
664 }
665
666 ~CommandOptions ()
667 {
668 }
669
670 Error
671 SetOptionValue (uint32_t option_idx, const char *option_arg)
672 {
673 Error error;
Greg Clayton3bcdfc02012-12-04 00:32:51 +0000674 const int short_option = m_getopt_table[option_idx].val;
Jim Ingham0e410842012-08-11 01:27:55 +0000675 bool success = false;
676 switch (short_option)
677 {
678 case 'i':
Vince Harron5275aaa2015-01-15 20:08:35 +0000679 m_ignore = StringConvert::ToUInt32 (option_arg, 0, 0, &success);
Jim Ingham0e410842012-08-11 01:27:55 +0000680 if (!success)
681 error.SetErrorStringWithFormat ("invalid value for ignore option: \"%s\", should be a number.", option_arg);
682 break;
683
684 default:
685 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
686 break;
687 }
688 return error;
689 }
690
691 void
692 OptionParsingStarting ()
693 {
694 m_ignore = 0;
695 }
696
697 const OptionDefinition*
698 GetDefinitions ()
699 {
700 return g_option_table;
701 }
702
703 // Options table: Required for subclasses of Options.
704
705 static OptionDefinition g_option_table[];
706
707 uint32_t m_ignore;
708 };
709
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000710 bool
Greg Claytonf9fc6092013-01-09 19:44:40 +0000711 DoExecute (Args& command, CommandReturnObject &result)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000712 {
Greg Claytonf9fc6092013-01-09 19:44:40 +0000713 Process *process = m_exe_ctx.GetProcessPtr();
Greg Claytona7015092010-09-18 01:14:36 +0000714 bool synchronous_execution = m_interpreter.GetSynchronous ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000715 StateType state = process->GetState();
716 if (state == eStateStopped)
717 {
718 if (command.GetArgumentCount() != 0)
719 {
720 result.AppendErrorWithFormat ("The '%s' command does not take any arguments.\n", m_cmd_name.c_str());
721 result.SetStatus (eReturnStatusFailed);
722 return false;
723 }
724
Jim Ingham0e410842012-08-11 01:27:55 +0000725 if (m_options.m_ignore > 0)
726 {
727 ThreadSP sel_thread_sp(process->GetThreadList().GetSelectedThread());
728 if (sel_thread_sp)
729 {
730 StopInfoSP stop_info_sp = sel_thread_sp->GetStopInfo();
731 if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint)
732 {
Greg Claytonc7bece562013-01-25 18:06:21 +0000733 lldb::break_id_t bp_site_id = (lldb::break_id_t)stop_info_sp->GetValue();
Jim Ingham0e410842012-08-11 01:27:55 +0000734 BreakpointSiteSP bp_site_sp(process->GetBreakpointSiteList().FindByID(bp_site_id));
735 if (bp_site_sp)
736 {
Greg Claytonc7bece562013-01-25 18:06:21 +0000737 const size_t num_owners = bp_site_sp->GetNumberOfOwners();
738 for (size_t i = 0; i < num_owners; i++)
Jim Ingham0e410842012-08-11 01:27:55 +0000739 {
740 Breakpoint &bp_ref = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
741 if (!bp_ref.IsInternal())
742 {
743 bp_ref.SetIgnoreCount(m_options.m_ignore);
744 }
745 }
746 }
747 }
748 }
749 }
750
Jim Ingham41f2b942012-09-10 20:50:15 +0000751 { // Scope for thread list mutex:
752 Mutex::Locker locker (process->GetThreadList().GetMutex());
753 const uint32_t num_threads = process->GetThreadList().GetSize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000754
Jim Ingham41f2b942012-09-10 20:50:15 +0000755 // Set the actions that the threads should each take when resuming
756 for (uint32_t idx=0; idx<num_threads; ++idx)
757 {
Jim Ingham6c9ed912014-04-03 01:26:14 +0000758 const bool override_suspend = false;
759 process->GetThreadList().GetThreadAtIndex(idx)->SetResumeState (eStateRunning, override_suspend);
Jim Ingham41f2b942012-09-10 20:50:15 +0000760 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000761 }
Todd Fialaa3b89e22014-08-12 14:33:19 +0000762
Pavel Labath44464872015-05-27 12:40:32 +0000763 const uint32_t iohandler_id = process->GetIOHandlerID();
764
Greg Claytondc6224e2014-10-21 01:00:42 +0000765 StreamString stream;
766 Error error;
767 if (synchronous_execution)
768 error = process->ResumeSynchronous (&stream);
769 else
770 error = process->Resume ();
Todd Fialaa3b89e22014-08-12 14:33:19 +0000771
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000772 if (error.Success())
773 {
Todd Fialaa3b89e22014-08-12 14:33:19 +0000774 // There is a race condition where this thread will return up the call stack to the main command
Pavel Labath44464872015-05-27 12:40:32 +0000775 // handler and show an (lldb) prompt before HandlePrivateEvent (from PrivateStateThread) has
776 // a chance to call PushProcessIOHandler().
777 process->SyncIOHandler(iohandler_id, 2000);
Todd Fialaa3b89e22014-08-12 14:33:19 +0000778
Daniel Malead01b2952012-11-29 21:49:15 +0000779 result.AppendMessageWithFormat ("Process %" PRIu64 " resuming\n", process->GetID());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000780 if (synchronous_execution)
781 {
Greg Claytondc6224e2014-10-21 01:00:42 +0000782 // If any state changed events had anything to say, add that to the result
783 if (stream.GetData())
784 result.AppendMessage(stream.GetData());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000785
786 result.SetDidChangeProcessState (true);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000787 result.SetStatus (eReturnStatusSuccessFinishNoResult);
788 }
789 else
790 {
791 result.SetStatus (eReturnStatusSuccessContinuingNoResult);
792 }
793 }
794 else
795 {
796 result.AppendErrorWithFormat("Failed to resume process: %s.\n", error.AsCString());
797 result.SetStatus (eReturnStatusFailed);
798 }
799 }
800 else
801 {
802 result.AppendErrorWithFormat ("Process cannot be continued from its current state (%s).\n",
803 StateAsCString(state));
804 result.SetStatus (eReturnStatusFailed);
805 }
806 return result.Succeeded();
807 }
Jim Ingham0e410842012-08-11 01:27:55 +0000808
809 Options *
810 GetOptions ()
811 {
812 return &m_options;
813 }
814
815 CommandOptions m_options;
816
817};
818
819OptionDefinition
820CommandObjectProcessContinue::CommandOptions::g_option_table[] =
821{
Zachary Turnerd37221d2014-07-09 16:31:49 +0000822{ LLDB_OPT_SET_ALL, false, "ignore-count",'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeUnsignedInteger,
Jim Ingham0e410842012-08-11 01:27:55 +0000823 "Ignore <N> crossings of the breakpoint (if it exists) for the currently selected thread."},
Zachary Turnerd37221d2014-07-09 16:31:49 +0000824{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000825};
826
827//-------------------------------------------------------------------------
828// CommandObjectProcessDetach
829//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +0000830#pragma mark CommandObjectProcessDetach
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000831
Jim Ingham5a988412012-06-08 21:56:10 +0000832class CommandObjectProcessDetach : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000833{
834public:
Jim Inghamacff8952013-05-02 00:27:30 +0000835 class CommandOptions : public Options
836 {
837 public:
838
839 CommandOptions (CommandInterpreter &interpreter) :
840 Options (interpreter)
841 {
842 OptionParsingStarting ();
843 }
844
845 ~CommandOptions ()
846 {
847 }
848
849 Error
850 SetOptionValue (uint32_t option_idx, const char *option_arg)
851 {
852 Error error;
853 const int short_option = m_getopt_table[option_idx].val;
854
855 switch (short_option)
856 {
857 case 's':
858 bool tmp_result;
859 bool success;
860 tmp_result = Args::StringToBoolean(option_arg, false, &success);
861 if (!success)
862 error.SetErrorStringWithFormat("invalid boolean option: \"%s\"", option_arg);
863 else
864 {
865 if (tmp_result)
866 m_keep_stopped = eLazyBoolYes;
867 else
868 m_keep_stopped = eLazyBoolNo;
869 }
870 break;
871 default:
872 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
873 break;
874 }
875 return error;
876 }
877
878 void
879 OptionParsingStarting ()
880 {
881 m_keep_stopped = eLazyBoolCalculate;
882 }
883
884 const OptionDefinition*
885 GetDefinitions ()
886 {
887 return g_option_table;
888 }
889
890 // Options table: Required for subclasses of Options.
891
892 static OptionDefinition g_option_table[];
893
894 // Instance variables to hold the values for command options.
895 LazyBool m_keep_stopped;
896 };
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000897
Greg Claytona7015092010-09-18 01:14:36 +0000898 CommandObjectProcessDetach (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +0000899 CommandObjectParsed (interpreter,
900 "process detach",
901 "Detach from the current process being debugged.",
902 "process detach",
Enrico Granatae87764f2015-05-27 05:04:35 +0000903 eCommandRequiresProcess |
904 eCommandTryTargetAPILock |
905 eCommandProcessMustBeLaunched),
Jim Inghamacff8952013-05-02 00:27:30 +0000906 m_options(interpreter)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000907 {
908 }
909
910 ~CommandObjectProcessDetach ()
911 {
912 }
913
Jim Inghamacff8952013-05-02 00:27:30 +0000914 Options *
915 GetOptions ()
916 {
917 return &m_options;
918 }
919
920
Jim Ingham5a988412012-06-08 21:56:10 +0000921protected:
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000922 bool
Greg Claytonf9fc6092013-01-09 19:44:40 +0000923 DoExecute (Args& command, CommandReturnObject &result)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000924 {
Greg Claytonf9fc6092013-01-09 19:44:40 +0000925 Process *process = m_exe_ctx.GetProcessPtr();
Jim Inghamacff8952013-05-02 00:27:30 +0000926 // FIXME: This will be a Command Option:
927 bool keep_stopped;
928 if (m_options.m_keep_stopped == eLazyBoolCalculate)
929 {
930 // Check the process default:
931 if (process->GetDetachKeepsStopped())
932 keep_stopped = true;
933 else
934 keep_stopped = false;
935 }
936 else if (m_options.m_keep_stopped == eLazyBoolYes)
937 keep_stopped = true;
938 else
939 keep_stopped = false;
940
941 Error error (process->Detach(keep_stopped));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000942 if (error.Success())
943 {
944 result.SetStatus (eReturnStatusSuccessFinishResult);
945 }
946 else
947 {
948 result.AppendErrorWithFormat ("Detach failed: %s\n", error.AsCString());
949 result.SetStatus (eReturnStatusFailed);
950 return false;
951 }
952 return result.Succeeded();
953 }
Jim Inghamacff8952013-05-02 00:27:30 +0000954
955 CommandOptions m_options;
956};
957
958OptionDefinition
959CommandObjectProcessDetach::CommandOptions::g_option_table[] =
960{
Zachary Turnerd37221d2014-07-09 16:31:49 +0000961{ LLDB_OPT_SET_1, false, "keep-stopped", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." },
962{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000963};
964
965//-------------------------------------------------------------------------
Greg Claytonb766a732011-02-04 01:58:07 +0000966// CommandObjectProcessConnect
967//-------------------------------------------------------------------------
968#pragma mark CommandObjectProcessConnect
969
Jim Ingham5a988412012-06-08 21:56:10 +0000970class CommandObjectProcessConnect : public CommandObjectParsed
Greg Claytonb766a732011-02-04 01:58:07 +0000971{
972public:
973
974 class CommandOptions : public Options
975 {
976 public:
977
Greg Claytoneb0103f2011-04-07 22:46:35 +0000978 CommandOptions (CommandInterpreter &interpreter) :
979 Options(interpreter)
Greg Claytonb766a732011-02-04 01:58:07 +0000980 {
Greg Claytonf6b8b582011-04-13 00:18:08 +0000981 // Keep default values of all options in one place: OptionParsingStarting ()
982 OptionParsingStarting ();
Greg Claytonb766a732011-02-04 01:58:07 +0000983 }
984
985 ~CommandOptions ()
986 {
987 }
988
989 Error
Greg Claytonf6b8b582011-04-13 00:18:08 +0000990 SetOptionValue (uint32_t option_idx, const char *option_arg)
Greg Claytonb766a732011-02-04 01:58:07 +0000991 {
992 Error error;
Greg Clayton3bcdfc02012-12-04 00:32:51 +0000993 const int short_option = m_getopt_table[option_idx].val;
Greg Claytonb766a732011-02-04 01:58:07 +0000994
995 switch (short_option)
996 {
997 case 'p':
998 plugin_name.assign (option_arg);
999 break;
1000
1001 default:
Greg Clayton86edbf42011-10-26 00:56:27 +00001002 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
Greg Claytonb766a732011-02-04 01:58:07 +00001003 break;
1004 }
1005 return error;
1006 }
1007
1008 void
Greg Claytonf6b8b582011-04-13 00:18:08 +00001009 OptionParsingStarting ()
Greg Claytonb766a732011-02-04 01:58:07 +00001010 {
Greg Claytonb766a732011-02-04 01:58:07 +00001011 plugin_name.clear();
1012 }
1013
Greg Claytone0d378b2011-03-24 21:19:54 +00001014 const OptionDefinition*
Greg Claytonb766a732011-02-04 01:58:07 +00001015 GetDefinitions ()
1016 {
1017 return g_option_table;
1018 }
1019
1020 // Options table: Required for subclasses of Options.
1021
Greg Claytone0d378b2011-03-24 21:19:54 +00001022 static OptionDefinition g_option_table[];
Greg Claytonb766a732011-02-04 01:58:07 +00001023
1024 // Instance variables to hold the values for command options.
1025
1026 std::string plugin_name;
1027 };
1028
1029 CommandObjectProcessConnect (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001030 CommandObjectParsed (interpreter,
1031 "process connect",
1032 "Connect to a remote debug service.",
1033 "process connect <remote-url>",
1034 0),
Greg Claytoneb0103f2011-04-07 22:46:35 +00001035 m_options (interpreter)
Greg Claytonb766a732011-02-04 01:58:07 +00001036 {
1037 }
1038
1039 ~CommandObjectProcessConnect ()
1040 {
1041 }
1042
1043
Jim Ingham5a988412012-06-08 21:56:10 +00001044 Options *
1045 GetOptions ()
1046 {
1047 return &m_options;
1048 }
1049
1050protected:
Greg Claytonb766a732011-02-04 01:58:07 +00001051 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001052 DoExecute (Args& command,
Greg Claytonb766a732011-02-04 01:58:07 +00001053 CommandReturnObject &result)
1054 {
1055
1056 TargetSP target_sp (m_interpreter.GetDebugger().GetSelectedTarget());
1057 Error error;
Greg Claytonf9fc6092013-01-09 19:44:40 +00001058 Process *process = m_exe_ctx.GetProcessPtr();
Greg Claytonb766a732011-02-04 01:58:07 +00001059 if (process)
1060 {
1061 if (process->IsAlive())
1062 {
Daniel Malead01b2952012-11-29 21:49:15 +00001063 result.AppendErrorWithFormat ("Process %" PRIu64 " is currently being debugged, kill the process before connecting.\n",
Greg Claytonb766a732011-02-04 01:58:07 +00001064 process->GetID());
1065 result.SetStatus (eReturnStatusFailed);
1066 return false;
1067 }
1068 }
1069
1070 if (!target_sp)
1071 {
1072 // If there isn't a current target create one.
Greg Claytonb766a732011-02-04 01:58:07 +00001073
1074 error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(),
Greg Claytona0ca6602012-10-18 16:33:33 +00001075 NULL,
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001076 NULL,
Greg Claytonb766a732011-02-04 01:58:07 +00001077 false,
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001078 NULL, // No platform options
Greg Claytonb766a732011-02-04 01:58:07 +00001079 target_sp);
1080 if (!target_sp || error.Fail())
1081 {
1082 result.AppendError(error.AsCString("Error creating target"));
1083 result.SetStatus (eReturnStatusFailed);
1084 return false;
1085 }
1086 m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target_sp.get());
1087 }
1088
1089 if (command.GetArgumentCount() == 1)
1090 {
1091 const char *plugin_name = NULL;
1092 if (!m_options.plugin_name.empty())
1093 plugin_name = m_options.plugin_name.c_str();
1094
1095 const char *remote_url = command.GetArgumentAtIndex(0);
Greg Claytonc3776bf2012-02-09 06:16:32 +00001096 process = target_sp->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name, NULL).get();
Greg Claytonb766a732011-02-04 01:58:07 +00001097
1098 if (process)
1099 {
Greg Clayton44d93782014-01-27 23:43:24 +00001100 error = process->ConnectRemote (process->GetTarget().GetDebugger().GetOutputFile().get(), remote_url);
Greg Claytonb766a732011-02-04 01:58:07 +00001101
1102 if (error.Fail())
1103 {
1104 result.AppendError(error.AsCString("Remote connect failed"));
1105 result.SetStatus (eReturnStatusFailed);
Greg Clayton1517dd32012-03-31 00:10:30 +00001106 target_sp->DeleteCurrentProcess();
Greg Claytonb766a732011-02-04 01:58:07 +00001107 return false;
1108 }
1109 }
1110 else
1111 {
Jason Molendafd54b362011-09-20 21:44:10 +00001112 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",
Daniel Maleaf00b7512012-12-18 20:00:40 +00001113 remote_url);
Greg Claytonb766a732011-02-04 01:58:07 +00001114 result.SetStatus (eReturnStatusFailed);
1115 }
1116 }
1117 else
1118 {
Jason Molendafd54b362011-09-20 21:44:10 +00001119 result.AppendErrorWithFormat ("'%s' takes exactly one argument:\nUsage: %s\n",
Greg Claytonb766a732011-02-04 01:58:07 +00001120 m_cmd_name.c_str(),
1121 m_cmd_syntax.c_str());
1122 result.SetStatus (eReturnStatusFailed);
1123 }
1124 return result.Succeeded();
1125 }
Greg Claytonb766a732011-02-04 01:58:07 +00001126
1127 CommandOptions m_options;
1128};
1129
Greg Claytone0d378b2011-03-24 21:19:54 +00001130OptionDefinition
Greg Claytonb766a732011-02-04 01:58:07 +00001131CommandObjectProcessConnect::CommandOptions::g_option_table[] =
1132{
Zachary Turnerd37221d2014-07-09 16:31:49 +00001133 { LLDB_OPT_SET_ALL, false, "plugin", 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
1134 { 0, false, NULL, 0 , 0, NULL, NULL, 0, eArgTypeNone, NULL }
Greg Claytonb766a732011-02-04 01:58:07 +00001135};
1136
1137//-------------------------------------------------------------------------
Greg Clayton998255b2012-10-13 02:07:45 +00001138// CommandObjectProcessPlugin
1139//-------------------------------------------------------------------------
1140#pragma mark CommandObjectProcessPlugin
1141
1142class CommandObjectProcessPlugin : public CommandObjectProxy
1143{
1144public:
1145
1146 CommandObjectProcessPlugin (CommandInterpreter &interpreter) :
1147 CommandObjectProxy (interpreter,
1148 "process plugin",
1149 "Send a custom command to the current process plug-in.",
1150 "process plugin <args>",
1151 0)
1152 {
1153 }
1154
1155 ~CommandObjectProcessPlugin ()
1156 {
1157 }
1158
1159 virtual CommandObject *
1160 GetProxyCommandObject()
1161 {
Greg Claytone05b2ef2013-01-09 22:58:18 +00001162 Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
Greg Clayton998255b2012-10-13 02:07:45 +00001163 if (process)
1164 return process->GetPluginCommandObject();
1165 return NULL;
1166 }
1167};
1168
1169
1170//-------------------------------------------------------------------------
Greg Clayton8f343b02010-11-04 01:54:29 +00001171// CommandObjectProcessLoad
1172//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +00001173#pragma mark CommandObjectProcessLoad
Greg Clayton8f343b02010-11-04 01:54:29 +00001174
Jim Ingham5a988412012-06-08 21:56:10 +00001175class CommandObjectProcessLoad : public CommandObjectParsed
Greg Clayton8f343b02010-11-04 01:54:29 +00001176{
1177public:
1178
1179 CommandObjectProcessLoad (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001180 CommandObjectParsed (interpreter,
1181 "process load",
1182 "Load a shared library into the current process.",
1183 "process load <filename> [<filename> ...]",
Enrico Granatae87764f2015-05-27 05:04:35 +00001184 eCommandRequiresProcess |
1185 eCommandTryTargetAPILock |
1186 eCommandProcessMustBeLaunched |
1187 eCommandProcessMustBePaused )
Greg Clayton8f343b02010-11-04 01:54:29 +00001188 {
1189 }
1190
1191 ~CommandObjectProcessLoad ()
1192 {
1193 }
1194
Jim Ingham5a988412012-06-08 21:56:10 +00001195protected:
Greg Clayton8f343b02010-11-04 01:54:29 +00001196 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001197 DoExecute (Args& command,
Greg Clayton8f343b02010-11-04 01:54:29 +00001198 CommandReturnObject &result)
1199 {
Greg Claytonf9fc6092013-01-09 19:44:40 +00001200 Process *process = m_exe_ctx.GetProcessPtr();
Greg Clayton8f343b02010-11-04 01:54:29 +00001201
Greg Claytonc7bece562013-01-25 18:06:21 +00001202 const size_t argc = command.GetArgumentCount();
Greg Clayton8f343b02010-11-04 01:54:29 +00001203
1204 for (uint32_t i=0; i<argc; ++i)
1205 {
1206 Error error;
1207 const char *image_path = command.GetArgumentAtIndex(i);
1208 FileSpec image_spec (image_path, false);
Greg Claytonaa516842011-08-11 16:25:18 +00001209 process->GetTarget().GetPlatform()->ResolveRemotePath(image_spec, image_spec);
Greg Clayton8f343b02010-11-04 01:54:29 +00001210 uint32_t image_token = process->LoadImage(image_spec, error);
1211 if (image_token != LLDB_INVALID_IMAGE_TOKEN)
1212 {
1213 result.AppendMessageWithFormat ("Loading \"%s\"...ok\nImage %u loaded.\n", image_path, image_token);
1214 result.SetStatus (eReturnStatusSuccessFinishResult);
1215 }
1216 else
1217 {
1218 result.AppendErrorWithFormat ("failed to load '%s': %s", image_path, error.AsCString());
1219 result.SetStatus (eReturnStatusFailed);
1220 }
1221 }
1222 return result.Succeeded();
1223 }
1224};
1225
1226
1227//-------------------------------------------------------------------------
1228// CommandObjectProcessUnload
1229//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +00001230#pragma mark CommandObjectProcessUnload
Greg Clayton8f343b02010-11-04 01:54:29 +00001231
Jim Ingham5a988412012-06-08 21:56:10 +00001232class CommandObjectProcessUnload : public CommandObjectParsed
Greg Clayton8f343b02010-11-04 01:54:29 +00001233{
1234public:
1235
1236 CommandObjectProcessUnload (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001237 CommandObjectParsed (interpreter,
1238 "process unload",
1239 "Unload a shared library from the current process using the index returned by a previous call to \"process load\".",
1240 "process unload <index>",
Enrico Granatae87764f2015-05-27 05:04:35 +00001241 eCommandRequiresProcess |
1242 eCommandTryTargetAPILock |
1243 eCommandProcessMustBeLaunched |
1244 eCommandProcessMustBePaused )
Greg Clayton8f343b02010-11-04 01:54:29 +00001245 {
1246 }
1247
1248 ~CommandObjectProcessUnload ()
1249 {
1250 }
1251
Jim Ingham5a988412012-06-08 21:56:10 +00001252protected:
Greg Clayton8f343b02010-11-04 01:54:29 +00001253 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001254 DoExecute (Args& command,
Greg Clayton8f343b02010-11-04 01:54:29 +00001255 CommandReturnObject &result)
1256 {
Greg Claytonf9fc6092013-01-09 19:44:40 +00001257 Process *process = m_exe_ctx.GetProcessPtr();
Greg Clayton8f343b02010-11-04 01:54:29 +00001258
Greg Claytonc7bece562013-01-25 18:06:21 +00001259 const size_t argc = command.GetArgumentCount();
Greg Clayton8f343b02010-11-04 01:54:29 +00001260
1261 for (uint32_t i=0; i<argc; ++i)
1262 {
1263 const char *image_token_cstr = command.GetArgumentAtIndex(i);
Vince Harron5275aaa2015-01-15 20:08:35 +00001264 uint32_t image_token = StringConvert::ToUInt32(image_token_cstr, LLDB_INVALID_IMAGE_TOKEN, 0);
Greg Clayton8f343b02010-11-04 01:54:29 +00001265 if (image_token == LLDB_INVALID_IMAGE_TOKEN)
1266 {
1267 result.AppendErrorWithFormat ("invalid image index argument '%s'", image_token_cstr);
1268 result.SetStatus (eReturnStatusFailed);
1269 break;
1270 }
1271 else
1272 {
1273 Error error (process->UnloadImage(image_token));
1274 if (error.Success())
1275 {
1276 result.AppendMessageWithFormat ("Unloading shared library with index %u...ok\n", image_token);
1277 result.SetStatus (eReturnStatusSuccessFinishResult);
1278 }
1279 else
1280 {
1281 result.AppendErrorWithFormat ("failed to unload image: %s", error.AsCString());
1282 result.SetStatus (eReturnStatusFailed);
1283 break;
1284 }
1285 }
1286 }
1287 return result.Succeeded();
1288 }
1289};
1290
1291//-------------------------------------------------------------------------
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001292// CommandObjectProcessSignal
1293//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +00001294#pragma mark CommandObjectProcessSignal
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001295
Jim Ingham5a988412012-06-08 21:56:10 +00001296class CommandObjectProcessSignal : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001297{
1298public:
1299
Greg Claytona7015092010-09-18 01:14:36 +00001300 CommandObjectProcessSignal (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001301 CommandObjectParsed (interpreter,
1302 "process signal",
1303 "Send a UNIX signal to the current process being debugged.",
Greg Claytonf9fc6092013-01-09 19:44:40 +00001304 NULL,
Enrico Granatae87764f2015-05-27 05:04:35 +00001305 eCommandRequiresProcess | eCommandTryTargetAPILock)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001306 {
Caroline Tice405fe672010-10-04 22:28:36 +00001307 CommandArgumentEntry arg;
1308 CommandArgumentData signal_arg;
1309
1310 // Define the first (and only) variant of this arg.
Caroline Ticec0dbdfb2010-10-18 22:56:57 +00001311 signal_arg.arg_type = eArgTypeUnixSignal;
Caroline Tice405fe672010-10-04 22:28:36 +00001312 signal_arg.arg_repetition = eArgRepeatPlain;
1313
1314 // There is only one variant this argument could be; put it into the argument entry.
1315 arg.push_back (signal_arg);
1316
1317 // Push the data for the first argument into the m_arguments vector.
1318 m_arguments.push_back (arg);
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001319 }
1320
1321 ~CommandObjectProcessSignal ()
1322 {
1323 }
1324
Jim Ingham5a988412012-06-08 21:56:10 +00001325protected:
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001326 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001327 DoExecute (Args& command,
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001328 CommandReturnObject &result)
1329 {
Greg Claytonf9fc6092013-01-09 19:44:40 +00001330 Process *process = m_exe_ctx.GetProcessPtr();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001331
1332 if (command.GetArgumentCount() == 1)
1333 {
Greg Clayton237cd902010-10-09 01:40:57 +00001334 int signo = LLDB_INVALID_SIGNAL_NUMBER;
1335
1336 const char *signal_name = command.GetArgumentAtIndex(0);
1337 if (::isxdigit (signal_name[0]))
Vince Harron5275aaa2015-01-15 20:08:35 +00001338 signo = StringConvert::ToSInt32(signal_name, LLDB_INVALID_SIGNAL_NUMBER, 0);
Greg Clayton237cd902010-10-09 01:40:57 +00001339 else
1340 signo = process->GetUnixSignals().GetSignalNumberFromName (signal_name);
1341
1342 if (signo == LLDB_INVALID_SIGNAL_NUMBER)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001343 {
1344 result.AppendErrorWithFormat ("Invalid signal argument '%s'.\n", command.GetArgumentAtIndex(0));
1345 result.SetStatus (eReturnStatusFailed);
1346 }
1347 else
1348 {
1349 Error error (process->Signal (signo));
1350 if (error.Success())
1351 {
1352 result.SetStatus (eReturnStatusSuccessFinishResult);
1353 }
1354 else
1355 {
1356 result.AppendErrorWithFormat ("Failed to send signal %i: %s\n", signo, error.AsCString());
1357 result.SetStatus (eReturnStatusFailed);
1358 }
1359 }
1360 }
1361 else
1362 {
Jason Molendafd54b362011-09-20 21:44:10 +00001363 result.AppendErrorWithFormat("'%s' takes exactly one signal number argument:\nUsage: %s\n", m_cmd_name.c_str(),
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001364 m_cmd_syntax.c_str());
1365 result.SetStatus (eReturnStatusFailed);
1366 }
1367 return result.Succeeded();
1368 }
1369};
1370
1371
1372//-------------------------------------------------------------------------
1373// CommandObjectProcessInterrupt
1374//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +00001375#pragma mark CommandObjectProcessInterrupt
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001376
Jim Ingham5a988412012-06-08 21:56:10 +00001377class CommandObjectProcessInterrupt : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001378{
1379public:
1380
1381
Greg Claytona7015092010-09-18 01:14:36 +00001382 CommandObjectProcessInterrupt (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001383 CommandObjectParsed (interpreter,
1384 "process interrupt",
1385 "Interrupt the current process being debugged.",
1386 "process interrupt",
Enrico Granatae87764f2015-05-27 05:04:35 +00001387 eCommandRequiresProcess |
1388 eCommandTryTargetAPILock |
1389 eCommandProcessMustBeLaunched)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001390 {
1391 }
1392
1393 ~CommandObjectProcessInterrupt ()
1394 {
1395 }
1396
Jim Ingham5a988412012-06-08 21:56:10 +00001397protected:
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001398 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001399 DoExecute (Args& command,
Greg Claytonf9b57b92013-05-10 23:48:10 +00001400 CommandReturnObject &result)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001401 {
Greg Claytonf9fc6092013-01-09 19:44:40 +00001402 Process *process = m_exe_ctx.GetProcessPtr();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001403 if (process == NULL)
1404 {
1405 result.AppendError ("no process to halt");
1406 result.SetStatus (eReturnStatusFailed);
1407 return false;
1408 }
1409
1410 if (command.GetArgumentCount() == 0)
1411 {
Greg Claytonf9b57b92013-05-10 23:48:10 +00001412 bool clear_thread_plans = true;
1413 Error error(process->Halt (clear_thread_plans));
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001414 if (error.Success())
1415 {
1416 result.SetStatus (eReturnStatusSuccessFinishResult);
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001417 }
1418 else
1419 {
1420 result.AppendErrorWithFormat ("Failed to halt process: %s\n", error.AsCString());
1421 result.SetStatus (eReturnStatusFailed);
1422 }
1423 }
1424 else
1425 {
Jason Molendafd54b362011-09-20 21:44:10 +00001426 result.AppendErrorWithFormat("'%s' takes no arguments:\nUsage: %s\n",
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001427 m_cmd_name.c_str(),
1428 m_cmd_syntax.c_str());
1429 result.SetStatus (eReturnStatusFailed);
1430 }
1431 return result.Succeeded();
1432 }
1433};
1434
1435//-------------------------------------------------------------------------
1436// CommandObjectProcessKill
1437//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +00001438#pragma mark CommandObjectProcessKill
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001439
Jim Ingham5a988412012-06-08 21:56:10 +00001440class CommandObjectProcessKill : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001441{
1442public:
1443
Greg Claytona7015092010-09-18 01:14:36 +00001444 CommandObjectProcessKill (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001445 CommandObjectParsed (interpreter,
1446 "process kill",
1447 "Terminate the current process being debugged.",
1448 "process kill",
Enrico Granatae87764f2015-05-27 05:04:35 +00001449 eCommandRequiresProcess |
1450 eCommandTryTargetAPILock |
1451 eCommandProcessMustBeLaunched)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001452 {
1453 }
1454
1455 ~CommandObjectProcessKill ()
1456 {
1457 }
1458
Jim Ingham5a988412012-06-08 21:56:10 +00001459protected:
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001460 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001461 DoExecute (Args& command,
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001462 CommandReturnObject &result)
1463 {
Greg Claytonf9fc6092013-01-09 19:44:40 +00001464 Process *process = m_exe_ctx.GetProcessPtr();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001465 if (process == NULL)
1466 {
1467 result.AppendError ("no process to kill");
1468 result.SetStatus (eReturnStatusFailed);
1469 return false;
1470 }
1471
1472 if (command.GetArgumentCount() == 0)
1473 {
Jason Molenda8980e6b2015-05-01 23:39:48 +00001474 Error error (process->Destroy(true));
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001475 if (error.Success())
1476 {
1477 result.SetStatus (eReturnStatusSuccessFinishResult);
1478 }
1479 else
1480 {
1481 result.AppendErrorWithFormat ("Failed to kill process: %s\n", error.AsCString());
1482 result.SetStatus (eReturnStatusFailed);
1483 }
1484 }
1485 else
1486 {
Jason Molendafd54b362011-09-20 21:44:10 +00001487 result.AppendErrorWithFormat("'%s' takes no arguments:\nUsage: %s\n",
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001488 m_cmd_name.c_str(),
1489 m_cmd_syntax.c_str());
1490 result.SetStatus (eReturnStatusFailed);
1491 }
1492 return result.Succeeded();
1493 }
1494};
1495
1496//-------------------------------------------------------------------------
Greg Claytona2715cf2014-06-13 00:54:12 +00001497// CommandObjectProcessSaveCore
1498//-------------------------------------------------------------------------
1499#pragma mark CommandObjectProcessSaveCore
1500
1501class CommandObjectProcessSaveCore : public CommandObjectParsed
1502{
1503public:
1504
1505 CommandObjectProcessSaveCore (CommandInterpreter &interpreter) :
1506 CommandObjectParsed (interpreter,
1507 "process save-core",
1508 "Save the current process as a core file using an appropriate file type.",
1509 "process save-core FILE",
Enrico Granatae87764f2015-05-27 05:04:35 +00001510 eCommandRequiresProcess |
1511 eCommandTryTargetAPILock |
1512 eCommandProcessMustBeLaunched)
Greg Claytona2715cf2014-06-13 00:54:12 +00001513 {
1514 }
1515
1516 ~CommandObjectProcessSaveCore ()
1517 {
1518 }
1519
1520protected:
1521 bool
1522 DoExecute (Args& command,
1523 CommandReturnObject &result)
1524 {
1525 ProcessSP process_sp = m_exe_ctx.GetProcessSP();
1526 if (process_sp)
1527 {
1528 if (command.GetArgumentCount() == 1)
1529 {
1530 FileSpec output_file(command.GetArgumentAtIndex(0), false);
1531 Error error = PluginManager::SaveCore(process_sp, output_file);
1532 if (error.Success())
1533 {
1534 result.SetStatus (eReturnStatusSuccessFinishResult);
1535 }
1536 else
1537 {
1538 result.AppendErrorWithFormat ("Failed to save core file for process: %s\n", error.AsCString());
1539 result.SetStatus (eReturnStatusFailed);
1540 }
1541 }
1542 else
1543 {
1544 result.AppendErrorWithFormat ("'%s' takes one arguments:\nUsage: %s\n",
1545 m_cmd_name.c_str(),
1546 m_cmd_syntax.c_str());
1547 result.SetStatus (eReturnStatusFailed);
1548 }
1549 }
1550 else
1551 {
1552 result.AppendError ("invalid process");
1553 result.SetStatus (eReturnStatusFailed);
1554 return false;
1555 }
1556
1557 return result.Succeeded();
1558 }
1559};
1560
1561//-------------------------------------------------------------------------
Jim Ingham4b9bea82010-06-18 01:23:09 +00001562// CommandObjectProcessStatus
1563//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +00001564#pragma mark CommandObjectProcessStatus
1565
Jim Ingham5a988412012-06-08 21:56:10 +00001566class CommandObjectProcessStatus : public CommandObjectParsed
Jim Ingham4b9bea82010-06-18 01:23:09 +00001567{
1568public:
Greg Claytona7015092010-09-18 01:14:36 +00001569 CommandObjectProcessStatus (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001570 CommandObjectParsed (interpreter,
1571 "process status",
1572 "Show the current status and location of executing process.",
1573 "process status",
Enrico Granatae87764f2015-05-27 05:04:35 +00001574 eCommandRequiresProcess | eCommandTryTargetAPILock)
Jim Ingham4b9bea82010-06-18 01:23:09 +00001575 {
1576 }
1577
1578 ~CommandObjectProcessStatus()
1579 {
1580 }
1581
1582
1583 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001584 DoExecute (Args& command, CommandReturnObject &result)
Jim Ingham4b9bea82010-06-18 01:23:09 +00001585 {
Greg Clayton7260f622011-04-18 08:33:37 +00001586 Stream &strm = result.GetOutputStream();
Jim Ingham4b9bea82010-06-18 01:23:09 +00001587 result.SetStatus (eReturnStatusSuccessFinishNoResult);
Enrico Granatae87764f2015-05-27 05:04:35 +00001588 // No need to check "process" for validity as eCommandRequiresProcess ensures it is valid
Greg Claytonf9fc6092013-01-09 19:44:40 +00001589 Process *process = m_exe_ctx.GetProcessPtr();
1590 const bool only_threads_with_stop_reason = true;
1591 const uint32_t start_frame = 0;
1592 const uint32_t num_frames = 1;
1593 const uint32_t num_frames_with_source = 1;
1594 process->GetStatus(strm);
1595 process->GetThreadStatus (strm,
1596 only_threads_with_stop_reason,
1597 start_frame,
1598 num_frames,
1599 num_frames_with_source);
Jim Ingham4b9bea82010-06-18 01:23:09 +00001600 return result.Succeeded();
1601 }
1602};
1603
1604//-------------------------------------------------------------------------
Caroline Tice35731352010-10-13 20:44:39 +00001605// CommandObjectProcessHandle
1606//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +00001607#pragma mark CommandObjectProcessHandle
Caroline Tice35731352010-10-13 20:44:39 +00001608
Jim Ingham5a988412012-06-08 21:56:10 +00001609class CommandObjectProcessHandle : public CommandObjectParsed
Caroline Tice35731352010-10-13 20:44:39 +00001610{
1611public:
1612
1613 class CommandOptions : public Options
1614 {
1615 public:
1616
Greg Claytoneb0103f2011-04-07 22:46:35 +00001617 CommandOptions (CommandInterpreter &interpreter) :
1618 Options (interpreter)
Caroline Tice35731352010-10-13 20:44:39 +00001619 {
Greg Claytonf6b8b582011-04-13 00:18:08 +00001620 OptionParsingStarting ();
Caroline Tice35731352010-10-13 20:44:39 +00001621 }
1622
1623 ~CommandOptions ()
1624 {
1625 }
1626
1627 Error
Greg Claytonf6b8b582011-04-13 00:18:08 +00001628 SetOptionValue (uint32_t option_idx, const char *option_arg)
Caroline Tice35731352010-10-13 20:44:39 +00001629 {
1630 Error error;
Greg Clayton3bcdfc02012-12-04 00:32:51 +00001631 const int short_option = m_getopt_table[option_idx].val;
Caroline Tice35731352010-10-13 20:44:39 +00001632
1633 switch (short_option)
1634 {
1635 case 's':
1636 stop = option_arg;
1637 break;
1638 case 'n':
1639 notify = option_arg;
1640 break;
1641 case 'p':
1642 pass = option_arg;
1643 break;
1644 default:
Greg Clayton86edbf42011-10-26 00:56:27 +00001645 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
Caroline Tice35731352010-10-13 20:44:39 +00001646 break;
1647 }
1648 return error;
1649 }
1650
1651 void
Greg Claytonf6b8b582011-04-13 00:18:08 +00001652 OptionParsingStarting ()
Caroline Tice35731352010-10-13 20:44:39 +00001653 {
Caroline Tice35731352010-10-13 20:44:39 +00001654 stop.clear();
1655 notify.clear();
1656 pass.clear();
1657 }
1658
Greg Claytone0d378b2011-03-24 21:19:54 +00001659 const OptionDefinition*
Caroline Tice35731352010-10-13 20:44:39 +00001660 GetDefinitions ()
1661 {
1662 return g_option_table;
1663 }
1664
1665 // Options table: Required for subclasses of Options.
1666
Greg Claytone0d378b2011-03-24 21:19:54 +00001667 static OptionDefinition g_option_table[];
Caroline Tice35731352010-10-13 20:44:39 +00001668
1669 // Instance variables to hold the values for command options.
1670
1671 std::string stop;
1672 std::string notify;
1673 std::string pass;
1674 };
1675
1676
1677 CommandObjectProcessHandle (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001678 CommandObjectParsed (interpreter,
1679 "process handle",
1680 "Show or update what the process and debugger should do with various signals received from the OS.",
1681 NULL),
Greg Claytoneb0103f2011-04-07 22:46:35 +00001682 m_options (interpreter)
Caroline Tice35731352010-10-13 20:44:39 +00001683 {
Caroline Tice10ad7992010-10-14 21:31:13 +00001684 SetHelpLong ("If no signals are specified, update them all. If no update option is specified, list the current values.\n");
Caroline Tice35731352010-10-13 20:44:39 +00001685 CommandArgumentEntry arg;
Caroline Ticec0dbdfb2010-10-18 22:56:57 +00001686 CommandArgumentData signal_arg;
Caroline Tice35731352010-10-13 20:44:39 +00001687
Caroline Ticec0dbdfb2010-10-18 22:56:57 +00001688 signal_arg.arg_type = eArgTypeUnixSignal;
1689 signal_arg.arg_repetition = eArgRepeatStar;
Caroline Tice35731352010-10-13 20:44:39 +00001690
Caroline Ticec0dbdfb2010-10-18 22:56:57 +00001691 arg.push_back (signal_arg);
Caroline Tice35731352010-10-13 20:44:39 +00001692
1693 m_arguments.push_back (arg);
1694 }
1695
1696 ~CommandObjectProcessHandle ()
1697 {
1698 }
1699
1700 Options *
1701 GetOptions ()
1702 {
1703 return &m_options;
1704 }
1705
1706 bool
Caroline Tice10ad7992010-10-14 21:31:13 +00001707 VerifyCommandOptionValue (const std::string &option, int &real_value)
Caroline Tice35731352010-10-13 20:44:39 +00001708 {
1709 bool okay = true;
1710
Caroline Tice10ad7992010-10-14 21:31:13 +00001711 bool success = false;
1712 bool tmp_value = Args::StringToBoolean (option.c_str(), false, &success);
1713
1714 if (success && tmp_value)
1715 real_value = 1;
1716 else if (success && !tmp_value)
1717 real_value = 0;
Caroline Tice35731352010-10-13 20:44:39 +00001718 else
1719 {
1720 // If the value isn't 'true' or 'false', it had better be 0 or 1.
Vince Harron5275aaa2015-01-15 20:08:35 +00001721 real_value = StringConvert::ToUInt32 (option.c_str(), 3);
Caroline Tice10ad7992010-10-14 21:31:13 +00001722 if (real_value != 0 && real_value != 1)
Caroline Tice35731352010-10-13 20:44:39 +00001723 okay = false;
1724 }
1725
1726 return okay;
1727 }
1728
Caroline Tice10ad7992010-10-14 21:31:13 +00001729 void
1730 PrintSignalHeader (Stream &str)
1731 {
Pavel Labathb84141a2015-05-22 08:46:18 +00001732 str.Printf ("NAME PASS STOP NOTIFY\n");
1733 str.Printf ("=========== ===== ===== ======\n");
Caroline Tice10ad7992010-10-14 21:31:13 +00001734 }
1735
1736 void
1737 PrintSignal (Stream &str, int32_t signo, const char *sig_name, UnixSignals &signals)
1738 {
1739 bool stop;
1740 bool suppress;
1741 bool notify;
1742
Pavel Labathb84141a2015-05-22 08:46:18 +00001743 str.Printf ("%-11s ", sig_name);
Caroline Tice10ad7992010-10-14 21:31:13 +00001744 if (signals.GetSignalInfo (signo, suppress, stop, notify))
1745 {
1746 bool pass = !suppress;
1747 str.Printf ("%s %s %s",
1748 (pass ? "true " : "false"),
1749 (stop ? "true " : "false"),
1750 (notify ? "true " : "false"));
1751 }
1752 str.Printf ("\n");
1753 }
1754
1755 void
1756 PrintSignalInformation (Stream &str, Args &signal_args, int num_valid_signals, UnixSignals &signals)
1757 {
1758 PrintSignalHeader (str);
1759
1760 if (num_valid_signals > 0)
1761 {
1762 size_t num_args = signal_args.GetArgumentCount();
1763 for (size_t i = 0; i < num_args; ++i)
1764 {
1765 int32_t signo = signals.GetSignalNumberFromName (signal_args.GetArgumentAtIndex (i));
1766 if (signo != LLDB_INVALID_SIGNAL_NUMBER)
1767 PrintSignal (str, signo, signal_args.GetArgumentAtIndex (i), signals);
1768 }
1769 }
1770 else // Print info for ALL signals
1771 {
1772 int32_t signo = signals.GetFirstSignalNumber();
1773 while (signo != LLDB_INVALID_SIGNAL_NUMBER)
1774 {
1775 PrintSignal (str, signo, signals.GetSignalAsCString (signo), signals);
1776 signo = signals.GetNextSignalNumber (signo);
1777 }
1778 }
1779 }
1780
Jim Ingham5a988412012-06-08 21:56:10 +00001781protected:
Caroline Tice35731352010-10-13 20:44:39 +00001782 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001783 DoExecute (Args &signal_args, CommandReturnObject &result)
Caroline Tice35731352010-10-13 20:44:39 +00001784 {
1785 TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget();
1786
1787 if (!target_sp)
1788 {
1789 result.AppendError ("No current target;"
1790 " cannot handle signals until you have a valid target and process.\n");
1791 result.SetStatus (eReturnStatusFailed);
1792 return false;
1793 }
1794
1795 ProcessSP process_sp = target_sp->GetProcessSP();
1796
1797 if (!process_sp)
1798 {
1799 result.AppendError ("No current process; cannot handle signals until you have a valid process.\n");
1800 result.SetStatus (eReturnStatusFailed);
1801 return false;
1802 }
1803
Caroline Tice35731352010-10-13 20:44:39 +00001804 int stop_action = -1; // -1 means leave the current setting alone
Caroline Tice10ad7992010-10-14 21:31:13 +00001805 int pass_action = -1; // -1 means leave the current setting alone
Caroline Tice35731352010-10-13 20:44:39 +00001806 int notify_action = -1; // -1 means leave the current setting alone
1807
1808 if (! m_options.stop.empty()
Caroline Tice10ad7992010-10-14 21:31:13 +00001809 && ! VerifyCommandOptionValue (m_options.stop, stop_action))
Caroline Tice35731352010-10-13 20:44:39 +00001810 {
1811 result.AppendError ("Invalid argument for command option --stop; must be true or false.\n");
1812 result.SetStatus (eReturnStatusFailed);
1813 return false;
1814 }
1815
1816 if (! m_options.notify.empty()
Caroline Tice10ad7992010-10-14 21:31:13 +00001817 && ! VerifyCommandOptionValue (m_options.notify, notify_action))
Caroline Tice35731352010-10-13 20:44:39 +00001818 {
1819 result.AppendError ("Invalid argument for command option --notify; must be true or false.\n");
1820 result.SetStatus (eReturnStatusFailed);
1821 return false;
1822 }
1823
1824 if (! m_options.pass.empty()
Caroline Tice10ad7992010-10-14 21:31:13 +00001825 && ! VerifyCommandOptionValue (m_options.pass, pass_action))
Caroline Tice35731352010-10-13 20:44:39 +00001826 {
1827 result.AppendError ("Invalid argument for command option --pass; must be true or false.\n");
1828 result.SetStatus (eReturnStatusFailed);
1829 return false;
1830 }
1831
1832 size_t num_args = signal_args.GetArgumentCount();
1833 UnixSignals &signals = process_sp->GetUnixSignals();
1834 int num_signals_set = 0;
1835
Caroline Tice10ad7992010-10-14 21:31:13 +00001836 if (num_args > 0)
Caroline Tice35731352010-10-13 20:44:39 +00001837 {
Caroline Tice10ad7992010-10-14 21:31:13 +00001838 for (size_t i = 0; i < num_args; ++i)
Caroline Tice35731352010-10-13 20:44:39 +00001839 {
Caroline Tice10ad7992010-10-14 21:31:13 +00001840 int32_t signo = signals.GetSignalNumberFromName (signal_args.GetArgumentAtIndex (i));
1841 if (signo != LLDB_INVALID_SIGNAL_NUMBER)
Caroline Tice35731352010-10-13 20:44:39 +00001842 {
Caroline Tice10ad7992010-10-14 21:31:13 +00001843 // Casting the actions as bools here should be okay, because VerifyCommandOptionValue guarantees
1844 // the value is either 0 or 1.
1845 if (stop_action != -1)
1846 signals.SetShouldStop (signo, (bool) stop_action);
1847 if (pass_action != -1)
1848 {
1849 bool suppress = ! ((bool) pass_action);
1850 signals.SetShouldSuppress (signo, suppress);
1851 }
1852 if (notify_action != -1)
1853 signals.SetShouldNotify (signo, (bool) notify_action);
1854 ++num_signals_set;
Caroline Tice35731352010-10-13 20:44:39 +00001855 }
Caroline Tice10ad7992010-10-14 21:31:13 +00001856 else
1857 {
1858 result.AppendErrorWithFormat ("Invalid signal name '%s'\n", signal_args.GetArgumentAtIndex (i));
1859 }
Caroline Tice35731352010-10-13 20:44:39 +00001860 }
1861 }
Caroline Tice10ad7992010-10-14 21:31:13 +00001862 else
1863 {
1864 // No signal specified, if any command options were specified, update ALL signals.
1865 if ((notify_action != -1) || (stop_action != -1) || (pass_action != -1))
1866 {
1867 if (m_interpreter.Confirm ("Do you really want to update all the signals?", false))
1868 {
1869 int32_t signo = signals.GetFirstSignalNumber();
1870 while (signo != LLDB_INVALID_SIGNAL_NUMBER)
1871 {
1872 if (notify_action != -1)
1873 signals.SetShouldNotify (signo, (bool) notify_action);
1874 if (stop_action != -1)
1875 signals.SetShouldStop (signo, (bool) stop_action);
1876 if (pass_action != -1)
1877 {
1878 bool suppress = ! ((bool) pass_action);
1879 signals.SetShouldSuppress (signo, suppress);
1880 }
1881 signo = signals.GetNextSignalNumber (signo);
1882 }
1883 }
1884 }
1885 }
1886
1887 PrintSignalInformation (result.GetOutputStream(), signal_args, num_signals_set, signals);
Caroline Tice35731352010-10-13 20:44:39 +00001888
1889 if (num_signals_set > 0)
1890 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1891 else
1892 result.SetStatus (eReturnStatusFailed);
1893
1894 return result.Succeeded();
1895 }
1896
Caroline Tice35731352010-10-13 20:44:39 +00001897 CommandOptions m_options;
1898};
1899
Greg Claytone0d378b2011-03-24 21:19:54 +00001900OptionDefinition
Caroline Tice35731352010-10-13 20:44:39 +00001901CommandObjectProcessHandle::CommandOptions::g_option_table[] =
1902{
Zachary Turnerd37221d2014-07-09 16:31:49 +00001903{ LLDB_OPT_SET_1, false, "stop", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Whether or not the process should be stopped if the signal is received." },
1904{ LLDB_OPT_SET_1, false, "notify", 'n', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Whether or not the debugger should notify the user if the signal is received." },
1905{ LLDB_OPT_SET_1, false, "pass", 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Whether or not the signal should be passed to the process." },
1906{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
Caroline Tice35731352010-10-13 20:44:39 +00001907};
1908
1909//-------------------------------------------------------------------------
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001910// CommandObjectMultiwordProcess
1911//-------------------------------------------------------------------------
1912
Greg Clayton66111032010-06-23 01:19:29 +00001913CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter &interpreter) :
Greg Claytona7015092010-09-18 01:14:36 +00001914 CommandObjectMultiword (interpreter,
1915 "process",
1916 "A set of commands for operating on a process.",
1917 "process <subcommand> [<subcommand-options>]")
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001918{
Greg Clayton197bacf2011-07-02 21:07:54 +00001919 LoadSubCommand ("attach", CommandObjectSP (new CommandObjectProcessAttach (interpreter)));
1920 LoadSubCommand ("launch", CommandObjectSP (new CommandObjectProcessLaunch (interpreter)));
1921 LoadSubCommand ("continue", CommandObjectSP (new CommandObjectProcessContinue (interpreter)));
1922 LoadSubCommand ("connect", CommandObjectSP (new CommandObjectProcessConnect (interpreter)));
1923 LoadSubCommand ("detach", CommandObjectSP (new CommandObjectProcessDetach (interpreter)));
1924 LoadSubCommand ("load", CommandObjectSP (new CommandObjectProcessLoad (interpreter)));
1925 LoadSubCommand ("unload", CommandObjectSP (new CommandObjectProcessUnload (interpreter)));
1926 LoadSubCommand ("signal", CommandObjectSP (new CommandObjectProcessSignal (interpreter)));
1927 LoadSubCommand ("handle", CommandObjectSP (new CommandObjectProcessHandle (interpreter)));
1928 LoadSubCommand ("status", CommandObjectSP (new CommandObjectProcessStatus (interpreter)));
Greg Claytona7015092010-09-18 01:14:36 +00001929 LoadSubCommand ("interrupt", CommandObjectSP (new CommandObjectProcessInterrupt (interpreter)));
Greg Clayton197bacf2011-07-02 21:07:54 +00001930 LoadSubCommand ("kill", CommandObjectSP (new CommandObjectProcessKill (interpreter)));
Greg Clayton998255b2012-10-13 02:07:45 +00001931 LoadSubCommand ("plugin", CommandObjectSP (new CommandObjectProcessPlugin (interpreter)));
Greg Claytona2715cf2014-06-13 00:54:12 +00001932 LoadSubCommand ("save-core", CommandObjectSP (new CommandObjectProcessSaveCore (interpreter)));
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001933}
1934
1935CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess ()
1936{
1937}
1938