LLDB mainline
CommandObjectPlugin.cpp
Go to the documentation of this file.
1//===-- CommandObjectPlugin.cpp -------------------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
12
13using namespace lldb;
14using namespace lldb_private;
15
17public:
19 : CommandObjectParsed(interpreter, "plugin load",
20 "Import a dylib that implements an LLDB plugin.",
21 nullptr) {
23 CommandArgumentData cmd_arg;
24
25 // Define the first (and only) variant of this arg.
26 cmd_arg.arg_type = eArgTypeFilename;
28
29 // There is only one variant this argument could be; put it into the
30 // argument entry.
31 arg1.push_back(cmd_arg);
32
33 // Push the data for the first argument into the m_arguments vector.
34 m_arguments.push_back(arg1);
35 }
36
37 ~CommandObjectPluginLoad() override = default;
38
39 void
41 OptionElementVector &opt_element_vector) override {
44 }
45
46protected:
47 bool DoExecute(Args &command, CommandReturnObject &result) override {
48 size_t argc = command.GetArgumentCount();
49
50 if (argc != 1) {
51 result.AppendError("'plugin load' requires one argument");
52 return false;
53 }
54
56
57 FileSpec dylib_fspec(command[0].ref());
58 FileSystem::Instance().Resolve(dylib_fspec);
59
60 if (GetDebugger().LoadPlugin(dylib_fspec, error))
62 else {
63 result.AppendError(error.AsCString());
64 }
65
66 return result.Succeeded();
67 }
68};
69
71 : CommandObjectMultiword(interpreter, "plugin",
72 "Commands for managing LLDB plugins.",
73 "plugin <subcommand> [<subcommand-options>]") {
74 LoadSubCommand("load",
75 CommandObjectSP(new CommandObjectPluginLoad(interpreter)));
76}
77
static llvm::raw_ostream & error(Stream &strm)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
bool DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectPluginLoad() override=default
CommandObjectPluginLoad(CommandInterpreter &interpreter)
A command line argument class.
Definition: Args.h:33
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition: Args.h:116
static bool InvokeCommonCompletionCallbacks(CommandInterpreter &interpreter, uint32_t completion_mask, lldb_private::CompletionRequest &request, SearchFilter *searcher)
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandObjectPlugin(CommandInterpreter &interpreter)
std::vector< CommandArgumentData > CommandArgumentEntry
std::vector< CommandArgumentEntry > m_arguments
CommandInterpreter & GetCommandInterpreter()
void void AppendError(llvm::StringRef in_string)
void SetStatus(lldb::ReturnStatus status)
"lldb/Utility/ArgCompletionRequest.h"
A file utility class.
Definition: FileSpec.h:56
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
static FileSystem & Instance()
An error handling class.
Definition: Status.h:44
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
std::vector< OptionArgElement > OptionElementVector
Definition: Options.h:43
Definition: SBAddress.h:15
@ eDiskFileCompletion
@ eReturnStatusSuccessFinishResult
@ eArgTypeFilename
Used to build individual command argument lists.
Definition: CommandObject.h:93