1 //===-- plugin.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 subcommand
11 Compile this into a dylib foo.dylib and load by placing in appropriate locations on disk or
12 by typing plugin load foo.dylib at the LLDB command line
19 PluginInitialize (lldb::SBDebugger debugger);
22 class ChildCommand : public lldb::SBCommandPluginInterface
26 DoExecute (lldb::SBDebugger debugger,
28 lldb::SBCommandReturnObject &result)
32 const char* arg = *command;
35 result.Printf("%s ",arg);
47 lldb::PluginInitialize (lldb::SBDebugger debugger)
49 lldb::SBCommandInterpreter interpreter = debugger.GetCommandInterpreter();
50 lldb::SBCommand foo = interpreter.AddMultiwordCommand("plugin_loaded_command",NULL);
51 foo.AddCommand("child",new ChildCommand(),"a child of plugin_loaded_command");