brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 8ce7f9f Raw
68 lines · cpp
1//===-- StructuredDataPlugin.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-exception6//7//===----------------------------------------------------------------------===//8 9#include "lldb/Target/StructuredDataPlugin.h"10 11#include "lldb/Core/Debugger.h"12#include "lldb/Interpreter/CommandInterpreter.h"13#include "lldb/Interpreter/CommandObjectMultiword.h"14 15using namespace lldb;16using namespace lldb_private;17 18namespace {19class CommandStructuredData : public CommandObjectMultiword {20public:21  CommandStructuredData(CommandInterpreter &interpreter)22      : CommandObjectMultiword(interpreter, "structured-data",23                               "Parent for per-plugin structured data commands",24                               "plugin structured-data <plugin>") {}25 26  ~CommandStructuredData() override = default;27};28}29 30StructuredDataPlugin::StructuredDataPlugin(const ProcessWP &process_wp)31    : PluginInterface(), m_process_wp(process_wp) {}32 33StructuredDataPlugin::~StructuredDataPlugin() = default;34 35bool StructuredDataPlugin::GetEnabled(llvm::StringRef type_name) const {36  // By default, plugins are always enabled.  Plugin authors should override37  // this if there is an enabled/disabled state for their plugin.38  return true;39}40 41ProcessSP StructuredDataPlugin::GetProcess() const {42  return m_process_wp.lock();43}44 45void StructuredDataPlugin::InitializeBasePluginForDebugger(Debugger &debugger) {46  // Create our multiword command anchor if it doesn't already exist.47  auto &interpreter = debugger.GetCommandInterpreter();48  if (!interpreter.GetCommandObject("plugin structured-data")) {49    // Find the parent command.50    auto parent_command =51        debugger.GetCommandInterpreter().GetCommandObject("plugin");52    if (!parent_command)53      return;54 55    // Create the structured-data command object.56    auto command_name = "structured-data";57    auto command_sp = CommandObjectSP(new CommandStructuredData(interpreter));58 59    // Hook it up under the top-level plugin command.60    parent_command->LoadSubCommand(command_name, command_sp);61  }62}63 64void StructuredDataPlugin::ModulesDidLoad(Process &process,65                                          ModuleList &module_list) {66  // Default implementation does nothing.67}68