blob: fe267e5e45a042d34f481dd2bd825d13c221c00f [file] [log] [blame]
Todd Fiala75930012016-08-19 04:21:48 +00001//===-- StructuredDataPlugin.cpp --------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "lldb/Target/StructuredDataPlugin.h"
11
12#include "lldb/Core/Debugger.h"
13#include "lldb/Interpreter/CommandInterpreter.h"
14#include "lldb/Interpreter/CommandObjectMultiword.h"
15
16using namespace lldb;
17using namespace lldb_private;
18
Kate Stoneb9c1b512016-09-06 20:57:50 +000019namespace {
20class CommandStructuredData : public CommandObjectMultiword {
21public:
22 CommandStructuredData(CommandInterpreter &interpreter)
23 : CommandObjectMultiword(interpreter, "structured-data",
Todd Fiala75930012016-08-19 04:21:48 +000024 "Parent for per-plugin structured data commands",
Kate Stoneb9c1b512016-09-06 20:57:50 +000025 "plugin structured-data <plugin>") {}
Todd Fiala75930012016-08-19 04:21:48 +000026
Kate Stoneb9c1b512016-09-06 20:57:50 +000027 ~CommandStructuredData() {}
28};
Todd Fiala75930012016-08-19 04:21:48 +000029}
30
Kate Stoneb9c1b512016-09-06 20:57:50 +000031StructuredDataPlugin::StructuredDataPlugin(const ProcessWP &process_wp)
32 : PluginInterface(), m_process_wp(process_wp) {}
33
34StructuredDataPlugin::~StructuredDataPlugin() {}
35
36bool 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.
39 return true;
Todd Fiala75930012016-08-19 04:21:48 +000040}
41
Kate Stoneb9c1b512016-09-06 20:57:50 +000042ProcessSP StructuredDataPlugin::GetProcess() const {
43 return m_process_wp.lock();
Todd Fiala75930012016-08-19 04:21:48 +000044}
45
Kate Stoneb9c1b512016-09-06 20:57:50 +000046void 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.
51 auto parent_command =
52 debugger.GetCommandInterpreter().GetCommandObject("plugin");
53 if (!parent_command)
54 return;
55
56 // Create the structured-data ommand object.
57 auto command_name = "structured-data";
58 auto command_sp = CommandObjectSP(new CommandStructuredData(interpreter));
59
60 // Hook it up under the top-level plugin command.
61 parent_command->LoadSubCommand(command_name, command_sp);
62 }
Todd Fiala75930012016-08-19 04:21:48 +000063}
64
Kate Stoneb9c1b512016-09-06 20:57:50 +000065void StructuredDataPlugin::ModulesDidLoad(Process &process,
66 ModuleList &module_list) {
67 // Default implementation does nothing.
Todd Fiala75930012016-08-19 04:21:48 +000068}