LLDB  mainline
CommandObjectExpression.cpp
Go to the documentation of this file.
1 //===-- CommandObjectExpression.cpp -----------------------------*- C++ -*-===//
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 
9 #include "llvm/ADT/STLExtras.h"
10 #include "llvm/ADT/StringRef.h"
11 
14 #include "lldb/Core/Debugger.h"
15 #include "lldb/Core/Value.h"
19 #include "lldb/Expression/REPL.h"
21 #include "lldb/Host/Host.h"
22 #include "lldb/Host/OptionParser.h"
26 #include "lldb/Symbol/ObjectFile.h"
27 #include "lldb/Symbol/Variable.h"
28 #include "lldb/Target/Language.h"
29 #include "lldb/Target/Process.h"
30 #include "lldb/Target/StackFrame.h"
31 #include "lldb/Target/Target.h"
32 #include "lldb/Target/Thread.h"
33 
34 using namespace lldb;
35 using namespace lldb_private;
36 
37 CommandObjectExpression::CommandOptions::CommandOptions() : OptionGroup() {}
38 
40 
41 static constexpr OptionEnumValueElement g_description_verbosity_type[] = {
43  "Only show the description string"},
45  "Show the full output, including persistent variable's name and type"} };
46 
47 static constexpr OptionEnumValues DescriptionVerbosityTypes() {
48  return OptionEnumValues(g_description_verbosity_type);
49 }
50 
51 static constexpr OptionDefinition g_expression_options[] = {
52  // clang-format off
53  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "all-threads", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Should we run all threads if the execution doesn't complete on one thread."},
54  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "ignore-breakpoints", 'i', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Ignore breakpoint hits while running expressions"},
55  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "timeout", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeUnsignedInteger, "Timeout value (in microseconds) for running the expression."},
56  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error", 'u', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, or raises a signal. "
57  "Note, unlike gdb hitting a breakpoint is controlled by another option (-i)."},
58  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "debug", 'g', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "When specified, debug the JIT code by setting a breakpoint on the first instruction "
59  "and forcing breakpoints to not be ignored (-i0) and no unwinding to happen on error (-u0)."},
60  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Specifies the Language to use when parsing the expression. If not set the target.language "
61  "setting is used." },
62  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "apply-fixits", 'X', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "If true, simple fix-it hints will be automatically applied to the expression." },
63  {LLDB_OPT_SET_1, false, "description-verbosity", 'v', OptionParser::eOptionalArgument, nullptr, DescriptionVerbosityTypes(), 0, eArgTypeDescriptionVerbosity, "How verbose should the output of this expression be, if the object description is asked for."},
64  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "top-level", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Interpret the expression as a complete translation unit, without injecting it into the local "
65  "context. Allows declaration of persistent, top-level entities without a $ prefix."},
66  {LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "allow-jit", 'j', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Controls whether the expression can fall back to being JITted if it's not supported by "
67  "the interpreter (defaults to true)."}
68  // clang-format on
69 };
70 
72  uint32_t option_idx, llvm::StringRef option_arg,
73  ExecutionContext *execution_context) {
74  Status error;
75 
76  const int short_option = GetDefinitions()[option_idx].short_option;
77 
78  switch (short_option) {
79  case 'l':
83  "unknown language type: '%s' for expression",
84  option_arg.str().c_str());
85  break;
86 
87  case 'a': {
88  bool success;
89  bool result;
90  result = OptionArgParser::ToBoolean(option_arg, true, &success);
91  if (!success)
93  "invalid all-threads value setting: \"%s\"",
94  option_arg.str().c_str());
95  else
96  try_all_threads = result;
97  } break;
98 
99  case 'i': {
100  bool success;
101  bool tmp_value = OptionArgParser::ToBoolean(option_arg, true, &success);
102  if (success)
103  ignore_breakpoints = tmp_value;
104  else
106  "could not convert \"%s\" to a boolean value.",
107  option_arg.str().c_str());
108  break;
109  }
110 
111  case 'j': {
112  bool success;
113  bool tmp_value = OptionArgParser::ToBoolean(option_arg, true, &success);
114  if (success)
115  allow_jit = tmp_value;
116  else
118  "could not convert \"%s\" to a boolean value.",
119  option_arg.str().c_str());
120  break;
121  }
122 
123  case 't':
124  if (option_arg.getAsInteger(0, timeout)) {
125  timeout = 0;
126  error.SetErrorStringWithFormat("invalid timeout setting \"%s\"",
127  option_arg.str().c_str());
128  }
129  break;
130 
131  case 'u': {
132  bool success;
133  bool tmp_value = OptionArgParser::ToBoolean(option_arg, true, &success);
134  if (success)
135  unwind_on_error = tmp_value;
136  else
138  "could not convert \"%s\" to a boolean value.",
139  option_arg.str().c_str());
140  break;
141  }
142 
143  case 'v':
144  if (option_arg.empty()) {
146  break;
147  }
150  option_arg, GetDefinitions()[option_idx].enum_values, 0, error);
151  if (!error.Success())
153  "unrecognized value for description-verbosity '%s'",
154  option_arg.str().c_str());
155  break;
156 
157  case 'g':
158  debug = true;
159  unwind_on_error = false;
160  ignore_breakpoints = false;
161  break;
162 
163  case 'p':
164  top_level = true;
165  break;
166 
167  case 'X': {
168  bool success;
169  bool tmp_value = OptionArgParser::ToBoolean(option_arg, true, &success);
170  if (success)
172  else
174  "could not convert \"%s\" to a boolean value.",
175  option_arg.str().c_str());
176  break;
177  }
178 
179  default:
180  error.SetErrorStringWithFormat("invalid short option character '%c'",
181  short_option);
182  break;
183  }
184 
185  return error;
186 }
187 
189  ExecutionContext *execution_context) {
190  auto process_sp =
191  execution_context ? execution_context->GetProcessSP() : ProcessSP();
192  if (process_sp) {
193  ignore_breakpoints = process_sp->GetIgnoreBreakpointsInExpressions();
194  unwind_on_error = process_sp->GetUnwindOnErrorInExpressions();
195  } else {
196  ignore_breakpoints = true;
197  unwind_on_error = true;
198  }
199 
200  show_summary = true;
201  try_all_threads = true;
202  timeout = 0;
203  debug = false;
207  top_level = false;
208  allow_jit = true;
209 }
210 
211 llvm::ArrayRef<OptionDefinition>
213  return llvm::makeArrayRef(g_expression_options);
214 }
215 
217  CommandInterpreter &interpreter)
219  interpreter, "expression", "Evaluate an expression on the current "
220  "thread. Displays any returned value "
221  "with LLDB's default formatting.",
222  "", eCommandProcessMustBePaused | eCommandTryTargetAPILock),
225  m_repl_option(LLDB_OPT_SET_1, false, "repl", 'r', "Drop into REPL", false,
226  true),
228  SetHelpLong(
229  R"(
230 Single and multi-line expressions:
231 
232 )"
233  " The expression provided on the command line must be a complete expression \
234 with no newlines. To evaluate a multi-line expression, \
235 hit a return after an empty expression, and lldb will enter the multi-line expression editor. \
236 Hit return on an empty line to end the multi-line expression."
237 
238  R"(
239 
240 Timeouts:
241 
242 )"
243  " If the expression can be evaluated statically (without running code) then it will be. \
244 Otherwise, by default the expression will run on the current thread with a short timeout: \
245 currently .25 seconds. If it doesn't return in that time, the evaluation will be interrupted \
246 and resumed with all threads running. You can use the -a option to disable retrying on all \
247 threads. You can use the -t option to set a shorter timeout."
248  R"(
249 
250 User defined variables:
251 
252 )"
253  " You can define your own variables for convenience or to be used in subsequent expressions. \
254 You define them the same way you would define variables in C. If the first character of \
255 your user defined variable is a $, then the variable's value will be available in future \
256 expressions, otherwise it will just be available in the current expression."
257  R"(
258 
259 Continuing evaluation after a breakpoint:
260 
261 )"
262  " If the \"-i false\" option is used, and execution is interrupted by a breakpoint hit, once \
263 you are done with your investigation, you can either remove the expression execution frames \
264 from the stack with \"thread return -x\" or if you are still interested in the expression result \
265 you can issue the \"continue\" command and the expression evaluation will complete and the \
266 expression result will be available using the \"thread.completed-expression\" key in the thread \
267 format."
268 
269  R"(
270 
271 Examples:
272 
273  expr my_struct->a = my_array[3]
274  expr -f bin -- (index * 8) + 5
275  expr unsigned int $foo = 5
276  expr char c[] = \"foo\"; c[0])");
277 
279  CommandArgumentData expression_arg;
280 
281  // Define the first (and only) variant of this arg.
282  expression_arg.arg_type = eArgTypeExpression;
283  expression_arg.arg_repetition = eArgRepeatPlain;
284 
285  // There is only one variant this argument could be; put it into the argument
286  // entry.
287  arg.push_back(expression_arg);
288 
289  // Push the data for the first argument into the m_arguments vector.
290  m_arguments.push_back(arg);
291 
292  // Add the "--format" and "--gdb-format"
302 }
303 
305 
307 
313  options.SetAutoApplyFixIts(false);
314  options.SetGenerateDebugInfo(false);
315 
316  // We need a valid execution context with a frame pointer for this
317  // completion, so if we don't have one we should try to make a valid
318  // execution context.
319  if (m_interpreter.GetExecutionContext().GetFramePtr() == nullptr)
321 
322  // This didn't work, so let's get out before we start doing things that
323  // expect a valid frame pointer.
324  if (m_interpreter.GetExecutionContext().GetFramePtr() == nullptr)
325  return 0;
326 
328 
329  Target *target = exe_ctx.GetTargetPtr();
330 
331  if (!target)
332  target = GetDummyTarget();
333 
334  if (!target)
335  return 0;
336 
337  unsigned cursor_pos = request.GetRawCursorPos();
338  llvm::StringRef code = request.GetRawLine();
339 
340  const std::size_t original_code_size = code.size();
341 
342  // Remove the first token which is 'expr' or some alias/abbreviation of that.
343  code = llvm::getToken(code).second.ltrim();
344  OptionsWithRaw args(code);
345  code = args.GetRawPart();
346 
347  // The position where the expression starts in the command line.
348  assert(original_code_size >= code.size());
349  std::size_t raw_start = original_code_size - code.size();
350 
351  // Check if the cursor is actually in the expression string, and if not, we
352  // exit.
353  // FIXME: We should complete the options here.
354  if (cursor_pos < raw_start)
355  return 0;
356 
357  // Make the cursor_pos again relative to the start of the code string.
358  assert(cursor_pos >= raw_start);
359  cursor_pos -= raw_start;
360 
361  auto language = exe_ctx.GetFrameRef().GetLanguage();
362 
363  Status error;
364  lldb::UserExpressionSP expr(target->GetUserExpressionForLanguage(
365  code, llvm::StringRef(), language, UserExpression::eResultTypeAny,
366  options, nullptr, error));
367  if (error.Fail())
368  return 0;
369 
370  expr->Complete(exe_ctx, request, cursor_pos);
371  return request.GetNumberOfMatches();
372 }
373 
376  CompilerType type(valobj.GetCompilerType());
377  CompilerType pointee;
378  if (!type.IsPointerType(&pointee))
379  return Status("as it does not refer to a pointer");
380  if (pointee.IsVoidType())
381  return Status("as it refers to a pointer to void");
382  return Status();
383 }
384 
386  Stream *output_stream,
387  Stream *error_stream,
388  CommandReturnObject *result) {
389  // Don't use m_exe_ctx as this might be called asynchronously after the
390  // command object DoExecute has finished when doing multi-line expression
391  // that use an input reader...
393 
394  Target *target = exe_ctx.GetTargetPtr();
395 
396  if (!target)
397  target = GetDummyTarget();
398 
399  if (target) {
400  lldb::ValueObjectSP result_valobj_sp;
401  bool keep_in_memory = true;
402  StackFrame *frame = exe_ctx.GetFramePtr();
403 
408  options.SetKeepInMemory(keep_in_memory);
413  options.SetExecutionPolicy(
417 
418  bool auto_apply_fixits;
420  auto_apply_fixits = target->GetEnableAutoApplyFixIts();
421  else
422  auto_apply_fixits = m_command_options.auto_apply_fixits == eLazyBoolYes;
423 
424  options.SetAutoApplyFixIts(auto_apply_fixits);
425 
428 
429  // If there is any chance we are going to stop and want to see what went
430  // wrong with our expression, we should generate debug info
433  options.SetGenerateDebugInfo(true);
434 
435  if (m_command_options.timeout > 0)
436  options.SetTimeout(std::chrono::microseconds(m_command_options.timeout));
437  else
438  options.SetTimeout(llvm::None);
439 
440  ExpressionResults success = target->EvaluateExpression(
441  expr, frame, result_valobj_sp, options, &m_fixed_expression);
442 
443  // We only tell you about the FixIt if we applied it. The compiler errors
444  // will suggest the FixIt if it parsed.
445  if (error_stream && !m_fixed_expression.empty() &&
446  target->GetEnableNotifyAboutFixIts()) {
447  if (success == eExpressionCompleted)
448  error_stream->Printf(
449  " Fix-it applied, fixed expression was: \n %s\n",
450  m_fixed_expression.c_str());
451  }
452 
453  if (result_valobj_sp) {
454  Format format = m_format_options.GetFormat();
455 
456  if (result_valobj_sp->GetError().Success()) {
457  if (format != eFormatVoid) {
458  if (format != eFormatDefault)
459  result_valobj_sp->SetFormat(format);
460 
461  if (m_varobj_options.elem_count > 0) {
462  Status error(CanBeUsedForElementCountPrinting(*result_valobj_sp));
463  if (error.Fail()) {
464  result->AppendErrorWithFormat(
465  "expression cannot be used with --element-count %s\n",
466  error.AsCString(""));
468  return false;
469  }
470  }
471 
473  m_command_options.m_verbosity, format));
474  options.SetVariableFormatDisplayLanguage(
475  result_valobj_sp->GetPreferredDisplayLanguage());
476 
477  result_valobj_sp->Dump(*output_stream, options);
478 
479  if (result)
481  }
482  } else {
483  if (result_valobj_sp->GetError().GetError() ==
485  if (format != eFormatVoid && GetDebugger().GetNotifyVoid()) {
486  error_stream->PutCString("(void)\n");
487  }
488 
489  if (result)
491  } else {
492  const char *error_cstr = result_valobj_sp->GetError().AsCString();
493  if (error_cstr && error_cstr[0]) {
494  const size_t error_cstr_len = strlen(error_cstr);
495  const bool ends_with_newline =
496  error_cstr[error_cstr_len - 1] == '\n';
497  if (strstr(error_cstr, "error:") != error_cstr)
498  error_stream->PutCString("error: ");
499  error_stream->Write(error_cstr, error_cstr_len);
500  if (!ends_with_newline)
501  error_stream->EOL();
502  } else {
503  error_stream->PutCString("error: unknown error\n");
504  }
505 
506  if (result)
508  }
509  }
510  }
511  } else {
512  error_stream->Printf("error: invalid execution context for expression\n");
513  return false;
514  }
515 
516  return true;
517 }
518 
520  std::string &line) {
521  io_handler.SetIsDone(true);
522  // StreamSP output_stream =
523  // io_handler.GetDebugger().GetAsyncOutputStream();
524  // StreamSP error_stream = io_handler.GetDebugger().GetAsyncErrorStream();
525  StreamFileSP output_sp(io_handler.GetOutputStreamFile());
526  StreamFileSP error_sp(io_handler.GetErrorStreamFile());
527 
528  EvaluateExpression(line.c_str(), output_sp.get(), error_sp.get());
529  if (output_sp)
530  output_sp->Flush();
531  if (error_sp)
532  error_sp->Flush();
533 }
534 
536  StringList &lines) {
537  // An empty lines is used to indicate the end of input
538  const size_t num_lines = lines.GetSize();
539  if (num_lines > 0 && lines[num_lines - 1].empty()) {
540  // Remove the last empty line from "lines" so it doesn't appear in our
541  // resulting input and return true to indicate we are done getting lines
542  lines.PopBack();
543  return true;
544  }
545  return false;
546 }
547 
549  m_expr_lines.clear();
550  m_expr_line_count = 0;
551 
553  bool color_prompt = debugger.GetUseColor();
554  const bool multiple_lines = true; // Get multiple lines
555  IOHandlerSP io_handler_sp(
557  "lldb-expr", // Name of input reader for history
558  llvm::StringRef(), // No prompt
559  llvm::StringRef(), // Continuation prompt
560  multiple_lines, color_prompt,
561  1, // Show line numbers starting at 1
562  *this, nullptr));
563 
564  StreamFileSP output_sp(io_handler_sp->GetOutputStreamFile());
565  if (output_sp) {
566  output_sp->PutCString(
567  "Enter expressions, then terminate with an empty line to evaluate:\n");
568  output_sp->Flush();
569  }
570  debugger.PushIOHandler(io_handler_sp);
571 }
572 
575  CommandObjectExpression::CommandOptions command_options) {
576  command_options.OptionParsingStarting(&ctx);
577 
578  // Default certain settings for REPL regardless of the global settings.
579  command_options.unwind_on_error = false;
580  command_options.ignore_breakpoints = false;
581  command_options.debug = false;
582 
583  EvaluateExpressionOptions expr_options;
584  expr_options.SetUnwindOnError(command_options.unwind_on_error);
585  expr_options.SetIgnoreBreakpoints(command_options.ignore_breakpoints);
586  expr_options.SetTryAllThreads(command_options.try_all_threads);
587 
588  if (command_options.timeout > 0)
589  expr_options.SetTimeout(std::chrono::microseconds(command_options.timeout));
590  else
591  expr_options.SetTimeout(llvm::None);
592 
593  return expr_options;
594 }
595 
596 bool CommandObjectExpression::DoExecute(llvm::StringRef command,
597  CommandReturnObject &result) {
598  m_fixed_expression.clear();
599  auto exe_ctx = GetCommandInterpreter().GetExecutionContext();
601 
602  if (command.empty()) {
604  return result.Succeeded();
605  }
606 
607  OptionsWithRaw args(command);
608  llvm::StringRef expr = args.GetRawPart();
609 
610  if (args.HasArgs()) {
611  if (!ParseOptionsAndNotify(args.GetArgs(), result, m_option_group, exe_ctx))
612  return false;
613 
616  if (target) {
617  // Drop into REPL
618  m_expr_lines.clear();
619  m_expr_line_count = 0;
620 
621  Debugger &debugger = target->GetDebugger();
622 
623  // Check if the LLDB command interpreter is sitting on top of a REPL
624  // that launched it...
627  // the LLDB command interpreter is sitting on top of a REPL that
628  // launched it, so just say the command interpreter is done and
629  // fall back to the existing REPL
630  m_interpreter.GetIOHandler(false)->SetIsDone(true);
631  } else {
632  // We are launching the REPL on top of the current LLDB command
633  // interpreter, so just push one
634  bool initialize = false;
635  Status repl_error;
636  REPLSP repl_sp(target->GetREPL(repl_error, m_command_options.language,
637  nullptr, false));
638 
639  if (!repl_sp) {
640  initialize = true;
641  repl_sp = target->GetREPL(repl_error, m_command_options.language,
642  nullptr, true);
643  if (!repl_error.Success()) {
644  result.SetError(repl_error);
645  return result.Succeeded();
646  }
647  }
648 
649  if (repl_sp) {
650  if (initialize) {
651  repl_sp->SetEvaluateOptions(
653  repl_sp->SetFormatOptions(m_format_options);
654  repl_sp->SetValueObjectDisplayOptions(m_varobj_options);
655  }
656 
657  IOHandlerSP io_handler_sp(repl_sp->GetIOHandler());
658 
659  io_handler_sp->SetIsDone(false);
660 
661  debugger.PushIOHandler(io_handler_sp);
662  } else {
663  repl_error.SetErrorStringWithFormat(
664  "Couldn't create a REPL for %s",
666  result.SetError(repl_error);
667  return result.Succeeded();
668  }
669  }
670  }
671  }
672  // No expression following options
673  else if (expr.empty()) {
675  return result.Succeeded();
676  }
677  }
678 
679  Target *target = GetSelectedOrDummyTarget();
680  if (EvaluateExpression(expr, &(result.GetOutputStream()),
681  &(result.GetErrorStream()), &result)) {
682 
683  if (!m_fixed_expression.empty() && target->GetEnableNotifyAboutFixIts()) {
685  // FIXME: Can we figure out what the user actually typed (e.g. some alias
686  // for expr???)
687  // If we can it would be nice to show that.
688  std::string fixed_command("expression ");
689  if (args.HasArgs()) {
690  // Add in any options that might have been in the original command:
691  fixed_command.append(args.GetArgStringWithDelimiter());
692  fixed_command.append(m_fixed_expression);
693  } else
694  fixed_command.append(m_fixed_expression);
695  history.AppendString(fixed_command);
696  }
697  // Increment statistics to record this expression evaluation success.
699  return true;
700  }
701 
702  // Increment statistics to record this expression evaluation failure.
705  return false;
706 }
void SetIgnoreBreakpoints(bool ignore=false)
Definition: Target.h:289
A class to manage flag bits.
Definition: Debugger.h:82
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:61
bool CheckTopIOHandlerTypes(IOHandler::Type top_type, IOHandler::Type second_top_type)
Definition: Debugger.cpp:1006
std::vector< CommandArgumentData > CommandArgumentEntry
llvm::StringRef GetRawLine() const
void SetExecutionPolicy(ExecutionPolicy policy=eExecutionPolicyAlways)
Definition: Target.h:260
CommandObjectExpression(CommandInterpreter &interpreter)
CompilerType GetCompilerType()
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
CommandInterpreter & m_interpreter
static lldb::LanguageType GetLanguageTypeFromString(const char *string)=delete
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
static constexpr OptionDefinition g_expression_options[]
bool IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines) override
Called to determine whether typing enter after the last line in lines should end input.
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
OptionGroupValueObjectDisplay m_varobj_options
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
void SetUseDynamic(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
Definition: Target.h:300
void SetUnwindOnError(bool unwind=false)
Definition: Target.h:285
int history(History *, HistEvent *, int,...)
bool GetNotifyVoid() const
Definition: Debugger.cpp:392
std::size_t GetNumberOfMatches() const
Encapsulates a single expression for use in lldb.
Definition: Expression.h:33
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
bool ParseOptionsAndNotify(Args &args, CommandReturnObject &result, OptionGroupOptions &group_options, ExecutionContext &exe_ctx)
bool HasArgs() const
Returns true if there are any arguments before the raw suffix.
Definition: Args.h:352
lldb::StreamFileSP & GetErrorStreamFile()
Definition: IOHandler.cpp:128
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
Definition: Stream.h:100
void IOHandlerInputComplete(IOHandler &io_handler, std::string &line) override
Called when a line or lines have been retrieved.
A delegate class for use with IOHandler subclasses.
Definition: IOHandler.h:188
DumpValueObjectOptions GetAsDumpOptions(LanguageRuntimeDescriptionDisplayVerbosity lang_descr_verbosity=eLanguageRuntimeDescriptionDisplayVerbosityFull, lldb::Format format=lldb::eFormatDefault, lldb::TypeSummaryImplSP summary_sp=lldb::TypeSummaryImplSP())
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
llvm::StringRef GetArgStringWithDelimiter() const
Returns the part of the input string that was used for parsing the argument list. ...
Definition: Args.h:375
#define LLDB_OPT_SET_3
Definition: lldb-defines.h:113
"lldb/Utility/ArgCompletionRequest.h"
void IncrementStats(lldb_private::StatisticKind key)
Definition: Target.h:1323
void SetKeepInMemory(bool keep=true)
Definition: Target.h:295
virtual void SetHelpLong(llvm::StringRef str)
LanguageRuntimeDescriptionDisplayVerbosity m_verbosity
bool DoExecute(llvm::StringRef command, CommandReturnObject &result) override
Target * GetTargetPtr() const
Returns a pointer to the target object.
void SetTimeout(const Timeout< std::micro > &timeout)
Definition: Target.h:306
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:127
lldb::REPLSP GetREPL(Status &err, lldb::LanguageType language, const char *repl_options, bool can_create)
Definition: Target.cpp:208
static const uint32_t OPTION_GROUP_FORMAT
void UpdateExecutionContext(ExecutionContext *override_context)
void SetError(const Status &error, const char *fallback_error_cstr=nullptr)
lldb::IOHandlerSP GetIOHandler(bool force_create=false, CommandInterpreterRunOptions *options=nullptr)
const std::string & GetRawPart() const
Returns the raw suffix part of the parsed string.
Definition: Args.h:390
static int64_t ToOptionEnum(llvm::StringRef s, const OptionEnumValues &enum_values, int32_t fail_value, Status &error)
void PushIOHandler(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Definition: Debugger.cpp:1095
static bool ToBoolean(llvm::StringRef s, bool fail_value, bool *success_ptr)
static constexpr ExecutionPolicy default_execution_policy
Definition: Target.h:253
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:106
static constexpr OptionEnumValueElement g_description_verbosity_type[]
bool Success() const
Test for success condition.
Definition: Status.cpp:287
static const Status::ValueType kNoResult
ValueObject::GetError() returns this if there is no result from the expression.
const lldb::ProcessSP & GetProcessSP() const
Get accessor to get the process shared pointer.
static EvaluateExpressionOptions GetExprOptions(ExecutionContext &ctx, CommandObjectExpression::CommandOptions command_options)
bool EvaluateExpression(llvm::StringRef expr, Stream *output_stream, Stream *error_stream, CommandReturnObject *result=NULL)
size_t GetSize() const
Definition: StringList.cpp:70
void SetLanguage(lldb::LanguageType language)
Definition: Target.h:266
#define LLDB_OPT_SET_2
Definition: lldb-defines.h:112
A command line option parsing protocol class.
Definition: Options.h:62
const CommandHistory & GetCommandHistory() const
void SetCoerceToId(bool coerce=true)
Definition: Target.h:281
void AppendString(llvm::StringRef str, bool reject_if_dupe=true)
CommandInterpreter & GetCommandInterpreter()
static constexpr OptionEnumValues DescriptionVerbosityTypes()
bool GetUseColor() const
Definition: Debugger.cpp:464
Target * GetSelectedOrDummyTarget(bool prefer_dummy=false)
Unknown or invalid language value.
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
Definition: SBAddress.h:15
void SetTryAllThreads(bool try_others=true)
Definition: Target.h:318
void OptionParsingStarting(ExecutionContext *execution_context) override
virtual void SetIsDone(bool b)
Definition: IOHandler.h:86
#define LLDB_OPT_SET_ALL
Definition: lldb-defines.h:110
OptionValueBoolean & GetOptionValue()
bool GetEnableNotifyAboutFixIts() const
Definition: Target.cpp:3920
Args & GetArgs()
Returns the list of arguments.
Definition: Args.h:357
int HandleCompletion(CompletionRequest &request) override
This default version handles calling option argument completions and then calls HandleArgumentComplet...
static const uint32_t OPTION_GROUP_GDB_FMT
lldb::StreamFileSP & GetOutputStreamFile()
Definition: IOHandler.cpp:126
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
Definition: Status.cpp:255
void Append(OptionGroup *group)
Append options from a OptionGroup class.
Definition: Options.cpp:843
#define LLDB_OPT_SET_1
Definition: lldb-defines.h:111
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:130
A pair of an option list with a &#39;raw&#39; string as a suffix.
Definition: Args.h:341
static const char * GetNameForLanguageType(lldb::LanguageType language)
Definition: Language.cpp:219
void SetStatus(lldb::ReturnStatus status)
This base class provides an interface to stack frames.
Definition: StackFrame.h:40
Debugger & GetDebugger()
Definition: Target.h:974
void NotifyOptionParsingStarting(ExecutionContext *execution_context)
Definition: Options.cpp:32
static lldb_private::Status CanBeUsedForElementCountPrinting(ValueObject &valobj)
An error handling class.
Definition: Status.h:44
std::vector< CommandArgumentEntry > m_arguments