1 //===-- fooplugin.cpp -------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 An example plugin for LLDB that provides a new foo command with a child
13 Compile this into a dylib foo.dylib and load by placing in appropriate locations
15 by typing plugin load foo.dylib at the LLDB command line
18 #include <LLDB/SBCommandInterpreter.h>
19 #include <LLDB/SBCommandReturnObject.h>
20 #include <LLDB/SBDebugger.h>
23 bool PluginInitialize(lldb::SBDebugger debugger);
26 class ChildCommand : public lldb::SBCommandPluginInterface {
28 virtual bool DoExecute(lldb::SBDebugger debugger, char **command,
29 lldb::SBCommandReturnObject &result) {
31 const char *arg = *command;
33 result.Printf("%s\n", arg);
42 bool lldb::PluginInitialize(lldb::SBDebugger debugger) {
43 lldb::SBCommandInterpreter interpreter = debugger.GetCommandInterpreter();
44 lldb::SBCommand foo = interpreter.AddMultiwordCommand("foo", NULL);
45 foo.AddCommand("child", new ChildCommand(), "a child of foo");