Path: blob/main/contrib/llvm-project/lldb/source/Target/StructuredDataPlugin.cpp
39587 views
//===-- StructuredDataPlugin.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 "lldb/Target/StructuredDataPlugin.h"910#include "lldb/Core/Debugger.h"11#include "lldb/Interpreter/CommandInterpreter.h"12#include "lldb/Interpreter/CommandObjectMultiword.h"1314using namespace lldb;15using namespace lldb_private;1617namespace {18class CommandStructuredData : public CommandObjectMultiword {19public:20CommandStructuredData(CommandInterpreter &interpreter)21: CommandObjectMultiword(interpreter, "structured-data",22"Parent for per-plugin structured data commands",23"plugin structured-data <plugin>") {}2425~CommandStructuredData() override = default;26};27}2829StructuredDataPlugin::StructuredDataPlugin(const ProcessWP &process_wp)30: PluginInterface(), m_process_wp(process_wp) {}3132StructuredDataPlugin::~StructuredDataPlugin() = default;3334bool StructuredDataPlugin::GetEnabled(llvm::StringRef type_name) const {35// By default, plugins are always enabled. Plugin authors should override36// this if there is an enabled/disabled state for their plugin.37return true;38}3940ProcessSP StructuredDataPlugin::GetProcess() const {41return m_process_wp.lock();42}4344void StructuredDataPlugin::InitializeBasePluginForDebugger(Debugger &debugger) {45// Create our mutliword command anchor if it doesn't already exist.46auto &interpreter = debugger.GetCommandInterpreter();47if (!interpreter.GetCommandObject("plugin structured-data")) {48// Find the parent command.49auto parent_command =50debugger.GetCommandInterpreter().GetCommandObject("plugin");51if (!parent_command)52return;5354// Create the structured-data ommand object.55auto command_name = "structured-data";56auto command_sp = CommandObjectSP(new CommandStructuredData(interpreter));5758// Hook it up under the top-level plugin command.59parent_command->LoadSubCommand(command_name, command_sp);60}61}6263void StructuredDataPlugin::ModulesDidLoad(Process &process,64ModuleList &module_list) {65// Default implementation does nothing.66}676869