blob: 3534df3a870191c75c6ed1e1cd925d6a91260ab3 [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
Daniel Malea93a64302012-12-05 00:20:57 +000010#include "lldb/lldb-python.h"
11
Chris Lattner30fdc8d2010-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 Ingham0e410842012-08-11 01:27:55 +000018#include "lldb/Breakpoint/Breakpoint.h"
19#include "lldb/Breakpoint/BreakpointLocation.h"
20#include "lldb/Breakpoint/BreakpointSite.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000021#include "lldb/Core/State.h"
Greg Clayton1f746072012-08-29 21:13:06 +000022#include "lldb/Core/Module.h"
Greg Claytona2715cf2014-06-13 00:54:12 +000023#include "lldb/Core/PluginManager.h"
Greg Clayton7260f622011-04-18 08:33:37 +000024#include "lldb/Host/Host.h"
Jim Ingham0e410842012-08-11 01:27:55 +000025#include "lldb/Interpreter/Args.h"
26#include "lldb/Interpreter/Options.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000027#include "lldb/Interpreter/CommandInterpreter.h"
28#include "lldb/Interpreter/CommandReturnObject.h"
Greg Claytone996fd32011-03-08 22:40:15 +000029#include "lldb/Target/Platform.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000030#include "lldb/Target/Process.h"
Jim Ingham0e410842012-08-11 01:27:55 +000031#include "lldb/Target/StopInfo.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000032#include "lldb/Target/Target.h"
33#include "lldb/Target/Thread.h"
34
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 {
94 Error destroy_error (process->Destroy());
95 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,
126 eFlagRequiresTarget,
127 "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
Greg Claytonb09c5382013-12-13 17:20:18 +0000208 if (target->GetDisableASLR())
209 m_options.launch_info.GetFlags().Set (eLaunchFlagDisableASLR);
Greg Clayton45392552012-10-17 22:57:12 +0000210
Jim Ingham106d0282014-06-25 02:32:56 +0000211 if (target->GetDetachOnError())
212 m_options.launch_info.GetFlags().Set (eLaunchFlagDetachOnError);
213
Greg Claytonb09c5382013-12-13 17:20:18 +0000214 if (target->GetDisableSTDIO())
215 m_options.launch_info.GetFlags().Set (eLaunchFlagDisableSTDIO);
216
217 Args environment;
218 target->GetEnvironmentAsArgs (environment);
219 if (environment.GetArgumentCount() > 0)
220 m_options.launch_info.GetEnvironmentEntries ().AppendArguments (environment);
221
Greg Clayton45392552012-10-17 22:57:12 +0000222 if (target_settings_argv0)
223 {
224 m_options.launch_info.GetArguments().AppendArgument (target_settings_argv0);
Greg Claytonb09c5382013-12-13 17:20:18 +0000225 m_options.launch_info.SetExecutableFile(exe_module_sp->GetPlatformFileSpec(), false);
Greg Clayton45392552012-10-17 22:57:12 +0000226 }
227 else
228 {
Greg Claytonb09c5382013-12-13 17:20:18 +0000229 m_options.launch_info.SetExecutableFile(exe_module_sp->GetPlatformFileSpec(), true);
Greg Clayton45392552012-10-17 22:57:12 +0000230 }
231
Greg Clayton144f3a92011-11-15 03:53:30 +0000232 if (launch_args.GetArgumentCount() == 0)
233 {
Greg Clayton67cc0632012-08-22 17:17:09 +0000234 Args target_setting_args;
Greg Clayton45392552012-10-17 22:57:12 +0000235 if (target->GetRunArguments(target_setting_args))
Greg Clayton67cc0632012-08-22 17:17:09 +0000236 m_options.launch_info.GetArguments().AppendArguments (target_setting_args);
Greg Clayton144f3a92011-11-15 03:53:30 +0000237 }
238 else
Greg Clayton1d885962011-11-08 02:43:13 +0000239 {
Greg Clayton45392552012-10-17 22:57:12 +0000240 m_options.launch_info.GetArguments().AppendArguments (launch_args);
Greg Clayton162b5972011-11-21 21:51:18 +0000241 // Save the arguments for subsequent runs in the current target.
242 target->SetRunArguments (launch_args);
Greg Clayton1d885962011-11-08 02:43:13 +0000243 }
Greg Clayton1d885962011-11-08 02:43:13 +0000244
Greg Claytonb09c5382013-12-13 17:20:18 +0000245 Error error = target->Launch(debugger.GetListener(), m_options.launch_info);
Jim Inghamdcb1d852013-03-29 00:56:30 +0000246
Greg Claytona7015092010-09-18 01:14:36 +0000247 if (error.Success())
248 {
Greg Claytonb09c5382013-12-13 17:20:18 +0000249 const char *archname = exe_module_sp->GetArchitecture().GetArchitectureName();
250 ProcessSP process_sp (target->GetProcessSP());
251 if (process_sp)
Greg Claytona7015092010-09-18 01:14:36 +0000252 {
Greg Claytonb09c5382013-12-13 17:20:18 +0000253 result.AppendMessageWithFormat ("Process %" PRIu64 " launched: '%s' (%s)\n", process_sp->GetID(), exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
254 result.SetStatus (eReturnStatusSuccessFinishResult);
255 result.SetDidChangeProcessState (true);
256 }
257 else
258 {
259 result.AppendError("no error returned from Target::Launch, and target has no process");
260 result.SetStatus (eReturnStatusFailed);
Greg Claytona7015092010-09-18 01:14:36 +0000261 }
262 }
Greg Clayton514487e2011-02-15 21:59:32 +0000263 else
264 {
Greg Claytonb09c5382013-12-13 17:20:18 +0000265 result.AppendError(error.AsCString());
Greg Clayton514487e2011-02-15 21:59:32 +0000266 result.SetStatus (eReturnStatusFailed);
267 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000268 return result.Succeeded();
269 }
270
271protected:
Greg Clayton982c9762011-11-03 21:22:33 +0000272 ProcessLaunchCommandOptions m_options;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000273};
274
275
Greg Clayton982c9762011-11-03 21:22:33 +0000276//#define SET1 LLDB_OPT_SET_1
277//#define SET2 LLDB_OPT_SET_2
278//#define SET3 LLDB_OPT_SET_3
279//
280//OptionDefinition
281//CommandObjectProcessLaunch::CommandOptions::g_option_table[] =
282//{
Virgile Belloe2607b52013-09-05 16:42:23 +0000283//{ 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."},
284//{ SET1 , false, "stdin", 'i', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stdin for the process to <path>."},
285//{ SET1 , false, "stdout", 'o', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stdout for the process to <path>."},
286//{ SET1 , false, "stderr", 'e', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stderr for the process to <path>."},
287//{ SET1 | SET2 | SET3, false, "plugin", 'p', OptionParser::eRequiredArgument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
288//{ 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."},
289//{ SET3, false, "no-stdio", 'n', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Do not set up for terminal I/O to go to running process."},
290//{ 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 +0000291//{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
292//};
293//
294//#undef SET1
295//#undef SET2
296//#undef SET3
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000297
298//-------------------------------------------------------------------------
299// CommandObjectProcessAttach
300//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +0000301#pragma mark CommandObjectProcessAttach
Jim Inghamdcb1d852013-03-29 00:56:30 +0000302class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000303{
304public:
305
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000306 class CommandOptions : public Options
307 {
308 public:
309
Greg Claytoneb0103f2011-04-07 22:46:35 +0000310 CommandOptions (CommandInterpreter &interpreter) :
311 Options(interpreter)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000312 {
Greg Claytonf6b8b582011-04-13 00:18:08 +0000313 // Keep default values of all options in one place: OptionParsingStarting ()
314 OptionParsingStarting ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000315 }
316
317 ~CommandOptions ()
318 {
319 }
320
321 Error
Greg Claytonf6b8b582011-04-13 00:18:08 +0000322 SetOptionValue (uint32_t option_idx, const char *option_arg)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000323 {
324 Error error;
Greg Clayton3bcdfc02012-12-04 00:32:51 +0000325 const int short_option = m_getopt_table[option_idx].val;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000326 bool success = false;
327 switch (short_option)
328 {
Johnny Chena95ce622012-05-24 00:43:00 +0000329 case 'c':
330 attach_info.SetContinueOnceAttached(true);
331 break;
332
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000333 case 'p':
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000334 {
Greg Clayton144f3a92011-11-15 03:53:30 +0000335 lldb::pid_t pid = Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success);
336 if (!success || pid == LLDB_INVALID_PROCESS_ID)
337 {
338 error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg);
339 }
340 else
341 {
342 attach_info.SetProcessID (pid);
343 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000344 }
345 break;
346
347 case 'P':
Greg Clayton144f3a92011-11-15 03:53:30 +0000348 attach_info.SetProcessPluginName (option_arg);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000349 break;
350
351 case 'n':
Greg Clayton144f3a92011-11-15 03:53:30 +0000352 attach_info.GetExecutableFile().SetFile(option_arg, false);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000353 break;
354
355 case 'w':
Greg Clayton144f3a92011-11-15 03:53:30 +0000356 attach_info.SetWaitForLaunch(true);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000357 break;
Jim Inghamcd16df92012-07-20 21:37:13 +0000358
359 case 'i':
360 attach_info.SetIgnoreExisting(false);
361 break;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000362
363 default:
Greg Clayton86edbf42011-10-26 00:56:27 +0000364 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000365 break;
366 }
367 return error;
368 }
369
370 void
Greg Claytonf6b8b582011-04-13 00:18:08 +0000371 OptionParsingStarting ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000372 {
Greg Clayton144f3a92011-11-15 03:53:30 +0000373 attach_info.Clear();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000374 }
375
Greg Claytone0d378b2011-03-24 21:19:54 +0000376 const OptionDefinition*
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000377 GetDefinitions ()
378 {
379 return g_option_table;
380 }
381
Jim Ingham5aee1622010-08-09 23:31:02 +0000382 virtual bool
Greg Claytoneb0103f2011-04-07 22:46:35 +0000383 HandleOptionArgumentCompletion (Args &input,
Jim Ingham5aee1622010-08-09 23:31:02 +0000384 int cursor_index,
385 int char_pos,
386 OptionElementVector &opt_element_vector,
387 int opt_element_index,
388 int match_start_point,
389 int max_return_elements,
390 bool &word_complete,
391 StringList &matches)
392 {
393 int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos;
394 int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index;
395
396 // We are only completing the name option for now...
397
Greg Claytone0d378b2011-03-24 21:19:54 +0000398 const OptionDefinition *opt_defs = GetDefinitions();
Jim Ingham5aee1622010-08-09 23:31:02 +0000399 if (opt_defs[opt_defs_index].short_option == 'n')
400 {
401 // Are we in the name?
402
403 // Look to see if there is a -P argument provided, and if so use that plugin, otherwise
404 // use the default plugin.
Jim Ingham5aee1622010-08-09 23:31:02 +0000405
406 const char *partial_name = NULL;
407 partial_name = input.GetArgumentAtIndex(opt_arg_pos);
Greg Claytone996fd32011-03-08 22:40:15 +0000408
Greg Clayton8b82f082011-04-12 05:54:46 +0000409 PlatformSP platform_sp (m_interpreter.GetPlatform (true));
Greg Claytone996fd32011-03-08 22:40:15 +0000410 if (platform_sp)
Jim Ingham5aee1622010-08-09 23:31:02 +0000411 {
Greg Clayton8b82f082011-04-12 05:54:46 +0000412 ProcessInstanceInfoList process_infos;
413 ProcessInstanceInfoMatch match_info;
Greg Clayton32e0a752011-03-30 18:16:51 +0000414 if (partial_name)
415 {
Greg Clayton144f3a92011-11-15 03:53:30 +0000416 match_info.GetProcessInfo().GetExecutableFile().SetFile(partial_name, false);
Greg Clayton32e0a752011-03-30 18:16:51 +0000417 match_info.SetNameMatchType(eNameMatchStartsWith);
418 }
419 platform_sp->FindProcesses (match_info, process_infos);
Greg Claytonc7bece562013-01-25 18:06:21 +0000420 const size_t num_matches = process_infos.GetSize();
Greg Claytone996fd32011-03-08 22:40:15 +0000421 if (num_matches > 0)
422 {
Greg Claytonc7bece562013-01-25 18:06:21 +0000423 for (size_t i=0; i<num_matches; ++i)
Greg Claytone996fd32011-03-08 22:40:15 +0000424 {
425 matches.AppendString (process_infos.GetProcessNameAtIndex(i),
426 process_infos.GetProcessNameLengthAtIndex(i));
427 }
428 }
Jim Ingham5aee1622010-08-09 23:31:02 +0000429 }
430 }
431
432 return false;
433 }
434
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000435 // Options table: Required for subclasses of Options.
436
Greg Claytone0d378b2011-03-24 21:19:54 +0000437 static OptionDefinition g_option_table[];
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000438
439 // Instance variables to hold the values for command options.
440
Greg Clayton144f3a92011-11-15 03:53:30 +0000441 ProcessAttachInfo attach_info;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000442 };
443
Greg Claytona7015092010-09-18 01:14:36 +0000444 CommandObjectProcessAttach (CommandInterpreter &interpreter) :
Jim Inghamdcb1d852013-03-29 00:56:30 +0000445 CommandObjectProcessLaunchOrAttach (interpreter,
446 "process attach",
447 "Attach to a process.",
448 "process attach <cmd-options>",
449 0,
450 "attach"),
Greg Claytoneb0103f2011-04-07 22:46:35 +0000451 m_options (interpreter)
Jim Ingham5aee1622010-08-09 23:31:02 +0000452 {
Jim Ingham5aee1622010-08-09 23:31:02 +0000453 }
454
455 ~CommandObjectProcessAttach ()
456 {
457 }
458
Jim Ingham5a988412012-06-08 21:56:10 +0000459 Options *
460 GetOptions ()
461 {
462 return &m_options;
463 }
464
465protected:
Jim Ingham5aee1622010-08-09 23:31:02 +0000466 bool
Jim Ingham5a988412012-06-08 21:56:10 +0000467 DoExecute (Args& command,
Jim Ingham5aee1622010-08-09 23:31:02 +0000468 CommandReturnObject &result)
469 {
Greg Claytona7015092010-09-18 01:14:36 +0000470 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
Jim Ingham31412642011-09-15 01:08:57 +0000471 // N.B. The attach should be synchronous. It doesn't help much to get the prompt back between initiating the attach
472 // and the target actually stopping. So even if the interpreter is set to be asynchronous, we wait for the stop
473 // ourselves here.
Jim Inghambb3a2832011-01-29 01:49:25 +0000474
Greg Clayton71337622011-02-24 22:24:29 +0000475 StateType state = eStateInvalid;
Jim Inghamdcb1d852013-03-29 00:56:30 +0000476 Process *process = m_exe_ctx.GetProcessPtr();
477
478 if (!StopProcessIfNecessary (process, state, result))
479 return false;
480
Jim Ingham5aee1622010-08-09 23:31:02 +0000481 if (target == NULL)
482 {
483 // If there isn't a current target create one.
484 TargetSP new_target_sp;
Jim Ingham5aee1622010-08-09 23:31:02 +0000485 Error error;
486
Greg Claytona7015092010-09-18 01:14:36 +0000487 error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(),
Greg Claytona0ca6602012-10-18 16:33:33 +0000488 NULL,
Greg Claytoncac9c5f2011-09-24 00:52:29 +0000489 NULL,
Greg Claytona7015092010-09-18 01:14:36 +0000490 false,
Greg Claytoncac9c5f2011-09-24 00:52:29 +0000491 NULL, // No platform options
Greg Claytona7015092010-09-18 01:14:36 +0000492 new_target_sp);
Jim Ingham5aee1622010-08-09 23:31:02 +0000493 target = new_target_sp.get();
494 if (target == NULL || error.Fail())
495 {
Greg Claytonb766a732011-02-04 01:58:07 +0000496 result.AppendError(error.AsCString("Error creating target"));
Jim Ingham5aee1622010-08-09 23:31:02 +0000497 return false;
498 }
Greg Claytona7015092010-09-18 01:14:36 +0000499 m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target);
Jim Ingham5aee1622010-08-09 23:31:02 +0000500 }
501
502 // Record the old executable module, we want to issue a warning if the process of attaching changed the
503 // current executable (like somebody said "file foo" then attached to a PID whose executable was bar.)
504
505 ModuleSP old_exec_module_sp = target->GetExecutableModule();
506 ArchSpec old_arch_spec = target->GetArchitecture();
507
508 if (command.GetArgumentCount())
509 {
Jason Molendafd54b362011-09-20 21:44:10 +0000510 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 +0000511 result.SetStatus (eReturnStatusFailed);
512 }
513 else
514 {
Greg Clayton71337622011-02-24 22:24:29 +0000515 if (state != eStateConnected)
516 {
Greg Clayton144f3a92011-11-15 03:53:30 +0000517 const char *plugin_name = m_options.attach_info.GetProcessPluginName();
Greg Claytonc3776bf2012-02-09 06:16:32 +0000518 process = target->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name, NULL).get();
Greg Clayton71337622011-02-24 22:24:29 +0000519 }
Jim Ingham5aee1622010-08-09 23:31:02 +0000520
521 if (process)
522 {
523 Error error;
Greg Clayton144f3a92011-11-15 03:53:30 +0000524 // If no process info was specified, then use the target executable
525 // name as the process to attach to by default
526 if (!m_options.attach_info.ProcessInfoSpecified ())
Jim Ingham3a0b9cd2010-09-15 01:34:14 +0000527 {
528 if (old_exec_module_sp)
Greg Claytonad9e8282011-11-29 04:03:30 +0000529 m_options.attach_info.GetExecutableFile().GetFilename() = old_exec_module_sp->GetPlatformFileSpec().GetFilename();
Jim Ingham3a0b9cd2010-09-15 01:34:14 +0000530
Greg Clayton144f3a92011-11-15 03:53:30 +0000531 if (!m_options.attach_info.ProcessInfoSpecified ())
532 {
533 error.SetErrorString ("no process specified, create a target with a file, or specify the --pid or --name command option");
534 }
535 }
536
537 if (error.Success())
538 {
Greg Clayton44d93782014-01-27 23:43:24 +0000539 ListenerSP listener_sp (new Listener("lldb.CommandObjectProcessAttach.DoExecute.attach.hijack"));
540 m_options.attach_info.SetHijackListener(listener_sp);
541 process->HijackProcessEvents(listener_sp.get());
Greg Clayton144f3a92011-11-15 03:53:30 +0000542 error = process->Attach (m_options.attach_info);
543
Jim Ingham3a0b9cd2010-09-15 01:34:14 +0000544 if (error.Success())
545 {
546 result.SetStatus (eReturnStatusSuccessContinuingNoResult);
Greg Clayton44d93782014-01-27 23:43:24 +0000547 StateType state = process->WaitForProcessToStop (NULL, NULL, false, listener_sp.get());
548
549 process->RestoreProcessEvents();
550
551 result.SetDidChangeProcessState (true);
552
553 if (state == eStateStopped)
554 {
555 result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
556 result.SetStatus (eReturnStatusSuccessFinishNoResult);
557 }
558 else
559 {
560 result.AppendError ("attach failed: process did not stop (no such process or permission problem?)");
561 process->Destroy();
562 result.SetStatus (eReturnStatusFailed);
563 }
Jim Ingham3a0b9cd2010-09-15 01:34:14 +0000564 }
Jim Ingham5aee1622010-08-09 23:31:02 +0000565 else
566 {
Greg Clayton144f3a92011-11-15 03:53:30 +0000567 result.AppendErrorWithFormat ("attach failed: %s\n", error.AsCString());
Jim Ingham3a0b9cd2010-09-15 01:34:14 +0000568 result.SetStatus (eReturnStatusFailed);
Johnny Chenaa739092012-05-18 00:51:36 +0000569 }
Jim Ingham5aee1622010-08-09 23:31:02 +0000570 }
Jim Ingham5aee1622010-08-09 23:31:02 +0000571 }
572 }
573
574 if (result.Succeeded())
575 {
576 // Okay, we're done. Last step is to warn if the executable module has changed:
Greg Clayton513c26c2011-01-29 07:10:55 +0000577 char new_path[PATH_MAX];
Greg Claytonaa149cb2011-08-11 02:48:45 +0000578 ModuleSP new_exec_module_sp (target->GetExecutableModule());
Jim Ingham5aee1622010-08-09 23:31:02 +0000579 if (!old_exec_module_sp)
580 {
Greg Clayton513c26c2011-01-29 07:10:55 +0000581 // We might not have a module if we attached to a raw pid...
Greg Claytonaa149cb2011-08-11 02:48:45 +0000582 if (new_exec_module_sp)
Greg Clayton513c26c2011-01-29 07:10:55 +0000583 {
Greg Claytonaa149cb2011-08-11 02:48:45 +0000584 new_exec_module_sp->GetFileSpec().GetPath(new_path, PATH_MAX);
Greg Clayton513c26c2011-01-29 07:10:55 +0000585 result.AppendMessageWithFormat("Executable module set to \"%s\".\n", new_path);
586 }
Jim Ingham5aee1622010-08-09 23:31:02 +0000587 }
Greg Claytonaa149cb2011-08-11 02:48:45 +0000588 else if (old_exec_module_sp->GetFileSpec() != new_exec_module_sp->GetFileSpec())
Jim Ingham5aee1622010-08-09 23:31:02 +0000589 {
Greg Clayton513c26c2011-01-29 07:10:55 +0000590 char old_path[PATH_MAX];
Jim Ingham5aee1622010-08-09 23:31:02 +0000591
Greg Claytonaa149cb2011-08-11 02:48:45 +0000592 old_exec_module_sp->GetFileSpec().GetPath (old_path, PATH_MAX);
593 new_exec_module_sp->GetFileSpec().GetPath (new_path, PATH_MAX);
Jim Ingham5aee1622010-08-09 23:31:02 +0000594
595 result.AppendWarningWithFormat("Executable module changed from \"%s\" to \"%s\".\n",
596 old_path, new_path);
597 }
598
599 if (!old_arch_spec.IsValid())
600 {
Greg Claytonc1b1f1e2012-09-14 02:41:36 +0000601 result.AppendMessageWithFormat ("Architecture set to: %s.\n", target->GetArchitecture().GetTriple().getTriple().c_str());
Jim Ingham5aee1622010-08-09 23:31:02 +0000602 }
Sean Callananbf4b7be2012-12-13 22:07:14 +0000603 else if (!old_arch_spec.IsExactMatch(target->GetArchitecture()))
Jim Ingham5aee1622010-08-09 23:31:02 +0000604 {
605 result.AppendWarningWithFormat("Architecture changed from %s to %s.\n",
Greg Claytonc1b1f1e2012-09-14 02:41:36 +0000606 old_arch_spec.GetTriple().getTriple().c_str(),
607 target->GetArchitecture().GetTriple().getTriple().c_str());
Jim Ingham5aee1622010-08-09 23:31:02 +0000608 }
Johnny Chena95ce622012-05-24 00:43:00 +0000609
610 // This supports the use-case scenario of immediately continuing the process once attached.
611 if (m_options.attach_info.GetContinueOnceAttached())
Sean Callanan5bcaf582012-05-31 01:30:08 +0000612 m_interpreter.HandleCommand("process continue", eLazyBoolNo, result);
Jim Ingham5aee1622010-08-09 23:31:02 +0000613 }
614 return result.Succeeded();
615 }
616
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000617 CommandOptions m_options;
618};
619
620
Greg Claytone0d378b2011-03-24 21:19:54 +0000621OptionDefinition
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000622CommandObjectProcessAttach::CommandOptions::g_option_table[] =
623{
Zachary Turnerd37221d2014-07-09 16:31:49 +0000624{ LLDB_OPT_SET_ALL, false, "continue",'c', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Immediately continue the process once attached."},
625{ LLDB_OPT_SET_ALL, false, "plugin", 'P', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
626{ LLDB_OPT_SET_1, false, "pid", 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePid, "The process ID of an existing process to attach to."},
627{ LLDB_OPT_SET_2, false, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeProcessName, "The name of the process to attach to."},
628{ LLDB_OPT_SET_2, false, "include-existing", 'i', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Include existing processes when doing attach -w."},
629{ LLDB_OPT_SET_2, false, "waitfor", 'w', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone, "Wait for the process with <process-name> to launch."},
630{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000631};
632
633//-------------------------------------------------------------------------
634// CommandObjectProcessContinue
635//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +0000636#pragma mark CommandObjectProcessContinue
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000637
Jim Ingham5a988412012-06-08 21:56:10 +0000638class CommandObjectProcessContinue : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000639{
640public:
641
Greg Claytona7015092010-09-18 01:14:36 +0000642 CommandObjectProcessContinue (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +0000643 CommandObjectParsed (interpreter,
644 "process continue",
645 "Continue execution of all threads in the current process.",
646 "process continue",
Greg Claytonf9fc6092013-01-09 19:44:40 +0000647 eFlagRequiresProcess |
648 eFlagTryTargetAPILock |
649 eFlagProcessMustBeLaunched |
650 eFlagProcessMustBePaused ),
Jim Ingham0e410842012-08-11 01:27:55 +0000651 m_options(interpreter)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000652 {
653 }
654
655
656 ~CommandObjectProcessContinue ()
657 {
658 }
659
Jim Ingham5a988412012-06-08 21:56:10 +0000660protected:
Jim Ingham0e410842012-08-11 01:27:55 +0000661
662 class CommandOptions : public Options
663 {
664 public:
665
666 CommandOptions (CommandInterpreter &interpreter) :
667 Options(interpreter)
668 {
669 // Keep default values of all options in one place: OptionParsingStarting ()
670 OptionParsingStarting ();
671 }
672
673 ~CommandOptions ()
674 {
675 }
676
677 Error
678 SetOptionValue (uint32_t option_idx, const char *option_arg)
679 {
680 Error error;
Greg Clayton3bcdfc02012-12-04 00:32:51 +0000681 const int short_option = m_getopt_table[option_idx].val;
Jim Ingham0e410842012-08-11 01:27:55 +0000682 bool success = false;
683 switch (short_option)
684 {
685 case 'i':
686 m_ignore = Args::StringToUInt32 (option_arg, 0, 0, &success);
687 if (!success)
688 error.SetErrorStringWithFormat ("invalid value for ignore option: \"%s\", should be a number.", option_arg);
689 break;
690
691 default:
692 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
693 break;
694 }
695 return error;
696 }
697
698 void
699 OptionParsingStarting ()
700 {
701 m_ignore = 0;
702 }
703
704 const OptionDefinition*
705 GetDefinitions ()
706 {
707 return g_option_table;
708 }
709
710 // Options table: Required for subclasses of Options.
711
712 static OptionDefinition g_option_table[];
713
714 uint32_t m_ignore;
715 };
716
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000717 bool
Greg Claytonf9fc6092013-01-09 19:44:40 +0000718 DoExecute (Args& command, CommandReturnObject &result)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000719 {
Greg Claytonf9fc6092013-01-09 19:44:40 +0000720 Process *process = m_exe_ctx.GetProcessPtr();
Greg Claytona7015092010-09-18 01:14:36 +0000721 bool synchronous_execution = m_interpreter.GetSynchronous ();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000722 StateType state = process->GetState();
723 if (state == eStateStopped)
724 {
725 if (command.GetArgumentCount() != 0)
726 {
727 result.AppendErrorWithFormat ("The '%s' command does not take any arguments.\n", m_cmd_name.c_str());
728 result.SetStatus (eReturnStatusFailed);
729 return false;
730 }
731
Jim Ingham0e410842012-08-11 01:27:55 +0000732 if (m_options.m_ignore > 0)
733 {
734 ThreadSP sel_thread_sp(process->GetThreadList().GetSelectedThread());
735 if (sel_thread_sp)
736 {
737 StopInfoSP stop_info_sp = sel_thread_sp->GetStopInfo();
738 if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint)
739 {
Greg Claytonc7bece562013-01-25 18:06:21 +0000740 lldb::break_id_t bp_site_id = (lldb::break_id_t)stop_info_sp->GetValue();
Jim Ingham0e410842012-08-11 01:27:55 +0000741 BreakpointSiteSP bp_site_sp(process->GetBreakpointSiteList().FindByID(bp_site_id));
742 if (bp_site_sp)
743 {
Greg Claytonc7bece562013-01-25 18:06:21 +0000744 const size_t num_owners = bp_site_sp->GetNumberOfOwners();
745 for (size_t i = 0; i < num_owners; i++)
Jim Ingham0e410842012-08-11 01:27:55 +0000746 {
747 Breakpoint &bp_ref = bp_site_sp->GetOwnerAtIndex(i)->GetBreakpoint();
748 if (!bp_ref.IsInternal())
749 {
750 bp_ref.SetIgnoreCount(m_options.m_ignore);
751 }
752 }
753 }
754 }
755 }
756 }
757
Jim Ingham41f2b942012-09-10 20:50:15 +0000758 { // Scope for thread list mutex:
759 Mutex::Locker locker (process->GetThreadList().GetMutex());
760 const uint32_t num_threads = process->GetThreadList().GetSize();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000761
Jim Ingham41f2b942012-09-10 20:50:15 +0000762 // Set the actions that the threads should each take when resuming
763 for (uint32_t idx=0; idx<num_threads; ++idx)
764 {
Jim Ingham6c9ed912014-04-03 01:26:14 +0000765 const bool override_suspend = false;
766 process->GetThreadList().GetThreadAtIndex(idx)->SetResumeState (eStateRunning, override_suspend);
Jim Ingham41f2b942012-09-10 20:50:15 +0000767 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000768 }
Jim Ingham41f2b942012-09-10 20:50:15 +0000769
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000770 Error error(process->Resume());
771 if (error.Success())
772 {
Daniel Malead01b2952012-11-29 21:49:15 +0000773 result.AppendMessageWithFormat ("Process %" PRIu64 " resuming\n", process->GetID());
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000774 if (synchronous_execution)
775 {
Greg Claytonb1320972010-07-14 00:18:15 +0000776 state = process->WaitForProcessToStop (NULL);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000777
778 result.SetDidChangeProcessState (true);
Daniel Malead01b2952012-11-29 21:49:15 +0000779 result.AppendMessageWithFormat ("Process %" PRIu64 " %s\n", process->GetID(), StateAsCString (state));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000780 result.SetStatus (eReturnStatusSuccessFinishNoResult);
781 }
782 else
783 {
784 result.SetStatus (eReturnStatusSuccessContinuingNoResult);
785 }
786 }
787 else
788 {
789 result.AppendErrorWithFormat("Failed to resume process: %s.\n", error.AsCString());
790 result.SetStatus (eReturnStatusFailed);
791 }
792 }
793 else
794 {
795 result.AppendErrorWithFormat ("Process cannot be continued from its current state (%s).\n",
796 StateAsCString(state));
797 result.SetStatus (eReturnStatusFailed);
798 }
799 return result.Succeeded();
800 }
Jim Ingham0e410842012-08-11 01:27:55 +0000801
802 Options *
803 GetOptions ()
804 {
805 return &m_options;
806 }
807
808 CommandOptions m_options;
809
810};
811
812OptionDefinition
813CommandObjectProcessContinue::CommandOptions::g_option_table[] =
814{
Zachary Turnerd37221d2014-07-09 16:31:49 +0000815{ LLDB_OPT_SET_ALL, false, "ignore-count",'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeUnsignedInteger,
Jim Ingham0e410842012-08-11 01:27:55 +0000816 "Ignore <N> crossings of the breakpoint (if it exists) for the currently selected thread."},
Zachary Turnerd37221d2014-07-09 16:31:49 +0000817{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000818};
819
820//-------------------------------------------------------------------------
821// CommandObjectProcessDetach
822//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +0000823#pragma mark CommandObjectProcessDetach
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000824
Jim Ingham5a988412012-06-08 21:56:10 +0000825class CommandObjectProcessDetach : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000826{
827public:
Jim Inghamacff8952013-05-02 00:27:30 +0000828 class CommandOptions : public Options
829 {
830 public:
831
832 CommandOptions (CommandInterpreter &interpreter) :
833 Options (interpreter)
834 {
835 OptionParsingStarting ();
836 }
837
838 ~CommandOptions ()
839 {
840 }
841
842 Error
843 SetOptionValue (uint32_t option_idx, const char *option_arg)
844 {
845 Error error;
846 const int short_option = m_getopt_table[option_idx].val;
847
848 switch (short_option)
849 {
850 case 's':
851 bool tmp_result;
852 bool success;
853 tmp_result = Args::StringToBoolean(option_arg, false, &success);
854 if (!success)
855 error.SetErrorStringWithFormat("invalid boolean option: \"%s\"", option_arg);
856 else
857 {
858 if (tmp_result)
859 m_keep_stopped = eLazyBoolYes;
860 else
861 m_keep_stopped = eLazyBoolNo;
862 }
863 break;
864 default:
865 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
866 break;
867 }
868 return error;
869 }
870
871 void
872 OptionParsingStarting ()
873 {
874 m_keep_stopped = eLazyBoolCalculate;
875 }
876
877 const OptionDefinition*
878 GetDefinitions ()
879 {
880 return g_option_table;
881 }
882
883 // Options table: Required for subclasses of Options.
884
885 static OptionDefinition g_option_table[];
886
887 // Instance variables to hold the values for command options.
888 LazyBool m_keep_stopped;
889 };
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000890
Greg Claytona7015092010-09-18 01:14:36 +0000891 CommandObjectProcessDetach (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +0000892 CommandObjectParsed (interpreter,
893 "process detach",
894 "Detach from the current process being debugged.",
895 "process detach",
Greg Claytonf9fc6092013-01-09 19:44:40 +0000896 eFlagRequiresProcess |
897 eFlagTryTargetAPILock |
Jim Inghamacff8952013-05-02 00:27:30 +0000898 eFlagProcessMustBeLaunched),
899 m_options(interpreter)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000900 {
901 }
902
903 ~CommandObjectProcessDetach ()
904 {
905 }
906
Jim Inghamacff8952013-05-02 00:27:30 +0000907 Options *
908 GetOptions ()
909 {
910 return &m_options;
911 }
912
913
Jim Ingham5a988412012-06-08 21:56:10 +0000914protected:
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000915 bool
Greg Claytonf9fc6092013-01-09 19:44:40 +0000916 DoExecute (Args& command, CommandReturnObject &result)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000917 {
Greg Claytonf9fc6092013-01-09 19:44:40 +0000918 Process *process = m_exe_ctx.GetProcessPtr();
Jim Inghamacff8952013-05-02 00:27:30 +0000919 // FIXME: This will be a Command Option:
920 bool keep_stopped;
921 if (m_options.m_keep_stopped == eLazyBoolCalculate)
922 {
923 // Check the process default:
924 if (process->GetDetachKeepsStopped())
925 keep_stopped = true;
926 else
927 keep_stopped = false;
928 }
929 else if (m_options.m_keep_stopped == eLazyBoolYes)
930 keep_stopped = true;
931 else
932 keep_stopped = false;
933
934 Error error (process->Detach(keep_stopped));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000935 if (error.Success())
936 {
937 result.SetStatus (eReturnStatusSuccessFinishResult);
938 }
939 else
940 {
941 result.AppendErrorWithFormat ("Detach failed: %s\n", error.AsCString());
942 result.SetStatus (eReturnStatusFailed);
943 return false;
944 }
945 return result.Succeeded();
946 }
Jim Inghamacff8952013-05-02 00:27:30 +0000947
948 CommandOptions m_options;
949};
950
951OptionDefinition
952CommandObjectProcessDetach::CommandOptions::g_option_table[] =
953{
Zachary Turnerd37221d2014-07-09 16:31:49 +0000954{ 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)." },
955{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000956};
957
958//-------------------------------------------------------------------------
Greg Claytonb766a732011-02-04 01:58:07 +0000959// CommandObjectProcessConnect
960//-------------------------------------------------------------------------
961#pragma mark CommandObjectProcessConnect
962
Jim Ingham5a988412012-06-08 21:56:10 +0000963class CommandObjectProcessConnect : public CommandObjectParsed
Greg Claytonb766a732011-02-04 01:58:07 +0000964{
965public:
966
967 class CommandOptions : public Options
968 {
969 public:
970
Greg Claytoneb0103f2011-04-07 22:46:35 +0000971 CommandOptions (CommandInterpreter &interpreter) :
972 Options(interpreter)
Greg Claytonb766a732011-02-04 01:58:07 +0000973 {
Greg Claytonf6b8b582011-04-13 00:18:08 +0000974 // Keep default values of all options in one place: OptionParsingStarting ()
975 OptionParsingStarting ();
Greg Claytonb766a732011-02-04 01:58:07 +0000976 }
977
978 ~CommandOptions ()
979 {
980 }
981
982 Error
Greg Claytonf6b8b582011-04-13 00:18:08 +0000983 SetOptionValue (uint32_t option_idx, const char *option_arg)
Greg Claytonb766a732011-02-04 01:58:07 +0000984 {
985 Error error;
Greg Clayton3bcdfc02012-12-04 00:32:51 +0000986 const int short_option = m_getopt_table[option_idx].val;
Greg Claytonb766a732011-02-04 01:58:07 +0000987
988 switch (short_option)
989 {
990 case 'p':
991 plugin_name.assign (option_arg);
992 break;
993
994 default:
Greg Clayton86edbf42011-10-26 00:56:27 +0000995 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
Greg Claytonb766a732011-02-04 01:58:07 +0000996 break;
997 }
998 return error;
999 }
1000
1001 void
Greg Claytonf6b8b582011-04-13 00:18:08 +00001002 OptionParsingStarting ()
Greg Claytonb766a732011-02-04 01:58:07 +00001003 {
Greg Claytonb766a732011-02-04 01:58:07 +00001004 plugin_name.clear();
1005 }
1006
Greg Claytone0d378b2011-03-24 21:19:54 +00001007 const OptionDefinition*
Greg Claytonb766a732011-02-04 01:58:07 +00001008 GetDefinitions ()
1009 {
1010 return g_option_table;
1011 }
1012
1013 // Options table: Required for subclasses of Options.
1014
Greg Claytone0d378b2011-03-24 21:19:54 +00001015 static OptionDefinition g_option_table[];
Greg Claytonb766a732011-02-04 01:58:07 +00001016
1017 // Instance variables to hold the values for command options.
1018
1019 std::string plugin_name;
1020 };
1021
1022 CommandObjectProcessConnect (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001023 CommandObjectParsed (interpreter,
1024 "process connect",
1025 "Connect to a remote debug service.",
1026 "process connect <remote-url>",
1027 0),
Greg Claytoneb0103f2011-04-07 22:46:35 +00001028 m_options (interpreter)
Greg Claytonb766a732011-02-04 01:58:07 +00001029 {
1030 }
1031
1032 ~CommandObjectProcessConnect ()
1033 {
1034 }
1035
1036
Jim Ingham5a988412012-06-08 21:56:10 +00001037 Options *
1038 GetOptions ()
1039 {
1040 return &m_options;
1041 }
1042
1043protected:
Greg Claytonb766a732011-02-04 01:58:07 +00001044 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001045 DoExecute (Args& command,
Greg Claytonb766a732011-02-04 01:58:07 +00001046 CommandReturnObject &result)
1047 {
1048
1049 TargetSP target_sp (m_interpreter.GetDebugger().GetSelectedTarget());
1050 Error error;
Greg Claytonf9fc6092013-01-09 19:44:40 +00001051 Process *process = m_exe_ctx.GetProcessPtr();
Greg Claytonb766a732011-02-04 01:58:07 +00001052 if (process)
1053 {
1054 if (process->IsAlive())
1055 {
Daniel Malead01b2952012-11-29 21:49:15 +00001056 result.AppendErrorWithFormat ("Process %" PRIu64 " is currently being debugged, kill the process before connecting.\n",
Greg Claytonb766a732011-02-04 01:58:07 +00001057 process->GetID());
1058 result.SetStatus (eReturnStatusFailed);
1059 return false;
1060 }
1061 }
1062
1063 if (!target_sp)
1064 {
1065 // If there isn't a current target create one.
Greg Claytonb766a732011-02-04 01:58:07 +00001066
1067 error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(),
Greg Claytona0ca6602012-10-18 16:33:33 +00001068 NULL,
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001069 NULL,
Greg Claytonb766a732011-02-04 01:58:07 +00001070 false,
Greg Claytoncac9c5f2011-09-24 00:52:29 +00001071 NULL, // No platform options
Greg Claytonb766a732011-02-04 01:58:07 +00001072 target_sp);
1073 if (!target_sp || error.Fail())
1074 {
1075 result.AppendError(error.AsCString("Error creating target"));
1076 result.SetStatus (eReturnStatusFailed);
1077 return false;
1078 }
1079 m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target_sp.get());
1080 }
1081
1082 if (command.GetArgumentCount() == 1)
1083 {
1084 const char *plugin_name = NULL;
1085 if (!m_options.plugin_name.empty())
1086 plugin_name = m_options.plugin_name.c_str();
1087
1088 const char *remote_url = command.GetArgumentAtIndex(0);
Greg Claytonc3776bf2012-02-09 06:16:32 +00001089 process = target_sp->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name, NULL).get();
Greg Claytonb766a732011-02-04 01:58:07 +00001090
1091 if (process)
1092 {
Greg Clayton44d93782014-01-27 23:43:24 +00001093 error = process->ConnectRemote (process->GetTarget().GetDebugger().GetOutputFile().get(), remote_url);
Greg Claytonb766a732011-02-04 01:58:07 +00001094
1095 if (error.Fail())
1096 {
1097 result.AppendError(error.AsCString("Remote connect failed"));
1098 result.SetStatus (eReturnStatusFailed);
Greg Clayton1517dd32012-03-31 00:10:30 +00001099 target_sp->DeleteCurrentProcess();
Greg Claytonb766a732011-02-04 01:58:07 +00001100 return false;
1101 }
1102 }
1103 else
1104 {
Jason Molendafd54b362011-09-20 21:44:10 +00001105 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 +00001106 remote_url);
Greg Claytonb766a732011-02-04 01:58:07 +00001107 result.SetStatus (eReturnStatusFailed);
1108 }
1109 }
1110 else
1111 {
Jason Molendafd54b362011-09-20 21:44:10 +00001112 result.AppendErrorWithFormat ("'%s' takes exactly one argument:\nUsage: %s\n",
Greg Claytonb766a732011-02-04 01:58:07 +00001113 m_cmd_name.c_str(),
1114 m_cmd_syntax.c_str());
1115 result.SetStatus (eReturnStatusFailed);
1116 }
1117 return result.Succeeded();
1118 }
Greg Claytonb766a732011-02-04 01:58:07 +00001119
1120 CommandOptions m_options;
1121};
1122
Greg Claytone0d378b2011-03-24 21:19:54 +00001123OptionDefinition
Greg Claytonb766a732011-02-04 01:58:07 +00001124CommandObjectProcessConnect::CommandOptions::g_option_table[] =
1125{
Zachary Turnerd37221d2014-07-09 16:31:49 +00001126 { LLDB_OPT_SET_ALL, false, "plugin", 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."},
1127 { 0, false, NULL, 0 , 0, NULL, NULL, 0, eArgTypeNone, NULL }
Greg Claytonb766a732011-02-04 01:58:07 +00001128};
1129
1130//-------------------------------------------------------------------------
Greg Clayton998255b2012-10-13 02:07:45 +00001131// CommandObjectProcessPlugin
1132//-------------------------------------------------------------------------
1133#pragma mark CommandObjectProcessPlugin
1134
1135class CommandObjectProcessPlugin : public CommandObjectProxy
1136{
1137public:
1138
1139 CommandObjectProcessPlugin (CommandInterpreter &interpreter) :
1140 CommandObjectProxy (interpreter,
1141 "process plugin",
1142 "Send a custom command to the current process plug-in.",
1143 "process plugin <args>",
1144 0)
1145 {
1146 }
1147
1148 ~CommandObjectProcessPlugin ()
1149 {
1150 }
1151
1152 virtual CommandObject *
1153 GetProxyCommandObject()
1154 {
Greg Claytone05b2ef2013-01-09 22:58:18 +00001155 Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
Greg Clayton998255b2012-10-13 02:07:45 +00001156 if (process)
1157 return process->GetPluginCommandObject();
1158 return NULL;
1159 }
1160};
1161
1162
1163//-------------------------------------------------------------------------
Greg Clayton8f343b02010-11-04 01:54:29 +00001164// CommandObjectProcessLoad
1165//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +00001166#pragma mark CommandObjectProcessLoad
Greg Clayton8f343b02010-11-04 01:54:29 +00001167
Jim Ingham5a988412012-06-08 21:56:10 +00001168class CommandObjectProcessLoad : public CommandObjectParsed
Greg Clayton8f343b02010-11-04 01:54:29 +00001169{
1170public:
1171
1172 CommandObjectProcessLoad (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001173 CommandObjectParsed (interpreter,
1174 "process load",
1175 "Load a shared library into the current process.",
1176 "process load <filename> [<filename> ...]",
Greg Claytonf9fc6092013-01-09 19:44:40 +00001177 eFlagRequiresProcess |
1178 eFlagTryTargetAPILock |
1179 eFlagProcessMustBeLaunched |
1180 eFlagProcessMustBePaused )
Greg Clayton8f343b02010-11-04 01:54:29 +00001181 {
1182 }
1183
1184 ~CommandObjectProcessLoad ()
1185 {
1186 }
1187
Jim Ingham5a988412012-06-08 21:56:10 +00001188protected:
Greg Clayton8f343b02010-11-04 01:54:29 +00001189 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001190 DoExecute (Args& command,
Greg Clayton8f343b02010-11-04 01:54:29 +00001191 CommandReturnObject &result)
1192 {
Greg Claytonf9fc6092013-01-09 19:44:40 +00001193 Process *process = m_exe_ctx.GetProcessPtr();
Greg Clayton8f343b02010-11-04 01:54:29 +00001194
Greg Claytonc7bece562013-01-25 18:06:21 +00001195 const size_t argc = command.GetArgumentCount();
Greg Clayton8f343b02010-11-04 01:54:29 +00001196
1197 for (uint32_t i=0; i<argc; ++i)
1198 {
1199 Error error;
1200 const char *image_path = command.GetArgumentAtIndex(i);
1201 FileSpec image_spec (image_path, false);
Greg Claytonaa516842011-08-11 16:25:18 +00001202 process->GetTarget().GetPlatform()->ResolveRemotePath(image_spec, image_spec);
Greg Clayton8f343b02010-11-04 01:54:29 +00001203 uint32_t image_token = process->LoadImage(image_spec, error);
1204 if (image_token != LLDB_INVALID_IMAGE_TOKEN)
1205 {
1206 result.AppendMessageWithFormat ("Loading \"%s\"...ok\nImage %u loaded.\n", image_path, image_token);
1207 result.SetStatus (eReturnStatusSuccessFinishResult);
1208 }
1209 else
1210 {
1211 result.AppendErrorWithFormat ("failed to load '%s': %s", image_path, error.AsCString());
1212 result.SetStatus (eReturnStatusFailed);
1213 }
1214 }
1215 return result.Succeeded();
1216 }
1217};
1218
1219
1220//-------------------------------------------------------------------------
1221// CommandObjectProcessUnload
1222//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +00001223#pragma mark CommandObjectProcessUnload
Greg Clayton8f343b02010-11-04 01:54:29 +00001224
Jim Ingham5a988412012-06-08 21:56:10 +00001225class CommandObjectProcessUnload : public CommandObjectParsed
Greg Clayton8f343b02010-11-04 01:54:29 +00001226{
1227public:
1228
1229 CommandObjectProcessUnload (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001230 CommandObjectParsed (interpreter,
1231 "process unload",
1232 "Unload a shared library from the current process using the index returned by a previous call to \"process load\".",
1233 "process unload <index>",
Greg Claytonf9fc6092013-01-09 19:44:40 +00001234 eFlagRequiresProcess |
1235 eFlagTryTargetAPILock |
1236 eFlagProcessMustBeLaunched |
1237 eFlagProcessMustBePaused )
Greg Clayton8f343b02010-11-04 01:54:29 +00001238 {
1239 }
1240
1241 ~CommandObjectProcessUnload ()
1242 {
1243 }
1244
Jim Ingham5a988412012-06-08 21:56:10 +00001245protected:
Greg Clayton8f343b02010-11-04 01:54:29 +00001246 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001247 DoExecute (Args& command,
Greg Clayton8f343b02010-11-04 01:54:29 +00001248 CommandReturnObject &result)
1249 {
Greg Claytonf9fc6092013-01-09 19:44:40 +00001250 Process *process = m_exe_ctx.GetProcessPtr();
Greg Clayton8f343b02010-11-04 01:54:29 +00001251
Greg Claytonc7bece562013-01-25 18:06:21 +00001252 const size_t argc = command.GetArgumentCount();
Greg Clayton8f343b02010-11-04 01:54:29 +00001253
1254 for (uint32_t i=0; i<argc; ++i)
1255 {
1256 const char *image_token_cstr = command.GetArgumentAtIndex(i);
1257 uint32_t image_token = Args::StringToUInt32(image_token_cstr, LLDB_INVALID_IMAGE_TOKEN, 0);
1258 if (image_token == LLDB_INVALID_IMAGE_TOKEN)
1259 {
1260 result.AppendErrorWithFormat ("invalid image index argument '%s'", image_token_cstr);
1261 result.SetStatus (eReturnStatusFailed);
1262 break;
1263 }
1264 else
1265 {
1266 Error error (process->UnloadImage(image_token));
1267 if (error.Success())
1268 {
1269 result.AppendMessageWithFormat ("Unloading shared library with index %u...ok\n", image_token);
1270 result.SetStatus (eReturnStatusSuccessFinishResult);
1271 }
1272 else
1273 {
1274 result.AppendErrorWithFormat ("failed to unload image: %s", error.AsCString());
1275 result.SetStatus (eReturnStatusFailed);
1276 break;
1277 }
1278 }
1279 }
1280 return result.Succeeded();
1281 }
1282};
1283
1284//-------------------------------------------------------------------------
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001285// CommandObjectProcessSignal
1286//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +00001287#pragma mark CommandObjectProcessSignal
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001288
Jim Ingham5a988412012-06-08 21:56:10 +00001289class CommandObjectProcessSignal : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001290{
1291public:
1292
Greg Claytona7015092010-09-18 01:14:36 +00001293 CommandObjectProcessSignal (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001294 CommandObjectParsed (interpreter,
1295 "process signal",
1296 "Send a UNIX signal to the current process being debugged.",
Greg Claytonf9fc6092013-01-09 19:44:40 +00001297 NULL,
1298 eFlagRequiresProcess | eFlagTryTargetAPILock)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001299 {
Caroline Tice405fe672010-10-04 22:28:36 +00001300 CommandArgumentEntry arg;
1301 CommandArgumentData signal_arg;
1302
1303 // Define the first (and only) variant of this arg.
Caroline Ticec0dbdfb2010-10-18 22:56:57 +00001304 signal_arg.arg_type = eArgTypeUnixSignal;
Caroline Tice405fe672010-10-04 22:28:36 +00001305 signal_arg.arg_repetition = eArgRepeatPlain;
1306
1307 // There is only one variant this argument could be; put it into the argument entry.
1308 arg.push_back (signal_arg);
1309
1310 // Push the data for the first argument into the m_arguments vector.
1311 m_arguments.push_back (arg);
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001312 }
1313
1314 ~CommandObjectProcessSignal ()
1315 {
1316 }
1317
Jim Ingham5a988412012-06-08 21:56:10 +00001318protected:
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001319 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001320 DoExecute (Args& command,
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001321 CommandReturnObject &result)
1322 {
Greg Claytonf9fc6092013-01-09 19:44:40 +00001323 Process *process = m_exe_ctx.GetProcessPtr();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001324
1325 if (command.GetArgumentCount() == 1)
1326 {
Greg Clayton237cd902010-10-09 01:40:57 +00001327 int signo = LLDB_INVALID_SIGNAL_NUMBER;
1328
1329 const char *signal_name = command.GetArgumentAtIndex(0);
1330 if (::isxdigit (signal_name[0]))
1331 signo = Args::StringToSInt32(signal_name, LLDB_INVALID_SIGNAL_NUMBER, 0);
1332 else
1333 signo = process->GetUnixSignals().GetSignalNumberFromName (signal_name);
1334
1335 if (signo == LLDB_INVALID_SIGNAL_NUMBER)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001336 {
1337 result.AppendErrorWithFormat ("Invalid signal argument '%s'.\n", command.GetArgumentAtIndex(0));
1338 result.SetStatus (eReturnStatusFailed);
1339 }
1340 else
1341 {
1342 Error error (process->Signal (signo));
1343 if (error.Success())
1344 {
1345 result.SetStatus (eReturnStatusSuccessFinishResult);
1346 }
1347 else
1348 {
1349 result.AppendErrorWithFormat ("Failed to send signal %i: %s\n", signo, error.AsCString());
1350 result.SetStatus (eReturnStatusFailed);
1351 }
1352 }
1353 }
1354 else
1355 {
Jason Molendafd54b362011-09-20 21:44:10 +00001356 result.AppendErrorWithFormat("'%s' takes exactly one signal number argument:\nUsage: %s\n", m_cmd_name.c_str(),
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001357 m_cmd_syntax.c_str());
1358 result.SetStatus (eReturnStatusFailed);
1359 }
1360 return result.Succeeded();
1361 }
1362};
1363
1364
1365//-------------------------------------------------------------------------
1366// CommandObjectProcessInterrupt
1367//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +00001368#pragma mark CommandObjectProcessInterrupt
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001369
Jim Ingham5a988412012-06-08 21:56:10 +00001370class CommandObjectProcessInterrupt : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001371{
1372public:
1373
1374
Greg Claytona7015092010-09-18 01:14:36 +00001375 CommandObjectProcessInterrupt (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001376 CommandObjectParsed (interpreter,
1377 "process interrupt",
1378 "Interrupt the current process being debugged.",
1379 "process interrupt",
Greg Claytonf9fc6092013-01-09 19:44:40 +00001380 eFlagRequiresProcess |
1381 eFlagTryTargetAPILock |
Jim Ingham5a988412012-06-08 21:56:10 +00001382 eFlagProcessMustBeLaunched)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001383 {
1384 }
1385
1386 ~CommandObjectProcessInterrupt ()
1387 {
1388 }
1389
Jim Ingham5a988412012-06-08 21:56:10 +00001390protected:
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001391 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001392 DoExecute (Args& command,
Greg Claytonf9b57b92013-05-10 23:48:10 +00001393 CommandReturnObject &result)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001394 {
Greg Claytonf9fc6092013-01-09 19:44:40 +00001395 Process *process = m_exe_ctx.GetProcessPtr();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001396 if (process == NULL)
1397 {
1398 result.AppendError ("no process to halt");
1399 result.SetStatus (eReturnStatusFailed);
1400 return false;
1401 }
1402
1403 if (command.GetArgumentCount() == 0)
1404 {
Greg Claytonf9b57b92013-05-10 23:48:10 +00001405 bool clear_thread_plans = true;
1406 Error error(process->Halt (clear_thread_plans));
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001407 if (error.Success())
1408 {
1409 result.SetStatus (eReturnStatusSuccessFinishResult);
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001410 }
1411 else
1412 {
1413 result.AppendErrorWithFormat ("Failed to halt process: %s\n", error.AsCString());
1414 result.SetStatus (eReturnStatusFailed);
1415 }
1416 }
1417 else
1418 {
Jason Molendafd54b362011-09-20 21:44:10 +00001419 result.AppendErrorWithFormat("'%s' takes no arguments:\nUsage: %s\n",
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001420 m_cmd_name.c_str(),
1421 m_cmd_syntax.c_str());
1422 result.SetStatus (eReturnStatusFailed);
1423 }
1424 return result.Succeeded();
1425 }
1426};
1427
1428//-------------------------------------------------------------------------
1429// CommandObjectProcessKill
1430//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +00001431#pragma mark CommandObjectProcessKill
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001432
Jim Ingham5a988412012-06-08 21:56:10 +00001433class CommandObjectProcessKill : public CommandObjectParsed
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001434{
1435public:
1436
Greg Claytona7015092010-09-18 01:14:36 +00001437 CommandObjectProcessKill (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001438 CommandObjectParsed (interpreter,
1439 "process kill",
1440 "Terminate the current process being debugged.",
1441 "process kill",
Greg Claytonf9fc6092013-01-09 19:44:40 +00001442 eFlagRequiresProcess |
1443 eFlagTryTargetAPILock |
Jim Ingham5a988412012-06-08 21:56:10 +00001444 eFlagProcessMustBeLaunched)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001445 {
1446 }
1447
1448 ~CommandObjectProcessKill ()
1449 {
1450 }
1451
Jim Ingham5a988412012-06-08 21:56:10 +00001452protected:
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001453 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001454 DoExecute (Args& command,
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001455 CommandReturnObject &result)
1456 {
Greg Claytonf9fc6092013-01-09 19:44:40 +00001457 Process *process = m_exe_ctx.GetProcessPtr();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001458 if (process == NULL)
1459 {
1460 result.AppendError ("no process to kill");
1461 result.SetStatus (eReturnStatusFailed);
1462 return false;
1463 }
1464
1465 if (command.GetArgumentCount() == 0)
1466 {
1467 Error error (process->Destroy());
1468 if (error.Success())
1469 {
1470 result.SetStatus (eReturnStatusSuccessFinishResult);
1471 }
1472 else
1473 {
1474 result.AppendErrorWithFormat ("Failed to kill process: %s\n", error.AsCString());
1475 result.SetStatus (eReturnStatusFailed);
1476 }
1477 }
1478 else
1479 {
Jason Molendafd54b362011-09-20 21:44:10 +00001480 result.AppendErrorWithFormat("'%s' takes no arguments:\nUsage: %s\n",
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001481 m_cmd_name.c_str(),
1482 m_cmd_syntax.c_str());
1483 result.SetStatus (eReturnStatusFailed);
1484 }
1485 return result.Succeeded();
1486 }
1487};
1488
1489//-------------------------------------------------------------------------
Greg Claytona2715cf2014-06-13 00:54:12 +00001490// CommandObjectProcessSaveCore
1491//-------------------------------------------------------------------------
1492#pragma mark CommandObjectProcessSaveCore
1493
1494class CommandObjectProcessSaveCore : public CommandObjectParsed
1495{
1496public:
1497
1498 CommandObjectProcessSaveCore (CommandInterpreter &interpreter) :
1499 CommandObjectParsed (interpreter,
1500 "process save-core",
1501 "Save the current process as a core file using an appropriate file type.",
1502 "process save-core FILE",
1503 eFlagRequiresProcess |
1504 eFlagTryTargetAPILock |
1505 eFlagProcessMustBeLaunched)
1506 {
1507 }
1508
1509 ~CommandObjectProcessSaveCore ()
1510 {
1511 }
1512
1513protected:
1514 bool
1515 DoExecute (Args& command,
1516 CommandReturnObject &result)
1517 {
1518 ProcessSP process_sp = m_exe_ctx.GetProcessSP();
1519 if (process_sp)
1520 {
1521 if (command.GetArgumentCount() == 1)
1522 {
1523 FileSpec output_file(command.GetArgumentAtIndex(0), false);
1524 Error error = PluginManager::SaveCore(process_sp, output_file);
1525 if (error.Success())
1526 {
1527 result.SetStatus (eReturnStatusSuccessFinishResult);
1528 }
1529 else
1530 {
1531 result.AppendErrorWithFormat ("Failed to save core file for process: %s\n", error.AsCString());
1532 result.SetStatus (eReturnStatusFailed);
1533 }
1534 }
1535 else
1536 {
1537 result.AppendErrorWithFormat ("'%s' takes one arguments:\nUsage: %s\n",
1538 m_cmd_name.c_str(),
1539 m_cmd_syntax.c_str());
1540 result.SetStatus (eReturnStatusFailed);
1541 }
1542 }
1543 else
1544 {
1545 result.AppendError ("invalid process");
1546 result.SetStatus (eReturnStatusFailed);
1547 return false;
1548 }
1549
1550 return result.Succeeded();
1551 }
1552};
1553
1554//-------------------------------------------------------------------------
Jim Ingham4b9bea82010-06-18 01:23:09 +00001555// CommandObjectProcessStatus
1556//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +00001557#pragma mark CommandObjectProcessStatus
1558
Jim Ingham5a988412012-06-08 21:56:10 +00001559class CommandObjectProcessStatus : public CommandObjectParsed
Jim Ingham4b9bea82010-06-18 01:23:09 +00001560{
1561public:
Greg Claytona7015092010-09-18 01:14:36 +00001562 CommandObjectProcessStatus (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001563 CommandObjectParsed (interpreter,
1564 "process status",
1565 "Show the current status and location of executing process.",
1566 "process status",
Greg Claytonf9fc6092013-01-09 19:44:40 +00001567 eFlagRequiresProcess | eFlagTryTargetAPILock)
Jim Ingham4b9bea82010-06-18 01:23:09 +00001568 {
1569 }
1570
1571 ~CommandObjectProcessStatus()
1572 {
1573 }
1574
1575
1576 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001577 DoExecute (Args& command, CommandReturnObject &result)
Jim Ingham4b9bea82010-06-18 01:23:09 +00001578 {
Greg Clayton7260f622011-04-18 08:33:37 +00001579 Stream &strm = result.GetOutputStream();
Jim Ingham4b9bea82010-06-18 01:23:09 +00001580 result.SetStatus (eReturnStatusSuccessFinishNoResult);
Greg Claytonf9fc6092013-01-09 19:44:40 +00001581 // No need to check "process" for validity as eFlagRequiresProcess ensures it is valid
1582 Process *process = m_exe_ctx.GetProcessPtr();
1583 const bool only_threads_with_stop_reason = true;
1584 const uint32_t start_frame = 0;
1585 const uint32_t num_frames = 1;
1586 const uint32_t num_frames_with_source = 1;
1587 process->GetStatus(strm);
1588 process->GetThreadStatus (strm,
1589 only_threads_with_stop_reason,
1590 start_frame,
1591 num_frames,
1592 num_frames_with_source);
Jim Ingham4b9bea82010-06-18 01:23:09 +00001593 return result.Succeeded();
1594 }
1595};
1596
1597//-------------------------------------------------------------------------
Caroline Tice35731352010-10-13 20:44:39 +00001598// CommandObjectProcessHandle
1599//-------------------------------------------------------------------------
Jim Inghambb9caf72010-12-09 18:58:16 +00001600#pragma mark CommandObjectProcessHandle
Caroline Tice35731352010-10-13 20:44:39 +00001601
Jim Ingham5a988412012-06-08 21:56:10 +00001602class CommandObjectProcessHandle : public CommandObjectParsed
Caroline Tice35731352010-10-13 20:44:39 +00001603{
1604public:
1605
1606 class CommandOptions : public Options
1607 {
1608 public:
1609
Greg Claytoneb0103f2011-04-07 22:46:35 +00001610 CommandOptions (CommandInterpreter &interpreter) :
1611 Options (interpreter)
Caroline Tice35731352010-10-13 20:44:39 +00001612 {
Greg Claytonf6b8b582011-04-13 00:18:08 +00001613 OptionParsingStarting ();
Caroline Tice35731352010-10-13 20:44:39 +00001614 }
1615
1616 ~CommandOptions ()
1617 {
1618 }
1619
1620 Error
Greg Claytonf6b8b582011-04-13 00:18:08 +00001621 SetOptionValue (uint32_t option_idx, const char *option_arg)
Caroline Tice35731352010-10-13 20:44:39 +00001622 {
1623 Error error;
Greg Clayton3bcdfc02012-12-04 00:32:51 +00001624 const int short_option = m_getopt_table[option_idx].val;
Caroline Tice35731352010-10-13 20:44:39 +00001625
1626 switch (short_option)
1627 {
1628 case 's':
1629 stop = option_arg;
1630 break;
1631 case 'n':
1632 notify = option_arg;
1633 break;
1634 case 'p':
1635 pass = option_arg;
1636 break;
1637 default:
Greg Clayton86edbf42011-10-26 00:56:27 +00001638 error.SetErrorStringWithFormat("invalid short option character '%c'", short_option);
Caroline Tice35731352010-10-13 20:44:39 +00001639 break;
1640 }
1641 return error;
1642 }
1643
1644 void
Greg Claytonf6b8b582011-04-13 00:18:08 +00001645 OptionParsingStarting ()
Caroline Tice35731352010-10-13 20:44:39 +00001646 {
Caroline Tice35731352010-10-13 20:44:39 +00001647 stop.clear();
1648 notify.clear();
1649 pass.clear();
1650 }
1651
Greg Claytone0d378b2011-03-24 21:19:54 +00001652 const OptionDefinition*
Caroline Tice35731352010-10-13 20:44:39 +00001653 GetDefinitions ()
1654 {
1655 return g_option_table;
1656 }
1657
1658 // Options table: Required for subclasses of Options.
1659
Greg Claytone0d378b2011-03-24 21:19:54 +00001660 static OptionDefinition g_option_table[];
Caroline Tice35731352010-10-13 20:44:39 +00001661
1662 // Instance variables to hold the values for command options.
1663
1664 std::string stop;
1665 std::string notify;
1666 std::string pass;
1667 };
1668
1669
1670 CommandObjectProcessHandle (CommandInterpreter &interpreter) :
Jim Ingham5a988412012-06-08 21:56:10 +00001671 CommandObjectParsed (interpreter,
1672 "process handle",
1673 "Show or update what the process and debugger should do with various signals received from the OS.",
1674 NULL),
Greg Claytoneb0103f2011-04-07 22:46:35 +00001675 m_options (interpreter)
Caroline Tice35731352010-10-13 20:44:39 +00001676 {
Caroline Tice10ad7992010-10-14 21:31:13 +00001677 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 +00001678 CommandArgumentEntry arg;
Caroline Ticec0dbdfb2010-10-18 22:56:57 +00001679 CommandArgumentData signal_arg;
Caroline Tice35731352010-10-13 20:44:39 +00001680
Caroline Ticec0dbdfb2010-10-18 22:56:57 +00001681 signal_arg.arg_type = eArgTypeUnixSignal;
1682 signal_arg.arg_repetition = eArgRepeatStar;
Caroline Tice35731352010-10-13 20:44:39 +00001683
Caroline Ticec0dbdfb2010-10-18 22:56:57 +00001684 arg.push_back (signal_arg);
Caroline Tice35731352010-10-13 20:44:39 +00001685
1686 m_arguments.push_back (arg);
1687 }
1688
1689 ~CommandObjectProcessHandle ()
1690 {
1691 }
1692
1693 Options *
1694 GetOptions ()
1695 {
1696 return &m_options;
1697 }
1698
1699 bool
Caroline Tice10ad7992010-10-14 21:31:13 +00001700 VerifyCommandOptionValue (const std::string &option, int &real_value)
Caroline Tice35731352010-10-13 20:44:39 +00001701 {
1702 bool okay = true;
1703
Caroline Tice10ad7992010-10-14 21:31:13 +00001704 bool success = false;
1705 bool tmp_value = Args::StringToBoolean (option.c_str(), false, &success);
1706
1707 if (success && tmp_value)
1708 real_value = 1;
1709 else if (success && !tmp_value)
1710 real_value = 0;
Caroline Tice35731352010-10-13 20:44:39 +00001711 else
1712 {
1713 // If the value isn't 'true' or 'false', it had better be 0 or 1.
Caroline Tice10ad7992010-10-14 21:31:13 +00001714 real_value = Args::StringToUInt32 (option.c_str(), 3);
1715 if (real_value != 0 && real_value != 1)
Caroline Tice35731352010-10-13 20:44:39 +00001716 okay = false;
1717 }
1718
1719 return okay;
1720 }
1721
Caroline Tice10ad7992010-10-14 21:31:13 +00001722 void
1723 PrintSignalHeader (Stream &str)
1724 {
1725 str.Printf ("NAME PASS STOP NOTIFY\n");
1726 str.Printf ("========== ===== ===== ======\n");
1727 }
1728
1729 void
1730 PrintSignal (Stream &str, int32_t signo, const char *sig_name, UnixSignals &signals)
1731 {
1732 bool stop;
1733 bool suppress;
1734 bool notify;
1735
1736 str.Printf ("%-10s ", sig_name);
1737 if (signals.GetSignalInfo (signo, suppress, stop, notify))
1738 {
1739 bool pass = !suppress;
1740 str.Printf ("%s %s %s",
1741 (pass ? "true " : "false"),
1742 (stop ? "true " : "false"),
1743 (notify ? "true " : "false"));
1744 }
1745 str.Printf ("\n");
1746 }
1747
1748 void
1749 PrintSignalInformation (Stream &str, Args &signal_args, int num_valid_signals, UnixSignals &signals)
1750 {
1751 PrintSignalHeader (str);
1752
1753 if (num_valid_signals > 0)
1754 {
1755 size_t num_args = signal_args.GetArgumentCount();
1756 for (size_t i = 0; i < num_args; ++i)
1757 {
1758 int32_t signo = signals.GetSignalNumberFromName (signal_args.GetArgumentAtIndex (i));
1759 if (signo != LLDB_INVALID_SIGNAL_NUMBER)
1760 PrintSignal (str, signo, signal_args.GetArgumentAtIndex (i), signals);
1761 }
1762 }
1763 else // Print info for ALL signals
1764 {
1765 int32_t signo = signals.GetFirstSignalNumber();
1766 while (signo != LLDB_INVALID_SIGNAL_NUMBER)
1767 {
1768 PrintSignal (str, signo, signals.GetSignalAsCString (signo), signals);
1769 signo = signals.GetNextSignalNumber (signo);
1770 }
1771 }
1772 }
1773
Jim Ingham5a988412012-06-08 21:56:10 +00001774protected:
Caroline Tice35731352010-10-13 20:44:39 +00001775 bool
Jim Ingham5a988412012-06-08 21:56:10 +00001776 DoExecute (Args &signal_args, CommandReturnObject &result)
Caroline Tice35731352010-10-13 20:44:39 +00001777 {
1778 TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget();
1779
1780 if (!target_sp)
1781 {
1782 result.AppendError ("No current target;"
1783 " cannot handle signals until you have a valid target and process.\n");
1784 result.SetStatus (eReturnStatusFailed);
1785 return false;
1786 }
1787
1788 ProcessSP process_sp = target_sp->GetProcessSP();
1789
1790 if (!process_sp)
1791 {
1792 result.AppendError ("No current process; cannot handle signals until you have a valid process.\n");
1793 result.SetStatus (eReturnStatusFailed);
1794 return false;
1795 }
1796
Caroline Tice35731352010-10-13 20:44:39 +00001797 int stop_action = -1; // -1 means leave the current setting alone
Caroline Tice10ad7992010-10-14 21:31:13 +00001798 int pass_action = -1; // -1 means leave the current setting alone
Caroline Tice35731352010-10-13 20:44:39 +00001799 int notify_action = -1; // -1 means leave the current setting alone
1800
1801 if (! m_options.stop.empty()
Caroline Tice10ad7992010-10-14 21:31:13 +00001802 && ! VerifyCommandOptionValue (m_options.stop, stop_action))
Caroline Tice35731352010-10-13 20:44:39 +00001803 {
1804 result.AppendError ("Invalid argument for command option --stop; must be true or false.\n");
1805 result.SetStatus (eReturnStatusFailed);
1806 return false;
1807 }
1808
1809 if (! m_options.notify.empty()
Caroline Tice10ad7992010-10-14 21:31:13 +00001810 && ! VerifyCommandOptionValue (m_options.notify, notify_action))
Caroline Tice35731352010-10-13 20:44:39 +00001811 {
1812 result.AppendError ("Invalid argument for command option --notify; must be true or false.\n");
1813 result.SetStatus (eReturnStatusFailed);
1814 return false;
1815 }
1816
1817 if (! m_options.pass.empty()
Caroline Tice10ad7992010-10-14 21:31:13 +00001818 && ! VerifyCommandOptionValue (m_options.pass, pass_action))
Caroline Tice35731352010-10-13 20:44:39 +00001819 {
1820 result.AppendError ("Invalid argument for command option --pass; must be true or false.\n");
1821 result.SetStatus (eReturnStatusFailed);
1822 return false;
1823 }
1824
1825 size_t num_args = signal_args.GetArgumentCount();
1826 UnixSignals &signals = process_sp->GetUnixSignals();
1827 int num_signals_set = 0;
1828
Caroline Tice10ad7992010-10-14 21:31:13 +00001829 if (num_args > 0)
Caroline Tice35731352010-10-13 20:44:39 +00001830 {
Caroline Tice10ad7992010-10-14 21:31:13 +00001831 for (size_t i = 0; i < num_args; ++i)
Caroline Tice35731352010-10-13 20:44:39 +00001832 {
Caroline Tice10ad7992010-10-14 21:31:13 +00001833 int32_t signo = signals.GetSignalNumberFromName (signal_args.GetArgumentAtIndex (i));
1834 if (signo != LLDB_INVALID_SIGNAL_NUMBER)
Caroline Tice35731352010-10-13 20:44:39 +00001835 {
Caroline Tice10ad7992010-10-14 21:31:13 +00001836 // Casting the actions as bools here should be okay, because VerifyCommandOptionValue guarantees
1837 // the value is either 0 or 1.
1838 if (stop_action != -1)
1839 signals.SetShouldStop (signo, (bool) stop_action);
1840 if (pass_action != -1)
1841 {
1842 bool suppress = ! ((bool) pass_action);
1843 signals.SetShouldSuppress (signo, suppress);
1844 }
1845 if (notify_action != -1)
1846 signals.SetShouldNotify (signo, (bool) notify_action);
1847 ++num_signals_set;
Caroline Tice35731352010-10-13 20:44:39 +00001848 }
Caroline Tice10ad7992010-10-14 21:31:13 +00001849 else
1850 {
1851 result.AppendErrorWithFormat ("Invalid signal name '%s'\n", signal_args.GetArgumentAtIndex (i));
1852 }
Caroline Tice35731352010-10-13 20:44:39 +00001853 }
1854 }
Caroline Tice10ad7992010-10-14 21:31:13 +00001855 else
1856 {
1857 // No signal specified, if any command options were specified, update ALL signals.
1858 if ((notify_action != -1) || (stop_action != -1) || (pass_action != -1))
1859 {
1860 if (m_interpreter.Confirm ("Do you really want to update all the signals?", false))
1861 {
1862 int32_t signo = signals.GetFirstSignalNumber();
1863 while (signo != LLDB_INVALID_SIGNAL_NUMBER)
1864 {
1865 if (notify_action != -1)
1866 signals.SetShouldNotify (signo, (bool) notify_action);
1867 if (stop_action != -1)
1868 signals.SetShouldStop (signo, (bool) stop_action);
1869 if (pass_action != -1)
1870 {
1871 bool suppress = ! ((bool) pass_action);
1872 signals.SetShouldSuppress (signo, suppress);
1873 }
1874 signo = signals.GetNextSignalNumber (signo);
1875 }
1876 }
1877 }
1878 }
1879
1880 PrintSignalInformation (result.GetOutputStream(), signal_args, num_signals_set, signals);
Caroline Tice35731352010-10-13 20:44:39 +00001881
1882 if (num_signals_set > 0)
1883 result.SetStatus (eReturnStatusSuccessFinishNoResult);
1884 else
1885 result.SetStatus (eReturnStatusFailed);
1886
1887 return result.Succeeded();
1888 }
1889
Caroline Tice35731352010-10-13 20:44:39 +00001890 CommandOptions m_options;
1891};
1892
Greg Claytone0d378b2011-03-24 21:19:54 +00001893OptionDefinition
Caroline Tice35731352010-10-13 20:44:39 +00001894CommandObjectProcessHandle::CommandOptions::g_option_table[] =
1895{
Zachary Turnerd37221d2014-07-09 16:31:49 +00001896{ 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." },
1897{ 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." },
1898{ LLDB_OPT_SET_1, false, "pass", 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Whether or not the signal should be passed to the process." },
1899{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL }
Caroline Tice35731352010-10-13 20:44:39 +00001900};
1901
1902//-------------------------------------------------------------------------
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001903// CommandObjectMultiwordProcess
1904//-------------------------------------------------------------------------
1905
Greg Clayton66111032010-06-23 01:19:29 +00001906CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter &interpreter) :
Greg Claytona7015092010-09-18 01:14:36 +00001907 CommandObjectMultiword (interpreter,
1908 "process",
1909 "A set of commands for operating on a process.",
1910 "process <subcommand> [<subcommand-options>]")
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001911{
Greg Clayton197bacf2011-07-02 21:07:54 +00001912 LoadSubCommand ("attach", CommandObjectSP (new CommandObjectProcessAttach (interpreter)));
1913 LoadSubCommand ("launch", CommandObjectSP (new CommandObjectProcessLaunch (interpreter)));
1914 LoadSubCommand ("continue", CommandObjectSP (new CommandObjectProcessContinue (interpreter)));
1915 LoadSubCommand ("connect", CommandObjectSP (new CommandObjectProcessConnect (interpreter)));
1916 LoadSubCommand ("detach", CommandObjectSP (new CommandObjectProcessDetach (interpreter)));
1917 LoadSubCommand ("load", CommandObjectSP (new CommandObjectProcessLoad (interpreter)));
1918 LoadSubCommand ("unload", CommandObjectSP (new CommandObjectProcessUnload (interpreter)));
1919 LoadSubCommand ("signal", CommandObjectSP (new CommandObjectProcessSignal (interpreter)));
1920 LoadSubCommand ("handle", CommandObjectSP (new CommandObjectProcessHandle (interpreter)));
1921 LoadSubCommand ("status", CommandObjectSP (new CommandObjectProcessStatus (interpreter)));
Greg Claytona7015092010-09-18 01:14:36 +00001922 LoadSubCommand ("interrupt", CommandObjectSP (new CommandObjectProcessInterrupt (interpreter)));
Greg Clayton197bacf2011-07-02 21:07:54 +00001923 LoadSubCommand ("kill", CommandObjectSP (new CommandObjectProcessKill (interpreter)));
Greg Clayton998255b2012-10-13 02:07:45 +00001924 LoadSubCommand ("plugin", CommandObjectSP (new CommandObjectProcessPlugin (interpreter)));
Greg Claytona2715cf2014-06-13 00:54:12 +00001925 LoadSubCommand ("save-core", CommandObjectSP (new CommandObjectProcessSaveCore (interpreter)));
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001926}
1927
1928CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess ()
1929{
1930}
1931