LLDB mainline
CommandObjectScripting.cpp
Go to the documentation of this file.
1//===-- CommandObjectScripting.cpp ----------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "lldb/Core/Debugger.h"
13#include "lldb/Host/Config.h"
14#include "lldb/Host/Host.h"
23#include "lldb/Utility/Args.h"
25#include "lldb/Utility/Log.h"
26
27#include "llvm/ADT/StringMap.h"
28
29using namespace lldb;
30using namespace lldb_private;
31
32#define LLDB_OPTIONS_scripting_run
33#include "CommandOptions.inc"
34
36public:
39 interpreter, "scripting run",
40 "Invoke the script interpreter with provided code and display any "
41 "results. Start the interactive interpreter if no code is "
42 "supplied.",
43 "scripting run [--language <scripting-language> --] "
44 "[<script-code>]") {}
45
46 ~CommandObjectScriptingRun() override = default;
47
48 Options *GetOptions() override { return &m_options; }
49
50 class CommandOptions : public Options {
51 public:
52 CommandOptions() = default;
53 ~CommandOptions() override = default;
54 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
55 ExecutionContext *execution_context) override {
57 const int short_option = m_getopt_table[option_idx].val;
58
59 switch (short_option) {
60 case 'l':
62 option_arg, GetDefinitions()[option_idx].enum_values,
64 if (!error.Success())
66 "unrecognized value for language '%s'", option_arg.str().c_str());
67 break;
68 default:
69 llvm_unreachable("Unimplemented option");
70 }
71
72 return error;
73 }
74
75 void OptionParsingStarting(ExecutionContext *execution_context) override {
77 }
78
79 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
80 return llvm::ArrayRef(g_scripting_run_options);
81 }
82
84 };
85
86protected:
87 void DoExecute(llvm::StringRef command,
88 CommandReturnObject &result) override {
89 // Try parsing the language option but when the command contains a raw part
90 // separated by the -- delimiter.
91 OptionsWithRaw raw_args(command);
92 if (raw_args.HasArgs()) {
93 if (!ParseOptions(raw_args.GetArgs(), result))
94 return;
95 command = raw_args.GetRawPart();
96 }
97
98 lldb::ScriptLanguage language =
100 ? m_interpreter.GetDebugger().GetScriptLanguage()
101 : m_options.language;
102
103 if (language == lldb::eScriptLanguageNone) {
104 result.AppendError(
105 "the script-lang setting is set to none - scripting not available");
106 return;
107 }
108
109 ScriptInterpreter *script_interpreter =
110 GetDebugger().GetScriptInterpreter(true, language);
111
112 if (script_interpreter == nullptr) {
113 result.AppendError("no script interpreter");
114 return;
115 }
116
117 // Script might change Python code we use for formatting. Make sure we keep
118 // up to date with it.
120
121 if (command.empty()) {
122 script_interpreter->ExecuteInterpreterLoop();
124 return;
125 }
126
127 // We can do better when reporting the status of one-liner script execution.
128 if (script_interpreter->ExecuteOneLine(command, &result))
130 else
132 }
133
134private:
136};
137
138#define LLDB_OPTIONS_scripting_extension_list
139#include "CommandOptions.inc"
140
142public:
145 interpreter, "scripting extension list",
146 "List the available scripting extension templates, or with "
147 "--instances, the instantiated scripting extensions grouped by "
148 "class.",
149 "scripting extension list [--language <scripting-language>] "
150 "[--json] [--instances] [<extension-name> ...]") {
152 }
153
155
156 Options *GetOptions() override { return &m_options; }
157
158 void
165
166 class CommandOptions : public Options {
167 public:
168 CommandOptions() = default;
169 ~CommandOptions() override = default;
170 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
171 ExecutionContext *execution_context) override {
173 const int short_option = m_getopt_table[option_idx].val;
174
175 switch (short_option) {
176 case 'l':
178 option_arg, GetDefinitions()[option_idx].enum_values,
180 if (!error.Success())
182 "unrecognized value for language '{0}'", option_arg);
183 break;
184 case 'j':
185 m_json_format = true;
186 break;
187 case 'i':
188 m_instances = true;
189 break;
190 default:
191 llvm_unreachable("Unimplemented option");
192 }
193
194 return error;
195 }
196
197 void OptionParsingStarting(ExecutionContext *execution_context) override {
199 m_json_format = false;
200 m_instances = false;
201 }
202
203 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
204 return llvm::ArrayRef(g_scripting_extension_list_options);
205 }
206
208 bool m_json_format = false;
209 bool m_instances = false;
210 };
211
212protected:
213 void DoExecute(Args &command, CommandReturnObject &result) override {
214 if (m_options.m_instances) {
215 ListInstances(command, result);
216 return;
217 }
218
219 llvm::StringMap<std::vector<size_t>> grouped_by_extension;
220 for (size_t i = 0; i < PluginManager::GetNumScriptedInterfaces(); i++) {
221 lldb::ScriptedExtension extension =
223 if (extension == eScriptedExtensionInvalid)
224 continue;
225
226 llvm::StringLiteral extension_name =
228 if (grouped_by_extension.contains(extension_name))
229 grouped_by_extension[extension_name].push_back(i);
230 else
231 grouped_by_extension[extension_name] = {i};
232 }
233
234 if (command.GetArgumentCount() > 0) {
235 llvm::StringMap<std::vector<size_t>> filtered;
236 for (const Args::ArgEntry &arg : command.entries()) {
237 lldb::ScriptedExtension extension =
239 if (extension == eScriptedExtensionInvalid) {
240 result.AppendErrorWithFormat("no scripted extension named '%s'",
241 arg.c_str());
242 return;
243 }
244 llvm::StringLiteral extension_name =
246 auto it = grouped_by_extension.find(extension_name);
247 if (it != grouped_by_extension.end())
248 filtered[extension_name] = it->second;
249 }
250 grouped_by_extension = std::move(filtered);
251 }
252
253 if (m_options.m_json_format)
254 OutputJsonFormat(grouped_by_extension, result);
255 else
256 OutputTextFormat(grouped_by_extension, result);
257 }
258
259private:
260 static std::string GetSeparator(const Debugger &debugger, bool use_color) {
262 use_color) +
263 std::string(std::min<uint64_t>(debugger.GetTerminalWidth(), 80),
264 '-') +
266 use_color);
267 }
268
269 void ListInstances(Args &command, CommandReturnObject &result) {
270 std::vector<lldb::ScriptedExtension> extensions;
271 for (const Args::ArgEntry &arg : command.entries()) {
272 lldb::ScriptedExtension extension =
274 if (extension == eScriptedExtensionInvalid) {
275 result.AppendErrorWithFormat("no scripted extension named '%s'",
276 arg.c_str());
277 return;
278 }
279 extensions.push_back(extension);
280 }
281
282 std::vector<ScriptedInstanceGroup> groups;
283 if (ScriptInterpreter *script_interpreter =
284 GetDebugger().GetScriptInterpreter(/*can_create=*/false,
285 m_options.m_language))
286 groups =
287 script_interpreter->GetScriptedInstanceRegistry()->GetInstanceGroups(
288 extensions);
289
290 if (m_options.m_json_format) {
291 StructuredData::Array groups_array;
292 for (const ScriptedInstanceGroup &group : groups)
293 groups_array.AddItem(group.ToStructuredData());
294 groups_array.Dump(result.GetOutputStream());
295 result.GetOutputStream().EOL();
297 return;
298 }
299
300 Stream &s = result.GetOutputStream();
301 const bool use_color = s.AsRawOstream().colors_enabled();
302 const Debugger &debugger = GetDebugger();
303 const std::string separator = GetSeparator(debugger, use_color);
304
305 s.PutCString("Instantiated scripted extensions:");
306 if (groups.empty())
307 s << " None";
308 s.EOL();
309 for (const ScriptedInstanceGroup &group : groups) {
310 s << separator << '\n';
311 group.Dump(s, debugger, use_color);
312 }
314 }
315
316 std::vector<std::string>
317 GetLanguagesForExtension(const std::vector<size_t> &indices) {
318 std::vector<std::string> languages;
319 for (const size_t idx : indices) {
322 if (lang != m_options.m_language)
323 continue;
324 languages.push_back(ScriptInterpreter::LanguageToString(lang));
325 }
326 return languages;
327 }
328
330 const llvm::StringMap<std::vector<size_t>> &grouped_by_extension,
331 CommandReturnObject &result) {
332 llvm::json::Array extensions;
333 for (const auto &extension_pair : grouped_by_extension) {
334 // llvm::json::Value's StringRef constructor does not copy the
335 // underlying characters, so every string handed to the JSON structure
336 // below must be an owned std::string -- otherwise it dangles by the
337 // time the object tree is serialized at the end of this function.
338 llvm::json::Array languages;
339 for (const std::string &lang :
340 GetLanguagesForExtension(extension_pair.second))
341 languages.push_back(lang);
342 if (languages.empty())
343 continue;
344
345 llvm::StringRef desc =
347 extension_pair.second[0]);
350 extension_pair.second[0]);
351
352 llvm::json::Array api_usages;
353 for (llvm::StringRef usage : usages.GetSBAPIUsages())
354 api_usages.push_back(usage.str());
355
356 llvm::json::Array cmd_usages;
357 for (llvm::StringRef usage : usages.GetCommandInterpreterUsages())
358 cmd_usages.push_back(usage.str());
359
360 extensions.push_back(llvm::json::Object{
361 {"name", extension_pair.first().str()},
362 {"description", desc.str()},
363 {"languages", std::move(languages)},
364 {"api_usages", std::move(api_usages)},
365 {"command_interpreter_usages", std::move(cmd_usages)},
366 });
367 }
368
369 std::string str;
370 llvm::raw_string_ostream os(str);
371 os << llvm::formatv("{0:2}", llvm::json::Value(std::move(extensions)));
372 result.AppendMessage(str);
374 }
375
377 const llvm::StringMap<std::vector<size_t>> &grouped_by_extension,
378 CommandReturnObject &result) {
379 Stream &s = result.GetOutputStream();
380 const bool use_color = s.AsRawOstream().colors_enabled();
381 const Debugger &debugger = GetDebugger();
382 auto ansi_code = [use_color](llvm::StringRef code) {
383 return ansi::FormatAnsiTerminalCodes(code, use_color);
384 };
385 const std::string label_prefix = ansi_code(debugger.GetLabelAnsiPrefix());
386 const std::string label_suffix = ansi_code(debugger.GetLabelAnsiSuffix());
387 const std::string title_prefix = ansi_code(debugger.GetTitleAnsiPrefix());
388 const std::string title_suffix = ansi_code(debugger.GetTitleAnsiSuffix());
389 const std::string separator = GetSeparator(debugger, use_color);
390
391 s.PutCString("Available scripted extension templates:");
392
393 auto print_field = [&](llvm::StringRef key, llvm::StringRef value,
394 bool is_title = false) {
395 if (value.empty())
396 return;
397 s.IndentMore();
398 s.Indent();
399 s << label_prefix << key << ": " << label_suffix;
400 if (is_title)
401 s << title_prefix << value << title_suffix;
402 else
403 s << value;
404 s << '\n';
405 s.IndentLess();
406 };
407
408 size_t num_listed_interface = 0;
409 for (const auto &extension_pair : grouped_by_extension) {
410 std::vector<std::string> languages =
411 GetLanguagesForExtension(extension_pair.second);
412 if (languages.empty())
413 continue;
414 num_listed_interface++;
415
416 s.EOL();
417 s << separator;
418 s.EOL();
419
420 llvm::StringRef desc =
422 extension_pair.second[0]);
425 extension_pair.second[0]);
426
427 print_field("Name", extension_pair.first(), /*is_title=*/true);
428 print_field("Description", desc);
429 print_field("Language", llvm::join(languages, ""));
430 usages.Dump(s, ScriptedInterfaceUsages::UsageKind::API, use_color);
432 use_color);
433 }
434
435 if (!num_listed_interface)
436 s << " None\n";
437
439 }
440
441private:
443};
444
445#define LLDB_OPTIONS_scripting_extension_generate
446#include "CommandOptions.inc"
447
449public:
451 : CommandObjectParsed(interpreter, "scripting extension generate",
452 "Generate a scripting extension template. ",
453 "scripting extension generate") {
455 }
456
458
459 Options *GetOptions() override { return &m_options; }
460
461 class CommandOptions : public Options {
462 public:
463 CommandOptions() = default;
464 ~CommandOptions() override = default;
465 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
466 ExecutionContext *execution_context) override {
468 const char short_option =
469 g_scripting_extension_generate_options[option_idx].short_option;
470
471 switch (short_option) {
472 case 'a':
474 break;
475 case 'l':
477 option_arg, GetDefinitions()[option_idx].enum_values,
479 if (!error.Success())
481 "unrecognized value for language '{0}'", option_arg);
482 break;
483 case 'n':
484 m_generated_class_prefix = option_arg.str();
485 break;
486 case 'o':
487 m_output_filepath = option_arg.str();
488 break;
489 case 'e': {
490 bool success;
491 m_open_editor = OptionArgParser::ToBoolean(option_arg, true, &success)
493 : eLazyBoolNo;
494 if (!success)
496 "invalid boolean value for -e: '{0}'", option_arg);
497 } break;
498 default:
499 llvm_unreachable("Unimplemented option");
500 }
501
502 return error;
503 }
504
512
513 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
514 return llvm::ArrayRef(g_scripting_extension_generate_options);
515 }
516
520 std::string m_output_filepath;
522 };
523
524 void
526 OptionElementVector &opt_element_vector) override {
527 // If `-l <lang>` was already given, complete only extensions available
528 // in that language. Bare `-l` (no value yet) and any parse failures
529 // fall back to language-agnostic completion.
531 llvm::ArrayRef<OptionDefinition> defs = m_options.GetDefinitions();
532 for (const OptionArgElement &elem : opt_element_vector) {
533 if (elem.opt_defs_index < 0 ||
534 static_cast<size_t>(elem.opt_defs_index) >= defs.size())
535 continue;
536 if (defs[elem.opt_defs_index].short_option != 'l' ||
537 elem.opt_arg_pos <= 0)
538 continue;
539 llvm::StringRef value =
540 request.GetParsedLine().GetArgumentAtIndex(elem.opt_arg_pos);
542 auto candidate =
544 value, defs[elem.opt_defs_index].enum_values,
546 if (error.Success())
547 language = candidate;
548 break;
549 }
551 request.GetCursorArgumentPrefix(), request, language);
554 }
555
556protected:
557 void DoExecute(Args &command, CommandReturnObject &result) override {
558 if (command.GetArgumentCount() == 0) {
559 result.SetError(
560 Status::FromErrorString("specify extension name to generate"));
561 return;
562 }
563
564 std::vector<ScriptInterpreter::ExtensionTemplateRequest> extension_requests;
565
566 for (size_t i = 0; i < command.GetArgumentCount(); i++) {
567 llvm::StringRef extension_name = command.GetArgumentAtIndex(i);
568 llvm::SmallVector<llvm::StringRef> extension_components;
569 extension_name.split(extension_components, ".");
570 lldb::ScriptedExtension extension =
571 ScriptInterpreter::StringToExtension(extension_components.back());
572 if (extension == eScriptedExtensionInvalid) {
574 "unknown scripted extension: '{0}'", extension_name));
575 return;
576 }
577 extension_requests.push_back({extension_name, extension_components});
578 }
579
580 lldb::ScriptLanguage language =
582 ? m_interpreter.GetDebugger().GetScriptLanguage()
583 : m_options.m_language;
584
585 if (language == lldb::eScriptLanguageNone) {
586 result.AppendError(
587 "the script-lang setting is set to none - scripting not available");
588 return;
589 }
590
591 ScriptInterpreter *script_interpreter =
592 GetDebugger().GetScriptInterpreter(true, language);
593
594 if (script_interpreter == nullptr) {
595 result.AppendError("no script interpreter");
596 return;
597 }
598
599 auto generated_file_or_err = script_interpreter->GenerateExtensionTemplate(
600 m_options.m_generated_class_prefix, extension_requests,
601 m_options.m_generate_non_abstract_methods, m_options.m_output_filepath);
602 if (!generated_file_or_err) {
603 result.SetError(generated_file_or_err.takeError());
604 return;
605 }
606
607 bool should_open_editor = false;
608 switch (m_options.m_open_editor) {
609 case eLazyBoolYes:
610 should_open_editor = true;
611 break;
612 case eLazyBoolNo:
613 should_open_editor = false;
614 break;
616 should_open_editor = result.GetInteractive();
617 break;
618 }
619
620 if (should_open_editor) {
621 if (llvm::Error err = Host::OpenFileInExternalEditor(
622 "", *generated_file_or_err, 1, true)) {
623 LLDB_LOG_ERROR(GetLog(LLDBLog::Host), std::move(err),
624 "OpenFileInExternalEditor failed: {0}");
625 }
626 }
628 "Generated scripting extension template: {0}",
629 generated_file_or_err->GetPath());
631 }
632
633private:
635};
636
638public:
641 interpreter, "scripting extension",
642 "Commands for operating on the scripting extensions.",
643 "scripting extension [<subcommand-options>]") {
645 "list",
647 LoadSubCommand("generate",
649 interpreter)));
650 }
651
653};
654
656 CommandInterpreter &interpreter)
658 interpreter, "scripting",
659 "Commands for operating on the scripting functionalities.",
660 "scripting <subcommand> [<subcommand-options>]") {
661 LoadSubCommand("run",
663 LoadSubCommand("extension",
665 interpreter)));
666}
667
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG_ERROR(log, error,...)
Definition Log.h:405
CommandObjectMultiwordScriptingExtension(CommandInterpreter &interpreter)
~CommandObjectMultiwordScriptingExtension() override=default
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
~CommandObjectScriptingExtensionGenerate() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
CommandObjectScriptingExtensionGenerate(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
void DoExecute(Args &command, CommandReturnObject &result) override
std::vector< std::string > GetLanguagesForExtension(const std::vector< size_t > &indices)
void OutputJsonFormat(const llvm::StringMap< std::vector< size_t > > &grouped_by_extension, CommandReturnObject &result)
~CommandObjectScriptingExtensionList() override=default
void OutputTextFormat(const llvm::StringMap< std::vector< size_t > > &grouped_by_extension, CommandReturnObject &result)
static std::string GetSeparator(const Debugger &debugger, bool use_color)
void ListInstances(Args &command, CommandReturnObject &result)
CommandObjectScriptingExtensionList(CommandInterpreter &interpreter)
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
CommandObjectScriptingRun(CommandInterpreter &interpreter)
void DoExecute(llvm::StringRef command, CommandReturnObject &result) override
~CommandObjectScriptingRun() override=default
A command line argument class.
Definition Args.h:33
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition Args.h:120
llvm::ArrayRef< ArgEntry > entries() const
Definition Args.h:132
const char * GetArgumentAtIndex(size_t idx) const
Gets the null-terminated C string argument pointer for the argument at index idx.
Definition Args.cpp:273
static bool InvokeCommonCompletionCallbacks(CommandInterpreter &interpreter, uint32_t completion_mask, lldb_private::CompletionRequest &request, SearchFilter *searcher)
CommandObjectMultiwordScripting(CommandInterpreter &interpreter)
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandObjectMultiword(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
CommandObjectParsed(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
CommandObjectRaw(CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help="", llvm::StringRef syntax="", uint32_t flags=0)
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
CommandInterpreter & GetCommandInterpreter()
CommandInterpreter & m_interpreter
bool ParseOptions(Args &args, CommandReturnObject &result)
void AppendMessage(llvm::StringRef in_string)
void AppendError(llvm::StringRef in_string)
void SetStatus(lldb::ReturnStatus status)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
void void AppendMessageWithFormatv(const char *format, Args &&...args)
"lldb/Utility/ArgCompletionRequest.h"
llvm::StringRef GetCursorArgumentPrefix() const
A class to manage flag bits.
Definition Debugger.h:103
llvm::StringRef GetLabelAnsiSuffix() const
Definition Debugger.cpp:587
llvm::StringRef GetDividerAnsiPrefix() const
Definition Debugger.cpp:605
uint64_t GetTerminalWidth() const
Definition Debugger.cpp:480
llvm::StringRef GetDividerAnsiSuffix() const
Definition Debugger.cpp:611
llvm::StringRef GetTitleAnsiPrefix() const
Definition Debugger.cpp:593
llvm::StringRef GetTitleAnsiSuffix() const
Definition Debugger.cpp:599
llvm::StringRef GetLabelAnsiPrefix() const
Definition Debugger.cpp:581
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, std::optional< lldb::ScriptLanguage > language={})
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
static llvm::Error OpenFileInExternalEditor(llvm::StringRef editor, const FileSpec &file_spec, uint32_t line_no, bool foreground=false)
A pair of an option list with a 'raw' string as a suffix.
Definition Args.h:319
bool HasArgs() const
Returns true if there are any arguments before the raw suffix.
Definition Args.h:330
Args & GetArgs()
Returns the list of arguments.
Definition Args.h:335
const std::string & GetRawPart() const
Returns the raw suffix part of the parsed string.
Definition Args.h:368
A command line option parsing protocol class.
Definition Options.h:58
std::vector< Option > m_getopt_table
Definition Options.h:198
static void AutoCompleteScriptedExtension(llvm::StringRef partial_name, CompletionRequest &request, lldb::ScriptLanguage language=lldb::eScriptLanguageUnknown)
static lldb::ScriptLanguage GetScriptedInterfaceLanguageAtIndex(uint32_t idx)
static size_t GetNumScriptedInterfaces()
static lldb::ScriptedExtension GetScriptedInterfaceExtensionAtIndex(uint32_t idx)
static llvm::StringRef GetScriptedInterfaceDescriptionAtIndex(uint32_t idx)
static ScriptedInterfaceUsages GetScriptedInterfaceUsagesAtIndex(uint32_t idx)
virtual llvm::Expected< FileSpec > GenerateExtensionTemplate(const std::string &name, std::vector< ExtensionTemplateRequest > &extensions, bool generate_non_abstract_methods, std::string output_file)
virtual void ExecuteInterpreterLoop()=0
static llvm::StringLiteral ExtensionToString(lldb::ScriptedExtension extension)
static lldb::ScriptedExtension StringToExtension(llvm::StringRef string)
virtual bool ExecuteOneLine(llvm::StringRef command, CommandReturnObject *result, const ExecuteScriptOptions &options=ExecuteScriptOptions())=0
static std::string LanguageToString(lldb::ScriptLanguage language)
void Dump(Stream &s, UsageKind kind, bool use_color=false) const
const std::vector< llvm::StringRef > & GetCommandInterpreterUsages() const
const std::vector< llvm::StringRef > & GetSBAPIUsages() const
An error handling class.
Definition Status.h:118
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition Status.cpp:106
static Status FromErrorString(const char *str)
Definition Status.h:141
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
Definition Status.h:151
A stream class that can stream formatted output to a file.
Definition Stream.h:28
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition Stream.h:405
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition Stream.cpp:157
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition Stream.cpp:63
size_t EOL()
Output and End of Line character to the stream.
Definition Stream.cpp:155
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition Stream.cpp:204
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition Stream.cpp:201
void AddItem(const ObjectSP &item)
void Dump(lldb_private::Stream &s, bool pretty_print=true) const
std::string FormatAnsiTerminalCodes(llvm::StringRef format, bool do_color=true)
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:338
std::vector< OptionArgElement > OptionElementVector
Definition Options.h:43
@ eScriptedExtensionCompletion
ScriptLanguage
Script interpreter types.
@ eScriptLanguageUnknown
@ eScriptLanguageDefault
@ eScriptLanguageNone
ScriptedExtension
Scripting extension types.
@ eScriptedExtensionInvalid
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
@ eReturnStatusFailed
@ eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishNoResult
@ eArgTypeScriptedExtension
static int64_t ToOptionEnum(llvm::StringRef s, const OptionEnumValues &enum_values, int32_t fail_value, Status &error)
static bool ToBoolean(llvm::StringRef s, bool fail_value, bool *success_ptr)
The live instances of one extension class.