1 //===-- CommandObjectPlatform.cpp -------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/lldb-python.h"
12 #include "CommandObjectPlatform.h"
16 // Other libraries and framework includes
18 #include "lldb/Core/DataExtractor.h"
19 #include "lldb/Core/Debugger.h"
20 #include "lldb/Core/Module.h"
21 #include "lldb/Core/PluginManager.h"
22 #include "lldb/Interpreter/Args.h"
23 #include "lldb/Interpreter/CommandInterpreter.h"
24 #include "lldb/Interpreter/CommandReturnObject.h"
25 #include "lldb/Interpreter/OptionGroupPlatform.h"
26 #include "lldb/Target/ExecutionContext.h"
27 #include "lldb/Target/Platform.h"
28 #include "lldb/Target/Process.h"
31 using namespace lldb_private;
34 //----------------------------------------------------------------------
35 // "platform select <platform-name>"
36 //----------------------------------------------------------------------
37 class CommandObjectPlatformSelect : public CommandObjectParsed
40 CommandObjectPlatformSelect (CommandInterpreter &interpreter) :
41 CommandObjectParsed (interpreter,
43 "Create a platform if needed and select it as the current platform.",
44 "platform select <platform-name>",
46 m_option_group (interpreter),
47 m_platform_options (false) // Don't include the "--platform" option by passing false
49 m_option_group.Append (&m_platform_options, LLDB_OPT_SET_ALL, 1);
50 m_option_group.Finalize();
54 ~CommandObjectPlatformSelect ()
59 HandleCompletion (Args &input,
61 int &cursor_char_position,
62 int match_start_point,
63 int max_return_elements,
67 std::string completion_str (input.GetArgumentAtIndex(cursor_index));
68 completion_str.erase (cursor_char_position);
70 CommandCompletions::PlatformPluginNames (m_interpreter,
71 completion_str.c_str(),
77 return matches.GetSize();
83 return &m_option_group;
88 DoExecute (Args& args, CommandReturnObject &result)
90 if (args.GetArgumentCount() == 1)
92 const char *platform_name = args.GetArgumentAtIndex (0);
93 if (platform_name && platform_name[0])
95 const bool select = true;
96 m_platform_options.SetPlatformName (platform_name);
98 ArchSpec platform_arch;
99 PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter, ArchSpec(), select, error, platform_arch));
102 platform_sp->GetStatus (result.GetOutputStream());
103 result.SetStatus (eReturnStatusSuccessFinishResult);
107 result.AppendError(error.AsCString());
108 result.SetStatus (eReturnStatusFailed);
113 result.AppendError ("invalid platform name");
114 result.SetStatus (eReturnStatusFailed);
119 result.AppendError ("platform create takes a platform name as an argument\n");
120 result.SetStatus (eReturnStatusFailed);
122 return result.Succeeded();
125 OptionGroupOptions m_option_group;
126 OptionGroupPlatform m_platform_options;
129 //----------------------------------------------------------------------
131 //----------------------------------------------------------------------
132 class CommandObjectPlatformList : public CommandObjectParsed
135 CommandObjectPlatformList (CommandInterpreter &interpreter) :
136 CommandObjectParsed (interpreter,
138 "List all platforms that are available.",
145 ~CommandObjectPlatformList ()
151 DoExecute (Args& args, CommandReturnObject &result)
153 Stream &ostrm = result.GetOutputStream();
154 ostrm.Printf("Available platforms:\n");
156 PlatformSP host_platform_sp (Platform::GetDefaultPlatform());
157 ostrm.Printf ("%s: %s\n",
158 host_platform_sp->GetPluginName().GetCString(),
159 host_platform_sp->GetDescription());
162 for (idx = 0; 1; ++idx)
164 const char *plugin_name = PluginManager::GetPlatformPluginNameAtIndex (idx);
165 if (plugin_name == NULL)
167 const char *plugin_desc = PluginManager::GetPlatformPluginDescriptionAtIndex (idx);
168 if (plugin_desc == NULL)
170 ostrm.Printf("%s: %s\n", plugin_name, plugin_desc);
175 result.AppendError ("no platforms are available\n");
176 result.SetStatus (eReturnStatusFailed);
179 result.SetStatus (eReturnStatusSuccessFinishResult);
180 return result.Succeeded();
184 //----------------------------------------------------------------------
186 //----------------------------------------------------------------------
187 class CommandObjectPlatformStatus : public CommandObjectParsed
190 CommandObjectPlatformStatus (CommandInterpreter &interpreter) :
191 CommandObjectParsed (interpreter,
193 "Display status for the currently selected platform.",
200 ~CommandObjectPlatformStatus ()
206 DoExecute (Args& args, CommandReturnObject &result)
208 Stream &ostrm = result.GetOutputStream();
210 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
211 PlatformSP platform_sp;
214 platform_sp = target->GetPlatform();
218 platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
222 platform_sp->GetStatus (ostrm);
223 result.SetStatus (eReturnStatusSuccessFinishResult);
227 result.AppendError ("no platform us currently selected\n");
228 result.SetStatus (eReturnStatusFailed);
230 return result.Succeeded();
234 //----------------------------------------------------------------------
235 // "platform connect <connect-url>"
236 //----------------------------------------------------------------------
237 class CommandObjectPlatformConnect : public CommandObjectParsed
240 CommandObjectPlatformConnect (CommandInterpreter &interpreter) :
241 CommandObjectParsed (interpreter,
243 "Connect a platform by name to be the currently selected platform.",
244 "platform connect <connect-url>",
250 ~CommandObjectPlatformConnect ()
256 DoExecute (Args& args, CommandReturnObject &result)
258 Stream &ostrm = result.GetOutputStream();
260 PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
263 Error error (platform_sp->ConnectRemote (args));
266 platform_sp->GetStatus (ostrm);
267 result.SetStatus (eReturnStatusSuccessFinishResult);
271 result.AppendErrorWithFormat ("%s\n", error.AsCString());
272 result.SetStatus (eReturnStatusFailed);
277 result.AppendError ("no platform us currently selected\n");
278 result.SetStatus (eReturnStatusFailed);
280 return result.Succeeded();
284 //----------------------------------------------------------------------
285 // "platform disconnect"
286 //----------------------------------------------------------------------
287 class CommandObjectPlatformDisconnect : public CommandObjectParsed
290 CommandObjectPlatformDisconnect (CommandInterpreter &interpreter) :
291 CommandObjectParsed (interpreter,
292 "platform disconnect",
293 "Disconnect a platform by name to be the currently selected platform.",
294 "platform disconnect",
300 ~CommandObjectPlatformDisconnect ()
306 DoExecute (Args& args, CommandReturnObject &result)
308 PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
311 if (args.GetArgumentCount() == 0)
315 if (platform_sp->IsConnected())
317 // Cache the instance name if there is one since we are
318 // about to disconnect and the name might go with it.
319 const char *hostname_cstr = platform_sp->GetHostname();
320 std::string hostname;
322 hostname.assign (hostname_cstr);
324 error = platform_sp->DisconnectRemote ();
327 Stream &ostrm = result.GetOutputStream();
328 if (hostname.empty())
329 ostrm.Printf ("Disconnected from \"%s\"\n", platform_sp->GetPluginName().GetCString());
331 ostrm.Printf ("Disconnected from \"%s\"\n", hostname.c_str());
332 result.SetStatus (eReturnStatusSuccessFinishResult);
336 result.AppendErrorWithFormat ("%s", error.AsCString());
337 result.SetStatus (eReturnStatusFailed);
343 result.AppendErrorWithFormat ("not connected to '%s'", platform_sp->GetPluginName().GetCString());
344 result.SetStatus (eReturnStatusFailed);
350 result.AppendError ("\"platform disconnect\" doesn't take any arguments");
351 result.SetStatus (eReturnStatusFailed);
356 result.AppendError ("no platform is currently selected");
357 result.SetStatus (eReturnStatusFailed);
359 return result.Succeeded();
362 //----------------------------------------------------------------------
363 // "platform process launch"
364 //----------------------------------------------------------------------
365 class CommandObjectPlatformProcessLaunch : public CommandObjectParsed
368 CommandObjectPlatformProcessLaunch (CommandInterpreter &interpreter) :
369 CommandObjectParsed (interpreter,
370 "platform process launch",
371 "Launch a new process on a remote platform.",
372 "platform process launch program",
373 eFlagRequiresTarget | eFlagTryTargetAPILock),
374 m_options (interpreter)
379 ~CommandObjectPlatformProcessLaunch ()
391 DoExecute (Args& args, CommandReturnObject &result)
393 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
394 PlatformSP platform_sp;
397 platform_sp = target->GetPlatform();
401 platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
407 const size_t argc = args.GetArgumentCount();
408 Target *target = m_exe_ctx.GetTargetPtr();
409 Module *exe_module = target->GetExecutableModulePointer();
412 m_options.launch_info.GetExecutableFile () = exe_module->GetFileSpec();
413 char exe_path[PATH_MAX];
414 if (m_options.launch_info.GetExecutableFile ().GetPath (exe_path, sizeof(exe_path)))
415 m_options.launch_info.GetArguments().AppendArgument (exe_path);
416 m_options.launch_info.GetArchitecture() = exe_module->GetArchitecture();
421 if (m_options.launch_info.GetExecutableFile ())
423 // We already have an executable file, so we will use this
424 // and all arguments to this function are extra arguments
425 m_options.launch_info.GetArguments().AppendArguments (args);
429 // We don't have any file yet, so the first argument is our
430 // executable, and the rest are program arguments
431 const bool first_arg_is_executable = true;
432 m_options.launch_info.SetArguments (args, first_arg_is_executable);
436 if (m_options.launch_info.GetExecutableFile ())
438 Debugger &debugger = m_interpreter.GetDebugger();
441 target->GetRunArguments(m_options.launch_info.GetArguments());
443 ProcessSP process_sp (platform_sp->DebugProcess (m_options.launch_info,
446 debugger.GetListener(),
448 if (process_sp && process_sp->IsAlive())
450 result.SetStatus (eReturnStatusSuccessFinishNoResult);
455 result.AppendError ("process launch failed");
457 result.AppendError (error.AsCString());
458 result.SetStatus (eReturnStatusFailed);
462 result.AppendError ("'platform process launch' uses the current target file and arguments, or the executable and its arguments can be specified in this command");
463 result.SetStatus (eReturnStatusFailed);
469 result.AppendError ("no platform is selected\n");
471 return result.Succeeded();
475 ProcessLaunchCommandOptions m_options;
480 //----------------------------------------------------------------------
481 // "platform process list"
482 //----------------------------------------------------------------------
483 class CommandObjectPlatformProcessList : public CommandObjectParsed
486 CommandObjectPlatformProcessList (CommandInterpreter &interpreter) :
487 CommandObjectParsed (interpreter,
488 "platform process list",
489 "List processes on a remote platform by name, pid, or many other matching attributes.",
490 "platform process list",
492 m_options (interpreter)
497 ~CommandObjectPlatformProcessList ()
509 DoExecute (Args& args, CommandReturnObject &result)
511 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
512 PlatformSP platform_sp;
515 platform_sp = target->GetPlatform();
519 platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
525 if (args.GetArgumentCount() == 0)
530 Stream &ostrm = result.GetOutputStream();
532 lldb::pid_t pid = m_options.match_info.GetProcessInfo().GetProcessID();
533 if (pid != LLDB_INVALID_PROCESS_ID)
535 ProcessInstanceInfo proc_info;
536 if (platform_sp->GetProcessInfo (pid, proc_info))
538 ProcessInstanceInfo::DumpTableHeader (ostrm, platform_sp.get(), m_options.show_args, m_options.verbose);
539 proc_info.DumpAsTableRow(ostrm, platform_sp.get(), m_options.show_args, m_options.verbose);
540 result.SetStatus (eReturnStatusSuccessFinishResult);
544 result.AppendErrorWithFormat ("no process found with pid = %" PRIu64 "\n", pid);
545 result.SetStatus (eReturnStatusFailed);
550 ProcessInstanceInfoList proc_infos;
551 const uint32_t matches = platform_sp->FindProcesses (m_options.match_info, proc_infos);
552 const char *match_desc = NULL;
553 const char *match_name = m_options.match_info.GetProcessInfo().GetName();
554 if (match_name && match_name[0])
556 switch (m_options.match_info.GetNameMatchType())
558 case eNameMatchIgnore: break;
559 case eNameMatchEquals: match_desc = "matched"; break;
560 case eNameMatchContains: match_desc = "contained"; break;
561 case eNameMatchStartsWith: match_desc = "started with"; break;
562 case eNameMatchEndsWith: match_desc = "ended with"; break;
563 case eNameMatchRegularExpression: match_desc = "matched the regular expression"; break;
570 result.AppendErrorWithFormat ("no processes were found that %s \"%s\" on the \"%s\" platform\n",
573 platform_sp->GetPluginName().GetCString());
575 result.AppendErrorWithFormat ("no processes were found on the \"%s\" platform\n", platform_sp->GetPluginName().GetCString());
576 result.SetStatus (eReturnStatusFailed);
580 result.AppendMessageWithFormat ("%u matching process%s found on \"%s\"",
582 matches > 1 ? "es were" : " was",
583 platform_sp->GetName().GetCString());
585 result.AppendMessageWithFormat (" whose name %s \"%s\"",
588 result.AppendMessageWithFormat ("\n");
589 ProcessInstanceInfo::DumpTableHeader (ostrm, platform_sp.get(), m_options.show_args, m_options.verbose);
590 for (uint32_t i=0; i<matches; ++i)
592 proc_infos.GetProcessInfoAtIndex(i).DumpAsTableRow(ostrm, platform_sp.get(), m_options.show_args, m_options.verbose);
600 result.AppendError ("invalid args: process list takes only options\n");
601 result.SetStatus (eReturnStatusFailed);
606 result.AppendError ("no platform is selected\n");
607 result.SetStatus (eReturnStatusFailed);
609 return result.Succeeded();
612 class CommandOptions : public Options
616 CommandOptions (CommandInterpreter &interpreter) :
617 Options (interpreter),
628 SetOptionValue (uint32_t option_idx, const char *option_arg)
631 const int short_option = m_getopt_table[option_idx].val;
632 bool success = false;
634 switch (short_option)
637 match_info.GetProcessInfo().SetProcessID (Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success));
639 error.SetErrorStringWithFormat("invalid process ID string: '%s'", option_arg);
643 match_info.GetProcessInfo().SetParentProcessID (Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success));
645 error.SetErrorStringWithFormat("invalid parent process ID string: '%s'", option_arg);
649 match_info.GetProcessInfo().SetUserID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success));
651 error.SetErrorStringWithFormat("invalid user ID string: '%s'", option_arg);
655 match_info.GetProcessInfo().SetEffectiveUserID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success));
657 error.SetErrorStringWithFormat("invalid effective user ID string: '%s'", option_arg);
661 match_info.GetProcessInfo().SetGroupID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success));
663 error.SetErrorStringWithFormat("invalid group ID string: '%s'", option_arg);
667 match_info.GetProcessInfo().SetEffectiveGroupID (Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success));
669 error.SetErrorStringWithFormat("invalid effective group ID string: '%s'", option_arg);
673 match_info.GetProcessInfo().GetArchitecture().SetTriple (option_arg, m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform().get());
677 match_info.GetProcessInfo().GetExecutableFile().SetFile (option_arg, false);
678 match_info.SetNameMatchType (eNameMatchEquals);
682 match_info.GetProcessInfo().GetExecutableFile().SetFile (option_arg, false);
683 match_info.SetNameMatchType (eNameMatchEndsWith);
687 match_info.GetProcessInfo().GetExecutableFile().SetFile (option_arg, false);
688 match_info.SetNameMatchType (eNameMatchStartsWith);
692 match_info.GetProcessInfo().GetExecutableFile().SetFile (option_arg, false);
693 match_info.SetNameMatchType (eNameMatchContains);
697 match_info.GetProcessInfo().GetExecutableFile().SetFile (option_arg, false);
698 match_info.SetNameMatchType (eNameMatchRegularExpression);
710 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
718 OptionParsingStarting ()
725 const OptionDefinition*
728 return g_option_table;
731 // Options table: Required for subclasses of Options.
733 static OptionDefinition g_option_table[];
735 // Instance variables to hold the values for command options.
737 ProcessInstanceInfoMatch match_info;
741 CommandOptions m_options;
745 CommandObjectPlatformProcessList::CommandOptions::g_option_table[] =
747 { LLDB_OPT_SET_1 , false, "pid" , 'p', required_argument, NULL, 0, eArgTypePid , "List the process info for a specific process ID." },
748 { LLDB_OPT_SET_2 , true , "name" , 'n', required_argument, NULL, 0, eArgTypeProcessName , "Find processes with executable basenames that match a string." },
749 { LLDB_OPT_SET_3 , true , "ends-with" , 'e', required_argument, NULL, 0, eArgTypeProcessName , "Find processes with executable basenames that end with a string." },
750 { LLDB_OPT_SET_4 , true , "starts-with", 's', required_argument, NULL, 0, eArgTypeProcessName , "Find processes with executable basenames that start with a string." },
751 { LLDB_OPT_SET_5 , true , "contains" , 'c', required_argument, NULL, 0, eArgTypeProcessName , "Find processes with executable basenames that contain a string." },
752 { LLDB_OPT_SET_6 , true , "regex" , 'r', required_argument, NULL, 0, eArgTypeRegularExpression, "Find processes with executable basenames that match a regular expression." },
753 { LLDB_OPT_SET_FROM_TO(2, 6), false, "parent" , 'P', required_argument, NULL, 0, eArgTypePid , "Find processes that have a matching parent process ID." },
754 { LLDB_OPT_SET_FROM_TO(2, 6), false, "uid" , 'u', required_argument, NULL, 0, eArgTypeUnsignedInteger , "Find processes that have a matching user ID." },
755 { LLDB_OPT_SET_FROM_TO(2, 6), false, "euid" , 'U', required_argument, NULL, 0, eArgTypeUnsignedInteger , "Find processes that have a matching effective user ID." },
756 { LLDB_OPT_SET_FROM_TO(2, 6), false, "gid" , 'g', required_argument, NULL, 0, eArgTypeUnsignedInteger , "Find processes that have a matching group ID." },
757 { LLDB_OPT_SET_FROM_TO(2, 6), false, "egid" , 'G', required_argument, NULL, 0, eArgTypeUnsignedInteger , "Find processes that have a matching effective group ID." },
758 { LLDB_OPT_SET_FROM_TO(2, 6), false, "arch" , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Find processes that have a matching architecture." },
759 { LLDB_OPT_SET_FROM_TO(1, 6), false, "show-args" , 'A', no_argument , NULL, 0, eArgTypeNone , "Show process arguments instead of the process executable basename." },
760 { LLDB_OPT_SET_FROM_TO(1, 6), false, "verbose" , 'v', no_argument , NULL, 0, eArgTypeNone , "Enable verbose output." },
761 { 0 , false, NULL , 0 , 0 , NULL, 0, eArgTypeNone , NULL }
764 //----------------------------------------------------------------------
765 // "platform process info"
766 //----------------------------------------------------------------------
767 class CommandObjectPlatformProcessInfo : public CommandObjectParsed
770 CommandObjectPlatformProcessInfo (CommandInterpreter &interpreter) :
771 CommandObjectParsed (interpreter,
772 "platform process info",
773 "Get detailed information for one or more process by process ID.",
774 "platform process info <pid> [<pid> <pid> ...]",
777 CommandArgumentEntry arg;
778 CommandArgumentData pid_args;
780 // Define the first (and only) variant of this arg.
781 pid_args.arg_type = eArgTypePid;
782 pid_args.arg_repetition = eArgRepeatStar;
784 // There is only one variant this argument could be; put it into the argument entry.
785 arg.push_back (pid_args);
787 // Push the data for the first argument into the m_arguments vector.
788 m_arguments.push_back (arg);
792 ~CommandObjectPlatformProcessInfo ()
798 DoExecute (Args& args, CommandReturnObject &result)
800 Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
801 PlatformSP platform_sp;
804 platform_sp = target->GetPlatform();
808 platform_sp = m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
813 const size_t argc = args.GetArgumentCount();
818 if (platform_sp->IsConnected())
820 Stream &ostrm = result.GetOutputStream();
822 for (size_t i=0; i<argc; ++ i)
824 const char *arg = args.GetArgumentAtIndex(i);
825 lldb::pid_t pid = Args::StringToUInt32 (arg, LLDB_INVALID_PROCESS_ID, 0, &success);
828 ProcessInstanceInfo proc_info;
829 if (platform_sp->GetProcessInfo (pid, proc_info))
831 ostrm.Printf ("Process information for process %" PRIu64 ":\n", pid);
832 proc_info.Dump (ostrm, platform_sp.get());
836 ostrm.Printf ("error: no process information is available for process %" PRIu64 "\n", pid);
842 result.AppendErrorWithFormat ("invalid process ID argument '%s'", arg);
843 result.SetStatus (eReturnStatusFailed);
851 result.AppendErrorWithFormat ("not connected to '%s'", platform_sp->GetPluginName().GetCString());
852 result.SetStatus (eReturnStatusFailed);
858 result.AppendError ("one or more process id(s) must be specified");
859 result.SetStatus (eReturnStatusFailed);
864 result.AppendError ("no platform is currently selected");
865 result.SetStatus (eReturnStatusFailed);
867 return result.Succeeded();
874 class CommandObjectPlatformProcess : public CommandObjectMultiword
877 //------------------------------------------------------------------
878 // Constructors and Destructors
879 //------------------------------------------------------------------
880 CommandObjectPlatformProcess (CommandInterpreter &interpreter) :
881 CommandObjectMultiword (interpreter,
883 "A set of commands to query, launch and attach to platform processes",
884 "platform process [attach|launch|list] ...")
886 // LoadSubCommand ("attach", CommandObjectSP (new CommandObjectPlatformProcessAttach (interpreter)));
887 LoadSubCommand ("launch", CommandObjectSP (new CommandObjectPlatformProcessLaunch (interpreter)));
888 LoadSubCommand ("info" , CommandObjectSP (new CommandObjectPlatformProcessInfo (interpreter)));
889 LoadSubCommand ("list" , CommandObjectSP (new CommandObjectPlatformProcessList (interpreter)));
894 ~CommandObjectPlatformProcess ()
899 //------------------------------------------------------------------
900 // For CommandObjectPlatform only
901 //------------------------------------------------------------------
902 DISALLOW_COPY_AND_ASSIGN (CommandObjectPlatformProcess);
906 class CommandObjectPlatformShell : public CommandObjectRaw
909 CommandObjectPlatformShell (CommandInterpreter &interpreter) :
910 CommandObjectRaw (interpreter,
912 "Run a shell command on a the selected platform.",
913 "platform shell <shell-command>",
919 ~CommandObjectPlatformShell ()
925 DoExecute (const char *raw_command_line, CommandReturnObject &result)
927 // TODO: Implement "Platform::RunShellCommand()" and switch over to using
928 // the current platform when it is in the interface.
929 const char *working_dir = NULL;
933 Error error (Host::RunShellCommand (raw_command_line, working_dir, &status, &signo, &output, 10));
935 result.GetOutputStream().PutCString(output.c_str());
940 const char *signo_cstr = Host::GetSignalAsCString(signo);
942 result.GetOutputStream().Printf("error: command returned with status %i and signal %s\n", status, signo_cstr);
944 result.GetOutputStream().Printf("error: command returned with status %i and signal %i\n", status, signo);
947 result.GetOutputStream().Printf("error: command returned with status %i\n", status);
952 result.AppendError(error.AsCString());
953 result.SetStatus (eReturnStatusFailed);
957 result.SetStatus (eReturnStatusSuccessFinishResult);
963 //----------------------------------------------------------------------
964 // CommandObjectPlatform constructor
965 //----------------------------------------------------------------------
966 CommandObjectPlatform::CommandObjectPlatform(CommandInterpreter &interpreter) :
967 CommandObjectMultiword (interpreter,
969 "A set of commands to manage and create platforms.",
970 "platform [connect|disconnect|info|list|status|select] ...")
972 LoadSubCommand ("select", CommandObjectSP (new CommandObjectPlatformSelect (interpreter)));
973 LoadSubCommand ("list" , CommandObjectSP (new CommandObjectPlatformList (interpreter)));
974 LoadSubCommand ("status", CommandObjectSP (new CommandObjectPlatformStatus (interpreter)));
975 LoadSubCommand ("connect", CommandObjectSP (new CommandObjectPlatformConnect (interpreter)));
976 LoadSubCommand ("disconnect", CommandObjectSP (new CommandObjectPlatformDisconnect (interpreter)));
977 LoadSubCommand ("process", CommandObjectSP (new CommandObjectPlatformProcess (interpreter)));
978 LoadSubCommand ("shell", CommandObjectSP (new CommandObjectPlatformShell (interpreter)));
982 //----------------------------------------------------------------------
984 //----------------------------------------------------------------------
985 CommandObjectPlatform::~CommandObjectPlatform()