diff options
| author | Greg Clayton <gclayton@apple.com> | 2012-10-13 02:07:45 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2012-10-13 02:07:45 +0000 |
| commit | 998255bfe841a4191d458a56aae0267f673b1a72 (patch) | |
| tree | ada5b24a203f1a24e041f9cce2188283d037de98 /lldb/source/Plugins/Process | |
| parent | 88db3171dd5dcc54e3890b6f823c60831fc520a5 (diff) | |
| download | bcm5719-llvm-998255bfe841a4191d458a56aae0267f673b1a72.tar.gz bcm5719-llvm-998255bfe841a4191d458a56aae0267f673b1a72.zip | |
<rdar://problem/12491387>
I added the ability for a process plug-in to implement custom commands. All the lldb_private::Process plug-in has to do is override:
virtual CommandObject *
GetPluginCommandObject();
This object returned should be a multi-word command that vends LLDB commands. There is a sample implementation in ProcessGDBRemote that is hollowed out. It is intended to be used for sending a custom packet, though the body of the command execute function has yet to be implemented!
llvm-svn: 165861
Diffstat (limited to 'lldb/source/Plugins/Process')
| -rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp | 58 | ||||
| -rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h | 5 |
2 files changed, 60 insertions, 3 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 215e885ed66..a0658ab4f5b 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -196,7 +196,8 @@ ProcessGDBRemote::ProcessGDBRemote(Target& target, Listener &listener) : m_waiting_for_attach (false), m_destroy_tried_resuming (false), m_dyld_plugin_name(), - m_kernel_load_addr (LLDB_INVALID_ADDRESS) + m_kernel_load_addr (LLDB_INVALID_ADDRESS), + m_command_sp () { m_async_broadcaster.SetEventName (eBroadcastBitAsyncThreadShouldExit, "async thread should exit"); m_async_broadcaster.SetEventName (eBroadcastBitAsyncContinue, "async thread continue"); @@ -3013,3 +3014,58 @@ ProcessGDBRemote::GetDynamicLoader () return m_dyld_ap.get(); } +#include "lldb/Interpreter/CommandObject.h" +#include "lldb/Interpreter/CommandObjectMultiword.h" + +class CommandObjectProcessGDBRemotePacket : public CommandObjectParsed +{ +private: + +public: + CommandObjectProcessGDBRemotePacket(CommandInterpreter &interpreter) : + CommandObjectParsed (interpreter, + "process plugin packet", + "Send a custom packet through the GDB remote protocol and print the answer.", + NULL) + { + } + + ~CommandObjectProcessGDBRemotePacket () + { + } + + bool + DoExecute (Args& command, CommandReturnObject &result) + { + printf ("CommandObjectProcessGDBRemotePacket::DoExecute() called!!!\n"); + return true; + } +}; + + +class CommandObjectMultiwordProcessGDBRemote : public CommandObjectMultiword +{ +public: + CommandObjectMultiwordProcessGDBRemote (CommandInterpreter &interpreter) : + CommandObjectMultiword (interpreter, + "process plugin", + "A set of commands for operating on a ProcessGDBRemote process.", + "process plugin <subcommand> [<subcommand-options>]") + { + LoadSubCommand ("packet", CommandObjectSP (new CommandObjectProcessGDBRemotePacket (interpreter))); + } + + ~CommandObjectMultiwordProcessGDBRemote () + { + } +}; + + + +CommandObject * +ProcessGDBRemote::GetPluginCommandObject() +{ + if (!m_command_sp) + m_command_sp.reset (new CommandObjectMultiwordProcessGDBRemote (GetTarget().GetDebugger().GetCommandInterpreter())); + return m_command_sp.get(); +} diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index 82f840d69ff..5c642d44597 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -71,8 +71,8 @@ public: CanDebug (lldb_private::Target &target, bool plugin_specified_by_name); -// virtual uint32_t -// ListProcessesMatchingName (const char *name, lldb_private::StringList &matches, std::vector<lldb::pid_t> &pids); + virtual lldb_private::CommandObject * + GetPluginCommandObject(); //------------------------------------------------------------------ // Creating a new process, or attaching to an existing one @@ -331,6 +331,7 @@ protected: bool m_destroy_tried_resuming; std::string m_dyld_plugin_name; lldb::addr_t m_kernel_load_addr; + lldb::CommandObjectSP m_command_sp; bool StartAsyncThread (); |

