]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Target/StructuredDataPlugin.cpp
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r306325, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Target / StructuredDataPlugin.cpp
1 //===-- 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
16 using namespace lldb;
17 using namespace lldb_private;
18
19 namespace {
20 class CommandStructuredData : public CommandObjectMultiword {
21 public:
22   CommandStructuredData(CommandInterpreter &interpreter)
23       : CommandObjectMultiword(interpreter, "structured-data",
24                                "Parent for per-plugin structured data commands",
25                                "plugin structured-data <plugin>") {}
26
27   ~CommandStructuredData() {}
28 };
29 }
30
31 StructuredDataPlugin::StructuredDataPlugin(const ProcessWP &process_wp)
32     : PluginInterface(), m_process_wp(process_wp) {}
33
34 StructuredDataPlugin::~StructuredDataPlugin() {}
35
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.
39   return true;
40 }
41
42 ProcessSP StructuredDataPlugin::GetProcess() const {
43   return m_process_wp.lock();
44 }
45
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.
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   }
63 }
64
65 void StructuredDataPlugin::ModulesDidLoad(Process &process,
66                                           ModuleList &module_list) {
67   // Default implementation does nothing.
68 }