1 //===-- CommandObjectPlugin.cpp -------------------------------------------===//
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 //===----------------------------------------------------------------------===//
9 #include "CommandObjectPlugin.h"
10 #include "lldb/Interpreter/CommandInterpreter.h"
11 #include "lldb/Interpreter/CommandReturnObject.h"
14 using namespace lldb_private
;
16 class CommandObjectPluginLoad
: public CommandObjectParsed
{
18 CommandObjectPluginLoad(CommandInterpreter
&interpreter
)
19 : CommandObjectParsed(interpreter
, "plugin load",
20 "Import a dylib that implements an LLDB plugin.",
22 AddSimpleArgumentList(eArgTypeFilename
);
25 ~CommandObjectPluginLoad() override
= default;
28 void DoExecute(Args
&command
, CommandReturnObject
&result
) override
{
29 size_t argc
= command
.GetArgumentCount();
32 result
.AppendError("'plugin load' requires one argument");
38 FileSpec
dylib_fspec(command
[0].ref());
39 FileSystem::Instance().Resolve(dylib_fspec
);
41 if (GetDebugger().LoadPlugin(dylib_fspec
, error
))
42 result
.SetStatus(eReturnStatusSuccessFinishResult
);
44 result
.AppendError(error
.AsCString());
49 CommandObjectPlugin::CommandObjectPlugin(CommandInterpreter
&interpreter
)
50 : CommandObjectMultiword(interpreter
, "plugin",
51 "Commands for managing LLDB plugins.",
52 "plugin <subcommand> [<subcommand-options>]") {
53 LoadSubCommand("load",
54 CommandObjectSP(new CommandObjectPluginLoad(interpreter
)));
57 CommandObjectPlugin::~CommandObjectPlugin() = default;