1 //===-- CommandObjectExpression.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
9 #include "llvm/ADT/StringRef.h"
10
11 #include "CommandObjectExpression.h"
12 #include "lldb/Core/Debugger.h"
13 #include "lldb/Expression/REPL.h"
14 #include "lldb/Expression/UserExpression.h"
15 #include "lldb/Host/OptionParser.h"
16 #include "lldb/Interpreter/CommandInterpreter.h"
17 #include "lldb/Interpreter/CommandOptionArgumentTable.h"
18 #include "lldb/Interpreter/CommandReturnObject.h"
19 #include "lldb/Interpreter/OptionArgParser.h"
20 #include "lldb/Target/Language.h"
21 #include "lldb/Target/Process.h"
22 #include "lldb/Target/StackFrame.h"
23 #include "lldb/Target/Target.h"
24
25 using namespace lldb;
26 using namespace lldb_private;
27
28 CommandObjectExpression::CommandOptions::CommandOptions() = default;
29
30 CommandObjectExpression::CommandOptions::~CommandOptions() = default;
31
32 #define LLDB_OPTIONS_expression
33 #include "CommandOptions.inc"
34
SetOptionValue(uint32_t option_idx,llvm::StringRef option_arg,ExecutionContext * execution_context)35 Status CommandObjectExpression::CommandOptions::SetOptionValue(
36 uint32_t option_idx, llvm::StringRef option_arg,
37 ExecutionContext *execution_context) {
38 Status error;
39
40 const int short_option = GetDefinitions()[option_idx].short_option;
41
42 switch (short_option) {
43 case 'l':
44 language = Language::GetLanguageTypeFromString(option_arg);
45 if (language == eLanguageTypeUnknown) {
46 StreamString sstr;
47 sstr.Printf("unknown language type: '%s' for expression. "
48 "List of supported languages:\n",
49 option_arg.str().c_str());
50
51 Language::PrintSupportedLanguagesForExpressions(sstr, " ", "\n");
52 error.SetErrorString(sstr.GetString());
53 }
54 break;
55
56 case 'a': {
57 bool success;
58 bool result;
59 result = OptionArgParser::ToBoolean(option_arg, true, &success);
60 if (!success)
61 error.SetErrorStringWithFormat(
62 "invalid all-threads value setting: \"%s\"",
63 option_arg.str().c_str());
64 else
65 try_all_threads = result;
66 } break;
67
68 case 'i': {
69 bool success;
70 bool tmp_value = OptionArgParser::ToBoolean(option_arg, true, &success);
71 if (success)
72 ignore_breakpoints = tmp_value;
73 else
74 error.SetErrorStringWithFormat(
75 "could not convert \"%s\" to a boolean value.",
76 option_arg.str().c_str());
77 break;
78 }
79
80 case 'j': {
81 bool success;
82 bool tmp_value = OptionArgParser::ToBoolean(option_arg, true, &success);
83 if (success)
84 allow_jit = tmp_value;
85 else
86 error.SetErrorStringWithFormat(
87 "could not convert \"%s\" to a boolean value.",
88 option_arg.str().c_str());
89 break;
90 }
91
92 case 't':
93 if (option_arg.getAsInteger(0, timeout)) {
94 timeout = 0;
95 error.SetErrorStringWithFormat("invalid timeout setting \"%s\"",
96 option_arg.str().c_str());
97 }
98 break;
99
100 case 'u': {
101 bool success;
102 bool tmp_value = OptionArgParser::ToBoolean(option_arg, true, &success);
103 if (success)
104 unwind_on_error = tmp_value;
105 else
106 error.SetErrorStringWithFormat(
107 "could not convert \"%s\" to a boolean value.",
108 option_arg.str().c_str());
109 break;
110 }
111
112 case 'v':
113 if (option_arg.empty()) {
114 m_verbosity = eLanguageRuntimeDescriptionDisplayVerbosityFull;
115 break;
116 }
117 m_verbosity = (LanguageRuntimeDescriptionDisplayVerbosity)
118 OptionArgParser::ToOptionEnum(
119 option_arg, GetDefinitions()[option_idx].enum_values, 0, error);
120 if (!error.Success())
121 error.SetErrorStringWithFormat(
122 "unrecognized value for description-verbosity '%s'",
123 option_arg.str().c_str());
124 break;
125
126 case 'g':
127 debug = true;
128 unwind_on_error = false;
129 ignore_breakpoints = false;
130 break;
131
132 case 'p':
133 top_level = true;
134 break;
135
136 case 'X': {
137 bool success;
138 bool tmp_value = OptionArgParser::ToBoolean(option_arg, true, &success);
139 if (success)
140 auto_apply_fixits = tmp_value ? eLazyBoolYes : eLazyBoolNo;
141 else
142 error.SetErrorStringWithFormat(
143 "could not convert \"%s\" to a boolean value.",
144 option_arg.str().c_str());
145 break;
146 }
147
148 default:
149 llvm_unreachable("Unimplemented option");
150 }
151
152 return error;
153 }
154
OptionParsingStarting(ExecutionContext * execution_context)155 void CommandObjectExpression::CommandOptions::OptionParsingStarting(
156 ExecutionContext *execution_context) {
157 auto process_sp =
158 execution_context ? execution_context->GetProcessSP() : ProcessSP();
159 if (process_sp) {
160 ignore_breakpoints = process_sp->GetIgnoreBreakpointsInExpressions();
161 unwind_on_error = process_sp->GetUnwindOnErrorInExpressions();
162 } else {
163 ignore_breakpoints = true;
164 unwind_on_error = true;
165 }
166
167 show_summary = true;
168 try_all_threads = true;
169 timeout = 0;
170 debug = false;
171 language = eLanguageTypeUnknown;
172 m_verbosity = eLanguageRuntimeDescriptionDisplayVerbosityCompact;
173 auto_apply_fixits = eLazyBoolCalculate;
174 top_level = false;
175 allow_jit = true;
176 }
177
178 llvm::ArrayRef<OptionDefinition>
GetDefinitions()179 CommandObjectExpression::CommandOptions::GetDefinitions() {
180 return llvm::ArrayRef(g_expression_options);
181 }
182
CommandObjectExpression(CommandInterpreter & interpreter)183 CommandObjectExpression::CommandObjectExpression(
184 CommandInterpreter &interpreter)
185 : CommandObjectRaw(interpreter, "expression",
186 "Evaluate an expression on the current "
187 "thread. Displays any returned value "
188 "with LLDB's default formatting.",
189 "",
190 eCommandProcessMustBePaused | eCommandTryTargetAPILock),
191 IOHandlerDelegate(IOHandlerDelegate::Completion::Expression),
192 m_format_options(eFormatDefault),
193 m_repl_option(LLDB_OPT_SET_1, false, "repl", 'r', "Drop into REPL", false,
194 true),
195 m_expr_line_count(0) {
196 SetHelpLong(
197 R"(
198 Single and multi-line expressions:
199
200 )"
201 " The expression provided on the command line must be a complete expression \
202 with no newlines. To evaluate a multi-line expression, \
203 hit a return after an empty expression, and lldb will enter the multi-line expression editor. \
204 Hit return on an empty line to end the multi-line expression."
205
206 R"(
207
208 Timeouts:
209
210 )"
211 " If the expression can be evaluated statically (without running code) then it will be. \
212 Otherwise, by default the expression will run on the current thread with a short timeout: \
213 currently .25 seconds. If it doesn't return in that time, the evaluation will be interrupted \
214 and resumed with all threads running. You can use the -a option to disable retrying on all \
215 threads. You can use the -t option to set a shorter timeout."
216 R"(
217
218 User defined variables:
219
220 )"
221 " You can define your own variables for convenience or to be used in subsequent expressions. \
222 You define them the same way you would define variables in C. If the first character of \
223 your user defined variable is a $, then the variable's value will be available in future \
224 expressions, otherwise it will just be available in the current expression."
225 R"(
226
227 Continuing evaluation after a breakpoint:
228
229 )"
230 " If the \"-i false\" option is used, and execution is interrupted by a breakpoint hit, once \
231 you are done with your investigation, you can either remove the expression execution frames \
232 from the stack with \"thread return -x\" or if you are still interested in the expression result \
233 you can issue the \"continue\" command and the expression evaluation will complete and the \
234 expression result will be available using the \"thread.completed-expression\" key in the thread \
235 format."
236
237 R"(
238
239 Examples:
240
241 expr my_struct->a = my_array[3]
242 expr -f bin -- (index * 8) + 5
243 expr unsigned int $foo = 5
244 expr char c[] = \"foo\"; c[0])");
245
246 CommandArgumentEntry arg;
247 CommandArgumentData expression_arg;
248
249 // Define the first (and only) variant of this arg.
250 expression_arg.arg_type = eArgTypeExpression;
251 expression_arg.arg_repetition = eArgRepeatPlain;
252
253 // There is only one variant this argument could be; put it into the argument
254 // entry.
255 arg.push_back(expression_arg);
256
257 // Push the data for the first argument into the m_arguments vector.
258 m_arguments.push_back(arg);
259
260 // Add the "--format" and "--gdb-format"
261 m_option_group.Append(&m_format_options,
262 OptionGroupFormat::OPTION_GROUP_FORMAT |
263 OptionGroupFormat::OPTION_GROUP_GDB_FMT,
264 LLDB_OPT_SET_1);
265 m_option_group.Append(&m_command_options);
266 m_option_group.Append(&m_varobj_options, LLDB_OPT_SET_ALL,
267 LLDB_OPT_SET_1 | LLDB_OPT_SET_2);
268 m_option_group.Append(&m_repl_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_3);
269 m_option_group.Finalize();
270 }
271
272 CommandObjectExpression::~CommandObjectExpression() = default;
273
GetOptions()274 Options *CommandObjectExpression::GetOptions() { return &m_option_group; }
275
HandleCompletion(CompletionRequest & request)276 void CommandObjectExpression::HandleCompletion(CompletionRequest &request) {
277 EvaluateExpressionOptions options;
278 options.SetCoerceToId(m_varobj_options.use_objc);
279 options.SetLanguage(m_command_options.language);
280 options.SetExecutionPolicy(lldb_private::eExecutionPolicyNever);
281 options.SetAutoApplyFixIts(false);
282 options.SetGenerateDebugInfo(false);
283
284 ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
285
286 // Get out before we start doing things that expect a valid frame pointer.
287 if (exe_ctx.GetFramePtr() == nullptr)
288 return;
289
290 Target *exe_target = exe_ctx.GetTargetPtr();
291 Target &target = exe_target ? *exe_target : GetDummyTarget();
292
293 unsigned cursor_pos = request.GetRawCursorPos();
294 // Get the full user input including the suffix. The suffix is necessary
295 // as OptionsWithRaw will use it to detect if the cursor is cursor is in the
296 // argument part of in the raw input part of the arguments. If we cut of
297 // of the suffix then "expr -arg[cursor] --" would interpret the "-arg" as
298 // the raw input (as the "--" is hidden in the suffix).
299 llvm::StringRef code = request.GetRawLineWithUnusedSuffix();
300
301 const std::size_t original_code_size = code.size();
302
303 // Remove the first token which is 'expr' or some alias/abbreviation of that.
304 code = llvm::getToken(code).second.ltrim();
305 OptionsWithRaw args(code);
306 code = args.GetRawPart();
307
308 // The position where the expression starts in the command line.
309 assert(original_code_size >= code.size());
310 std::size_t raw_start = original_code_size - code.size();
311
312 // Check if the cursor is actually in the expression string, and if not, we
313 // exit.
314 // FIXME: We should complete the options here.
315 if (cursor_pos < raw_start)
316 return;
317
318 // Make the cursor_pos again relative to the start of the code string.
319 assert(cursor_pos >= raw_start);
320 cursor_pos -= raw_start;
321
322 auto language = exe_ctx.GetFrameRef().GetLanguage();
323
324 Status error;
325 lldb::UserExpressionSP expr(target.GetUserExpressionForLanguage(
326 code, llvm::StringRef(), language, UserExpression::eResultTypeAny,
327 options, nullptr, error));
328 if (error.Fail())
329 return;
330
331 expr->Complete(exe_ctx, request, cursor_pos);
332 }
333
334 static lldb_private::Status
CanBeUsedForElementCountPrinting(ValueObject & valobj)335 CanBeUsedForElementCountPrinting(ValueObject &valobj) {
336 CompilerType type(valobj.GetCompilerType());
337 CompilerType pointee;
338 if (!type.IsPointerType(&pointee))
339 return Status("as it does not refer to a pointer");
340 if (pointee.IsVoidType())
341 return Status("as it refers to a pointer to void");
342 return Status();
343 }
344
345 EvaluateExpressionOptions
GetEvalOptions(const Target & target)346 CommandObjectExpression::GetEvalOptions(const Target &target) {
347 EvaluateExpressionOptions options;
348 options.SetCoerceToId(m_varobj_options.use_objc);
349 options.SetUnwindOnError(m_command_options.unwind_on_error);
350 options.SetIgnoreBreakpoints(m_command_options.ignore_breakpoints);
351 options.SetKeepInMemory(true);
352 options.SetUseDynamic(m_varobj_options.use_dynamic);
353 options.SetTryAllThreads(m_command_options.try_all_threads);
354 options.SetDebug(m_command_options.debug);
355 options.SetLanguage(m_command_options.language);
356 options.SetExecutionPolicy(
357 m_command_options.allow_jit
358 ? EvaluateExpressionOptions::default_execution_policy
359 : lldb_private::eExecutionPolicyNever);
360
361 bool auto_apply_fixits;
362 if (m_command_options.auto_apply_fixits == eLazyBoolCalculate)
363 auto_apply_fixits = target.GetEnableAutoApplyFixIts();
364 else
365 auto_apply_fixits = m_command_options.auto_apply_fixits == eLazyBoolYes;
366
367 options.SetAutoApplyFixIts(auto_apply_fixits);
368 options.SetRetriesWithFixIts(target.GetNumberOfRetriesWithFixits());
369
370 if (m_command_options.top_level)
371 options.SetExecutionPolicy(eExecutionPolicyTopLevel);
372
373 // If there is any chance we are going to stop and want to see what went
374 // wrong with our expression, we should generate debug info
375 if (!m_command_options.ignore_breakpoints ||
376 !m_command_options.unwind_on_error)
377 options.SetGenerateDebugInfo(true);
378
379 if (m_command_options.timeout > 0)
380 options.SetTimeout(std::chrono::microseconds(m_command_options.timeout));
381 else
382 options.SetTimeout(std::nullopt);
383 return options;
384 }
385
EvaluateExpression(llvm::StringRef expr,Stream & output_stream,Stream & error_stream,CommandReturnObject & result)386 bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
387 Stream &output_stream,
388 Stream &error_stream,
389 CommandReturnObject &result) {
390 // Don't use m_exe_ctx as this might be called asynchronously after the
391 // command object DoExecute has finished when doing multi-line expression
392 // that use an input reader...
393 ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
394 Target *exe_target = exe_ctx.GetTargetPtr();
395 Target &target = exe_target ? *exe_target : GetDummyTarget();
396
397 lldb::ValueObjectSP result_valobj_sp;
398 StackFrame *frame = exe_ctx.GetFramePtr();
399
400 if (m_command_options.top_level && !m_command_options.allow_jit) {
401 result.AppendErrorWithFormat(
402 "Can't disable JIT compilation for top-level expressions.\n");
403 return false;
404 }
405
406 const EvaluateExpressionOptions options = GetEvalOptions(target);
407 ExpressionResults success = target.EvaluateExpression(
408 expr, frame, result_valobj_sp, options, &m_fixed_expression);
409
410 // We only tell you about the FixIt if we applied it. The compiler errors
411 // will suggest the FixIt if it parsed.
412 if (!m_fixed_expression.empty() && target.GetEnableNotifyAboutFixIts()) {
413 error_stream.Printf(" Fix-it applied, fixed expression was: \n %s\n",
414 m_fixed_expression.c_str());
415 }
416
417 if (result_valobj_sp) {
418 Format format = m_format_options.GetFormat();
419
420 if (result_valobj_sp->GetError().Success()) {
421 if (format != eFormatVoid) {
422 if (format != eFormatDefault)
423 result_valobj_sp->SetFormat(format);
424
425 if (m_varobj_options.elem_count > 0) {
426 Status error(CanBeUsedForElementCountPrinting(*result_valobj_sp));
427 if (error.Fail()) {
428 result.AppendErrorWithFormat(
429 "expression cannot be used with --element-count %s\n",
430 error.AsCString(""));
431 return false;
432 }
433 }
434
435 DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(
436 m_command_options.m_verbosity, format));
437 options.SetVariableFormatDisplayLanguage(
438 result_valobj_sp->GetPreferredDisplayLanguage());
439
440 result_valobj_sp->Dump(output_stream, options);
441
442 result.SetStatus(eReturnStatusSuccessFinishResult);
443 }
444 } else {
445 if (result_valobj_sp->GetError().GetError() ==
446 UserExpression::kNoResult) {
447 if (format != eFormatVoid && GetDebugger().GetNotifyVoid()) {
448 error_stream.PutCString("(void)\n");
449 }
450
451 result.SetStatus(eReturnStatusSuccessFinishResult);
452 } else {
453 const char *error_cstr = result_valobj_sp->GetError().AsCString();
454 if (error_cstr && error_cstr[0]) {
455 const size_t error_cstr_len = strlen(error_cstr);
456 const bool ends_with_newline = error_cstr[error_cstr_len - 1] == '\n';
457 if (strstr(error_cstr, "error:") != error_cstr)
458 error_stream.PutCString("error: ");
459 error_stream.Write(error_cstr, error_cstr_len);
460 if (!ends_with_newline)
461 error_stream.EOL();
462 } else {
463 error_stream.PutCString("error: unknown error\n");
464 }
465
466 result.SetStatus(eReturnStatusFailed);
467 }
468 }
469 } else {
470 error_stream.Printf("error: unknown error\n");
471 }
472
473 return (success != eExpressionSetupError &&
474 success != eExpressionParseError);
475 }
476
IOHandlerInputComplete(IOHandler & io_handler,std::string & line)477 void CommandObjectExpression::IOHandlerInputComplete(IOHandler &io_handler,
478 std::string &line) {
479 io_handler.SetIsDone(true);
480 StreamFileSP output_sp = io_handler.GetOutputStreamFileSP();
481 StreamFileSP error_sp = io_handler.GetErrorStreamFileSP();
482
483 CommandReturnObject return_obj(
484 GetCommandInterpreter().GetDebugger().GetUseColor());
485 EvaluateExpression(line.c_str(), *output_sp, *error_sp, return_obj);
486 if (output_sp)
487 output_sp->Flush();
488 if (error_sp)
489 error_sp->Flush();
490 }
491
IOHandlerIsInputComplete(IOHandler & io_handler,StringList & lines)492 bool CommandObjectExpression::IOHandlerIsInputComplete(IOHandler &io_handler,
493 StringList &lines) {
494 // An empty lines is used to indicate the end of input
495 const size_t num_lines = lines.GetSize();
496 if (num_lines > 0 && lines[num_lines - 1].empty()) {
497 // Remove the last empty line from "lines" so it doesn't appear in our
498 // resulting input and return true to indicate we are done getting lines
499 lines.PopBack();
500 return true;
501 }
502 return false;
503 }
504
GetMultilineExpression()505 void CommandObjectExpression::GetMultilineExpression() {
506 m_expr_lines.clear();
507 m_expr_line_count = 0;
508
509 Debugger &debugger = GetCommandInterpreter().GetDebugger();
510 bool color_prompt = debugger.GetUseColor();
511 const bool multiple_lines = true; // Get multiple lines
512 IOHandlerSP io_handler_sp(
513 new IOHandlerEditline(debugger, IOHandler::Type::Expression,
514 "lldb-expr", // Name of input reader for history
515 llvm::StringRef(), // No prompt
516 llvm::StringRef(), // Continuation prompt
517 multiple_lines, color_prompt,
518 1, // Show line numbers starting at 1
519 *this));
520
521 StreamFileSP output_sp = io_handler_sp->GetOutputStreamFileSP();
522 if (output_sp) {
523 output_sp->PutCString(
524 "Enter expressions, then terminate with an empty line to evaluate:\n");
525 output_sp->Flush();
526 }
527 debugger.RunIOHandlerAsync(io_handler_sp);
528 }
529
530 static EvaluateExpressionOptions
GetExprOptions(ExecutionContext & ctx,CommandObjectExpression::CommandOptions command_options)531 GetExprOptions(ExecutionContext &ctx,
532 CommandObjectExpression::CommandOptions command_options) {
533 command_options.OptionParsingStarting(&ctx);
534
535 // Default certain settings for REPL regardless of the global settings.
536 command_options.unwind_on_error = false;
537 command_options.ignore_breakpoints = false;
538 command_options.debug = false;
539
540 EvaluateExpressionOptions expr_options;
541 expr_options.SetUnwindOnError(command_options.unwind_on_error);
542 expr_options.SetIgnoreBreakpoints(command_options.ignore_breakpoints);
543 expr_options.SetTryAllThreads(command_options.try_all_threads);
544
545 if (command_options.timeout > 0)
546 expr_options.SetTimeout(std::chrono::microseconds(command_options.timeout));
547 else
548 expr_options.SetTimeout(std::nullopt);
549
550 return expr_options;
551 }
552
DoExecute(llvm::StringRef command,CommandReturnObject & result)553 bool CommandObjectExpression::DoExecute(llvm::StringRef command,
554 CommandReturnObject &result) {
555 m_fixed_expression.clear();
556 auto exe_ctx = GetCommandInterpreter().GetExecutionContext();
557 m_option_group.NotifyOptionParsingStarting(&exe_ctx);
558
559 if (command.empty()) {
560 GetMultilineExpression();
561 return result.Succeeded();
562 }
563
564 OptionsWithRaw args(command);
565 llvm::StringRef expr = args.GetRawPart();
566
567 if (args.HasArgs()) {
568 if (!ParseOptionsAndNotify(args.GetArgs(), result, m_option_group, exe_ctx))
569 return false;
570
571 if (m_repl_option.GetOptionValue().GetCurrentValue()) {
572 Target &target = GetSelectedOrDummyTarget();
573 // Drop into REPL
574 m_expr_lines.clear();
575 m_expr_line_count = 0;
576
577 Debugger &debugger = target.GetDebugger();
578
579 // Check if the LLDB command interpreter is sitting on top of a REPL
580 // that launched it...
581 if (debugger.CheckTopIOHandlerTypes(IOHandler::Type::CommandInterpreter,
582 IOHandler::Type::REPL)) {
583 // the LLDB command interpreter is sitting on top of a REPL that
584 // launched it, so just say the command interpreter is done and
585 // fall back to the existing REPL
586 m_interpreter.GetIOHandler(false)->SetIsDone(true);
587 } else {
588 // We are launching the REPL on top of the current LLDB command
589 // interpreter, so just push one
590 bool initialize = false;
591 Status repl_error;
592 REPLSP repl_sp(target.GetREPL(repl_error, m_command_options.language,
593 nullptr, false));
594
595 if (!repl_sp) {
596 initialize = true;
597 repl_sp = target.GetREPL(repl_error, m_command_options.language,
598 nullptr, true);
599 if (!repl_error.Success()) {
600 result.SetError(repl_error);
601 return result.Succeeded();
602 }
603 }
604
605 if (repl_sp) {
606 if (initialize) {
607 repl_sp->SetEvaluateOptions(
608 GetExprOptions(exe_ctx, m_command_options));
609 repl_sp->SetFormatOptions(m_format_options);
610 repl_sp->SetValueObjectDisplayOptions(m_varobj_options);
611 }
612
613 IOHandlerSP io_handler_sp(repl_sp->GetIOHandler());
614 io_handler_sp->SetIsDone(false);
615 debugger.RunIOHandlerAsync(io_handler_sp);
616 } else {
617 repl_error.SetErrorStringWithFormat(
618 "Couldn't create a REPL for %s",
619 Language::GetNameForLanguageType(m_command_options.language));
620 result.SetError(repl_error);
621 return result.Succeeded();
622 }
623 }
624 }
625 // No expression following options
626 else if (expr.empty()) {
627 GetMultilineExpression();
628 return result.Succeeded();
629 }
630 }
631
632 Target &target = GetSelectedOrDummyTarget();
633 if (EvaluateExpression(expr, result.GetOutputStream(),
634 result.GetErrorStream(), result)) {
635
636 if (!m_fixed_expression.empty() && target.GetEnableNotifyAboutFixIts()) {
637 CommandHistory &history = m_interpreter.GetCommandHistory();
638 // FIXME: Can we figure out what the user actually typed (e.g. some alias
639 // for expr???)
640 // If we can it would be nice to show that.
641 std::string fixed_command("expression ");
642 if (args.HasArgs()) {
643 // Add in any options that might have been in the original command:
644 fixed_command.append(std::string(args.GetArgStringWithDelimiter()));
645 fixed_command.append(m_fixed_expression);
646 } else
647 fixed_command.append(m_fixed_expression);
648 history.AppendString(fixed_command);
649 }
650 return true;
651 }
652 result.SetStatus(eReturnStatusFailed);
653 return false;
654 }
655