blob: 7ad5f7be9351bea211419ffb922a36ffba5d2606 [file] [log] [blame]
Chris Lattner24943d22010-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
Daniel Malead891f9b2012-12-05 00:20:57 +000010#include "lldb/lldb-python.h"
11
Chris Lattner24943d22010-06-08 16:52:24 +000012#include "CommandObjectProcess.h"
13
14// C Includes
15// C++ Includes
16// Other libraries and framework includes
17// Project includes
Jim Ingham124e6902012-08-11 01:27:55 +000018#include "lldb/Breakpoint/Breakpoint.h"
19#include "lldb/Breakpoint/BreakpointLocation.h"
20#include "lldb/Breakpoint/BreakpointSite.h"
Chris Lattner24943d22010-06-08 16:52:24 +000021#include "lldb/Core/State.h"
Greg Clayton49ce8962012-08-29 21:13:06 +000022#include "lldb/Core/Module.h"
Greg Claytonabe0fed2011-04-18 08:33:37 +000023#include "lldb/Host/Host.h"
Jim Ingham124e6902012-08-11 01:27:55 +000024#include "lldb/Interpreter/Args.h"
25#include "lldb/Interpreter/Options.h"
Chris Lattner24943d22010-06-08 16:52:24 +000026#include "lldb/Interpreter/CommandInterpreter.h"
27#include "lldb/Interpreter/CommandReturnObject.h"
Greg Claytone4b9c1f2011-03-08 22:40:15 +000028#include "lldb/Target/Platform.h"
Chris Lattner24943d22010-06-08 16:52:24 +000029#include "lldb/Target/Process.h"
Jim Ingham124e6902012-08-11 01:27:55 +000030#include "lldb/Target/StopInfo.h"
Chris Lattner24943d22010-06-08 16:52:24 +000031#include "lldb/Target/Target.h"
32#include "lldb/Target/Thread.h"
33
34using namespace lldb;
35using namespace lldb_private;
36
Jim Inghamd3b4bd52013-03-29 00:56:30 +000037class CommandObjectProcessLaunchOrAttach : public CommandObjectParsed
38{
39public:
40 CommandObjectProcessLaunchOrAttach (CommandInterpreter &interpreter,
41 const char *name,
42 const char *help,
43 const char *syntax,
44 uint32_t flags,
45 const char *new_process_action) :
46 CommandObjectParsed (interpreter, name, help, syntax, flags),
47 m_new_process_action (new_process_action) {}
48
49 virtual ~CommandObjectProcessLaunchOrAttach () {}
50protected:
51 bool
52 StopProcessIfNecessary (Process *&process, StateType &state, CommandReturnObject &result)
53 {
54 state = eStateInvalid;
55 if (process)
56 {
57 state = process->GetState();
58
59 if (process->IsAlive() && state != eStateConnected)
60 {
61 char message[1024];
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());
66 else
67 ::snprintf (message, sizeof(message), "There is a running process, kill it and %s?", m_new_process_action.c_str());
68
69 if (!m_interpreter.Confirm (message, true))
70 {
71 result.SetStatus (eReturnStatusFailed);
72 return false;
73 }
74 else
75 {
76 if (process->GetShouldDetach())
77 {
Jim Ingham761afb82013-05-02 00:27:30 +000078 bool keep_stopped = false;
79 Error detach_error (process->Detach(keep_stopped));
Jim Inghamd3b4bd52013-03-29 00:56:30 +000080 if (detach_error.Success())
81 {
82 result.SetStatus (eReturnStatusSuccessFinishResult);
83 process = NULL;
84 }
85 else
86 {
87 result.AppendErrorWithFormat ("Failed to detach from process: %s\n", detach_error.AsCString());
88 result.SetStatus (eReturnStatusFailed);
89 }
90 }
91 else
92 {
93 Error destroy_error (process->Destroy());
94 if (destroy_error.Success())
95 {
96 result.SetStatus (eReturnStatusSuccessFinishResult);
97 process = NULL;
98 }
99 else
100 {
101 result.AppendErrorWithFormat ("Failed to kill process: %s\n", destroy_error.AsCString());
102 result.SetStatus (eReturnStatusFailed);
103 }
104 }
105 }
106 }
107 }
108 return result.Succeeded();
109 }
110 std::string m_new_process_action;
111};
Chris Lattner24943d22010-06-08 16:52:24 +0000112//-------------------------------------------------------------------------
113// CommandObjectProcessLaunch
114//-------------------------------------------------------------------------
Jim Ingham5a15e692012-02-16 06:50:00 +0000115#pragma mark CommandObjectProcessLaunch
Jim Inghamd3b4bd52013-03-29 00:56:30 +0000116class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach
Chris Lattner24943d22010-06-08 16:52:24 +0000117{
118public:
119
Greg Clayton238c0a12010-09-18 01:14:36 +0000120 CommandObjectProcessLaunch (CommandInterpreter &interpreter) :
Jim Inghamd3b4bd52013-03-29 00:56:30 +0000121 CommandObjectProcessLaunchOrAttach (interpreter,
122 "process launch",
123 "Launch the executable in the debugger.",
124 NULL,
125 eFlagRequiresTarget,
126 "restart"),
Greg Claytonf15996e2011-04-07 22:46:35 +0000127 m_options (interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +0000128 {
Caroline Tice43b014a2010-10-04 22:28:36 +0000129 CommandArgumentEntry arg;
130 CommandArgumentData run_args_arg;
131
132 // Define the first (and only) variant of this arg.
133 run_args_arg.arg_type = eArgTypeRunArgs;
134 run_args_arg.arg_repetition = eArgRepeatOptional;
135
136 // There is only one variant this argument could be; put it into the argument entry.
137 arg.push_back (run_args_arg);
138
139 // Push the data for the first argument into the m_arguments vector.
140 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000141 }
142
143
144 ~CommandObjectProcessLaunch ()
145 {
146 }
147
Greg Clayton36da2aa2013-01-25 18:06:21 +0000148 virtual int
Jim Ingham392d9e02012-08-10 21:48:41 +0000149 HandleArgumentCompletion (Args &input,
150 int &cursor_index,
151 int &cursor_char_position,
152 OptionElementVector &opt_element_vector,
153 int match_start_point,
154 int max_return_elements,
155 bool &word_complete,
156 StringList &matches)
157 {
158 std::string completion_str (input.GetArgumentAtIndex(cursor_index));
159 completion_str.erase (cursor_char_position);
160
161 CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
162 CommandCompletions::eDiskFileCompletion,
163 completion_str.c_str(),
164 match_start_point,
165 max_return_elements,
166 NULL,
167 word_complete,
168 matches);
169 return matches.GetSize();
170 }
171
Chris Lattner24943d22010-06-08 16:52:24 +0000172 Options *
173 GetOptions ()
174 {
175 return &m_options;
176 }
177
Jim Inghamda26bd22012-06-08 21:56:10 +0000178 virtual const char *GetRepeatCommand (Args &current_command_args, uint32_t index)
179 {
180 // No repeat for "process launch"...
181 return "";
182 }
183
184protected:
Chris Lattner24943d22010-06-08 16:52:24 +0000185 bool
Jim Inghamda26bd22012-06-08 21:56:10 +0000186 DoExecute (Args& launch_args, CommandReturnObject &result)
Chris Lattner24943d22010-06-08 16:52:24 +0000187 {
Greg Claytonabb33022011-11-08 02:43:13 +0000188 Debugger &debugger = m_interpreter.GetDebugger();
189 Target *target = debugger.GetSelectedTarget().get();
190 Error error;
Chris Lattner24943d22010-06-08 16:52:24 +0000191 // If our listener is NULL, users aren't allows to launch
Chris Lattner24943d22010-06-08 16:52:24 +0000192 char filename[PATH_MAX];
Greg Clayton5beb99d2011-08-11 02:48:45 +0000193 const Module *exe_module = target->GetExecutableModulePointer();
Greg Claytona2f74232011-02-24 22:24:29 +0000194
195 if (exe_module == NULL)
196 {
Greg Claytone1f50b92011-05-03 22:09:39 +0000197 result.AppendError ("no file in target, create a debug target using the 'target create' command");
Greg Claytona2f74232011-02-24 22:24:29 +0000198 result.SetStatus (eReturnStatusFailed);
199 return false;
200 }
201
Greg Claytona2f74232011-02-24 22:24:29 +0000202 StateType state = eStateInvalid;
Greg Claytonea0bb4d2013-01-09 19:44:40 +0000203 Process *process = m_exe_ctx.GetProcessPtr();
Greg Claytona2f74232011-02-24 22:24:29 +0000204
Jim Inghamd3b4bd52013-03-29 00:56:30 +0000205 if (!StopProcessIfNecessary(process, state, result))
206 return false;
Jim Ingham22dc9722010-12-09 18:58:16 +0000207
Greg Clayton0c8446c2012-10-17 22:57:12 +0000208 const char *target_settings_argv0 = target->GetArg0();
209
210 exe_module->GetFileSpec().GetPath (filename, sizeof(filename));
211
212 if (target_settings_argv0)
213 {
214 m_options.launch_info.GetArguments().AppendArgument (target_settings_argv0);
215 m_options.launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), false);
216 }
217 else
218 {
219 m_options.launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
220 }
221
Greg Clayton527154d2011-11-15 03:53:30 +0000222 if (launch_args.GetArgumentCount() == 0)
223 {
Greg Clayton73844aa2012-08-22 17:17:09 +0000224 Args target_setting_args;
Greg Clayton0c8446c2012-10-17 22:57:12 +0000225 if (target->GetRunArguments(target_setting_args))
Greg Clayton73844aa2012-08-22 17:17:09 +0000226 m_options.launch_info.GetArguments().AppendArguments (target_setting_args);
Greg Clayton527154d2011-11-15 03:53:30 +0000227 }
228 else
Greg Claytonabb33022011-11-08 02:43:13 +0000229 {
Greg Clayton0c8446c2012-10-17 22:57:12 +0000230 m_options.launch_info.GetArguments().AppendArguments (launch_args);
231
Greg Clayton3e6f2cc2011-11-21 21:51:18 +0000232 // Save the arguments for subsequent runs in the current target.
233 target->SetRunArguments (launch_args);
Greg Claytonabb33022011-11-08 02:43:13 +0000234 }
Greg Claytonabb33022011-11-08 02:43:13 +0000235
Greg Clayton527154d2011-11-15 03:53:30 +0000236 if (target->GetDisableASLR())
237 m_options.launch_info.GetFlags().Set (eLaunchFlagDisableASLR);
238
239 if (target->GetDisableSTDIO())
240 m_options.launch_info.GetFlags().Set (eLaunchFlagDisableSTDIO);
241
242 m_options.launch_info.GetFlags().Set (eLaunchFlagDebug);
243
244 Args environment;
245 target->GetEnvironmentAsArgs (environment);
246 if (environment.GetArgumentCount() > 0)
247 m_options.launch_info.GetEnvironmentEntries ().AppendArguments (environment);
248
Jim Ingham89e248f2013-02-09 01:29:05 +0000249 // 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 ();
253
Greg Clayton464c6162011-11-17 22:14:31 +0000254 // 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);
Greg Clayton527154d2011-11-15 03:53:30 +0000258
Greg Claytonabb33022011-11-08 02:43:13 +0000259 if (state == eStateConnected)
260 {
261 if (m_options.launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY))
262 {
263 result.AppendWarning("can't launch in tty when launching through a remote connection");
264 m_options.launch_info.GetFlags().Clear (eLaunchFlagLaunchInTTY);
265 }
266 }
Jim Inghamd3b4bd52013-03-29 00:56:30 +0000267
268 if (!m_options.launch_info.GetArchitecture().IsValid())
269 m_options.launch_info.GetArchitecture() = target->GetArchitecture();
270
271 PlatformSP platform_sp (target->GetPlatform());
272
273 if (platform_sp && platform_sp->CanDebugProcess ())
274 {
275 process = target->GetPlatform()->DebugProcess (m_options.launch_info,
276 debugger,
277 target,
278 debugger.GetListener(),
279 error).get();
280 }
Greg Claytonabb33022011-11-08 02:43:13 +0000281 else
Caroline Tice6e4c5ce2010-09-04 00:03:46 +0000282 {
Jim Inghamd3b4bd52013-03-29 00:56:30 +0000283 const char *plugin_name = m_options.launch_info.GetProcessPluginName();
284 process = target->CreateProcess (debugger.GetListener(), plugin_name, NULL).get();
285 if (process)
286 error = process->Launch (m_options.launch_info);
Chris Lattner24943d22010-06-08 16:52:24 +0000287 }
Jim Inghamd3b4bd52013-03-29 00:56:30 +0000288
289 if (process == NULL)
290 {
291 result.SetError (error, "failed to launch or debug process");
292 return false;
293 }
294
Greg Claytonabb33022011-11-08 02:43:13 +0000295
Greg Clayton238c0a12010-09-18 01:14:36 +0000296 if (error.Success())
297 {
Greg Clayton940b1032011-02-23 00:35:02 +0000298 const char *archname = exe_module->GetArchitecture().GetArchitectureName();
Greg Claytonc1d37752010-10-18 01:45:30 +0000299
Daniel Malea5f35a4b2012-11-29 21:49:15 +0000300 result.AppendMessageWithFormat ("Process %" PRIu64 " launched: '%s' (%s)\n", process->GetID(), filename, archname);
Greg Claytond8c62532010-10-07 04:19:01 +0000301 result.SetDidChangeProcessState (true);
Greg Clayton36bc5ea2011-11-03 21:22:33 +0000302 if (m_options.launch_info.GetFlags().Test(eLaunchFlagStopAtEntry) == false)
Greg Clayton238c0a12010-09-18 01:14:36 +0000303 {
Greg Claytond8c62532010-10-07 04:19:01 +0000304 result.SetStatus (eReturnStatusSuccessContinuingNoResult);
Greg Clayton238c0a12010-09-18 01:14:36 +0000305 StateType state = process->WaitForProcessToStop (NULL);
306
307 if (state == eStateStopped)
308 {
Greg Claytond8c62532010-10-07 04:19:01 +0000309 error = process->Resume();
310 if (error.Success())
311 {
Greg Claytond8c62532010-10-07 04:19:01 +0000312 if (synchronous_execution)
313 {
314 state = process->WaitForProcessToStop (NULL);
Greg Clayton20206082011-11-17 01:23:07 +0000315 const bool must_be_alive = true;
316 if (!StateIsStoppedState(state, must_be_alive))
Greg Clayton395fc332011-02-15 21:59:32 +0000317 {
Greg Clayton527154d2011-11-15 03:53:30 +0000318 result.AppendErrorWithFormat ("process isn't stopped: %s", StateAsCString(state));
Greg Clayton395fc332011-02-15 21:59:32 +0000319 }
Greg Claytond8c62532010-10-07 04:19:01 +0000320 result.SetDidChangeProcessState (true);
321 result.SetStatus (eReturnStatusSuccessFinishResult);
322 }
323 else
324 {
325 result.SetStatus (eReturnStatusSuccessContinuingNoResult);
326 }
327 }
Greg Clayton395fc332011-02-15 21:59:32 +0000328 else
329 {
Greg Clayton527154d2011-11-15 03:53:30 +0000330 result.AppendErrorWithFormat ("process resume at entry point failed: %s", error.AsCString());
Greg Clayton395fc332011-02-15 21:59:32 +0000331 result.SetStatus (eReturnStatusFailed);
332 }
Greg Clayton238c0a12010-09-18 01:14:36 +0000333 }
Greg Clayton395fc332011-02-15 21:59:32 +0000334 else
335 {
Greg Clayton527154d2011-11-15 03:53:30 +0000336 result.AppendErrorWithFormat ("initial process state wasn't stopped: %s", StateAsCString(state));
Greg Clayton395fc332011-02-15 21:59:32 +0000337 result.SetStatus (eReturnStatusFailed);
338 }
Greg Clayton238c0a12010-09-18 01:14:36 +0000339 }
340 }
Greg Clayton395fc332011-02-15 21:59:32 +0000341 else
342 {
Greg Claytona9eb8272011-07-02 21:07:54 +0000343 result.AppendErrorWithFormat ("process launch failed: %s", error.AsCString());
Greg Clayton395fc332011-02-15 21:59:32 +0000344 result.SetStatus (eReturnStatusFailed);
345 }
Greg Clayton238c0a12010-09-18 01:14:36 +0000346
Chris Lattner24943d22010-06-08 16:52:24 +0000347 return result.Succeeded();
348 }
349
350protected:
Greg Clayton36bc5ea2011-11-03 21:22:33 +0000351 ProcessLaunchCommandOptions m_options;
Chris Lattner24943d22010-06-08 16:52:24 +0000352};
353
354
Greg Clayton36bc5ea2011-11-03 21:22:33 +0000355//#define SET1 LLDB_OPT_SET_1
356//#define SET2 LLDB_OPT_SET_2
357//#define SET3 LLDB_OPT_SET_3
358//
359//OptionDefinition
360//CommandObjectProcessLaunch::CommandOptions::g_option_table[] =
361//{
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."},
Sean Callanan9a91ef62012-10-24 01:12:14 +0000363//{ 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>."},
Greg Clayton36bc5ea2011-11-03 21:22:33 +0000366//{ SET1 | SET2 | SET3, false, "plugin", 'p', required_argument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
Sean Callanan9a91ef62012-10-24 01:12:14 +0000367//{ 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."},
Greg Clayton36bc5ea2011-11-03 21:22:33 +0000368//{ SET3, false, "no-stdio", 'n', no_argument, NULL, 0, eArgTypeNone, "Do not set up for terminal I/O to go to running process."},
Sean Callanan9a91ef62012-10-24 01:12:14 +0000369//{ SET1 | SET2 | SET3, false, "working-dir", 'w', required_argument, NULL, 0, eArgTypeDirectoryName, "Set the current working directory to <path> when running the inferior."},
Greg Clayton36bc5ea2011-11-03 21:22:33 +0000370//{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
371//};
372//
373//#undef SET1
374//#undef SET2
375//#undef SET3
Chris Lattner24943d22010-06-08 16:52:24 +0000376
377//-------------------------------------------------------------------------
378// CommandObjectProcessAttach
379//-------------------------------------------------------------------------
Jim Ingham22dc9722010-12-09 18:58:16 +0000380#pragma mark CommandObjectProcessAttach
Jim Inghamd3b4bd52013-03-29 00:56:30 +0000381class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach
Chris Lattner24943d22010-06-08 16:52:24 +0000382{
383public:
384
Chris Lattner24943d22010-06-08 16:52:24 +0000385 class CommandOptions : public Options
386 {
387 public:
388
Greg Claytonf15996e2011-04-07 22:46:35 +0000389 CommandOptions (CommandInterpreter &interpreter) :
390 Options(interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +0000391 {
Greg Clayton143fcc32011-04-13 00:18:08 +0000392 // Keep default values of all options in one place: OptionParsingStarting ()
393 OptionParsingStarting ();
Chris Lattner24943d22010-06-08 16:52:24 +0000394 }
395
396 ~CommandOptions ()
397 {
398 }
399
400 Error
Greg Clayton143fcc32011-04-13 00:18:08 +0000401 SetOptionValue (uint32_t option_idx, const char *option_arg)
Chris Lattner24943d22010-06-08 16:52:24 +0000402 {
403 Error error;
Greg Clayton6475c422012-12-04 00:32:51 +0000404 const int short_option = m_getopt_table[option_idx].val;
Chris Lattner24943d22010-06-08 16:52:24 +0000405 bool success = false;
406 switch (short_option)
407 {
Johnny Chen7c099972012-05-24 00:43:00 +0000408 case 'c':
409 attach_info.SetContinueOnceAttached(true);
410 break;
411
Chris Lattner24943d22010-06-08 16:52:24 +0000412 case 'p':
Chris Lattner24943d22010-06-08 16:52:24 +0000413 {
Greg Clayton527154d2011-11-15 03:53:30 +0000414 lldb::pid_t pid = Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
415 if (!success || pid == LLDB_INVALID_PROCESS_ID)
416 {
417 error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg);
418 }
419 else
420 {
421 attach_info.SetProcessID (pid);
422 }
Chris Lattner24943d22010-06-08 16:52:24 +0000423 }
424 break;
425
426 case 'P':
Greg Clayton527154d2011-11-15 03:53:30 +0000427 attach_info.SetProcessPluginName (option_arg);
Chris Lattner24943d22010-06-08 16:52:24 +0000428 break;
429
430 case 'n':
Greg Clayton527154d2011-11-15 03:53:30 +0000431 attach_info.GetExecutableFile().SetFile(option_arg, false);
Chris Lattner24943d22010-06-08 16:52:24 +0000432 break;
433
434 case 'w':
Greg Clayton527154d2011-11-15 03:53:30 +0000435 attach_info.SetWaitForLaunch(true);
Chris Lattner24943d22010-06-08 16:52:24 +0000436 break;
Jim Ingham3a458eb2012-07-20 21:37:13 +0000437
438 case 'i':
439 attach_info.SetIgnoreExisting(false);
440 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000441
442 default:
Greg Clayton9c236732011-10-26 00:56:27 +0000443 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
Chris Lattner24943d22010-06-08 16:52:24 +0000444 break;
445 }
446 return error;
447 }
448
449 void
Greg Clayton143fcc32011-04-13 00:18:08 +0000450 OptionParsingStarting ()
Chris Lattner24943d22010-06-08 16:52:24 +0000451 {
Greg Clayton527154d2011-11-15 03:53:30 +0000452 attach_info.Clear();
Chris Lattner24943d22010-06-08 16:52:24 +0000453 }
454
Greg Claytonb3448432011-03-24 21:19:54 +0000455 const OptionDefinition*
Chris Lattner24943d22010-06-08 16:52:24 +0000456 GetDefinitions ()
457 {
458 return g_option_table;
459 }
460
Jim Ingham7508e732010-08-09 23:31:02 +0000461 virtual bool
Greg Claytonf15996e2011-04-07 22:46:35 +0000462 HandleOptionArgumentCompletion (Args &input,
Jim Ingham7508e732010-08-09 23:31:02 +0000463 int cursor_index,
464 int char_pos,
465 OptionElementVector &opt_element_vector,
466 int opt_element_index,
467 int match_start_point,
468 int max_return_elements,
469 bool &word_complete,
470 StringList &matches)
471 {
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;
474
475 // We are only completing the name option for now...
476
Greg Claytonb3448432011-03-24 21:19:54 +0000477 const OptionDefinition *opt_defs = GetDefinitions();
Jim Ingham7508e732010-08-09 23:31:02 +0000478 if (opt_defs[opt_defs_index].short_option == 'n')
479 {
480 // Are we in the name?
481
482 // Look to see if there is a -P argument provided, and if so use that plugin, otherwise
483 // use the default plugin.
Jim Ingham7508e732010-08-09 23:31:02 +0000484
485 const char *partial_name = NULL;
486 partial_name = input.GetArgumentAtIndex(opt_arg_pos);
Greg Claytone4b9c1f2011-03-08 22:40:15 +0000487
Greg Claytonb72d0f02011-04-12 05:54:46 +0000488 PlatformSP platform_sp (m_interpreter.GetPlatform (true));
Greg Claytone4b9c1f2011-03-08 22:40:15 +0000489 if (platform_sp)
Jim Ingham7508e732010-08-09 23:31:02 +0000490 {
Greg Claytonb72d0f02011-04-12 05:54:46 +0000491 ProcessInstanceInfoList process_infos;
492 ProcessInstanceInfoMatch match_info;
Greg Clayton24bc5d92011-03-30 18:16:51 +0000493 if (partial_name)
494 {
Greg Clayton527154d2011-11-15 03:53:30 +0000495 match_info.GetProcessInfo().GetExecutableFile().SetFile(partial_name, false);
Greg Clayton24bc5d92011-03-30 18:16:51 +0000496 match_info.SetNameMatchType(eNameMatchStartsWith);
497 }
498 platform_sp->FindProcesses (match_info, process_infos);
Greg Clayton36da2aa2013-01-25 18:06:21 +0000499 const size_t num_matches = process_infos.GetSize();
Greg Claytone4b9c1f2011-03-08 22:40:15 +0000500 if (num_matches > 0)
501 {
Greg Clayton36da2aa2013-01-25 18:06:21 +0000502 for (size_t i=0; i<num_matches; ++i)
Greg Claytone4b9c1f2011-03-08 22:40:15 +0000503 {
504 matches.AppendString (process_infos.GetProcessNameAtIndex(i),
505 process_infos.GetProcessNameLengthAtIndex(i));
506 }
507 }
Jim Ingham7508e732010-08-09 23:31:02 +0000508 }
509 }
510
511 return false;
512 }
513
Chris Lattner24943d22010-06-08 16:52:24 +0000514 // Options table: Required for subclasses of Options.
515
Greg Claytonb3448432011-03-24 21:19:54 +0000516 static OptionDefinition g_option_table[];
Chris Lattner24943d22010-06-08 16:52:24 +0000517
518 // Instance variables to hold the values for command options.
519
Greg Clayton527154d2011-11-15 03:53:30 +0000520 ProcessAttachInfo attach_info;
Chris Lattner24943d22010-06-08 16:52:24 +0000521 };
522
Greg Clayton238c0a12010-09-18 01:14:36 +0000523 CommandObjectProcessAttach (CommandInterpreter &interpreter) :
Jim Inghamd3b4bd52013-03-29 00:56:30 +0000524 CommandObjectProcessLaunchOrAttach (interpreter,
525 "process attach",
526 "Attach to a process.",
527 "process attach <cmd-options>",
528 0,
529 "attach"),
Greg Claytonf15996e2011-04-07 22:46:35 +0000530 m_options (interpreter)
Jim Ingham7508e732010-08-09 23:31:02 +0000531 {
Jim Ingham7508e732010-08-09 23:31:02 +0000532 }
533
534 ~CommandObjectProcessAttach ()
535 {
536 }
537
Jim Inghamda26bd22012-06-08 21:56:10 +0000538 Options *
539 GetOptions ()
540 {
541 return &m_options;
542 }
543
544protected:
Jim Ingham7508e732010-08-09 23:31:02 +0000545 bool
Jim Inghamda26bd22012-06-08 21:56:10 +0000546 DoExecute (Args& command,
Jim Ingham7508e732010-08-09 23:31:02 +0000547 CommandReturnObject &result)
548 {
Greg Clayton238c0a12010-09-18 01:14:36 +0000549 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Jim Inghamee940e22011-09-15 01:08:57 +0000550 // 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
552 // ourselves here.
Jim Inghamc2dc7c82011-01-29 01:49:25 +0000553
Greg Claytona2f74232011-02-24 22:24:29 +0000554 StateType state = eStateInvalid;
Jim Inghamd3b4bd52013-03-29 00:56:30 +0000555 Process *process = m_exe_ctx.GetProcessPtr();
556
557 if (!StopProcessIfNecessary (process, state, result))
558 return false;
559
Jim Ingham7508e732010-08-09 23:31:02 +0000560 if (target == NULL)
561 {
562 // If there isn't a current target create one.
563 TargetSP new_target_sp;
Jim Ingham7508e732010-08-09 23:31:02 +0000564 Error error;
565
Greg Clayton238c0a12010-09-18 01:14:36 +0000566 error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(),
Greg Claytoned0a0fb2012-10-18 16:33:33 +0000567 NULL,
Greg Clayton3e8c25f2011-09-24 00:52:29 +0000568 NULL,
Greg Clayton238c0a12010-09-18 01:14:36 +0000569 false,
Greg Clayton3e8c25f2011-09-24 00:52:29 +0000570 NULL, // No platform options
Greg Clayton238c0a12010-09-18 01:14:36 +0000571 new_target_sp);
Jim Ingham7508e732010-08-09 23:31:02 +0000572 target = new_target_sp.get();
573 if (target == NULL || error.Fail())
574 {
Greg Claytone71e2582011-02-04 01:58:07 +0000575 result.AppendError(error.AsCString("Error creating target"));
Jim Ingham7508e732010-08-09 23:31:02 +0000576 return false;
577 }
Greg Clayton238c0a12010-09-18 01:14:36 +0000578 m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target);
Jim Ingham7508e732010-08-09 23:31:02 +0000579 }
580
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.)
583
584 ModuleSP old_exec_module_sp = target->GetExecutableModule();
585 ArchSpec old_arch_spec = target->GetArchitecture();
586
587 if (command.GetArgumentCount())
588 {
Jason Molenda7e5fa7f2011-09-20 21:44:10 +0000589 result.AppendErrorWithFormat("Invalid arguments for '%s'.\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str());
Jim Ingham7508e732010-08-09 23:31:02 +0000590 result.SetStatus (eReturnStatusFailed);
591 }
592 else
593 {
Greg Claytona2f74232011-02-24 22:24:29 +0000594 if (state != eStateConnected)
595 {
Greg Clayton527154d2011-11-15 03:53:30 +0000596 const char *plugin_name = m_options.attach_info.GetProcessPluginName();
Greg Clayton46c9a352012-02-09 06:16:32 +0000597 process = target->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name, NULL).get();
Greg Claytona2f74232011-02-24 22:24:29 +0000598 }
Jim Ingham7508e732010-08-09 23:31:02 +0000599
600 if (process)
601 {
602 Error error;
Greg Clayton527154d2011-11-15 03:53:30 +0000603 // 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 ())
Jim Ingham4805a1c2010-09-15 01:34:14 +0000606 {
607 if (old_exec_module_sp)
Greg Clayton1d1f39e2011-11-29 04:03:30 +0000608 m_options.attach_info.GetExecutableFile().GetFilename() = old_exec_module_sp->GetPlatformFileSpec().GetFilename();
Jim Ingham4805a1c2010-09-15 01:34:14 +0000609
Greg Clayton527154d2011-11-15 03:53:30 +0000610 if (!m_options.attach_info.ProcessInfoSpecified ())
611 {
612 error.SetErrorString ("no process specified, create a target with a file, or specify the --pid or --name command option");
613 }
614 }
615
616 if (error.Success())
617 {
618 error = process->Attach (m_options.attach_info);
619
Jim Ingham4805a1c2010-09-15 01:34:14 +0000620 if (error.Success())
621 {
622 result.SetStatus (eReturnStatusSuccessContinuingNoResult);
623 }
Jim Ingham7508e732010-08-09 23:31:02 +0000624 else
625 {
Greg Clayton527154d2011-11-15 03:53:30 +0000626 result.AppendErrorWithFormat ("attach failed: %s\n", error.AsCString());
Jim Ingham4805a1c2010-09-15 01:34:14 +0000627 result.SetStatus (eReturnStatusFailed);
628 return false;
Jim Ingham7508e732010-08-09 23:31:02 +0000629 }
Jim Inghamc2dc7c82011-01-29 01:49:25 +0000630 // 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.
Jim Inghamee940e22011-09-15 01:08:57 +0000634 StateType state = process->WaitForProcessToStop (NULL);
Greg Clayton527154d2011-11-15 03:53:30 +0000635
Jim Inghamee940e22011-09-15 01:08:57 +0000636 result.SetDidChangeProcessState (true);
Johnny Chen9986a3b2012-05-18 00:51:36 +0000637
638 if (state == eStateStopped)
639 {
Daniel Malea5f35a4b2012-11-29 21:49:15 +0000640 result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
Johnny Chen9986a3b2012-05-18 00:51:36 +0000641 result.SetStatus (eReturnStatusSuccessFinishNoResult);
642 }
643 else
644 {
645 result.AppendError ("attach failed: process did not stop (no such process or permission problem?)");
Jim Ingham5d90ade2012-07-27 23:57:19 +0000646 process->Destroy();
Johnny Chen9986a3b2012-05-18 00:51:36 +0000647 result.SetStatus (eReturnStatusFailed);
648 return false;
649 }
Jim Ingham7508e732010-08-09 23:31:02 +0000650 }
Jim Ingham7508e732010-08-09 23:31:02 +0000651 }
652 }
653
654 if (result.Succeeded())
655 {
656 // Okay, we're done. Last step is to warn if the executable module has changed:
Greg Clayton7e2f91c2011-01-29 07:10:55 +0000657 char new_path[PATH_MAX];
Greg Clayton5beb99d2011-08-11 02:48:45 +0000658 ModuleSP new_exec_module_sp (target->GetExecutableModule());
Jim Ingham7508e732010-08-09 23:31:02 +0000659 if (!old_exec_module_sp)
660 {
Greg Clayton7e2f91c2011-01-29 07:10:55 +0000661 // We might not have a module if we attached to a raw pid...
Greg Clayton5beb99d2011-08-11 02:48:45 +0000662 if (new_exec_module_sp)
Greg Clayton7e2f91c2011-01-29 07:10:55 +0000663 {
Greg Clayton5beb99d2011-08-11 02:48:45 +0000664 new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);
Greg Clayton7e2f91c2011-01-29 07:10:55 +0000665 result.AppendMessageWithFormat("Executable module set to \"%s\".\n", new_path);
666 }
Jim Ingham7508e732010-08-09 23:31:02 +0000667 }
Greg Clayton5beb99d2011-08-11 02:48:45 +0000668 else if (old_exec_module_sp->GetFileSpec() != new_exec_module_sp->GetFileSpec())
Jim Ingham7508e732010-08-09 23:31:02 +0000669 {
Greg Clayton7e2f91c2011-01-29 07:10:55 +0000670 char old_path[PATH_MAX];
Jim Ingham7508e732010-08-09 23:31:02 +0000671
Greg Clayton5beb99d2011-08-11 02:48:45 +0000672 old_exec_module_sp->GetFileSpec().GetPath (old_path, PATH_MAX);
673 new_exec_module_sp->GetFileSpec().GetPath (new_path, PATH_MAX);
Jim Ingham7508e732010-08-09 23:31:02 +0000674
675 result.AppendWarningWithFormat("Executable module changed from \"%s\" to \"%s\".\n",
676 old_path, new_path);
677 }
678
679 if (!old_arch_spec.IsValid())
680 {
Greg Clayton92cb9a92012-09-14 02:41:36 +0000681 result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().GetTriple().getTriple().c_str());
Jim Ingham7508e732010-08-09 23:31:02 +0000682 }
Sean Callanan40e278c2012-12-13 22:07:14 +0000683 else if (!old_arch_spec.IsExactMatch(target->GetArchitecture()))
Jim Ingham7508e732010-08-09 23:31:02 +0000684 {
685 result.AppendWarningWithFormat("Architecture changed from %s to %s.\n",
Greg Clayton92cb9a92012-09-14 02:41:36 +0000686 old_arch_spec.GetTriple().getTriple().c_str(),
687 target->GetArchitecture().GetTriple().getTriple().c_str());
Jim Ingham7508e732010-08-09 23:31:02 +0000688 }
Johnny Chen7c099972012-05-24 00:43:00 +0000689
690 // This supports the use-case scenario of immediately continuing the process once attached.
691 if (m_options.attach_info.GetContinueOnceAttached())
Sean Callanan4336d932012-05-31 01:30:08 +0000692 m_interpreter.HandleCommand("process continue", eLazyBoolNo, result);
Jim Ingham7508e732010-08-09 23:31:02 +0000693 }
694 return result.Succeeded();
695 }
696
Chris Lattner24943d22010-06-08 16:52:24 +0000697 CommandOptions m_options;
698};
699
700
Greg Claytonb3448432011-03-24 21:19:54 +0000701OptionDefinition
Chris Lattner24943d22010-06-08 16:52:24 +0000702CommandObjectProcessAttach::CommandOptions::g_option_table[] =
703{
Jim Ingham3a458eb2012-07-20 21:37:13 +0000704{ 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."},
Caroline Tice4d6675c2010-10-01 19:59:14 +0000710{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
Chris Lattner24943d22010-06-08 16:52:24 +0000711};
712
713//-------------------------------------------------------------------------
714// CommandObjectProcessContinue
715//-------------------------------------------------------------------------
Jim Ingham22dc9722010-12-09 18:58:16 +0000716#pragma mark CommandObjectProcessContinue
Chris Lattner24943d22010-06-08 16:52:24 +0000717
Jim Inghamda26bd22012-06-08 21:56:10 +0000718class CommandObjectProcessContinue : public CommandObjectParsed
Chris Lattner24943d22010-06-08 16:52:24 +0000719{
720public:
721
Greg Clayton238c0a12010-09-18 01:14:36 +0000722 CommandObjectProcessContinue (CommandInterpreter &interpreter) :
Jim Inghamda26bd22012-06-08 21:56:10 +0000723 CommandObjectParsed (interpreter,
724 "process continue",
725 "Continue execution of all threads in the current process.",
726 "process continue",
Greg Claytonea0bb4d2013-01-09 19:44:40 +0000727 eFlagRequiresProcess |
728 eFlagTryTargetAPILock |
729 eFlagProcessMustBeLaunched |
730 eFlagProcessMustBePaused ),
Jim Ingham124e6902012-08-11 01:27:55 +0000731 m_options(interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +0000732 {
733 }
734
735
736 ~CommandObjectProcessContinue ()
737 {
738 }
739
Jim Inghamda26bd22012-06-08 21:56:10 +0000740protected:
Jim Ingham124e6902012-08-11 01:27:55 +0000741
742 class CommandOptions : public Options
743 {
744 public:
745
746 CommandOptions (CommandInterpreter &interpreter) :
747 Options(interpreter)
748 {
749 // Keep default values of all options in one place: OptionParsingStarting ()
750 OptionParsingStarting ();
751 }
752
753 ~CommandOptions ()
754 {
755 }
756
757 Error
758 SetOptionValue (uint32_t option_idx, const char *option_arg)
759 {
760 Error error;
Greg Clayton6475c422012-12-04 00:32:51 +0000761 const int short_option = m_getopt_table[option_idx].val;
Jim Ingham124e6902012-08-11 01:27:55 +0000762 bool success = false;
763 switch (short_option)
764 {
765 case 'i':
766 m_ignore = Args::StringToUInt32 (option_arg, 0, 0, &success);
767 if (!success)
768 error.SetErrorStringWithFormat ("invalid value for ignore option: \"%s\", should be a number.", option_arg);
769 break;
770
771 default:
772 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
773 break;
774 }
775 return error;
776 }
777
778 void
779 OptionParsingStarting ()
780 {
781 m_ignore = 0;
782 }
783
784 const OptionDefinition*
785 GetDefinitions ()
786 {
787 return g_option_table;
788 }
789
790 // Options table: Required for subclasses of Options.
791
792 static OptionDefinition g_option_table[];
793
794 uint32_t m_ignore;
795 };
796
Chris Lattner24943d22010-06-08 16:52:24 +0000797 bool
Greg Claytonea0bb4d2013-01-09 19:44:40 +0000798 DoExecute (Args& command, CommandReturnObject &result)
Chris Lattner24943d22010-06-08 16:52:24 +0000799 {
Greg Claytonea0bb4d2013-01-09 19:44:40 +0000800 Process *process = m_exe_ctx.GetProcessPtr();
Greg Clayton238c0a12010-09-18 01:14:36 +0000801 bool synchronous_execution = m_interpreter.GetSynchronous ();
Chris Lattner24943d22010-06-08 16:52:24 +0000802 StateType state = process->GetState();
803 if (state == eStateStopped)
804 {
805 if (command.GetArgumentCount() != 0)
806 {
807 result.AppendErrorWithFormat ("The '%s' command does not take any arguments.\n", m_cmd_name.c_str());
808 result.SetStatus (eReturnStatusFailed);
809 return false;
810 }
811
Jim Ingham124e6902012-08-11 01:27:55 +0000812 if (m_options.m_ignore > 0)
813 {
814 ThreadSP sel_thread_sp(process->GetThreadList().GetSelectedThread());
815 if (sel_thread_sp)
816 {
817 StopInfoSP stop_info_sp = sel_thread_sp->GetStopInfo();
818 if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint)
819 {
Greg Clayton36da2aa2013-01-25 18:06:21 +0000820 lldb::break_id_t bp_site_id = (lldb::break_id_t)stop_info_sp->GetValue();
Jim Ingham124e6902012-08-11 01:27:55 +0000821 BreakpointSiteSP bp_site_sp(process->GetBreakpointSiteList().FindByID(bp_site_id));
822 if (bp_site_sp)
823 {
Greg Clayton36da2aa2013-01-25 18:06:21 +0000824 const size_t num_owners = bp_site_sp->GetNumberOfOwners();
825 for (size_t i = 0; i < num_owners; i++)
Jim Ingham124e6902012-08-11 01:27:55 +0000826 {
827 Breakpoint &bp_ref = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
828 if (!bp_ref.IsInternal())
829 {
830 bp_ref.SetIgnoreCount(m_options.m_ignore);
831 }
832 }
833 }
834 }
835 }
836 }
837
Jim Inghamb9950592012-09-10 20:50:15 +0000838 { // Scope for thread list mutex:
839 Mutex::Locker locker (process->GetThreadList().GetMutex());
840 const uint32_t num_threads = process->GetThreadList().GetSize();
Chris Lattner24943d22010-06-08 16:52:24 +0000841
Jim Inghamb9950592012-09-10 20:50:15 +0000842 // Set the actions that the threads should each take when resuming
843 for (uint32_t idx=0; idx<num_threads; ++idx)
844 {
845 process->GetThreadList().GetThreadAtIndex(idx)->SetResumeState (eStateRunning);
846 }
Chris Lattner24943d22010-06-08 16:52:24 +0000847 }
Jim Inghamb9950592012-09-10 20:50:15 +0000848
Chris Lattner24943d22010-06-08 16:52:24 +0000849 Error error(process->Resume());
850 if (error.Success())
851 {
Daniel Malea5f35a4b2012-11-29 21:49:15 +0000852 result.AppendMessageWithFormat ("Process %" PRIu64 " resuming\n", process->GetID());
Chris Lattner24943d22010-06-08 16:52:24 +0000853 if (synchronous_execution)
854 {
Greg Claytonbef15832010-07-14 00:18:15 +0000855 state = process->WaitForProcessToStop (NULL);
Chris Lattner24943d22010-06-08 16:52:24 +0000856
857 result.SetDidChangeProcessState (true);
Daniel Malea5f35a4b2012-11-29 21:49:15 +0000858 result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
Chris Lattner24943d22010-06-08 16:52:24 +0000859 result.SetStatus (eReturnStatusSuccessFinishNoResult);
860 }
861 else
862 {
863 result.SetStatus (eReturnStatusSuccessContinuingNoResult);
864 }
865 }
866 else
867 {
868 result.AppendErrorWithFormat("Failed to resume process: %s.\n", error.AsCString());
869 result.SetStatus (eReturnStatusFailed);
870 }
871 }
872 else
873 {
874 result.AppendErrorWithFormat ("Process cannot be continued from its current state (%s).\n",
875 StateAsCString(state));
876 result.SetStatus (eReturnStatusFailed);
877 }
878 return result.Succeeded();
879 }
Jim Ingham124e6902012-08-11 01:27:55 +0000880
881 Options *
882 GetOptions ()
883 {
884 return &m_options;
885 }
886
887 CommandOptions m_options;
888
889};
890
891OptionDefinition
892CommandObjectProcessContinue::CommandOptions::g_option_table[] =
893{
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 }
Chris Lattner24943d22010-06-08 16:52:24 +0000897};
898
899//-------------------------------------------------------------------------
900// CommandObjectProcessDetach
901//-------------------------------------------------------------------------
Jim Ingham22dc9722010-12-09 18:58:16 +0000902#pragma mark CommandObjectProcessDetach
Chris Lattner24943d22010-06-08 16:52:24 +0000903
Jim Inghamda26bd22012-06-08 21:56:10 +0000904class CommandObjectProcessDetach : public CommandObjectParsed
Chris Lattner24943d22010-06-08 16:52:24 +0000905{
906public:
Jim Ingham761afb82013-05-02 00:27:30 +0000907 class CommandOptions : public Options
908 {
909 public:
910
911 CommandOptions (CommandInterpreter &interpreter) :
912 Options (interpreter)
913 {
914 OptionParsingStarting ();
915 }
916
917 ~CommandOptions ()
918 {
919 }
920
921 Error
922 SetOptionValue (uint32_t option_idx, const char *option_arg)
923 {
924 Error error;
925 const int short_option = m_getopt_table[option_idx].val;
926
927 switch (short_option)
928 {
929 case 's':
930 bool tmp_result;
931 bool success;
932 tmp_result = Args::StringToBoolean(option_arg, false, &success);
933 if (!success)
934 error.SetErrorStringWithFormat("invalid boolean option: \"%s\"", option_arg);
935 else
936 {
937 if (tmp_result)
938 m_keep_stopped = eLazyBoolYes;
939 else
940 m_keep_stopped = eLazyBoolNo;
941 }
942 break;
943 default:
944 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
945 break;
946 }
947 return error;
948 }
949
950 void
951 OptionParsingStarting ()
952 {
953 m_keep_stopped = eLazyBoolCalculate;
954 }
955
956 const OptionDefinition*
957 GetDefinitions ()
958 {
959 return g_option_table;
960 }
961
962 // Options table: Required for subclasses of Options.
963
964 static OptionDefinition g_option_table[];
965
966 // Instance variables to hold the values for command options.
967 LazyBool m_keep_stopped;
968 };
Chris Lattner24943d22010-06-08 16:52:24 +0000969
Greg Clayton238c0a12010-09-18 01:14:36 +0000970 CommandObjectProcessDetach (CommandInterpreter &interpreter) :
Jim Inghamda26bd22012-06-08 21:56:10 +0000971 CommandObjectParsed (interpreter,
972 "process detach",
973 "Detach from the current process being debugged.",
974 "process detach",
Greg Claytonea0bb4d2013-01-09 19:44:40 +0000975 eFlagRequiresProcess |
976 eFlagTryTargetAPILock |
Jim Ingham761afb82013-05-02 00:27:30 +0000977 eFlagProcessMustBeLaunched),
978 m_options(interpreter)
Chris Lattner24943d22010-06-08 16:52:24 +0000979 {
980 }
981
982 ~CommandObjectProcessDetach ()
983 {
984 }
985
Jim Ingham761afb82013-05-02 00:27:30 +0000986 Options *
987 GetOptions ()
988 {
989 return &m_options;
990 }
991
992
Jim Inghamda26bd22012-06-08 21:56:10 +0000993protected:
Chris Lattner24943d22010-06-08 16:52:24 +0000994 bool
Greg Claytonea0bb4d2013-01-09 19:44:40 +0000995 DoExecute (Args& command, CommandReturnObject &result)
Chris Lattner24943d22010-06-08 16:52:24 +0000996 {
Greg Claytonea0bb4d2013-01-09 19:44:40 +0000997 Process *process = m_exe_ctx.GetProcessPtr();
Daniel Malea5f35a4b2012-11-29 21:49:15 +0000998 result.AppendMessageWithFormat ("Detaching from process %" PRIu64 "\n", process->GetID());
Jim Ingham761afb82013-05-02 00:27:30 +0000999 // FIXME: This will be a Command Option:
1000 bool keep_stopped;
1001 if (m_options.m_keep_stopped == eLazyBoolCalculate)
1002 {
1003 // Check the process default:
1004 if (process->GetDetachKeepsStopped())
1005 keep_stopped = true;
1006 else
1007 keep_stopped = false;
1008 }
1009 else if (m_options.m_keep_stopped == eLazyBoolYes)
1010 keep_stopped = true;
1011 else
1012 keep_stopped = false;
1013
1014 Error error (process->Detach(keep_stopped));
Chris Lattner24943d22010-06-08 16:52:24 +00001015 if (error.Success())
1016 {
1017 result.SetStatus (eReturnStatusSuccessFinishResult);
1018 }
1019 else
1020 {
1021 result.AppendErrorWithFormat ("Detach failed: %s\n", error.AsCString());
1022 result.SetStatus (eReturnStatusFailed);
1023 return false;
1024 }
1025 return result.Succeeded();
1026 }
Jim Ingham761afb82013-05-02 00:27:30 +00001027
1028 CommandOptions m_options;
1029};
1030
1031OptionDefinition
1032CommandObjectProcessDetach::CommandOptions::g_option_table[] =
1033{
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 }
Chris Lattner24943d22010-06-08 16:52:24 +00001036};
1037
1038//-------------------------------------------------------------------------
Greg Claytone71e2582011-02-04 01:58:07 +00001039// CommandObjectProcessConnect
1040//-------------------------------------------------------------------------
1041#pragma mark CommandObjectProcessConnect
1042
Jim Inghamda26bd22012-06-08 21:56:10 +00001043class CommandObjectProcessConnect : public CommandObjectParsed
Greg Claytone71e2582011-02-04 01:58:07 +00001044{
1045public:
1046
1047 class CommandOptions : public Options
1048 {
1049 public:
1050
Greg Claytonf15996e2011-04-07 22:46:35 +00001051 CommandOptions (CommandInterpreter &interpreter) :
1052 Options(interpreter)
Greg Claytone71e2582011-02-04 01:58:07 +00001053 {
Greg Clayton143fcc32011-04-13 00:18:08 +00001054 // Keep default values of all options in one place: OptionParsingStarting ()
1055 OptionParsingStarting ();
Greg Claytone71e2582011-02-04 01:58:07 +00001056 }
1057
1058 ~CommandOptions ()
1059 {
1060 }
1061
1062 Error
Greg Clayton143fcc32011-04-13 00:18:08 +00001063 SetOptionValue (uint32_t option_idx, const char *option_arg)
Greg Claytone71e2582011-02-04 01:58:07 +00001064 {
1065 Error error;
Greg Clayton6475c422012-12-04 00:32:51 +00001066 const int short_option = m_getopt_table[option_idx].val;
Greg Claytone71e2582011-02-04 01:58:07 +00001067
1068 switch (short_option)
1069 {
1070 case 'p':
1071 plugin_name.assign (option_arg);
1072 break;
1073
1074 default:
Greg Clayton9c236732011-10-26 00:56:27 +00001075 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
Greg Claytone71e2582011-02-04 01:58:07 +00001076 break;
1077 }
1078 return error;
1079 }
1080
1081 void
Greg Clayton143fcc32011-04-13 00:18:08 +00001082 OptionParsingStarting ()
Greg Claytone71e2582011-02-04 01:58:07 +00001083 {
Greg Claytone71e2582011-02-04 01:58:07 +00001084 plugin_name.clear();
1085 }
1086
Greg Claytonb3448432011-03-24 21:19:54 +00001087 const OptionDefinition*
Greg Claytone71e2582011-02-04 01:58:07 +00001088 GetDefinitions ()
1089 {
1090 return g_option_table;
1091 }
1092
1093 // Options table: Required for subclasses of Options.
1094
Greg Claytonb3448432011-03-24 21:19:54 +00001095 static OptionDefinition g_option_table[];
Greg Claytone71e2582011-02-04 01:58:07 +00001096
1097 // Instance variables to hold the values for command options.
1098
1099 std::string plugin_name;
1100 };
1101
1102 CommandObjectProcessConnect (CommandInterpreter &interpreter) :
Jim Inghamda26bd22012-06-08 21:56:10 +00001103 CommandObjectParsed (interpreter,
1104 "process connect",
1105 "Connect to a remote debug service.",
1106 "process connect <remote-url>",
1107 0),
Greg Claytonf15996e2011-04-07 22:46:35 +00001108 m_options (interpreter)
Greg Claytone71e2582011-02-04 01:58:07 +00001109 {
1110 }
1111
1112 ~CommandObjectProcessConnect ()
1113 {
1114 }
1115
1116
Jim Inghamda26bd22012-06-08 21:56:10 +00001117 Options *
1118 GetOptions ()
1119 {
1120 return &m_options;
1121 }
1122
1123protected:
Greg Claytone71e2582011-02-04 01:58:07 +00001124 bool
Jim Inghamda26bd22012-06-08 21:56:10 +00001125 DoExecute (Args& command,
Greg Claytone71e2582011-02-04 01:58:07 +00001126 CommandReturnObject &result)
1127 {
1128
1129 TargetSP target_sp (m_interpreter.GetDebugger().GetSelectedTarget());
1130 Error error;
Greg Claytonea0bb4d2013-01-09 19:44:40 +00001131 Process *process = m_exe_ctx.GetProcessPtr();
Greg Claytone71e2582011-02-04 01:58:07 +00001132 if (process)
1133 {
1134 if (process->IsAlive())
1135 {
Daniel Malea5f35a4b2012-11-29 21:49:15 +00001136 result.AppendErrorWithFormat ("Process %" PRIu64 " is currently being debugged, kill the process before connecting.\n",
Greg Claytone71e2582011-02-04 01:58:07 +00001137 process->GetID());
1138 result.SetStatus (eReturnStatusFailed);
1139 return false;
1140 }
1141 }
1142
1143 if (!target_sp)
1144 {
1145 // If there isn't a current target create one.
Greg Claytone71e2582011-02-04 01:58:07 +00001146
1147 error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(),
Greg Claytoned0a0fb2012-10-18 16:33:33 +00001148 NULL,
Greg Clayton3e8c25f2011-09-24 00:52:29 +00001149 NULL,
Greg Claytone71e2582011-02-04 01:58:07 +00001150 false,
Greg Clayton3e8c25f2011-09-24 00:52:29 +00001151 NULL, // No platform options
Greg Claytone71e2582011-02-04 01:58:07 +00001152 target_sp);
1153 if (!target_sp || error.Fail())
1154 {
1155 result.AppendError(error.AsCString("Error creating target"));
1156 result.SetStatus (eReturnStatusFailed);
1157 return false;
1158 }
1159 m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target_sp.get());
1160 }
1161
1162 if (command.GetArgumentCount() == 1)
1163 {
1164 const char *plugin_name = NULL;
1165 if (!m_options.plugin_name.empty())
1166 plugin_name = m_options.plugin_name.c_str();
1167
1168 const char *remote_url = command.GetArgumentAtIndex(0);
Greg Clayton46c9a352012-02-09 06:16:32 +00001169 process = target_sp->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name, NULL).get();
Greg Claytone71e2582011-02-04 01:58:07 +00001170
1171 if (process)
1172 {
Jason Molendafac2e622012-09-29 04:02:01 +00001173 error = process->ConnectRemote (&process->GetTarget().GetDebugger().GetOutputStream(), remote_url);
Greg Claytone71e2582011-02-04 01:58:07 +00001174
1175 if (error.Fail())
1176 {
1177 result.AppendError(error.AsCString("Remote connect failed"));
1178 result.SetStatus (eReturnStatusFailed);
Greg Clayton0cbb93b2012-03-31 00:10:30 +00001179 target_sp->DeleteCurrentProcess();
Greg Claytone71e2582011-02-04 01:58:07 +00001180 return false;
1181 }
1182 }
1183 else
1184 {
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001185 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 Maleadd068882012-12-18 20:00:40 +00001186 remote_url);
Greg Claytone71e2582011-02-04 01:58:07 +00001187 result.SetStatus (eReturnStatusFailed);
1188 }
1189 }
1190 else
1191 {
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001192 result.AppendErrorWithFormat ("'%s' takes exactly one argument:\nUsage: %s\n",
Greg Claytone71e2582011-02-04 01:58:07 +00001193 m_cmd_name.c_str(),
1194 m_cmd_syntax.c_str());
1195 result.SetStatus (eReturnStatusFailed);
1196 }
1197 return result.Succeeded();
1198 }
Greg Claytone71e2582011-02-04 01:58:07 +00001199
1200 CommandOptions m_options;
1201};
1202
Greg Claytonb3448432011-03-24 21:19:54 +00001203OptionDefinition
Greg Claytone71e2582011-02-04 01:58:07 +00001204CommandObjectProcessConnect::CommandOptions::g_option_table[] =
1205{
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 }
1208};
1209
1210//-------------------------------------------------------------------------
Greg Clayton13193d52012-10-13 02:07:45 +00001211// CommandObjectProcessPlugin
1212//-------------------------------------------------------------------------
1213#pragma mark CommandObjectProcessPlugin
1214
1215class CommandObjectProcessPlugin : public CommandObjectProxy
1216{
1217public:
1218
1219 CommandObjectProcessPlugin (CommandInterpreter &interpreter) :
1220 CommandObjectProxy (interpreter,
1221 "process plugin",
1222 "Send a custom command to the current process plug-in.",
1223 "process plugin <args>",
1224 0)
1225 {
1226 }
1227
1228 ~CommandObjectProcessPlugin ()
1229 {
1230 }
1231
1232 virtual CommandObject *
1233 GetProxyCommandObject()
1234 {
Greg Clayton5ebdb032013-01-09 22:58:18 +00001235 Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
Greg Clayton13193d52012-10-13 02:07:45 +00001236 if (process)
1237 return process->GetPluginCommandObject();
1238 return NULL;
1239 }
1240};
1241
1242
1243//-------------------------------------------------------------------------
Greg Clayton0baa3942010-11-04 01:54:29 +00001244// CommandObjectProcessLoad
1245//-------------------------------------------------------------------------
Jim Ingham22dc9722010-12-09 18:58:16 +00001246#pragma mark CommandObjectProcessLoad
Greg Clayton0baa3942010-11-04 01:54:29 +00001247
Jim Inghamda26bd22012-06-08 21:56:10 +00001248class CommandObjectProcessLoad : public CommandObjectParsed
Greg Clayton0baa3942010-11-04 01:54:29 +00001249{
1250public:
1251
1252 CommandObjectProcessLoad (CommandInterpreter &interpreter) :
Jim Inghamda26bd22012-06-08 21:56:10 +00001253 CommandObjectParsed (interpreter,
1254 "process load",
1255 "Load a shared library into the current process.",
1256 "process load <filename> [<filename> ...]",
Greg Claytonea0bb4d2013-01-09 19:44:40 +00001257 eFlagRequiresProcess |
1258 eFlagTryTargetAPILock |
1259 eFlagProcessMustBeLaunched |
1260 eFlagProcessMustBePaused )
Greg Clayton0baa3942010-11-04 01:54:29 +00001261 {
1262 }
1263
1264 ~CommandObjectProcessLoad ()
1265 {
1266 }
1267
Jim Inghamda26bd22012-06-08 21:56:10 +00001268protected:
Greg Clayton0baa3942010-11-04 01:54:29 +00001269 bool
Jim Inghamda26bd22012-06-08 21:56:10 +00001270 DoExecute (Args& command,
Greg Clayton0baa3942010-11-04 01:54:29 +00001271 CommandReturnObject &result)
1272 {
Greg Claytonea0bb4d2013-01-09 19:44:40 +00001273 Process *process = m_exe_ctx.GetProcessPtr();
Greg Clayton0baa3942010-11-04 01:54:29 +00001274
Greg Clayton36da2aa2013-01-25 18:06:21 +00001275 const size_t argc = command.GetArgumentCount();
Greg Clayton0baa3942010-11-04 01:54:29 +00001276
1277 for (uint32_t i=0; i<argc; ++i)
1278 {
1279 Error error;
1280 const char *image_path = command.GetArgumentAtIndex(i);
1281 FileSpec image_spec (image_path, false);
Greg Claytonf2bf8702011-08-11 16:25:18 +00001282 process->GetTarget().GetPlatform()->ResolveRemotePath(image_spec, image_spec);
Greg Clayton0baa3942010-11-04 01:54:29 +00001283 uint32_t image_token = process->LoadImage(image_spec, error);
1284 if (image_token != LLDB_INVALID_IMAGE_TOKEN)
1285 {
1286 result.AppendMessageWithFormat ("Loading \"%s\"...ok\nImage %u loaded.\n", image_path, image_token);
1287 result.SetStatus (eReturnStatusSuccessFinishResult);
1288 }
1289 else
1290 {
1291 result.AppendErrorWithFormat ("failed to load '%s': %s", image_path, error.AsCString());
1292 result.SetStatus (eReturnStatusFailed);
1293 }
1294 }
1295 return result.Succeeded();
1296 }
1297};
1298
1299
1300//-------------------------------------------------------------------------
1301// CommandObjectProcessUnload
1302//-------------------------------------------------------------------------
Jim Ingham22dc9722010-12-09 18:58:16 +00001303#pragma mark CommandObjectProcessUnload
Greg Clayton0baa3942010-11-04 01:54:29 +00001304
Jim Inghamda26bd22012-06-08 21:56:10 +00001305class CommandObjectProcessUnload : public CommandObjectParsed
Greg Clayton0baa3942010-11-04 01:54:29 +00001306{
1307public:
1308
1309 CommandObjectProcessUnload (CommandInterpreter &interpreter) :
Jim Inghamda26bd22012-06-08 21:56:10 +00001310 CommandObjectParsed (interpreter,
1311 "process unload",
1312 "Unload a shared library from the current process using the index returned by a previous call to \"process load\".",
1313 "process unload <index>",
Greg Claytonea0bb4d2013-01-09 19:44:40 +00001314 eFlagRequiresProcess |
1315 eFlagTryTargetAPILock |
1316 eFlagProcessMustBeLaunched |
1317 eFlagProcessMustBePaused )
Greg Clayton0baa3942010-11-04 01:54:29 +00001318 {
1319 }
1320
1321 ~CommandObjectProcessUnload ()
1322 {
1323 }
1324
Jim Inghamda26bd22012-06-08 21:56:10 +00001325protected:
Greg Clayton0baa3942010-11-04 01:54:29 +00001326 bool
Jim Inghamda26bd22012-06-08 21:56:10 +00001327 DoExecute (Args& command,
Greg Clayton0baa3942010-11-04 01:54:29 +00001328 CommandReturnObject &result)
1329 {
Greg Claytonea0bb4d2013-01-09 19:44:40 +00001330 Process *process = m_exe_ctx.GetProcessPtr();
Greg Clayton0baa3942010-11-04 01:54:29 +00001331
Greg Clayton36da2aa2013-01-25 18:06:21 +00001332 const size_t argc = command.GetArgumentCount();
Greg Clayton0baa3942010-11-04 01:54:29 +00001333
1334 for (uint32_t i=0; i<argc; ++i)
1335 {
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)
1339 {
1340 result.AppendErrorWithFormat ("invalid image index argument '%s'", image_token_cstr);
1341 result.SetStatus (eReturnStatusFailed);
1342 break;
1343 }
1344 else
1345 {
1346 Error error (process->UnloadImage(image_token));
1347 if (error.Success())
1348 {
1349 result.AppendMessageWithFormat ("Unloading shared library with index %u...ok\n", image_token);
1350 result.SetStatus (eReturnStatusSuccessFinishResult);
1351 }
1352 else
1353 {
1354 result.AppendErrorWithFormat ("failed to unload image: %s", error.AsCString());
1355 result.SetStatus (eReturnStatusFailed);
1356 break;
1357 }
1358 }
1359 }
1360 return result.Succeeded();
1361 }
1362};
1363
1364//-------------------------------------------------------------------------
Chris Lattner24943d22010-06-08 16:52:24 +00001365// CommandObjectProcessSignal
1366//-------------------------------------------------------------------------
Jim Ingham22dc9722010-12-09 18:58:16 +00001367#pragma mark CommandObjectProcessSignal
Chris Lattner24943d22010-06-08 16:52:24 +00001368
Jim Inghamda26bd22012-06-08 21:56:10 +00001369class CommandObjectProcessSignal : public CommandObjectParsed
Chris Lattner24943d22010-06-08 16:52:24 +00001370{
1371public:
1372
Greg Clayton238c0a12010-09-18 01:14:36 +00001373 CommandObjectProcessSignal (CommandInterpreter &interpreter) :
Jim Inghamda26bd22012-06-08 21:56:10 +00001374 CommandObjectParsed (interpreter,
1375 "process signal",
1376 "Send a UNIX signal to the current process being debugged.",
Greg Claytonea0bb4d2013-01-09 19:44:40 +00001377 NULL,
1378 eFlagRequiresProcess | eFlagTryTargetAPILock)
Chris Lattner24943d22010-06-08 16:52:24 +00001379 {
Caroline Tice43b014a2010-10-04 22:28:36 +00001380 CommandArgumentEntry arg;
1381 CommandArgumentData signal_arg;
1382
1383 // Define the first (and only) variant of this arg.
Caroline Tice3a62e6d2010-10-18 22:56:57 +00001384 signal_arg.arg_type = eArgTypeUnixSignal;
Caroline Tice43b014a2010-10-04 22:28:36 +00001385 signal_arg.arg_repetition = eArgRepeatPlain;
1386
1387 // There is only one variant this argument could be; put it into the argument entry.
1388 arg.push_back (signal_arg);
1389
1390 // Push the data for the first argument into the m_arguments vector.
1391 m_arguments.push_back (arg);
Chris Lattner24943d22010-06-08 16:52:24 +00001392 }
1393
1394 ~CommandObjectProcessSignal ()
1395 {
1396 }
1397
Jim Inghamda26bd22012-06-08 21:56:10 +00001398protected:
Chris Lattner24943d22010-06-08 16:52:24 +00001399 bool
Jim Inghamda26bd22012-06-08 21:56:10 +00001400 DoExecute (Args& command,
Chris Lattner24943d22010-06-08 16:52:24 +00001401 CommandReturnObject &result)
1402 {
Greg Claytonea0bb4d2013-01-09 19:44:40 +00001403 Process *process = m_exe_ctx.GetProcessPtr();
Chris Lattner24943d22010-06-08 16:52:24 +00001404
1405 if (command.GetArgumentCount() == 1)
1406 {
Greg Clayton8f6be2a2010-10-09 01:40:57 +00001407 int signo = LLDB_INVALID_SIGNAL_NUMBER;
1408
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);
1412 else
1413 signo = process->GetUnixSignals().GetSignalNumberFromName (signal_name);
1414
1415 if (signo == LLDB_INVALID_SIGNAL_NUMBER)
Chris Lattner24943d22010-06-08 16:52:24 +00001416 {
1417 result.AppendErrorWithFormat ("Invalid signal argument '%s'.\n", command.GetArgumentAtIndex(0));
1418 result.SetStatus (eReturnStatusFailed);
1419 }
1420 else
1421 {
1422 Error error (process->Signal (signo));
1423 if (error.Success())
1424 {
1425 result.SetStatus (eReturnStatusSuccessFinishResult);
1426 }
1427 else
1428 {
1429 result.AppendErrorWithFormat ("Failed to send signal %i: %s\n", signo, error.AsCString());
1430 result.SetStatus (eReturnStatusFailed);
1431 }
1432 }
1433 }
1434 else
1435 {
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001436 result.AppendErrorWithFormat("'%s' takes exactly one signal number argument:\nUsage: %s\n", m_cmd_name.c_str(),
Chris Lattner24943d22010-06-08 16:52:24 +00001437 m_cmd_syntax.c_str());
1438 result.SetStatus (eReturnStatusFailed);
1439 }
1440 return result.Succeeded();
1441 }
1442};
1443
1444
1445//-------------------------------------------------------------------------
1446// CommandObjectProcessInterrupt
1447//-------------------------------------------------------------------------
Jim Ingham22dc9722010-12-09 18:58:16 +00001448#pragma mark CommandObjectProcessInterrupt
Chris Lattner24943d22010-06-08 16:52:24 +00001449
Jim Inghamda26bd22012-06-08 21:56:10 +00001450class CommandObjectProcessInterrupt : public CommandObjectParsed
Chris Lattner24943d22010-06-08 16:52:24 +00001451{
1452public:
1453
1454
Greg Clayton238c0a12010-09-18 01:14:36 +00001455 CommandObjectProcessInterrupt (CommandInterpreter &interpreter) :
Jim Inghamda26bd22012-06-08 21:56:10 +00001456 CommandObjectParsed (interpreter,
1457 "process interrupt",
1458 "Interrupt the current process being debugged.",
1459 "process interrupt",
Greg Claytonea0bb4d2013-01-09 19:44:40 +00001460 eFlagRequiresProcess |
1461 eFlagTryTargetAPILock |
Jim Inghamda26bd22012-06-08 21:56:10 +00001462 eFlagProcessMustBeLaunched)
Chris Lattner24943d22010-06-08 16:52:24 +00001463 {
1464 }
1465
1466 ~CommandObjectProcessInterrupt ()
1467 {
1468 }
1469
Jim Inghamda26bd22012-06-08 21:56:10 +00001470protected:
Chris Lattner24943d22010-06-08 16:52:24 +00001471 bool
Jim Inghamda26bd22012-06-08 21:56:10 +00001472 DoExecute (Args& command,
Chris Lattner24943d22010-06-08 16:52:24 +00001473 CommandReturnObject &result)
1474 {
Greg Claytonea0bb4d2013-01-09 19:44:40 +00001475 Process *process = m_exe_ctx.GetProcessPtr();
Chris Lattner24943d22010-06-08 16:52:24 +00001476 if (process == NULL)
1477 {
1478 result.AppendError ("no process to halt");
1479 result.SetStatus (eReturnStatusFailed);
1480 return false;
1481 }
1482
1483 if (command.GetArgumentCount() == 0)
1484 {
1485 Error error(process->Halt ());
1486 if (error.Success())
1487 {
1488 result.SetStatus (eReturnStatusSuccessFinishResult);
1489
1490 // Maybe we should add a "SuspendThreadPlans so we
1491 // can halt, and keep in place all the current thread plans.
1492 process->GetThreadList().DiscardThreadPlans();
1493 }
1494 else
1495 {
1496 result.AppendErrorWithFormat ("Failed to halt process: %s\n", error.AsCString());
1497 result.SetStatus (eReturnStatusFailed);
1498 }
1499 }
1500 else
1501 {
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001502 result.AppendErrorWithFormat("'%s' takes no arguments:\nUsage: %s\n",
Chris Lattner24943d22010-06-08 16:52:24 +00001503 m_cmd_name.c_str(),
1504 m_cmd_syntax.c_str());
1505 result.SetStatus (eReturnStatusFailed);
1506 }
1507 return result.Succeeded();
1508 }
1509};
1510
1511//-------------------------------------------------------------------------
1512// CommandObjectProcessKill
1513//-------------------------------------------------------------------------
Jim Ingham22dc9722010-12-09 18:58:16 +00001514#pragma mark CommandObjectProcessKill
Chris Lattner24943d22010-06-08 16:52:24 +00001515
Jim Inghamda26bd22012-06-08 21:56:10 +00001516class CommandObjectProcessKill : public CommandObjectParsed
Chris Lattner24943d22010-06-08 16:52:24 +00001517{
1518public:
1519
Greg Clayton238c0a12010-09-18 01:14:36 +00001520 CommandObjectProcessKill (CommandInterpreter &interpreter) :
Jim Inghamda26bd22012-06-08 21:56:10 +00001521 CommandObjectParsed (interpreter,
1522 "process kill",
1523 "Terminate the current process being debugged.",
1524 "process kill",
Greg Claytonea0bb4d2013-01-09 19:44:40 +00001525 eFlagRequiresProcess |
1526 eFlagTryTargetAPILock |
Jim Inghamda26bd22012-06-08 21:56:10 +00001527 eFlagProcessMustBeLaunched)
Chris Lattner24943d22010-06-08 16:52:24 +00001528 {
1529 }
1530
1531 ~CommandObjectProcessKill ()
1532 {
1533 }
1534
Jim Inghamda26bd22012-06-08 21:56:10 +00001535protected:
Chris Lattner24943d22010-06-08 16:52:24 +00001536 bool
Jim Inghamda26bd22012-06-08 21:56:10 +00001537 DoExecute (Args& command,
Chris Lattner24943d22010-06-08 16:52:24 +00001538 CommandReturnObject &result)
1539 {
Greg Claytonea0bb4d2013-01-09 19:44:40 +00001540 Process *process = m_exe_ctx.GetProcessPtr();
Chris Lattner24943d22010-06-08 16:52:24 +00001541 if (process == NULL)
1542 {
1543 result.AppendError ("no process to kill");
1544 result.SetStatus (eReturnStatusFailed);
1545 return false;
1546 }
1547
1548 if (command.GetArgumentCount() == 0)
1549 {
1550 Error error (process->Destroy());
1551 if (error.Success())
1552 {
1553 result.SetStatus (eReturnStatusSuccessFinishResult);
1554 }
1555 else
1556 {
1557 result.AppendErrorWithFormat ("Failed to kill process: %s\n", error.AsCString());
1558 result.SetStatus (eReturnStatusFailed);
1559 }
1560 }
1561 else
1562 {
Jason Molenda7e5fa7f2011-09-20 21:44:10 +00001563 result.AppendErrorWithFormat("'%s' takes no arguments:\nUsage: %s\n",
Chris Lattner24943d22010-06-08 16:52:24 +00001564 m_cmd_name.c_str(),
1565 m_cmd_syntax.c_str());
1566 result.SetStatus (eReturnStatusFailed);
1567 }
1568 return result.Succeeded();
1569 }
1570};
1571
1572//-------------------------------------------------------------------------
Jim Ingham41313fc2010-06-18 01:23:09 +00001573// CommandObjectProcessStatus
1574//-------------------------------------------------------------------------
Jim Ingham22dc9722010-12-09 18:58:16 +00001575#pragma mark CommandObjectProcessStatus
1576
Jim Inghamda26bd22012-06-08 21:56:10 +00001577class CommandObjectProcessStatus : public CommandObjectParsed
Jim Ingham41313fc2010-06-18 01:23:09 +00001578{
1579public:
Greg Clayton238c0a12010-09-18 01:14:36 +00001580 CommandObjectProcessStatus (CommandInterpreter &interpreter) :
Jim Inghamda26bd22012-06-08 21:56:10 +00001581 CommandObjectParsed (interpreter,
1582 "process status",
1583 "Show the current status and location of executing process.",
1584 "process status",
Greg Claytonea0bb4d2013-01-09 19:44:40 +00001585 eFlagRequiresProcess | eFlagTryTargetAPILock)
Jim Ingham41313fc2010-06-18 01:23:09 +00001586 {
1587 }
1588
1589 ~CommandObjectProcessStatus()
1590 {
1591 }
1592
1593
1594 bool
Jim Inghamda26bd22012-06-08 21:56:10 +00001595 DoExecute (Args& command, CommandReturnObject &result)
Jim Ingham41313fc2010-06-18 01:23:09 +00001596 {
Greg Claytonabe0fed2011-04-18 08:33:37 +00001597 Stream &strm = result.GetOutputStream();
Jim Ingham41313fc2010-06-18 01:23:09 +00001598 result.SetStatus (eReturnStatusSuccessFinishNoResult);
Greg Claytonea0bb4d2013-01-09 19:44:40 +00001599 // No need to check "process" for validity as eFlagRequiresProcess ensures it is valid
1600 Process *process = m_exe_ctx.GetProcessPtr();
1601 const bool only_threads_with_stop_reason = true;
1602 const uint32_t start_frame = 0;
1603 const uint32_t num_frames = 1;
1604 const uint32_t num_frames_with_source = 1;
1605 process->GetStatus(strm);
1606 process->GetThreadStatus (strm,
1607 only_threads_with_stop_reason,
1608 start_frame,
1609 num_frames,
1610 num_frames_with_source);
Jim Ingham41313fc2010-06-18 01:23:09 +00001611 return result.Succeeded();
1612 }
1613};
1614
1615//-------------------------------------------------------------------------
Caroline Tice23d6f272010-10-13 20:44:39 +00001616// CommandObjectProcessHandle
1617//-------------------------------------------------------------------------
Jim Ingham22dc9722010-12-09 18:58:16 +00001618#pragma mark CommandObjectProcessHandle
Caroline Tice23d6f272010-10-13 20:44:39 +00001619
Jim Inghamda26bd22012-06-08 21:56:10 +00001620class CommandObjectProcessHandle : public CommandObjectParsed
Caroline Tice23d6f272010-10-13 20:44:39 +00001621{
1622public:
1623
1624 class CommandOptions : public Options
1625 {
1626 public:
1627
Greg Claytonf15996e2011-04-07 22:46:35 +00001628 CommandOptions (CommandInterpreter &interpreter) :
1629 Options (interpreter)
Caroline Tice23d6f272010-10-13 20:44:39 +00001630 {
Greg Clayton143fcc32011-04-13 00:18:08 +00001631 OptionParsingStarting ();
Caroline Tice23d6f272010-10-13 20:44:39 +00001632 }
1633
1634 ~CommandOptions ()
1635 {
1636 }
1637
1638 Error
Greg Clayton143fcc32011-04-13 00:18:08 +00001639 SetOptionValue (uint32_t option_idx, const char *option_arg)
Caroline Tice23d6f272010-10-13 20:44:39 +00001640 {
1641 Error error;
Greg Clayton6475c422012-12-04 00:32:51 +00001642 const int short_option = m_getopt_table[option_idx].val;
Caroline Tice23d6f272010-10-13 20:44:39 +00001643
1644 switch (short_option)
1645 {
1646 case 's':
1647 stop = option_arg;
1648 break;
1649 case 'n':
1650 notify = option_arg;
1651 break;
1652 case 'p':
1653 pass = option_arg;
1654 break;
1655 default:
Greg Clayton9c236732011-10-26 00:56:27 +00001656 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
Caroline Tice23d6f272010-10-13 20:44:39 +00001657 break;
1658 }
1659 return error;
1660 }
1661
1662 void
Greg Clayton143fcc32011-04-13 00:18:08 +00001663 OptionParsingStarting ()
Caroline Tice23d6f272010-10-13 20:44:39 +00001664 {
Caroline Tice23d6f272010-10-13 20:44:39 +00001665 stop.clear();
1666 notify.clear();
1667 pass.clear();
1668 }
1669
Greg Claytonb3448432011-03-24 21:19:54 +00001670 const OptionDefinition*
Caroline Tice23d6f272010-10-13 20:44:39 +00001671 GetDefinitions ()
1672 {
1673 return g_option_table;
1674 }
1675
1676 // Options table: Required for subclasses of Options.
1677
Greg Claytonb3448432011-03-24 21:19:54 +00001678 static OptionDefinition g_option_table[];
Caroline Tice23d6f272010-10-13 20:44:39 +00001679
1680 // Instance variables to hold the values for command options.
1681
1682 std::string stop;
1683 std::string notify;
1684 std::string pass;
1685 };
1686
1687
1688 CommandObjectProcessHandle (CommandInterpreter &interpreter) :
Jim Inghamda26bd22012-06-08 21:56:10 +00001689 CommandObjectParsed (interpreter,
1690 "process handle",
1691 "Show or update what the process and debugger should do with various signals received from the OS.",
1692 NULL),
Greg Claytonf15996e2011-04-07 22:46:35 +00001693 m_options (interpreter)
Caroline Tice23d6f272010-10-13 20:44:39 +00001694 {
Caroline Ticee7471982010-10-14 21:31:13 +00001695 SetHelpLong ("If no signals are specified, update them all. If no update option is specified, list the current values.\n");
Caroline Tice23d6f272010-10-13 20:44:39 +00001696 CommandArgumentEntry arg;
Caroline Tice3a62e6d2010-10-18 22:56:57 +00001697 CommandArgumentData signal_arg;
Caroline Tice23d6f272010-10-13 20:44:39 +00001698
Caroline Tice3a62e6d2010-10-18 22:56:57 +00001699 signal_arg.arg_type = eArgTypeUnixSignal;
1700 signal_arg.arg_repetition = eArgRepeatStar;
Caroline Tice23d6f272010-10-13 20:44:39 +00001701
Caroline Tice3a62e6d2010-10-18 22:56:57 +00001702 arg.push_back (signal_arg);
Caroline Tice23d6f272010-10-13 20:44:39 +00001703
1704 m_arguments.push_back (arg);
1705 }
1706
1707 ~CommandObjectProcessHandle ()
1708 {
1709 }
1710
1711 Options *
1712 GetOptions ()
1713 {
1714 return &m_options;
1715 }
1716
1717 bool
Caroline Ticee7471982010-10-14 21:31:13 +00001718 VerifyCommandOptionValue (const std::string &option, int &real_value)
Caroline Tice23d6f272010-10-13 20:44:39 +00001719 {
1720 bool okay = true;
1721
Caroline Ticee7471982010-10-14 21:31:13 +00001722 bool success = false;
1723 bool tmp_value = Args::StringToBoolean (option.c_str(), false, &success);
1724
1725 if (success && tmp_value)
1726 real_value = 1;
1727 else if (success && !tmp_value)
1728 real_value = 0;
Caroline Tice23d6f272010-10-13 20:44:39 +00001729 else
1730 {
1731 // If the value isn't 'true' or 'false', it had better be 0 or 1.
Caroline Ticee7471982010-10-14 21:31:13 +00001732 real_value = Args::StringToUInt32 (option.c_str(), 3);
1733 if (real_value != 0 && real_value != 1)
Caroline Tice23d6f272010-10-13 20:44:39 +00001734 okay = false;
1735 }
1736
1737 return okay;
1738 }
1739
Caroline Ticee7471982010-10-14 21:31:13 +00001740 void
1741 PrintSignalHeader (Stream &str)
1742 {
1743 str.Printf ("NAME PASS STOP NOTIFY\n");
1744 str.Printf ("========== ===== ===== ======\n");
1745 }
1746
1747 void
1748 PrintSignal (Stream &str, int32_t signo, const char *sig_name, UnixSignals &signals)
1749 {
1750 bool stop;
1751 bool suppress;
1752 bool notify;
1753
1754 str.Printf ("%-10s ", sig_name);
1755 if (signals.GetSignalInfo (signo, suppress, stop, notify))
1756 {
1757 bool pass = !suppress;
1758 str.Printf ("%s %s %s",
1759 (pass ? "true " : "false"),
1760 (stop ? "true " : "false"),
1761 (notify ? "true " : "false"));
1762 }
1763 str.Printf ("\n");
1764 }
1765
1766 void
1767 PrintSignalInformation (Stream &str, Args &signal_args, int num_valid_signals, UnixSignals &signals)
1768 {
1769 PrintSignalHeader (str);
1770
1771 if (num_valid_signals > 0)
1772 {
1773 size_t num_args = signal_args.GetArgumentCount();
1774 for (size_t i = 0; i < num_args; ++i)
1775 {
1776 int32_t signo = signals.GetSignalNumberFromName (signal_args.GetArgumentAtIndex (i));
1777 if (signo != LLDB_INVALID_SIGNAL_NUMBER)
1778 PrintSignal (str, signo, signal_args.GetArgumentAtIndex (i), signals);
1779 }
1780 }
1781 else // Print info for ALL signals
1782 {
1783 int32_t signo = signals.GetFirstSignalNumber();
1784 while (signo != LLDB_INVALID_SIGNAL_NUMBER)
1785 {
1786 PrintSignal (str, signo, signals.GetSignalAsCString (signo), signals);
1787 signo = signals.GetNextSignalNumber (signo);
1788 }
1789 }
1790 }
1791
Jim Inghamda26bd22012-06-08 21:56:10 +00001792protected:
Caroline Tice23d6f272010-10-13 20:44:39 +00001793 bool
Jim Inghamda26bd22012-06-08 21:56:10 +00001794 DoExecute (Args &signal_args, CommandReturnObject &result)
Caroline Tice23d6f272010-10-13 20:44:39 +00001795 {
1796 TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget();
1797
1798 if (!target_sp)
1799 {
1800 result.AppendError ("No current target;"
1801 " cannot handle signals until you have a valid target and process.\n");
1802 result.SetStatus (eReturnStatusFailed);
1803 return false;
1804 }
1805
1806 ProcessSP process_sp = target_sp->GetProcessSP();
1807
1808 if (!process_sp)
1809 {
1810 result.AppendError ("No current process; cannot handle signals until you have a valid process.\n");
1811 result.SetStatus (eReturnStatusFailed);
1812 return false;
1813 }
1814
Caroline Tice23d6f272010-10-13 20:44:39 +00001815 int stop_action = -1; // -1 means leave the current setting alone
Caroline Ticee7471982010-10-14 21:31:13 +00001816 int pass_action = -1; // -1 means leave the current setting alone
Caroline Tice23d6f272010-10-13 20:44:39 +00001817 int notify_action = -1; // -1 means leave the current setting alone
1818
1819 if (! m_options.stop.empty()
Caroline Ticee7471982010-10-14 21:31:13 +00001820 && ! VerifyCommandOptionValue (m_options.stop, stop_action))
Caroline Tice23d6f272010-10-13 20:44:39 +00001821 {
1822 result.AppendError ("Invalid argument for command option --stop; must be true or false.\n");
1823 result.SetStatus (eReturnStatusFailed);
1824 return false;
1825 }
1826
1827 if (! m_options.notify.empty()
Caroline Ticee7471982010-10-14 21:31:13 +00001828 && ! VerifyCommandOptionValue (m_options.notify, notify_action))
Caroline Tice23d6f272010-10-13 20:44:39 +00001829 {
1830 result.AppendError ("Invalid argument for command option --notify; must be true or false.\n");
1831 result.SetStatus (eReturnStatusFailed);
1832 return false;
1833 }
1834
1835 if (! m_options.pass.empty()
Caroline Ticee7471982010-10-14 21:31:13 +00001836 && ! VerifyCommandOptionValue (m_options.pass, pass_action))
Caroline Tice23d6f272010-10-13 20:44:39 +00001837 {
1838 result.AppendError ("Invalid argument for command option --pass; must be true or false.\n");
1839 result.SetStatus (eReturnStatusFailed);
1840 return false;
1841 }
1842
1843 size_t num_args = signal_args.GetArgumentCount();
1844 UnixSignals &signals = process_sp->GetUnixSignals();
1845 int num_signals_set = 0;
1846
Caroline Ticee7471982010-10-14 21:31:13 +00001847 if (num_args > 0)
Caroline Tice23d6f272010-10-13 20:44:39 +00001848 {
Caroline Ticee7471982010-10-14 21:31:13 +00001849 for (size_t i = 0; i < num_args; ++i)
Caroline Tice23d6f272010-10-13 20:44:39 +00001850 {
Caroline Ticee7471982010-10-14 21:31:13 +00001851 int32_t signo = signals.GetSignalNumberFromName (signal_args.GetArgumentAtIndex (i));
1852 if (signo != LLDB_INVALID_SIGNAL_NUMBER)
Caroline Tice23d6f272010-10-13 20:44:39 +00001853 {
Caroline Ticee7471982010-10-14 21:31:13 +00001854 // Casting the actions as bools here should be okay, because VerifyCommandOptionValue guarantees
1855 // the value is either 0 or 1.
1856 if (stop_action != -1)
1857 signals.SetShouldStop (signo, (bool) stop_action);
1858 if (pass_action != -1)
1859 {
1860 bool suppress = ! ((bool) pass_action);
1861 signals.SetShouldSuppress (signo, suppress);
1862 }
1863 if (notify_action != -1)
1864 signals.SetShouldNotify (signo, (bool) notify_action);
1865 ++num_signals_set;
Caroline Tice23d6f272010-10-13 20:44:39 +00001866 }
Caroline Ticee7471982010-10-14 21:31:13 +00001867 else
1868 {
1869 result.AppendErrorWithFormat ("Invalid signal name '%s'\n", signal_args.GetArgumentAtIndex (i));
1870 }
Caroline Tice23d6f272010-10-13 20:44:39 +00001871 }
1872 }
Caroline Ticee7471982010-10-14 21:31:13 +00001873 else
1874 {
1875 // No signal specified, if any command options were specified, update ALL signals.
1876 if ((notify_action != -1) || (stop_action != -1) || (pass_action != -1))
1877 {
1878 if (m_interpreter.Confirm ("Do you really want to update all the signals?", false))
1879 {
1880 int32_t signo = signals.GetFirstSignalNumber();
1881 while (signo != LLDB_INVALID_SIGNAL_NUMBER)
1882 {
1883 if (notify_action != -1)
1884 signals.SetShouldNotify (signo, (bool) notify_action);
1885 if (stop_action != -1)
1886 signals.SetShouldStop (signo, (bool) stop_action);
1887 if (pass_action != -1)
1888 {
1889 bool suppress = ! ((bool) pass_action);
1890 signals.SetShouldSuppress (signo, suppress);
1891 }
1892 signo = signals.GetNextSignalNumber (signo);
1893 }
1894 }
1895 }
1896 }
1897
1898 PrintSignalInformation (result.GetOutputStream(), signal_args, num_signals_set, signals);
Caroline Tice23d6f272010-10-13 20:44:39 +00001899
1900 if (num_signals_set > 0)
1901 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1902 else
1903 result.SetStatus (eReturnStatusFailed);
1904
1905 return result.Succeeded();
1906 }
1907
Caroline Tice23d6f272010-10-13 20:44:39 +00001908 CommandOptions m_options;
1909};
1910
Greg Claytonb3448432011-03-24 21:19:54 +00001911OptionDefinition
Caroline Tice23d6f272010-10-13 20:44:39 +00001912CommandObjectProcessHandle::CommandOptions::g_option_table[] =
1913{
1914{ 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." },
1915{ 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." },
1916{ LLDB_OPT_SET_1, false, "pass", 'p', required_argument, NULL, 0, eArgTypeBoolean, "Whether or not the signal should be passed to the process." },
1917{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
1918};
1919
1920//-------------------------------------------------------------------------
Chris Lattner24943d22010-06-08 16:52:24 +00001921// CommandObjectMultiwordProcess
1922//-------------------------------------------------------------------------
1923
Greg Clayton63094e02010-06-23 01:19:29 +00001924CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter &interpreter) :
Greg Clayton238c0a12010-09-18 01:14:36 +00001925 CommandObjectMultiword (interpreter,
1926 "process",
1927 "A set of commands for operating on a process.",
1928 "process <subcommand> [<subcommand-options>]")
Chris Lattner24943d22010-06-08 16:52:24 +00001929{
Greg Claytona9eb8272011-07-02 21:07:54 +00001930 LoadSubCommand ("attach", CommandObjectSP (new CommandObjectProcessAttach (interpreter)));
1931 LoadSubCommand ("launch", CommandObjectSP (new CommandObjectProcessLaunch (interpreter)));
1932 LoadSubCommand ("continue", CommandObjectSP (new CommandObjectProcessContinue (interpreter)));
1933 LoadSubCommand ("connect", CommandObjectSP (new CommandObjectProcessConnect (interpreter)));
1934 LoadSubCommand ("detach", CommandObjectSP (new CommandObjectProcessDetach (interpreter)));
1935 LoadSubCommand ("load", CommandObjectSP (new CommandObjectProcessLoad (interpreter)));
1936 LoadSubCommand ("unload", CommandObjectSP (new CommandObjectProcessUnload (interpreter)));
1937 LoadSubCommand ("signal", CommandObjectSP (new CommandObjectProcessSignal (interpreter)));
1938 LoadSubCommand ("handle", CommandObjectSP (new CommandObjectProcessHandle (interpreter)));
1939 LoadSubCommand ("status", CommandObjectSP (new CommandObjectProcessStatus (interpreter)));
Greg Clayton238c0a12010-09-18 01:14:36 +00001940 LoadSubCommand ("interrupt", CommandObjectSP (new CommandObjectProcessInterrupt (interpreter)));
Greg Claytona9eb8272011-07-02 21:07:54 +00001941 LoadSubCommand ("kill", CommandObjectSP (new CommandObjectProcessKill (interpreter)));
Greg Clayton13193d52012-10-13 02:07:45 +00001942 LoadSubCommand ("plugin", CommandObjectSP (new CommandObjectProcessPlugin (interpreter)));
Chris Lattner24943d22010-06-08 16:52:24 +00001943}
1944
1945CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess ()
1946{
1947}
1948