1 //===-- StructuredDataPlugin.cpp --------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Target/StructuredDataPlugin.h"
12 #include "lldb/Core/Debugger.h"
13 #include "lldb/Interpreter/CommandInterpreter.h"
14 #include "lldb/Interpreter/CommandObjectMultiword.h"
17 using namespace lldb_private;
20 class CommandStructuredData : public CommandObjectMultiword {
22 CommandStructuredData(CommandInterpreter &interpreter)
23 : CommandObjectMultiword(interpreter, "structured-data",
24 "Parent for per-plugin structured data commands",
25 "plugin structured-data <plugin>") {}
27 ~CommandStructuredData() {}
31 StructuredDataPlugin::StructuredDataPlugin(const ProcessWP &process_wp)
32 : PluginInterface(), m_process_wp(process_wp) {}
34 StructuredDataPlugin::~StructuredDataPlugin() {}
36 bool StructuredDataPlugin::GetEnabled(const ConstString &type_name) const {
37 // By default, plugins are always enabled. Plugin authors should override
38 // this if there is an enabled/disabled state for their plugin.
42 ProcessSP StructuredDataPlugin::GetProcess() const {
43 return m_process_wp.lock();
46 void StructuredDataPlugin::InitializeBasePluginForDebugger(Debugger &debugger) {
47 // Create our mutliword command anchor if it doesn't already exist.
48 auto &interpreter = debugger.GetCommandInterpreter();
49 if (!interpreter.GetCommandObject("plugin structured-data")) {
50 // Find the parent command.
52 debugger.GetCommandInterpreter().GetCommandObject("plugin");
56 // Create the structured-data ommand object.
57 auto command_name = "structured-data";
58 auto command_sp = CommandObjectSP(new CommandStructuredData(interpreter));
60 // Hook it up under the top-level plugin command.
61 parent_command->LoadSubCommand(command_name, command_sp);
65 void StructuredDataPlugin::ModulesDidLoad(Process &process,
66 ModuleList &module_list) {
67 // Default implementation does nothing.