]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/plugins/commands/plugin.cpp.template
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / plugins / commands / plugin.cpp.template
1 //===-- plugin.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 /*
11 An example plugin for LLDB that provides a new foo command with a child subcommand
12 Compile this into a dylib foo.dylib and load by placing in appropriate locations on disk or
13 by typing plugin load foo.dylib at the LLDB command line
14 */
15
16 %include_SB_APIs%
17
18 namespace lldb {
19     bool
20     PluginInitialize (lldb::SBDebugger debugger);
21 }
22
23 class ChildCommand : public lldb::SBCommandPluginInterface
24 {
25 public:
26     virtual bool
27     DoExecute (lldb::SBDebugger debugger,
28                char** command,
29                lldb::SBCommandReturnObject &result)
30     {
31         if (command)
32         {
33             const char* arg = *command;
34             while (arg)
35             {
36                 result.Printf("%s ",arg);
37                 arg = *(++command);
38             }
39             result.Printf("\n");
40             return true;
41         }
42         return false;
43     }
44     
45 };
46
47 bool
48 lldb::PluginInitialize (lldb::SBDebugger debugger)
49 {
50     lldb::SBCommandInterpreter interpreter = debugger.GetCommandInterpreter();
51     lldb::SBCommand foo = interpreter.AddMultiwordCommand("plugin_loaded_command",NULL);
52     foo.AddCommand("child",new ChildCommand(),"a child of plugin_loaded_command");
53     return true;
54 }