Path: blob/main/contrib/llvm-project/lldb/source/Commands/CommandObjectPlugin.cpp
39587 views
//===-- CommandObjectPlugin.cpp -------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "CommandObjectPlugin.h"9#include "lldb/Interpreter/CommandInterpreter.h"10#include "lldb/Interpreter/CommandReturnObject.h"1112using namespace lldb;13using namespace lldb_private;1415class CommandObjectPluginLoad : public CommandObjectParsed {16public:17CommandObjectPluginLoad(CommandInterpreter &interpreter)18: CommandObjectParsed(interpreter, "plugin load",19"Import a dylib that implements an LLDB plugin.",20nullptr) {21AddSimpleArgumentList(eArgTypeFilename);22}2324~CommandObjectPluginLoad() override = default;2526protected:27void DoExecute(Args &command, CommandReturnObject &result) override {28size_t argc = command.GetArgumentCount();2930if (argc != 1) {31result.AppendError("'plugin load' requires one argument");32return;33}3435Status error;3637FileSpec dylib_fspec(command[0].ref());38FileSystem::Instance().Resolve(dylib_fspec);3940if (GetDebugger().LoadPlugin(dylib_fspec, error))41result.SetStatus(eReturnStatusSuccessFinishResult);42else {43result.AppendError(error.AsCString());44}45}46};4748CommandObjectPlugin::CommandObjectPlugin(CommandInterpreter &interpreter)49: CommandObjectMultiword(interpreter, "plugin",50"Commands for managing LLDB plugins.",51"plugin <subcommand> [<subcommand-options>]") {52LoadSubCommand("load",53CommandObjectSP(new CommandObjectPluginLoad(interpreter)));54}5556CommandObjectPlugin::~CommandObjectPlugin() = default;575859