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 }
24
25 ~CommandObjectPluginLoad() override = default;
26
27protected:
28 void DoExecute(Args &command, CommandReturnObject &result) override {
29 size_t argc = command.GetArgumentCount();
30
31 if (argc != 1) {
32 result.AppendError("'plugin load' requires one argument");
33 return;
34 }
35
37
38 FileSpec dylib_fspec(command[0].ref());
39 FileSystem::Instance().Resolve(dylib_fspec);
40
41 if (GetDebugger().LoadPlugin(dylib_fspec, error))
43 else {
44 result.AppendError(error.AsCString());
45 }
46 }
47};
48
50 : CommandObjectMultiword(interpreter, "plugin",
51 "Commands for managing LLDB plugins.",
52 "plugin <subcommand> [<subcommand-options>]") {
53 LoadSubCommand("load",
55}
56
static llvm::raw_ostream & error(Stream &strm)
void 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
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandObjectPlugin(CommandInterpreter &interpreter)
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
void void AppendError(llvm::StringRef in_string)
void SetStatus(lldb::ReturnStatus status)
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: SBAddress.h:15
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
Definition: lldb-forward.h:331
@ eReturnStatusSuccessFinishResult
@ eArgTypeFilename