diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index 6bd57294e848..c844e0692447 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -728,7 +728,7 @@ namespace lldb_private { uint64_t &high); virtual int32_t - GetResumeCountForShell (const char *shell) + GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info) { return 1; } diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index 42a458442a6f..94dcc60bea3e 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -415,7 +415,7 @@ PlatformLinux::LaunchProcess (ProcessLaunchInfo &launch_info) const bool is_localhost = true; const bool will_debug = launch_info.GetFlags().Test(eLaunchFlagDebug); const bool first_arg_is_full_shell_command = false; - uint32_t num_resumes = GetResumeCountForShell (launch_info.GetShell()); + uint32_t num_resumes = GetResumeCountForLaunchInfo (launch_info); if (!launch_info.ConvertArgumentsForLaunchingInShell (error, is_localhost, will_debug, diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 46fe00490508..b5327d5870d8 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -1226,8 +1226,12 @@ PlatformDarwin::GetEnvironment (StringList &env) } int32_t -PlatformDarwin::GetResumeCountForShell (const char *shell) +PlatformDarwin::GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info) { + const char *shell = launch_info.GetShell(); + if (shell == NULL) + return 1; + const char *shell_name = strrchr (shell, '/'); if (shell_name == NULL) shell_name = shell; @@ -1237,7 +1241,18 @@ PlatformDarwin::GetResumeCountForShell (const char *shell) if (strcmp (shell_name, "sh") == 0) { // /bin/sh re-exec's itself as /bin/bash requiring another resume. - return 2; + // But it only does this if the COMMAND_MODE environment variable + // is set to "legacy". + char * const *envp = (char * const*)launch_info.GetEnvironmentEntries().GetConstArgumentVector(); + if (envp != NULL) + { + for (int i = 0; envp[i] != NULL; i++) + { + if (strcmp (envp[i], "COMMAND_MODE=legacy" ) == 0) + return 2; + } + } + return 1; } else if (strcmp (shell_name, "csh") == 0 || strcmp (shell_name, "tcsh") == 0 diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h index 6b8f68baee5c..4e9b7029b518 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h @@ -118,7 +118,7 @@ public: x86GetSupportedArchitectureAtIndex (uint32_t idx, lldb_private::ArchSpec &arch); virtual int32_t - GetResumeCountForShell (const char *shell); + GetResumeCountForLaunchInfo (lldb_private::ProcessLaunchInfo &launch_info); protected: virtual lldb_private::Error diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index ec418f63564c..75d94bd91ce3 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -664,7 +664,7 @@ Platform::LaunchProcess (ProcessLaunchInfo &launch_info) const bool is_localhost = true; const bool will_debug = launch_info.GetFlags().Test(eLaunchFlagDebug); const bool first_arg_is_full_shell_command = false; - uint32_t num_resumes = GetResumeCountForShell (launch_info.GetShell()); + uint32_t num_resumes = GetResumeCountForLaunchInfo (launch_info); if (!launch_info.ConvertArgumentsForLaunchingInShell (error, is_localhost, will_debug,