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_SB_APIs% 8 9namespace lldb { 10 bool 11 PluginInitialize (lldb::SBDebugger debugger); 12} 13 14class ChildCommand : public lldb::SBCommandPluginInterface 15{ 16public: 17 virtual bool 18 DoExecute (lldb::SBDebugger debugger, 19 char** command, 20 lldb::SBCommandReturnObject &result) 21 { 22 if (command) 23 { 24 const char* arg = *command; 25 while (arg) 26 { 27 result.Printf("%s ",arg); 28 arg = *(++command); 29 } 30 result.Printf("\n"); 31 return true; 32 } 33 return false; 34 } 35 36}; 37 38bool 39lldb::PluginInitialize (lldb::SBDebugger debugger) 40{ 41 lldb::SBCommandInterpreter interpreter = debugger.GetCommandInterpreter(); 42 lldb::SBCommand foo = interpreter.AddMultiwordCommand("plugin_loaded_command",NULL); 43 foo.AddCommand("child",new ChildCommand(),"a child of plugin_loaded_command"); 44 return true; 45} 46