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 if (llvm::Error error = script_interpreter->ExecuteInterpreterLoop())
123 result.SetError(std::move(error));
124 else
126 return;
127 }
128
129 // We can do better when reporting the status of one-liner script execution.
130 if (script_interpreter->ExecuteOneLine(command, &result))
132 else
134 }
135
136private:
138};
139
140#define LLDB_OPTIONS_scripting_extension_list
141#include "CommandOptions.inc"
142
144public:
147 interpreter, "scripting extension list",
148 "List the available scripting extension templates, or with "
149 "--instances, the instantiated scripting extensions grouped by "
150 "class.",
151 "scripting extension list [--language <scripting-language>] "
152 "[--json] [--instances] [<extension-name> ...]") {
154 }
155
157
158 Options *GetOptions() override { return &m_options; }
159
160 void
167
168 class CommandOptions : public Options {
169 public:
170 CommandOptions() = default;
171 ~CommandOptions() override = default;
172 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
173 ExecutionContext *execution_context) override {
175 const int short_option = m_getopt_table[option_idx].val;
176
177 switch (short_option) {
178 case 'l':
180 option_arg, GetDefinitions()[option_idx].enum_values,
182 if (!error.Success())
184 "unrecognized value for language '{0}'", option_arg);
185 break;
186 case 'j':
187 m_json_format = true;
188 break;
189 case 'i':
190 m_instances = true;
191 break;
192 default:
193 llvm_unreachable("Unimplemented option");
194 }
195
196 return error;
197 }
198
199 void OptionParsingStarting(ExecutionContext *execution_context) override {
201 m_json_format = false;
202 m_instances = false;
203 }
204
205 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
206 return llvm::ArrayRef(g_scripting_extension_list_options);
207 }
208
210 bool m_json_format = false;
211 bool m_instances = false;
212 };
213
214protected:
215 void DoExecute(Args &command, CommandReturnObject &result) override {
216 if (m_options.m_instances) {
217 ListInstances(command, result);
218 return;
219 }
220
221 llvm::StringMap<std::vector<size_t>> grouped_by_extension;
222 for (size_t i = 0; i < PluginManager::GetNumScriptedInterfaces(); i++) {
223 lldb::ScriptedExtension extension =
225 if (extension == eScriptedExtensionInvalid)
226 continue;
227
228 llvm::StringLiteral extension_name =
230 if (grouped_by_extension.contains(extension_name))
231 grouped_by_extension[extension_name].push_back(i);
232 else
233 grouped_by_extension[extension_name] = {i};
234 }
235
236 if (command.GetArgumentCount() > 0) {
237 llvm::StringMap<std::vector<size_t>> filtered;
238 for (const Args::ArgEntry &arg : command.entries()) {
239 lldb::ScriptedExtension extension =
241 if (extension == eScriptedExtensionInvalid) {
242 result.AppendErrorWithFormat("no scripted extension named '%s'",
243 arg.c_str());
244 return;
245 }
246 llvm::StringLiteral extension_name =
248 auto it = grouped_by_extension.find(extension_name);
249 if (it != grouped_by_extension.end())
250 filtered[extension_name] = it->second;
251 }
252 grouped_by_extension = std::move(filtered);
253 }
254
255 if (m_options.m_json_format)
256 OutputJsonFormat(grouped_by_extension, result);
257 else
258 OutputTextFormat(grouped_by_extension, result);
259 }
260
261private:
262 static std::string GetSeparator(const Debugger &debugger, bool use_color) {
264 use_color) +
265 std::string(std::min<uint64_t>(debugger.GetTerminalWidth(), 80),
266 '-') +
268 use_color);
269 }
270
271 void ListInstances(Args &command, CommandReturnObject &result) {
272 std::vector<lldb::ScriptedExtension> extensions;
273 for (const Args::ArgEntry &arg : command.entries()) {
274 lldb::ScriptedExtension extension =
276 if (extension == eScriptedExtensionInvalid) {
277 result.AppendErrorWithFormat("no scripted extension named '%s'",
278 arg.c_str());
279 return;
280 }
281 extensions.push_back(extension);
282 }
283
284 std::vector<ScriptedInstanceGroup> groups;
285 if (ScriptInterpreter *script_interpreter =
286 GetDebugger().GetScriptInterpreter(/*can_create=*/false,
287 m_options.m_language))
288 groups =
289 script_interpreter->GetScriptedInstanceRegistry()->GetInstanceGroups(
290 extensions);
291
292 if (m_options.m_json_format) {
293 StructuredData::Array groups_array;
294 for (const ScriptedInstanceGroup &group : groups)
295 groups_array.AddItem(group.ToStructuredData());
296 groups_array.Dump(result.GetOutputStream());
297 result.GetOutputStream().EOL();
299 return;
300 }
301
302 Stream &s = result.GetOutputStream();
303 const bool use_color = s.AsRawOstream().colors_enabled();
304 const Debugger &debugger = GetDebugger();
305 const std::string separator = GetSeparator(debugger, use_color);
306
307 s.PutCString("Instantiated scripted extensions:");
308 if (groups.empty())
309 s << " None";
310 s.EOL();
311 for (const ScriptedInstanceGroup &group : groups) {
312 s << separator << '\n';
313 group.Dump(s, debugger, use_color);
314 }
316 }
317
318 std::vector<std::string>
319 GetLanguagesForExtension(const std::vector<size_t> &indices) {
320 std::vector<std::string> languages;
321 for (const size_t idx : indices) {
324 if (lang != m_options.m_language)
325 continue;
326 languages.push_back(ScriptInterpreter::LanguageToString(lang));
327 }
328 return languages;
329 }
330
332 const llvm::StringMap<std::vector<size_t>> &grouped_by_extension,
333 CommandReturnObject &result) {
334 llvm::json::Array extensions;
335 for (const auto &extension_pair : grouped_by_extension) {
336 // llvm::json::Value's StringRef constructor does not copy the
337 // underlying characters, so every string handed to the JSON structure
338 // below must be an owned std::string -- otherwise it dangles by the
339 // time the object tree is serialized at the end of this function.
340 llvm::json::Array languages;
341 for (const std::string &lang :
342 GetLanguagesForExtension(extension_pair.second))
343 languages.push_back(lang);
344 if (languages.empty())
345 continue;
346
347 llvm::StringRef desc =
349 extension_pair.second[0]);
352 extension_pair.second[0]);
353
354 llvm::json::Array api_usages;
355 for (llvm::StringRef usage : usages.GetSBAPIUsages())
356 api_usages.push_back(usage.str());
357
358 llvm::json::Array cmd_usages;
359 for (llvm::StringRef usage : usages.GetCommandInterpreterUsages())
360 cmd_usages.push_back(usage.str());
361
362 extensions.push_back(llvm::json::Object{
363 {"name", extension_pair.first().str()},
364 {"description", desc.str()},
365 {"languages", std::move(languages)},
366 {"api_usages", std::move(api_usages)},
367 {"command_interpreter_usages", std::move(cmd_usages)},
368 });
369 }
370
371 std::string str;
372 llvm::raw_string_ostream os(str);
373 os << llvm::formatv("{0:2}", llvm::json::Value(std::move(extensions)));
374 result.AppendMessage(str);
376 }
377
379 const llvm::StringMap<std::vector<size_t>> &grouped_by_extension,
380 CommandReturnObject &result) {
381 Stream &s = result.GetOutputStream();
382 const bool use_color = s.AsRawOstream().colors_enabled();
383 const Debugger &debugger = GetDebugger();
384 auto ansi_code = [use_color](llvm::StringRef code) {
385 return ansi::FormatAnsiTerminalCodes(code, use_color);
386 };
387 const std::string label_prefix = ansi_code(debugger.GetLabelAnsiPrefix());
388 const std::string label_suffix = ansi_code(debugger.GetLabelAnsiSuffix());
389 const std::string title_prefix = ansi_code(debugger.GetTitleAnsiPrefix());
390 const std::string title_suffix = ansi_code(debugger.GetTitleAnsiSuffix());
391 const std::string separator = GetSeparator(debugger, use_color);
392
393 s.PutCString("Available scripted extension templates:");
394
395 auto print_field = [&](llvm::StringRef key, llvm::StringRef value,
396 bool is_title = false) {
397 if (value.empty())
398 return;
399 s.IndentMore();
400 s.Indent();
401 s << label_prefix << key << ": " << label_suffix;
402 if (is_title)
403 s << title_prefix << value << title_suffix;
404 else
405 s << value;
406 s << '\n';
407 s.IndentLess();
408 };
409
410 size_t num_listed_interface = 0;
411 for (const auto &extension_pair : grouped_by_extension) {
412 std::vector<std::string> languages =
413 GetLanguagesForExtension(extension_pair.second);
414 if (languages.empty())
415 continue;
416 num_listed_interface++;
417
418 s.EOL();
419 s << separator;
420 s.EOL();
421
422 llvm::StringRef desc =
424 extension_pair.second[0]);
427 extension_pair.second[0]);
428
429 print_field("Name", extension_pair.first(), /*is_title=*/true);
430 print_field("Description", desc);
431 print_field("Language", llvm::join(languages, ""));
432 usages.Dump(s, ScriptedInterfaceUsages::UsageKind::API, use_color);
434 use_color);
435 }
436
437 if (!num_listed_interface)
438 s << " None\n";
439
441 }
442
443private:
445};
446
447#define LLDB_OPTIONS_scripting_extension_generate
448#include "CommandOptions.inc"
449
451public:
453 : CommandObjectParsed(interpreter, "scripting extension generate",
454 "Generate a scripting extension template. ",
455 "scripting extension generate") {
457 }
458
460
461 Options *GetOptions() override { return &m_options; }
462
463 class CommandOptions : public Options {
464 public:
465 CommandOptions() = default;
466 ~CommandOptions() override = default;
467 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
468 ExecutionContext *execution_context) override {
470 const char short_option =
471 g_scripting_extension_generate_options[option_idx].short_option;
472
473 switch (short_option) {
474 case 'a':
476 break;
477 case 'l':
479 option_arg, GetDefinitions()[option_idx].enum_values,
481 if (!error.Success())
483 "unrecognized value for language '{0}'", option_arg);
484 break;
485 case 'n':
486 m_generated_class_prefix = option_arg.str();
487 break;
488 case 'o':
489 m_output_filepath = option_arg.str();
490 break;
491 case 'e': {
492 bool success;
493 m_open_editor = OptionArgParser::ToBoolean(option_arg, true, &success)
495 : eLazyBoolNo;
496 if (!success)
498 "invalid boolean value for -e: '{0}'", option_arg);
499 } break;
500 default:
501 llvm_unreachable("Unimplemented option");
502 }
503
504 return error;
505 }
506
514
515 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
516 return llvm::ArrayRef(g_scripting_extension_generate_options);
517 }
518
522 std::string m_output_filepath;
524 };
525
526 void
528 OptionElementVector &opt_element_vector) override {
529 // If `-l <lang>` was already given, complete only extensions available
530 // in that language. Bare `-l` (no value yet) and any parse failures
531 // fall back to language-agnostic completion.
533 llvm::ArrayRef<OptionDefinition> defs = m_options.GetDefinitions();
534 for (const OptionArgElement &elem : opt_element_vector) {
535 if (elem.opt_defs_index < 0 ||
536 static_cast<size_t>(elem.opt_defs_index) >= defs.size())
537 continue;
538 if (defs[elem.opt_defs_index].short_option != 'l' ||
539 elem.opt_arg_pos <= 0)
540 continue;
541 llvm::StringRef value =
542 request.GetParsedLine().GetArgumentAtIndex(elem.opt_arg_pos);
544 auto candidate =
546 value, defs[elem.opt_defs_index].enum_values,
548 if (error.Success())
549 language = candidate;
550 break;
551 }
553 request.GetCursorArgumentPrefix(), request, language);
556 }
557
558protected:
559 void DoExecute(Args &command, CommandReturnObject &result) override {
560 if (command.GetArgumentCount() == 0) {
561 result.SetError(
562 Status::FromErrorString("specify extension name to generate"));
563 return;
564 }
565
566 std::vector<ScriptInterpreter::ExtensionTemplateRequest> extension_requests;
567
568 for (size_t i = 0; i < command.GetArgumentCount(); i++) {
569 llvm::StringRef extension_name = command.GetArgumentAtIndex(i);
570 llvm::SmallVector<llvm::StringRef> extension_components;
571 extension_name.split(extension_components, ".");
572 lldb::ScriptedExtension extension =
573 ScriptInterpreter::StringToExtension(extension_components.back());
574 if (extension == eScriptedExtensionInvalid) {
576 "unknown scripted extension: '{0}'", extension_name));
577 return;
578 }
579 extension_requests.push_back({extension_name, extension_components});
580 }
581
582 lldb::ScriptLanguage language =
584 ? m_interpreter.GetDebugger().GetScriptLanguage()
585 : m_options.m_language;
586
587 if (language == lldb::eScriptLanguageNone) {
588 result.AppendError(
589 "the script-lang setting is set to none - scripting not available");
590 return;
591 }
592
593 ScriptInterpreter *script_interpreter =
594 GetDebugger().GetScriptInterpreter(true, language);
595
596 if (script_interpreter == nullptr) {
597 result.AppendError("no script interpreter");
598 return;
599 }
600
601 auto generated_file_or_err = script_interpreter->GenerateExtensionTemplate(
602 m_options.m_generated_class_prefix, extension_requests,
603 m_options.m_generate_non_abstract_methods, m_options.m_output_filepath);
604 if (!generated_file_or_err) {
605 result.SetError(generated_file_or_err.takeError());
606 return;
607 }
608
609 bool should_open_editor = false;
610 switch (m_options.m_open_editor) {
611 case eLazyBoolYes:
612 should_open_editor = true;
613 break;
614 case eLazyBoolNo:
615 should_open_editor = false;
616 break;
618 should_open_editor = result.GetInteractive();
619 break;
620 }
621
622 if (should_open_editor) {
623 if (llvm::Error err = Host::OpenFileInExternalEditor(
624 "", *generated_file_or_err, 1, true)) {
625 LLDB_LOG_ERROR(GetLog(LLDBLog::Host), std::move(err),
626 "OpenFileInExternalEditor failed: {0}");
627 }
628 }
630 "Generated scripting extension template: {0}",
631 generated_file_or_err->GetPath());
633 }
634
635private:
637};
638
640public:
643 interpreter, "scripting extension",
644 "Commands for operating on the scripting extensions.",
645 "scripting extension [<subcommand-options>]") {
647 "list",
649 LoadSubCommand("generate",
651 interpreter)));
652 }
653
655};
656
658 CommandInterpreter &interpreter)
660 interpreter, "scripting",
661 "Commands for operating on the scripting functionalities.",
662 "scripting <subcommand> [<subcommand-options>]") {
663 LoadSubCommand("run",
665 LoadSubCommand("extension",
667 interpreter)));
668}
669
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:106
llvm::StringRef GetLabelAnsiSuffix() const
Definition Debugger.cpp:588
llvm::StringRef GetDividerAnsiPrefix() const
Definition Debugger.cpp:606
uint64_t GetTerminalWidth() const
Definition Debugger.cpp:481
llvm::StringRef GetDividerAnsiSuffix() const
Definition Debugger.cpp:612
llvm::StringRef GetTitleAnsiPrefix() const
Definition Debugger.cpp:594
llvm::StringRef GetTitleAnsiSuffix() const
Definition Debugger.cpp:600
llvm::StringRef GetLabelAnsiPrefix() const
Definition Debugger.cpp:582
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)
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)
virtual llvm::Error ExecuteInterpreterLoop()=0
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.