From: Jonas Devlieghere Date: Fri, 24 Apr 2020 19:50:06 +0000 (-0700) Subject: [lldb/Driver] Remove level of indentation (NFC) X-Git-Tag: llvmorg-12-init~7895 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d671dbca949e70536da371a43dc55248301705f;p=platform%2Fupstream%2Fllvm.git [lldb/Driver] Remove level of indentation (NFC) Use an early return for when we couldn't create a pipe to source the commands. --- diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 6703617..56f1815 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -592,57 +592,54 @@ int Driver::MainLoop() { bool quit_requested = false; bool stopped_for_crash = false; if ((commands_data != nullptr) && (commands_size != 0u)) { - bool success = true; FILE *commands_file = PrepareCommandsForSourcing(commands_data, commands_size); - if (commands_file != nullptr) { - m_debugger.SetInputFileHandle(commands_file, true); - - // Set the debugger into Sync mode when running the command file. - // Otherwise command files - // that run the target won't run in a sensible way. - bool old_async = m_debugger.GetAsync(); - m_debugger.SetAsync(false); - int num_errors = 0; - - SBCommandInterpreterRunOptions options; - options.SetStopOnError(true); - if (m_option_data.m_batch) - options.SetStopOnCrash(true); - - m_debugger.RunCommandInterpreter(handle_events, spawn_thread, options, - num_errors, quit_requested, - stopped_for_crash); - - if (m_option_data.m_batch && stopped_for_crash && - !m_option_data.m_after_crash_commands.empty()) { - SBStream crash_commands_stream; - WriteCommandsForSourcing(eCommandPlacementAfterCrash, - crash_commands_stream); - const char *crash_commands_data = crash_commands_stream.GetData(); - const size_t crash_commands_size = crash_commands_stream.GetSize(); - commands_file = PrepareCommandsForSourcing(crash_commands_data, - crash_commands_size); - if (commands_file != nullptr) { - bool local_quit_requested; - bool local_stopped_for_crash; - m_debugger.SetInputFileHandle(commands_file, true); - - m_debugger.RunCommandInterpreter(handle_events, spawn_thread, options, - num_errors, local_quit_requested, - local_stopped_for_crash); - if (local_quit_requested) - quit_requested = true; - } - } - m_debugger.SetAsync(old_async); - } else - success = false; - // Something went wrong with command pipe - if (!success) { + if (commands_file == nullptr) { + // We should have already printed an error in PrepareCommandsForSourcing. exit(1); } + + m_debugger.SetInputFileHandle(commands_file, true); + + // Set the debugger into Sync mode when running the command file. + // Otherwise command files + // that run the target won't run in a sensible way. + bool old_async = m_debugger.GetAsync(); + m_debugger.SetAsync(false); + int num_errors = 0; + + SBCommandInterpreterRunOptions options; + options.SetStopOnError(true); + if (m_option_data.m_batch) + options.SetStopOnCrash(true); + + m_debugger.RunCommandInterpreter(handle_events, spawn_thread, options, + num_errors, quit_requested, + stopped_for_crash); + + if (m_option_data.m_batch && stopped_for_crash && + !m_option_data.m_after_crash_commands.empty()) { + SBStream crash_commands_stream; + WriteCommandsForSourcing(eCommandPlacementAfterCrash, + crash_commands_stream); + const char *crash_commands_data = crash_commands_stream.GetData(); + const size_t crash_commands_size = crash_commands_stream.GetSize(); + commands_file = + PrepareCommandsForSourcing(crash_commands_data, crash_commands_size); + if (commands_file != nullptr) { + bool local_quit_requested; + bool local_stopped_for_crash; + m_debugger.SetInputFileHandle(commands_file, true); + + m_debugger.RunCommandInterpreter(handle_events, spawn_thread, options, + num_errors, local_quit_requested, + local_stopped_for_crash); + if (local_quit_requested) + quit_requested = true; + } + } + m_debugger.SetAsync(old_async); } // Now set the input file handle to STDIN and run the command