1*75930019STodd Fiala //===-- StructuredDataPlugin.cpp --------------------------------*- C++ -*-===//
2*75930019STodd Fiala //
3*75930019STodd Fiala //                     The LLVM Compiler Infrastructure
4*75930019STodd Fiala //
5*75930019STodd Fiala // This file is distributed under the University of Illinois Open Source
6*75930019STodd Fiala // License. See LICENSE.TXT for details.
7*75930019STodd Fiala //
8*75930019STodd Fiala //===----------------------------------------------------------------------===//
9*75930019STodd Fiala 
10*75930019STodd Fiala #include "lldb/Target/StructuredDataPlugin.h"
11*75930019STodd Fiala 
12*75930019STodd Fiala #include "lldb/Core/Debugger.h"
13*75930019STodd Fiala #include "lldb/Interpreter/CommandInterpreter.h"
14*75930019STodd Fiala #include "lldb/Interpreter/CommandObjectMultiword.h"
15*75930019STodd Fiala 
16*75930019STodd Fiala using namespace lldb;
17*75930019STodd Fiala using namespace lldb_private;
18*75930019STodd Fiala 
19*75930019STodd Fiala namespace
20*75930019STodd Fiala {
21*75930019STodd Fiala     class CommandStructuredData : public CommandObjectMultiword
22*75930019STodd Fiala     {
23*75930019STodd Fiala     public:
24*75930019STodd Fiala         CommandStructuredData(CommandInterpreter &interpreter) :
25*75930019STodd Fiala             CommandObjectMultiword(interpreter,
26*75930019STodd Fiala                                "structured-data",
27*75930019STodd Fiala                                "Parent for per-plugin structured data commands",
28*75930019STodd Fiala                                "plugin structured-data <plugin>")
29*75930019STodd Fiala         {
30*75930019STodd Fiala         }
31*75930019STodd Fiala 
32*75930019STodd Fiala         ~CommandStructuredData()
33*75930019STodd Fiala         {
34*75930019STodd Fiala         }
35*75930019STodd Fiala     };
36*75930019STodd Fiala }
37*75930019STodd Fiala 
38*75930019STodd Fiala StructuredDataPlugin::StructuredDataPlugin(const ProcessWP &process_wp) :
39*75930019STodd Fiala     PluginInterface(),
40*75930019STodd Fiala     m_process_wp(process_wp)
41*75930019STodd Fiala {
42*75930019STodd Fiala }
43*75930019STodd Fiala 
44*75930019STodd Fiala StructuredDataPlugin::~StructuredDataPlugin()
45*75930019STodd Fiala {
46*75930019STodd Fiala }
47*75930019STodd Fiala 
48*75930019STodd Fiala bool
49*75930019STodd Fiala StructuredDataPlugin::GetEnabled(const ConstString &type_name) const
50*75930019STodd Fiala {
51*75930019STodd Fiala     // By default, plugins are always enabled.  Plugin authors should override
52*75930019STodd Fiala     // this if there is an enabled/disabled state for their plugin.
53*75930019STodd Fiala     return true;
54*75930019STodd Fiala }
55*75930019STodd Fiala 
56*75930019STodd Fiala ProcessSP
57*75930019STodd Fiala StructuredDataPlugin::GetProcess() const
58*75930019STodd Fiala {
59*75930019STodd Fiala     return m_process_wp.lock();
60*75930019STodd Fiala }
61*75930019STodd Fiala 
62*75930019STodd Fiala void
63*75930019STodd Fiala StructuredDataPlugin::InitializeBasePluginForDebugger(Debugger &debugger)
64*75930019STodd Fiala {
65*75930019STodd Fiala     // Create our mutliword command anchor if it doesn't already exist.
66*75930019STodd Fiala     auto &interpreter = debugger.GetCommandInterpreter();
67*75930019STodd Fiala     if (!interpreter.GetCommandObject("plugin structured-data"))
68*75930019STodd Fiala     {
69*75930019STodd Fiala         // Find the parent command.
70*75930019STodd Fiala         auto parent_command =
71*75930019STodd Fiala             debugger.GetCommandInterpreter().GetCommandObject("plugin");
72*75930019STodd Fiala         if (!parent_command)
73*75930019STodd Fiala             return;
74*75930019STodd Fiala 
75*75930019STodd Fiala         // Create the structured-data ommand object.
76*75930019STodd Fiala         auto command_name = "structured-data";
77*75930019STodd Fiala         auto command_sp =
78*75930019STodd Fiala             CommandObjectSP(new CommandStructuredData(interpreter));
79*75930019STodd Fiala 
80*75930019STodd Fiala         // Hook it up under the top-level plugin command.
81*75930019STodd Fiala         parent_command->LoadSubCommand(command_name,
82*75930019STodd Fiala                                        command_sp);
83*75930019STodd Fiala     }
84*75930019STodd Fiala }
85*75930019STodd Fiala 
86*75930019STodd Fiala void
87*75930019STodd Fiala StructuredDataPlugin::ModulesDidLoad(Process &process, ModuleList &module_list)
88*75930019STodd Fiala {
89*75930019STodd Fiala     // Default implementation does nothing.
90*75930019STodd Fiala }
91