/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Commands/CommandObjectPlugin.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
9 | | #include "CommandObjectPlugin.h" |
10 | | #include "lldb/Interpreter/CommandInterpreter.h" |
11 | | #include "lldb/Interpreter/CommandReturnObject.h" |
12 | | |
13 | | using namespace lldb; |
14 | | using namespace lldb_private; |
15 | | |
16 | | class CommandObjectPluginLoad : public CommandObjectParsed { |
17 | | public: |
18 | | CommandObjectPluginLoad(CommandInterpreter &interpreter) |
19 | 6.14k | : CommandObjectParsed(interpreter, "plugin load", |
20 | 6.14k | "Import a dylib that implements an LLDB plugin.", |
21 | 6.14k | nullptr) { |
22 | 6.14k | CommandArgumentEntry arg1; |
23 | 6.14k | CommandArgumentData cmd_arg; |
24 | | |
25 | | // Define the first (and only) variant of this arg. |
26 | 6.14k | cmd_arg.arg_type = eArgTypeFilename; |
27 | 6.14k | cmd_arg.arg_repetition = eArgRepeatPlain; |
28 | | |
29 | | // There is only one variant this argument could be; put it into the |
30 | | // argument entry. |
31 | 6.14k | arg1.push_back(cmd_arg); |
32 | | |
33 | | // Push the data for the first argument into the m_arguments vector. |
34 | 6.14k | m_arguments.push_back(arg1); |
35 | 6.14k | } |
36 | | |
37 | 6.13k | ~CommandObjectPluginLoad() override = default; |
38 | | |
39 | | void |
40 | | HandleArgumentCompletion(CompletionRequest &request, |
41 | 1 | OptionElementVector &opt_element_vector) override { |
42 | 1 | lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks( |
43 | 1 | GetCommandInterpreter(), lldb::eDiskFileCompletion, request, nullptr); |
44 | 1 | } |
45 | | |
46 | | protected: |
47 | 3 | void DoExecute(Args &command, CommandReturnObject &result) override { |
48 | 3 | size_t argc = command.GetArgumentCount(); |
49 | | |
50 | 3 | if (argc != 1) { |
51 | 2 | result.AppendError("'plugin load' requires one argument"); |
52 | 2 | return; |
53 | 2 | } |
54 | | |
55 | 1 | Status error; |
56 | | |
57 | 1 | FileSpec dylib_fspec(command[0].ref()); |
58 | 1 | FileSystem::Instance().Resolve(dylib_fspec); |
59 | | |
60 | 1 | if (GetDebugger().LoadPlugin(dylib_fspec, error)) |
61 | 0 | result.SetStatus(eReturnStatusSuccessFinishResult); |
62 | 1 | else { |
63 | 1 | result.AppendError(error.AsCString()); |
64 | 1 | } |
65 | 1 | } |
66 | | }; |
67 | | |
68 | | CommandObjectPlugin::CommandObjectPlugin(CommandInterpreter &interpreter) |
69 | 6.14k | : CommandObjectMultiword(interpreter, "plugin", |
70 | 6.14k | "Commands for managing LLDB plugins.", |
71 | 6.14k | "plugin <subcommand> [<subcommand-options>]") { |
72 | 6.14k | LoadSubCommand("load", |
73 | 6.14k | CommandObjectSP(new CommandObjectPluginLoad(interpreter))); |
74 | 6.14k | } |
75 | | |
76 | 6.13k | CommandObjectPlugin::~CommandObjectPlugin() = default; |