Turns out the number of times you need to resume the process for /bin/sh depends on the

setting of the environment variable COMMAND_MODE.  Changed the Platform::GetResumeCountForShell
to Platform::GetResumeCountForLaunchInfo, and check both the shell and in the case of
/bin/sh the environment as well.

llvm-svn: 190538
This commit is contained in:
Jim Ingham 2013-09-11 18:23:22 +00:00
parent 48c9900713
commit d39907935c
5 changed files with 21 additions and 6 deletions

View File

@ -728,7 +728,7 @@ namespace lldb_private {
uint64_t &high);
virtual int32_t
GetResumeCountForShell (const char *shell)
GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info)
{
return 1;
}

View File

@ -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,

View File

@ -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,8 +1241,19 @@ PlatformDarwin::GetResumeCountForShell (const char *shell)
if (strcmp (shell_name, "sh") == 0)
{
// /bin/sh re-exec's itself as /bin/bash requiring another resume.
// 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
|| strcmp (shell_name, "zsh") == 0)

View File

@ -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

View File

@ -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,