fooplugin.cpp revision 6d101887bb427b3c879c0c06775ab4dcb1cd265b
1/* 2An example plugin for LLDB that provides a new foo command with a child subcommand 3Compile this into a dylib foo.dylib and load by placing in appropriate locations on disk or 4by typing plugin load foo.dylib at the LLDB command line 5*/ 6 7#include <LLDB/SBCommandInterpreter.h> 8#include <LLDB/SBCommandReturnObject.h> 9#include <LLDB/SBDebugger.h> 10 11namespace lldb { 12 bool 13 PluginInitialize (lldb::SBDebugger debugger); 14} 15 16class ChildCommand : public lldb::SBCommandPluginInterface 17{ 18public: 19 virtual bool 20 DoExecute (lldb::SBDebugger debugger, 21 char** command, 22 lldb::SBCommandReturnObject &result) 23 { 24 if (command) 25 { 26 const char* arg = *command; 27 while (arg) 28 { 29 printf("%s\n",arg); 30 arg = *(++command); 31 } 32 return true; 33 } 34 return false; 35 } 36 37}; 38 39bool 40lldb::PluginInitialize (lldb::SBDebugger debugger) 41{ 42 lldb::SBCommandInterpreter interpreter = debugger.GetCommandInterpreter(); 43 lldb::SBCommand foo = interpreter.AddMultiwordCommand("foo",NULL); 44 foo.AddCommand("child",new ChildCommand(),"a child of foo"); 45 return true; 46} 47 48