brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 00383c3 Raw
46 lines · plain
1/*2An example plugin for LLDB that provides a new foo command with a child subcommand3Compile this into a dylib foo.dylib and load by placing in appropriate locations on disk or4by typing plugin load foo.dylib at the LLDB command line5*/6 7%include_SB_APIs%8 9namespace lldb {10    bool11    PluginInitialize (lldb::SBDebugger debugger);12}13 14class ChildCommand : public lldb::SBCommandPluginInterface15{16public:17    virtual bool18    DoExecute (lldb::SBDebugger debugger,19               char** command,20               lldb::SBCommandReturnObject &result)21    {22        if (command)23        {24            const char* arg = *command;25            while (arg)26            {27                result.Printf("%s ",arg);28                arg = *(++command);29            }30            result.Printf("\n");31            return true;32        }33        return false;34    }35    36};37 38bool39lldb::PluginInitialize (lldb::SBDebugger debugger)40{41    lldb::SBCommandInterpreter interpreter = debugger.GetCommandInterpreter();42    lldb::SBCommand foo = interpreter.AddMultiwordCommand("plugin_loaded_command",NULL);43    foo.AddCommand("child",new ChildCommand(),"a child of plugin_loaded_command");44    return true;45}46