1 //===-- fooplugin.cpp -------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 An example plugin for LLDB that provides a new foo command with a child
12 Compile this into a dylib foo.dylib and load by placing in appropriate locations
14 by typing plugin load foo.dylib at the LLDB command line
17 #include <LLDB/SBCommandInterpreter.h>
18 #include <LLDB/SBCommandReturnObject.h>
19 #include <LLDB/SBDebugger.h>
22 bool PluginInitialize(lldb::SBDebugger debugger
);
25 class ChildCommand
: public lldb::SBCommandPluginInterface
{
27 virtual bool DoExecute(lldb::SBDebugger debugger
, char **command
,
28 lldb::SBCommandReturnObject
&result
) {
30 const char *arg
= *command
;
32 result
.Printf("%s\n", arg
);
41 bool lldb::PluginInitialize(lldb::SBDebugger debugger
) {
42 lldb::SBCommandInterpreter interpreter
= debugger
.GetCommandInterpreter();
43 lldb::SBCommand foo
= interpreter
.AddMultiwordCommand("foo", NULL
);
44 foo
.AddCommand("child", new ChildCommand(), "a child of foo");