Revert "[lldb/Commands] Add scripting template list
command with au… · llvm/llvm-project@39c23a3 (original) (raw)
`@@ -8,14 +8,12 @@
`
8
8
``
9
9
`#include "CommandObjectScripting.h"
`
10
10
`#include "lldb/Core/Debugger.h"
`
11
``
`-
#include "lldb/Core/PluginManager.h"
`
12
11
`#include "lldb/DataFormatters/DataVisualization.h"
`
13
12
`#include "lldb/Host/Config.h"
`
14
13
`#include "lldb/Host/OptionParser.h"
`
15
14
`#include "lldb/Interpreter/CommandInterpreter.h"
`
16
15
`#include "lldb/Interpreter/CommandOptionArgumentTable.h"
`
17
16
`#include "lldb/Interpreter/CommandReturnObject.h"
`
18
``
`-
#include "lldb/Interpreter/Interfaces/ScriptedInterfaceUsages.h"
`
19
17
`#include "lldb/Interpreter/OptionArgParser.h"
`
20
18
`#include "lldb/Interpreter/ScriptInterpreter.h"
`
21
19
`#include "lldb/Utility/Args.h"
`
`@@ -129,126 +127,9 @@ class CommandObjectScriptingRun : public CommandObjectRaw {
`
129
127
` CommandOptions m_options;
`
130
128
`};
`
131
129
``
132
``
`-
#define LLDB_OPTIONS_scripting_template_list
`
133
``
`-
#include "CommandOptions.inc"
`
134
``
-
135
``
`-
class CommandObjectScriptingTemplateList : public CommandObjectParsed {
`
136
``
`-
public:
`
137
``
`-
CommandObjectScriptingTemplateList(CommandInterpreter &interpreter)
`
138
``
`-
: CommandObjectParsed(
`
139
``
`-
interpreter, "scripting template list",
`
140
``
`-
"List all the available scripting extension templates. ",
`
141
``
`-
"scripting template list [--language --]") {}
`
142
``
-
143
``
`-
~CommandObjectScriptingTemplateList() override = default;
`
144
``
-
145
``
`-
Options *GetOptions() override { return &m_options; }
`
146
``
-
147
``
`-
class CommandOptions : public Options {
`
148
``
`-
public:
`
149
``
`-
CommandOptions() = default;
`
150
``
`-
~CommandOptions() override = default;
`
151
``
`-
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
`
152
``
`-
ExecutionContext *execution_context) override {
`
153
``
`-
Status error;
`
154
``
`-
const int short_option = m_getopt_table[option_idx].val;
`
``
130
`+
#pragma mark CommandObjectMultiwordScripting
`
155
131
``
156
``
`-
switch (short_option) {
`
157
``
`-
case 'l':
`
158
``
`-
m_language = (lldb::ScriptLanguage)OptionArgParser::ToOptionEnum(
`
159
``
`-
option_arg, GetDefinitions()[option_idx].enum_values,
`
160
``
`-
eScriptLanguageNone, error);
`
161
``
`-
if (!error.Success())
`
162
``
`-
error.SetErrorStringWithFormatv(
`
163
``
`-
"unrecognized value for language '{0}'", option_arg);
`
164
``
`-
break;
`
165
``
`-
default:
`
166
``
`-
llvm_unreachable("Unimplemented option");
`
167
``
`-
}
`
168
``
-
169
``
`-
return error;
`
170
``
`-
}
`
171
``
-
172
``
`-
void OptionParsingStarting(ExecutionContext *execution_context) override {
`
173
``
`-
m_language = lldb::eScriptLanguageDefault;
`
174
``
`-
}
`
175
``
-
176
``
`-
llvm::ArrayRef GetDefinitions() override {
`
177
``
`-
return llvm::ArrayRef(g_scripting_template_list_options);
`
178
``
`-
}
`
179
``
-
180
``
`-
lldb::ScriptLanguage m_language = lldb::eScriptLanguageDefault;
`
181
``
`-
};
`
182
``
-
183
``
`-
protected:
`
184
``
`-
void DoExecute(Args &command, CommandReturnObject &result) override {
`
185
``
`-
Stream &s = result.GetOutputStream();
`
186
``
`-
s.Printf("Available scripted extension templates:");
`
187
``
-
188
``
`-
auto print_field = [&s](llvm::StringRef key, llvm::StringRef value) {
`
189
``
`-
if (!value.empty()) {
`
190
``
`-
s.IndentMore();
`
191
``
`-
s.Indent();
`
192
``
`-
s << key << ": " << value << '\n';
`
193
``
`-
s.IndentLess();
`
194
``
`-
}
`
195
``
`-
};
`
196
``
-
197
``
`-
size_t num_listed_interface = 0;
`
198
``
`-
size_t num_templates = PluginManager::GetNumScriptedInterfaces();
`
199
``
`-
for (size_t i = 0; i < num_templates; i++) {
`
200
``
`-
llvm::StringRef plugin_name =
`
201
``
`-
PluginManager::GetScriptedInterfaceNameAtIndex(i);
`
202
``
`-
if (plugin_name.empty())
`
203
``
`-
break;
`
204
``
-
205
``
`-
lldb::ScriptLanguage lang =
`
206
``
`-
PluginManager::GetScriptedInterfaceLanguageAtIndex(i);
`
207
``
`-
if (lang != m_options.m_language)
`
208
``
`-
continue;
`
209
``
-
210
``
`-
if (!num_listed_interface)
`
211
``
`-
s.EOL();
`
212
``
-
213
``
`-
num_listed_interface++;
`
214
``
-
215
``
`-
llvm::StringRef desc =
`
216
``
`-
PluginManager::GetScriptedInterfaceDescriptionAtIndex(i);
`
217
``
`-
ScriptedInterfaceUsages usages =
`
218
``
`-
PluginManager::GetScriptedInterfaceUsagesAtIndex(i);
`
219
``
-
220
``
`-
print_field("Name", plugin_name);
`
221
``
`-
print_field("Language", ScriptInterpreter::LanguageToString(lang));
`
222
``
`-
print_field("Description", desc);
`
223
``
`-
usages.Dump(s, ScriptedInterfaceUsages::UsageKind::API);
`
224
``
`-
usages.Dump(s, ScriptedInterfaceUsages::UsageKind::CommandInterpreter);
`
225
``
-
226
``
`-
if (i != num_templates - 1)
`
227
``
`-
s.EOL();
`
228
``
`-
}
`
229
``
-
230
``
`-
if (!num_listed_interface)
`
231
``
`-
s << " None\n";
`
232
``
`-
}
`
233
``
-
234
``
`-
private:
`
235
``
`-
CommandOptions m_options;
`
236
``
`-
};
`
237
``
-
238
``
`-
class CommandObjectMultiwordScriptingTemplate : public CommandObjectMultiword {
`
239
``
`-
public:
`
240
``
`-
CommandObjectMultiwordScriptingTemplate(CommandInterpreter &interpreter)
`
241
``
`-
: CommandObjectMultiword(
`
242
``
`-
interpreter, "scripting template",
`
243
``
`-
"Commands for operating on the scripting templates.",
`
244
``
`-
"scripting template []") {
`
245
``
`-
LoadSubCommand(
`
246
``
`-
"list",
`
247
``
`-
CommandObjectSP(new CommandObjectScriptingTemplateList(interpreter)));
`
248
``
`-
}
`
249
``
-
250
``
`-
~CommandObjectMultiwordScriptingTemplate() override = default;
`
251
``
`-
};
`
``
132
`+
// CommandObjectMultiwordScripting
`
252
133
``
253
134
`CommandObjectMultiwordScripting::CommandObjectMultiwordScripting(
`
254
135
` CommandInterpreter &interpreter)
`
`@@ -258,9 +139,6 @@ CommandObjectMultiwordScripting::CommandObjectMultiwordScripting(
`
258
139
`"scripting []") {
`
259
140
`LoadSubCommand("run",
`
260
141
`CommandObjectSP(new CommandObjectScriptingRun(interpreter)));
`
261
``
`-
LoadSubCommand("template",
`
262
``
`-
CommandObjectSP(
`
263
``
`-
new CommandObjectMultiwordScriptingTemplate(interpreter)));
`
264
142
`}
`
265
143
``
266
144
`CommandObjectMultiwordScripting::~CommandObjectMultiwordScripting() = default;
`