[Lldb-commits] [lldb] 1d5e9d3 - Convert to early exit (NFC)
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 17 14:42:34 PDT 2020
Author: Adrian Prantl
Date: 2020-08-17T14:42:24-07:00
New Revision: 1d5e9d37c33906d2d7beb2ced62c7777482dd77e
URL: https://github.com/llvm/llvm-project/commit/1d5e9d37c33906d2d7beb2ced62c7777482dd77e
DIFF: https://github.com/llvm/llvm-project/commit/1d5e9d37c33906d2d7beb2ced62c7777482dd77e.diff
LOG: Convert to early exit (NFC)
Added:
Modified:
lldb/source/Target/Target.cpp
Removed:
################################################################################
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 405293d35cf3..a3ec621e7141 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -2896,49 +2896,47 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
error = m_process_sp->Launch(launch_info);
}
- if (!m_process_sp) {
- if (error.Success())
- error.SetErrorString("failed to launch or debug process");
+ if (!m_process_sp && error.Success())
+ error.SetErrorString("failed to launch or debug process");
+
+ if (!error.Success())
return error;
- }
- if (error.Success()) {
- if (synchronous_execution ||
- !launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)) {
- ListenerSP hijack_listener_sp(launch_info.GetHijackListener());
- if (!hijack_listener_sp) {
- hijack_listener_sp =
- Listener::MakeListener("lldb.Target.Launch.hijack");
- launch_info.SetHijackListener(hijack_listener_sp);
- m_process_sp->HijackProcessEvents(hijack_listener_sp);
- }
+ if (synchronous_execution ||
+ !launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)) {
+ ListenerSP hijack_listener_sp(launch_info.GetHijackListener());
+ if (!hijack_listener_sp) {
+ hijack_listener_sp = Listener::MakeListener("lldb.Target.Launch.hijack");
+ launch_info.SetHijackListener(hijack_listener_sp);
+ m_process_sp->HijackProcessEvents(hijack_listener_sp);
+ }
- StateType state = m_process_sp->WaitForProcessToStop(
- llvm::None, nullptr, false, hijack_listener_sp, nullptr);
-
- if (state == eStateStopped) {
- if (!launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)) {
- if (synchronous_execution) {
- // Now we have handled the stop-from-attach, and we are just
- // switching to a synchronous resume. So we should switch to the
- // SyncResume hijacker.
- m_process_sp->RestoreProcessEvents();
- m_process_sp->ResumeSynchronous(stream);
- } else {
- m_process_sp->RestoreProcessEvents();
- error = m_process_sp->PrivateResume();
- }
- if (!error.Success()) {
- Status error2;
- error2.SetErrorStringWithFormat(
- "process resume at entry point failed: %s", error.AsCString());
- error = error2;
- }
+ StateType state = m_process_sp->WaitForProcessToStop(
+ llvm::None, nullptr, false, hijack_listener_sp, nullptr);
+
+ if (state == eStateStopped) {
+ if (!launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)) {
+ if (synchronous_execution) {
+ // Now we have handled the stop-from-attach, and we are just
+ // switching to a synchronous resume. So we should switch to the
+ // SyncResume hijacker.
+ m_process_sp->RestoreProcessEvents();
+ m_process_sp->ResumeSynchronous(stream);
+ } else {
+ m_process_sp->RestoreProcessEvents();
+ error = m_process_sp->PrivateResume();
+ }
+ if (!error.Success()) {
+ Status error2;
+ error2.SetErrorStringWithFormat(
+ "process resume at entry point failed: %s", error.AsCString());
+ error = error2;
}
- } else if (state == eStateExited) {
- bool with_shell = !!launch_info.GetShell();
- const int exit_status = m_process_sp->GetExitStatus();
- const char *exit_desc = m_process_sp->GetExitDescription();
+ }
+ } else if (state == eStateExited) {
+ bool with_shell = !!launch_info.GetShell();
+ const int exit_status = m_process_sp->GetExitStatus();
+ const char *exit_desc = m_process_sp->GetExitDescription();
#define LAUNCH_SHELL_MESSAGE \
"\n'r' and 'run' are aliases that default to launching through a " \
"shell.\nTry launching without going through a shell by using 'process " \
@@ -2964,9 +2962,8 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
error.SetErrorStringWithFormat(
"initial process state wasn't stopped: %s", StateAsCString(state));
}
- }
- m_process_sp->RestoreProcessEvents();
}
+ m_process_sp->RestoreProcessEvents();
return error;
}
More information about the lldb-commits
mailing list