@@ -194,6 +194,60 @@ CommandObjectExpression::CommandOptions::GetDefinitions() {
194
194
return llvm::makeArrayRef (g_expression_options);
195
195
}
196
196
197
+ EvaluateExpressionOptions
198
+ CommandObjectExpression::CommandOptions::GetEvaluateExpressionOptions (
199
+ const Target &target, const OptionGroupValueObjectDisplay &display_opts) {
200
+ EvaluateExpressionOptions options;
201
+ options.SetCoerceToId (display_opts.use_objc );
202
+ if (m_verbosity == eLanguageRuntimeDescriptionDisplayVerbosityCompact)
203
+ options.SetSuppressPersistentResult (display_opts.use_objc );
204
+ options.SetUnwindOnError (unwind_on_error);
205
+ options.SetIgnoreBreakpoints (ignore_breakpoints);
206
+ options.SetKeepInMemory (true );
207
+ options.SetUseDynamic (display_opts.use_dynamic );
208
+ options.SetTryAllThreads (try_all_threads);
209
+ options.SetDebug (debug);
210
+
211
+ // BEGIN SWIFT
212
+ options.SetBindGenericTypes (bind_generic_types);
213
+ // If the language was not specified in the expression command,
214
+ // set it to the language in the target's properties if
215
+ // specified, else default to the language for the frame.
216
+ if (language != eLanguageTypeUnknown) {
217
+ // END SWIFT
218
+ options.SetLanguage (language);
219
+ // BEGIN SWIFT
220
+ }
221
+ // END SWIFT
222
+
223
+ options.SetExecutionPolicy (
224
+ allow_jit ? EvaluateExpressionOptions::default_execution_policy
225
+ : lldb_private::eExecutionPolicyNever);
226
+
227
+ bool auto_apply_fixits;
228
+ if (this ->auto_apply_fixits == eLazyBoolCalculate)
229
+ auto_apply_fixits = target.GetEnableAutoApplyFixIts ();
230
+ else
231
+ auto_apply_fixits = this ->auto_apply_fixits == eLazyBoolYes;
232
+
233
+ options.SetAutoApplyFixIts (auto_apply_fixits);
234
+ options.SetRetriesWithFixIts (target.GetNumberOfRetriesWithFixits ());
235
+
236
+ if (top_level)
237
+ options.SetExecutionPolicy (eExecutionPolicyTopLevel);
238
+
239
+ // If there is any chance we are going to stop and want to see what went
240
+ // wrong with our expression, we should generate debug info
241
+ if (!ignore_breakpoints || !unwind_on_error)
242
+ options.SetGenerateDebugInfo (true );
243
+
244
+ if (timeout > 0 )
245
+ options.SetTimeout (std::chrono::microseconds (timeout));
246
+ else
247
+ options.SetTimeout (std::nullopt);
248
+ return options;
249
+ }
250
+
197
251
CommandObjectExpression::CommandObjectExpression (
198
252
CommandInterpreter &interpreter)
199
253
: CommandObjectRaw(interpreter, " expression" ,
@@ -358,62 +412,6 @@ CanBeUsedForElementCountPrinting(ValueObject &valobj) {
358
412
return Status ();
359
413
}
360
414
361
- EvaluateExpressionOptions
362
- CommandObjectExpression::GetEvalOptions (const Target &target) {
363
- EvaluateExpressionOptions options;
364
- options.SetCoerceToId (m_varobj_options.use_objc );
365
- if (m_command_options.m_verbosity ==
366
- eLanguageRuntimeDescriptionDisplayVerbosityCompact)
367
- options.SetSuppressPersistentResult (m_varobj_options.use_objc );
368
- options.SetUnwindOnError (m_command_options.unwind_on_error );
369
- options.SetIgnoreBreakpoints (m_command_options.ignore_breakpoints );
370
- options.SetKeepInMemory (true );
371
- options.SetUseDynamic (m_varobj_options.use_dynamic );
372
- options.SetTryAllThreads (m_command_options.try_all_threads );
373
- options.SetDebug (m_command_options.debug );
374
-
375
- // BEGIN SWIFT
376
- options.SetBindGenericTypes (m_command_options.bind_generic_types );
377
- // If the language was not specified in the expression command,
378
- // set it to the language in the target's properties if
379
- // specified, else default to the language for the frame.
380
- if (m_command_options.language != eLanguageTypeUnknown) {
381
- // END SWIFT
382
- options.SetLanguage (m_command_options.language );
383
- // BEGIN SWIFT
384
- }
385
- // END SWIFT
386
-
387
- options.SetExecutionPolicy (
388
- m_command_options.allow_jit
389
- ? EvaluateExpressionOptions::default_execution_policy
390
- : lldb_private::eExecutionPolicyNever);
391
-
392
- bool auto_apply_fixits;
393
- if (m_command_options.auto_apply_fixits == eLazyBoolCalculate)
394
- auto_apply_fixits = target.GetEnableAutoApplyFixIts ();
395
- else
396
- auto_apply_fixits = m_command_options.auto_apply_fixits == eLazyBoolYes;
397
-
398
- options.SetAutoApplyFixIts (auto_apply_fixits);
399
- options.SetRetriesWithFixIts (target.GetNumberOfRetriesWithFixits ());
400
-
401
- if (m_command_options.top_level )
402
- options.SetExecutionPolicy (eExecutionPolicyTopLevel);
403
-
404
- // If there is any chance we are going to stop and want to see what went
405
- // wrong with our expression, we should generate debug info
406
- if (!m_command_options.ignore_breakpoints ||
407
- !m_command_options.unwind_on_error )
408
- options.SetGenerateDebugInfo (true );
409
-
410
- if (m_command_options.timeout > 0 )
411
- options.SetTimeout (std::chrono::microseconds (m_command_options.timeout ));
412
- else
413
- options.SetTimeout (llvm::None);
414
- return options;
415
- }
416
-
417
415
bool CommandObjectExpression::EvaluateExpression (llvm::StringRef expr,
418
416
Stream &output_stream,
419
417
Stream &error_stream,
@@ -434,7 +432,8 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
434
432
return false ;
435
433
}
436
434
437
- const EvaluateExpressionOptions options = GetEvalOptions (target);
435
+ const EvaluateExpressionOptions options =
436
+ m_command_options.GetEvaluateExpressionOptions (target, m_varobj_options);
438
437
ExpressionResults success = target.EvaluateExpression (
439
438
expr, frame, result_valobj_sp, options, &m_fixed_expression);
440
439
0 commit comments