diff options
Diffstat (limited to 'lldb/source/Commands/CommandObjectPlatform.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectPlatform.cpp | 231 |
1 files changed, 112 insertions, 119 deletions
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp index 7d99e71..7487f8a 100644 --- a/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/lldb/source/Commands/CommandObjectPlatform.cpp @@ -31,15 +31,15 @@ using namespace lldb_private; //---------------------------------------------------------------------- // "platform select <platform-name>" //---------------------------------------------------------------------- -class CommandObjectPlatformSelect : public CommandObject +class CommandObjectPlatformSelect : public CommandObjectParsed { public: CommandObjectPlatformSelect (CommandInterpreter &interpreter) : - CommandObject (interpreter, - "platform select", - "Create a platform if needed and select it as the current platform.", - "platform select <platform-name>", - 0), + CommandObjectParsed (interpreter, + "platform select", + "Create a platform if needed and select it as the current platform.", + "platform select <platform-name>", + 0), m_option_group (interpreter), m_platform_options (false) // Don't include the "--platform" option by passing false { @@ -52,8 +52,37 @@ public: { } + virtual int + HandleCompletion (Args &input, + int &cursor_index, + int &cursor_char_position, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) + { + std::string completion_str (input.GetArgumentAtIndex(cursor_index)); + completion_str.erase (cursor_char_position); + + CommandCompletions::PlatformPluginNames (m_interpreter, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + word_complete, + matches); + return matches.GetSize(); + } + + virtual Options * + GetOptions () + { + return &m_option_group; + } + +protected: virtual bool - Execute (Args& args, CommandReturnObject &result) + DoExecute (Args& args, CommandReturnObject &result) { if (args.GetArgumentCount() == 1) { @@ -89,37 +118,7 @@ public: } return result.Succeeded(); } - - - virtual int - HandleCompletion (Args &input, - int &cursor_index, - int &cursor_char_position, - int match_start_point, - int max_return_elements, - bool &word_complete, - StringList &matches) - { - std::string completion_str (input.GetArgumentAtIndex(cursor_index)); - completion_str.erase (cursor_char_position); - - CommandCompletions::PlatformPluginNames (m_interpreter, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); - return matches.GetSize(); - } - virtual Options * - GetOptions () - { - return &m_option_group; - } - -protected: OptionGroupOptions m_option_group; OptionGroupPlatform m_platform_options; }; @@ -127,15 +126,15 @@ protected: //---------------------------------------------------------------------- // "platform list" //---------------------------------------------------------------------- -class CommandObjectPlatformList : public CommandObject +class CommandObjectPlatformList : public CommandObjectParsed { public: CommandObjectPlatformList (CommandInterpreter &interpreter) : - CommandObject (interpreter, - "platform list", - "List all platforms that are available.", - NULL, - 0) + CommandObjectParsed (interpreter, + "platform list", + "List all platforms that are available.", + NULL, + 0) { } @@ -144,8 +143,9 @@ public: { } +protected: virtual bool - Execute (Args& args, CommandReturnObject &result) + DoExecute (Args& args, CommandReturnObject &result) { Stream &ostrm = result.GetOutputStream(); ostrm.Printf("Available platforms:\n"); @@ -181,15 +181,15 @@ public: //---------------------------------------------------------------------- // "platform status" //---------------------------------------------------------------------- -class CommandObjectPlatformStatus : public CommandObject +class CommandObjectPlatformStatus : public CommandObjectParsed { public: CommandObjectPlatformStatus (CommandInterpreter &interpreter) : - CommandObject (interpreter, - "platform status", - "Display status for the currently selected platform.", - NULL, - 0) + CommandObjectParsed (interpreter, + "platform status", + "Display status for the currently selected platform.", + NULL, + 0) { } @@ -198,8 +198,9 @@ public: { } +protected: virtual bool - Execute (Args& args, CommandReturnObject &result) + DoExecute (Args& args, CommandReturnObject &result) { Stream &ostrm = result.GetOutputStream(); @@ -221,15 +222,15 @@ public: //---------------------------------------------------------------------- // "platform connect <connect-url>" //---------------------------------------------------------------------- -class CommandObjectPlatformConnect : public CommandObject +class CommandObjectPlatformConnect : public CommandObjectParsed { public: CommandObjectPlatformConnect (CommandInterpreter &interpreter) : - CommandObject (interpreter, - "platform connect", - "Connect a platform by name to be the currently selected platform.", - "platform connect <connect-url>", - 0) + CommandObjectParsed (interpreter, + "platform connect", + "Connect a platform by name to be the currently selected platform.", + "platform connect <connect-url>", + 0) { } @@ -238,8 +239,9 @@ public: { } +protected: virtual bool - Execute (Args& args, CommandReturnObject &result) + DoExecute (Args& args, CommandReturnObject &result) { Stream &ostrm = result.GetOutputStream(); @@ -270,15 +272,15 @@ public: //---------------------------------------------------------------------- // "platform disconnect" //---------------------------------------------------------------------- -class CommandObjectPlatformDisconnect : public CommandObject +class CommandObjectPlatformDisconnect : public CommandObjectParsed { public: CommandObjectPlatformDisconnect (CommandInterpreter &interpreter) : - CommandObject (interpreter, - "platform disconnect", - "Disconnect a platform by name to be the currently selected platform.", - "platform disconnect", - 0) + CommandObjectParsed (interpreter, + "platform disconnect", + "Disconnect a platform by name to be the currently selected platform.", + "platform disconnect", + 0) { } @@ -287,8 +289,9 @@ public: { } +protected: virtual bool - Execute (Args& args, CommandReturnObject &result) + DoExecute (Args& args, CommandReturnObject &result) { PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) @@ -347,15 +350,15 @@ public: //---------------------------------------------------------------------- // "platform process launch" //---------------------------------------------------------------------- -class CommandObjectPlatformProcessLaunch : public CommandObject +class CommandObjectPlatformProcessLaunch : public CommandObjectParsed { public: CommandObjectPlatformProcessLaunch (CommandInterpreter &interpreter) : - CommandObject (interpreter, - "platform process launch", - "Launch a new process on a remote platform.", - "platform process launch program", - 0), + CommandObjectParsed (interpreter, + "platform process launch", + "Launch a new process on a remote platform.", + "platform process launch program", + 0), m_options (interpreter) { } @@ -365,8 +368,15 @@ public: { } + virtual Options * + GetOptions () + { + return &m_options; + } + +protected: virtual bool - Execute (Args& args, CommandReturnObject &result) + DoExecute (Args& args, CommandReturnObject &result) { PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); @@ -453,12 +463,6 @@ public: return result.Succeeded(); } - virtual Options * - GetOptions () - { - return &m_options; - } - protected: ProcessLaunchCommandOptions m_options; }; @@ -468,15 +472,15 @@ protected: //---------------------------------------------------------------------- // "platform process list" //---------------------------------------------------------------------- -class CommandObjectPlatformProcessList : public CommandObject +class CommandObjectPlatformProcessList : public CommandObjectParsed { public: CommandObjectPlatformProcessList (CommandInterpreter &interpreter) : - CommandObject (interpreter, - "platform process list", - "List processes on a remote platform by name, pid, or many other matching attributes.", - "platform process list", - 0), + CommandObjectParsed (interpreter, + "platform process list", + "List processes on a remote platform by name, pid, or many other matching attributes.", + "platform process list", + 0), m_options (interpreter) { } @@ -486,8 +490,15 @@ public: { } + virtual Options * + GetOptions () + { + return &m_options; + } + +protected: virtual bool - Execute (Args& args, CommandReturnObject &result) + DoExecute (Args& args, CommandReturnObject &result) { PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); @@ -581,14 +592,6 @@ public: return result.Succeeded(); } - virtual Options * - GetOptions () - { - return &m_options; - } - -protected: - class CommandOptions : public Options { public: @@ -744,15 +747,15 @@ CommandObjectPlatformProcessList::CommandOptions::g_option_table[] = //---------------------------------------------------------------------- // "platform process info" //---------------------------------------------------------------------- -class CommandObjectPlatformProcessInfo : public CommandObject +class CommandObjectPlatformProcessInfo : public CommandObjectParsed { public: CommandObjectPlatformProcessInfo (CommandInterpreter &interpreter) : - CommandObject (interpreter, - "platform process info", - "Get detailed information for one or more process by process ID.", - "platform process info <pid> [<pid> <pid> ...]", - 0) + CommandObjectParsed (interpreter, + "platform process info", + "Get detailed information for one or more process by process ID.", + "platform process info <pid> [<pid> <pid> ...]", + 0) { CommandArgumentEntry arg; CommandArgumentData pid_args; @@ -773,8 +776,9 @@ public: { } +protected: virtual bool - Execute (Args& args, CommandReturnObject &result) + DoExecute (Args& args, CommandReturnObject &result) { PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) @@ -872,15 +876,15 @@ private: }; -class CommandObjectPlatformShell : public CommandObject +class CommandObjectPlatformShell : public CommandObjectRaw { public: CommandObjectPlatformShell (CommandInterpreter &interpreter) : - CommandObject (interpreter, - "platform shell", - "Run a shell command on a the selected platform.", - "platform shell <shell-command>", - 0) + CommandObjectRaw (interpreter, + "platform shell", + "Run a shell command on a the selected platform.", + "platform shell <shell-command>", + 0) { } @@ -889,18 +893,9 @@ public: { } +protected: virtual bool - Execute (Args& command, - CommandReturnObject &result) - { - return false; - } - - virtual bool - WantsRawCommandString() { return true; } - - bool - ExecuteRawCommandString (const char *raw_command_line, CommandReturnObject &result) + DoExecute (const char *raw_command_line, CommandReturnObject &result) { // TODO: Implement "Platform::RunShellCommand()" and switch over to using // the current platform when it is in the interface. @@ -936,8 +931,6 @@ public: } return true; } - -protected: }; //---------------------------------------------------------------------- |