Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

82 lines
2.7 KiB
C++
Raw Permalink Normal View History

//===-- CommandObjectPlugin.cpp -------------------------------------------===//
2012-09-28 23:57:51 +00:00
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2012-09-28 23:57:51 +00:00
//
//===----------------------------------------------------------------------===//
#include "CommandObjectPlugin.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
using namespace lldb;
using namespace lldb_private;
class CommandObjectPluginLoad : public CommandObjectParsed {
public:
CommandObjectPluginLoad(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "plugin load",
"Import a dylib that implements an LLDB plugin.",
nullptr) {
2012-09-28 23:57:51 +00:00
CommandArgumentEntry arg1;
CommandArgumentData cmd_arg;
// Define the first (and only) variant of this arg.
2012-09-28 23:57:51 +00:00
cmd_arg.arg_type = eArgTypeFilename;
cmd_arg.arg_repetition = eArgRepeatPlain;
2012-09-28 23:57:51 +00:00
// There is only one variant this argument could be; put it into the
// argument entry.
arg1.push_back(cmd_arg);
2016-08-11 23:51:28 +00:00
// Push the data for the first argument into the m_arguments vector.
2012-09-28 23:57:51 +00:00
m_arguments.push_back(arg1);
}
2016-08-11 23:51:28 +00:00
~CommandObjectPluginLoad() override = default;
void
HandleArgumentCompletion(CompletionRequest &request,
OptionElementVector &opt_element_vector) override {
2016-08-11 23:51:28 +00:00
CommandCompletions::InvokeCommonCompletionCallbacks(
GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
request, nullptr);
2012-09-28 23:57:51 +00:00
}
protected:
2015-10-07 16:56:17 +00:00
bool DoExecute(Args &command, CommandReturnObject &result) override {
2012-09-28 23:57:51 +00:00
size_t argc = command.GetArgumentCount();
2012-09-28 23:57:51 +00:00
if (argc != 1) {
result.AppendError("'plugin load' requires one argument");
result.SetStatus(eReturnStatusFailed);
return false;
}
2017-05-12 04:51:55 +00:00
Status error;
2019-09-13 11:26:48 +00:00
FileSpec dylib_fspec(command[0].ref());
FileSystem::Instance().Resolve(dylib_fspec);
if (GetDebugger().LoadPlugin(dylib_fspec, error))
2012-09-28 23:57:51 +00:00
result.SetStatus(eReturnStatusSuccessFinishResult);
else {
2013-04-24 21:29:08 +00:00
result.AppendError(error.AsCString());
2012-09-28 23:57:51 +00:00
result.SetStatus(eReturnStatusFailed);
}
2012-09-28 23:57:51 +00:00
return result.Succeeded();
}
2012-09-28 23:57:51 +00:00
};
CommandObjectPlugin::CommandObjectPlugin(CommandInterpreter &interpreter)
: CommandObjectMultiword(interpreter, "plugin",
"Commands for managing LLDB plugins.",
"plugin <subcommand> [<subcommand-options>]") {
2012-09-28 23:57:51 +00:00
LoadSubCommand("load",
CommandObjectSP(new CommandObjectPluginLoad(interpreter)));
}
CommandObjectPlugin::~CommandObjectPlugin() = default;