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