summaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectScripting.cpp
diff options
context:
space:
mode:
authorMed Ismail Bennani <ismail@bennani.ma>2024-07-23 16:04:48 -0700
committerGitHub <noreply@github.com>2024-07-23 16:04:48 -0700
commit39c23a31d2ab9a6068fcaa22ed9b1e10101db5ff (patch)
tree00c03bd8c6bf3918d3120d6d90b1c698dffe2f22 /lldb/source/Commands/CommandObjectScripting.cpp
parent25f0381ba128e012e494701286450a374bf366a8 (diff)
Revert "[lldb/Commands] Add `scripting template list` command with auto discovery" (#100273)
Reverts llvm/llvm-project#97273 since it broke the windows bot: https://lab.llvm.org/buildbot/#/builders/141/builds/1025/steps/4/logs/stdio
Diffstat (limited to 'lldb/source/Commands/CommandObjectScripting.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectScripting.cpp126
1 files changed, 2 insertions, 124 deletions
diff --git a/lldb/source/Commands/CommandObjectScripting.cpp b/lldb/source/Commands/CommandObjectScripting.cpp
index 730a190a6e89..fee0565a7c48 100644
--- a/lldb/source/Commands/CommandObjectScripting.cpp
+++ b/lldb/source/Commands/CommandObjectScripting.cpp
@@ -8,14 +8,12 @@
#include "CommandObjectScripting.h"
#include "lldb/Core/Debugger.h"
-#include "lldb/Core/PluginManager.h"
#include "lldb/DataFormatters/DataVisualization.h"
#include "lldb/Host/Config.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandOptionArgumentTable.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Interpreter/Interfaces/ScriptedInterfaceUsages.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Utility/Args.h"
@@ -129,126 +127,9 @@ private:
CommandOptions m_options;
};
-#define LLDB_OPTIONS_scripting_template_list
-#include "CommandOptions.inc"
-
-class CommandObjectScriptingTemplateList : public CommandObjectParsed {
-public:
- CommandObjectScriptingTemplateList(CommandInterpreter &interpreter)
- : CommandObjectParsed(
- interpreter, "scripting template list",
- "List all the available scripting extension templates. ",
- "scripting template list [--language <scripting-language> --]") {}
-
- ~CommandObjectScriptingTemplateList() override = default;
-
- Options *GetOptions() override { return &m_options; }
-
- class CommandOptions : public Options {
- public:
- CommandOptions() = default;
- ~CommandOptions() override = default;
- Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
- ExecutionContext *execution_context) override {
- Status error;
- const int short_option = m_getopt_table[option_idx].val;
+#pragma mark CommandObjectMultiwordScripting
- switch (short_option) {
- case 'l':
- m_language = (lldb::ScriptLanguage)OptionArgParser::ToOptionEnum(
- option_arg, GetDefinitions()[option_idx].enum_values,
- eScriptLanguageNone, error);
- if (!error.Success())
- error.SetErrorStringWithFormatv(
- "unrecognized value for language '{0}'", option_arg);
- break;
- default:
- llvm_unreachable("Unimplemented option");
- }
-
- return error;
- }
-
- void OptionParsingStarting(ExecutionContext *execution_context) override {
- m_language = lldb::eScriptLanguageDefault;
- }
-
- llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
- return llvm::ArrayRef(g_scripting_template_list_options);
- }
-
- lldb::ScriptLanguage m_language = lldb::eScriptLanguageDefault;
- };
-
-protected:
- void DoExecute(Args &command, CommandReturnObject &result) override {
- Stream &s = result.GetOutputStream();
- s.Printf("Available scripted extension templates:");
-
- auto print_field = [&s](llvm::StringRef key, llvm::StringRef value) {
- if (!value.empty()) {
- s.IndentMore();
- s.Indent();
- s << key << ": " << value << '\n';
- s.IndentLess();
- }
- };
-
- size_t num_listed_interface = 0;
- size_t num_templates = PluginManager::GetNumScriptedInterfaces();
- for (size_t i = 0; i < num_templates; i++) {
- llvm::StringRef plugin_name =
- PluginManager::GetScriptedInterfaceNameAtIndex(i);
- if (plugin_name.empty())
- break;
-
- lldb::ScriptLanguage lang =
- PluginManager::GetScriptedInterfaceLanguageAtIndex(i);
- if (lang != m_options.m_language)
- continue;
-
- if (!num_listed_interface)
- s.EOL();
-
- num_listed_interface++;
-
- llvm::StringRef desc =
- PluginManager::GetScriptedInterfaceDescriptionAtIndex(i);
- ScriptedInterfaceUsages usages =
- PluginManager::GetScriptedInterfaceUsagesAtIndex(i);
-
- print_field("Name", plugin_name);
- print_field("Language", ScriptInterpreter::LanguageToString(lang));
- print_field("Description", desc);
- usages.Dump(s, ScriptedInterfaceUsages::UsageKind::API);
- usages.Dump(s, ScriptedInterfaceUsages::UsageKind::CommandInterpreter);
-
- if (i != num_templates - 1)
- s.EOL();
- }
-
- if (!num_listed_interface)
- s << " None\n";
- }
-
-private:
- CommandOptions m_options;
-};
-
-class CommandObjectMultiwordScriptingTemplate : public CommandObjectMultiword {
-public:
- CommandObjectMultiwordScriptingTemplate(CommandInterpreter &interpreter)
- : CommandObjectMultiword(
- interpreter, "scripting template",
- "Commands for operating on the scripting templates.",
- "scripting template [<subcommand-options>]") {
- LoadSubCommand(
- "list",
- CommandObjectSP(new CommandObjectScriptingTemplateList(interpreter)));
- }
-
- ~CommandObjectMultiwordScriptingTemplate() override = default;
-};
+// CommandObjectMultiwordScripting
CommandObjectMultiwordScripting::CommandObjectMultiwordScripting(
CommandInterpreter &interpreter)
@@ -258,9 +139,6 @@ CommandObjectMultiwordScripting::CommandObjectMultiwordScripting(
"scripting <subcommand> [<subcommand-options>]") {
LoadSubCommand("run",
CommandObjectSP(new CommandObjectScriptingRun(interpreter)));
- LoadSubCommand("template",
- CommandObjectSP(
- new CommandObjectMultiwordScriptingTemplate(interpreter)));
}
CommandObjectMultiwordScripting::~CommandObjectMultiwordScripting() = default;