summaryrefslogtreecommitdiffstats
path: root/lldb/examples/plugins/commands/fooplugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/examples/plugins/commands/fooplugin.cpp')
-rw-r--r--lldb/examples/plugins/commands/fooplugin.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/lldb/examples/plugins/commands/fooplugin.cpp b/lldb/examples/plugins/commands/fooplugin.cpp
new file mode 100644
index 00000000000..86033bb0de8
--- /dev/null
+++ b/lldb/examples/plugins/commands/fooplugin.cpp
@@ -0,0 +1,47 @@
+/*
+An example plugin for LLDB that provides a new foo command with a child subcommand
+Compile this into a dylib foo.dylib and load by placing in appropriate locations on disk or
+by typing plugin load foo.dylib at the LLDB command line
+*/
+
+#include <LLDB/SBCommandInterpreter.h>
+#include <LLDB/SBCommandReturnObject.h>
+#include <LLDB/SBDebugger.h>
+
+namespace lldb {
+ bool
+ PluginInitialize (lldb::SBDebugger debugger);
+}
+
+class ChildCommand : public lldb::SBCommandPluginInterface
+{
+public:
+ virtual bool
+ DoExecute (lldb::SBDebugger debugger,
+ char** command,
+ lldb::SBCommandReturnObject &result)
+ {
+ if (command)
+ {
+ const char* arg = *command;
+ while (arg)
+ {
+ printf("%s\n",arg);
+ arg = *(++command);
+ }
+ return true;
+ }
+ return false;
+ }
+
+};
+
+bool
+lldb::PluginInitialize (lldb::SBDebugger debugger)
+{
+ lldb::SBCommandInterpreter interpreter = debugger.GetCommandInterpreter();
+ lldb::SBCommand foo = interpreter.AddMultiwordCommand("foo",NULL);
+ foo.AddCommand("child",new ChildCommand(),"a child of foo");
+ return true;
+}
+
OpenPOWER on IntegriCloud