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