@@ -589,60 +589,58 @@ bool CommandObjectExpression::DoExecute(llvm::StringRef command,
589
589
return false ;
590
590
591
591
if (m_repl_option.GetOptionValue ().GetCurrentValue ()) {
592
- Target *target = m_interpreter.GetExecutionContext ().GetTargetPtr ();
593
- if (target) {
594
- // Drop into REPL
595
- m_expr_lines.clear ();
596
- m_expr_line_count = 0 ;
597
-
598
- Debugger &debugger = target->GetDebugger ();
599
-
600
- // Check if the LLDB command interpreter is sitting on top of a REPL
601
- // that launched it...
602
- if (debugger.CheckTopIOHandlerTypes (IOHandler::Type::CommandInterpreter,
603
- IOHandler::Type::REPL)) {
604
- // the LLDB command interpreter is sitting on top of a REPL that
605
- // launched it, so just say the command interpreter is done and
606
- // fall back to the existing REPL
607
- m_interpreter.GetIOHandler (false )->SetIsDone (true );
608
- } else {
609
- // We are launching the REPL on top of the current LLDB command
610
- // interpreter, so just push one
611
- bool initialize = false ;
612
- Status repl_error;
613
- REPLSP repl_sp (target->GetREPL (repl_error, m_command_options.language ,
614
- nullptr , false ));
615
-
616
- if (!repl_sp) {
617
- initialize = true ;
618
- repl_sp = target->GetREPL (repl_error, m_command_options.language ,
619
- nullptr , true );
620
- if (!repl_error.Success ()) {
621
- result.SetError (repl_error);
622
- return result.Succeeded ();
623
- }
592
+ Target &target = GetSelectedOrDummyTarget ();
593
+ // Drop into REPL
594
+ m_expr_lines.clear ();
595
+ m_expr_line_count = 0 ;
596
+
597
+ Debugger &debugger = target.GetDebugger ();
598
+
599
+ // Check if the LLDB command interpreter is sitting on top of a REPL
600
+ // that launched it...
601
+ if (debugger.CheckTopIOHandlerTypes (IOHandler::Type::CommandInterpreter,
602
+ IOHandler::Type::REPL)) {
603
+ // the LLDB command interpreter is sitting on top of a REPL that
604
+ // launched it, so just say the command interpreter is done and
605
+ // fall back to the existing REPL
606
+ m_interpreter.GetIOHandler (false )->SetIsDone (true );
607
+ } else {
608
+ // We are launching the REPL on top of the current LLDB command
609
+ // interpreter, so just push one
610
+ bool initialize = false ;
611
+ Status repl_error;
612
+ REPLSP repl_sp (target.GetREPL (repl_error, m_command_options.language ,
613
+ nullptr , false ));
614
+
615
+ if (!repl_sp) {
616
+ initialize = true ;
617
+ repl_sp = target.GetREPL (repl_error, m_command_options.language ,
618
+ nullptr , true );
619
+ if (!repl_error.Success ()) {
620
+ result.SetError (repl_error);
621
+ return result.Succeeded ();
624
622
}
623
+ }
625
624
626
- if (repl_sp) {
627
- if (initialize) {
628
- repl_sp->SetEvaluateOptions (
629
- GetExprOptions (exe_ctx, m_command_options));
630
- repl_sp->SetFormatOptions (m_format_options);
631
- repl_sp->SetValueObjectDisplayOptions (m_varobj_options);
632
- }
625
+ if (repl_sp) {
626
+ if (initialize) {
627
+ repl_sp->SetEvaluateOptions (
628
+ GetExprOptions (exe_ctx, m_command_options));
629
+ repl_sp->SetFormatOptions (m_format_options);
630
+ repl_sp->SetValueObjectDisplayOptions (m_varobj_options);
631
+ }
633
632
634
- IOHandlerSP io_handler_sp (repl_sp->GetIOHandler ());
633
+ IOHandlerSP io_handler_sp (repl_sp->GetIOHandler ());
635
634
636
- io_handler_sp->SetIsDone (false );
635
+ io_handler_sp->SetIsDone (false );
637
636
638
- debugger.PushIOHandler (io_handler_sp);
639
- } else {
640
- repl_error.SetErrorStringWithFormat (
641
- " Couldn't create a REPL for %s" ,
642
- Language::GetNameForLanguageType (m_command_options.language ));
643
- result.SetError (repl_error);
644
- return result.Succeeded ();
645
- }
637
+ debugger.PushIOHandler (io_handler_sp);
638
+ } else {
639
+ repl_error.SetErrorStringWithFormat (
640
+ " Couldn't create a REPL for %s" ,
641
+ Language::GetNameForLanguageType (m_command_options.language ));
642
+ result.SetError (repl_error);
643
+ return result.Succeeded ();
646
644
}
647
645
}
648
646
}
0 commit comments