@@ -592,57 +592,54 @@ int Driver::MainLoop() {
592592 bool quit_requested = false ;
593593 bool stopped_for_crash = false ;
594594 if ((commands_data != nullptr ) && (commands_size != 0u )) {
595- bool success = true ;
596595 FILE *commands_file =
597596 PrepareCommandsForSourcing (commands_data, commands_size);
598- if (commands_file != nullptr ) {
599- m_debugger.SetInputFileHandle (commands_file, true );
600-
601- // Set the debugger into Sync mode when running the command file.
602- // Otherwise command files
603- // that run the target won't run in a sensible way.
604- bool old_async = m_debugger.GetAsync ();
605- m_debugger.SetAsync (false );
606- int num_errors = 0 ;
607-
608- SBCommandInterpreterRunOptions options;
609- options.SetStopOnError (true );
610- if (m_option_data.m_batch )
611- options.SetStopOnCrash (true );
612-
613- m_debugger.RunCommandInterpreter (handle_events, spawn_thread, options,
614- num_errors, quit_requested,
615- stopped_for_crash);
616-
617- if (m_option_data.m_batch && stopped_for_crash &&
618- !m_option_data.m_after_crash_commands .empty ()) {
619- SBStream crash_commands_stream;
620- WriteCommandsForSourcing (eCommandPlacementAfterCrash,
621- crash_commands_stream);
622- const char *crash_commands_data = crash_commands_stream.GetData ();
623- const size_t crash_commands_size = crash_commands_stream.GetSize ();
624- commands_file = PrepareCommandsForSourcing (crash_commands_data,
625- crash_commands_size);
626- if (commands_file != nullptr ) {
627- bool local_quit_requested;
628- bool local_stopped_for_crash;
629- m_debugger.SetInputFileHandle (commands_file, true );
630-
631- m_debugger.RunCommandInterpreter (handle_events, spawn_thread, options,
632- num_errors, local_quit_requested,
633- local_stopped_for_crash);
634- if (local_quit_requested)
635- quit_requested = true ;
636- }
637- }
638- m_debugger.SetAsync (old_async);
639- } else
640- success = false ;
641597
642- // Something went wrong with command pipe
643- if (!success) {
598+ if (commands_file == nullptr ) {
599+ // We should have already printed an error in PrepareCommandsForSourcing.
644600 exit (1 );
645601 }
602+
603+ m_debugger.SetInputFileHandle (commands_file, true );
604+
605+ // Set the debugger into Sync mode when running the command file.
606+ // Otherwise command files
607+ // that run the target won't run in a sensible way.
608+ bool old_async = m_debugger.GetAsync ();
609+ m_debugger.SetAsync (false );
610+ int num_errors = 0 ;
611+
612+ SBCommandInterpreterRunOptions options;
613+ options.SetStopOnError (true );
614+ if (m_option_data.m_batch )
615+ options.SetStopOnCrash (true );
616+
617+ m_debugger.RunCommandInterpreter (handle_events, spawn_thread, options,
618+ num_errors, quit_requested,
619+ stopped_for_crash);
620+
621+ if (m_option_data.m_batch && stopped_for_crash &&
622+ !m_option_data.m_after_crash_commands .empty ()) {
623+ SBStream crash_commands_stream;
624+ WriteCommandsForSourcing (eCommandPlacementAfterCrash,
625+ crash_commands_stream);
626+ const char *crash_commands_data = crash_commands_stream.GetData ();
627+ const size_t crash_commands_size = crash_commands_stream.GetSize ();
628+ commands_file =
629+ PrepareCommandsForSourcing (crash_commands_data, crash_commands_size);
630+ if (commands_file != nullptr ) {
631+ bool local_quit_requested;
632+ bool local_stopped_for_crash;
633+ m_debugger.SetInputFileHandle (commands_file, true );
634+
635+ m_debugger.RunCommandInterpreter (handle_events, spawn_thread, options,
636+ num_errors, local_quit_requested,
637+ local_stopped_for_crash);
638+ if (local_quit_requested)
639+ quit_requested = true ;
640+ }
641+ }
642+ m_debugger.SetAsync (old_async);
646643 }
647644
648645 // Now set the input file handle to STDIN and run the command
0 commit comments