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