[Lldb-commits] [lldb] r190538 - Turns out the number of times you need to resume the process for /bin/sh depends on the
Jim Ingham
jingham at apple.com
Wed Sep 11 11:23:22 PDT 2013
Author: jingham
Date: Wed Sep 11 13:23:22 2013
New Revision: 190538
URL: http://llvm.org/viewvc/llvm-project?rev=190538&view=rev
Log:
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.
Modified:
lldb/trunk/include/lldb/Target/Platform.h
lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
lldb/trunk/source/Target/Platform.cpp
Modified: lldb/trunk/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=190538&r1=190537&r2=190538&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Platform.h (original)
+++ lldb/trunk/include/lldb/Target/Platform.h Wed Sep 11 13:23:22 2013
@@ -728,7 +728,7 @@ namespace lldb_private {
uint64_t &high);
virtual int32_t
- GetResumeCountForShell (const char *shell)
+ GetResumeCountForLaunchInfo (ProcessLaunchInfo &launch_info)
{
return 1;
}
Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=190538&r1=190537&r2=190538&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Wed Sep 11 13:23:22 2013
@@ -415,7 +415,7 @@ PlatformLinux::LaunchProcess (ProcessLau
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,
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=190538&r1=190537&r2=190538&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Wed Sep 11 13:23:22 2013
@@ -1226,8 +1226,12 @@ PlatformDarwin::GetEnvironment (StringLi
}
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 (
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
Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h?rev=190538&r1=190537&r2=190538&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h Wed Sep 11 13:23:22 2013
@@ -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
Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=190538&r1=190537&r2=190538&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Wed Sep 11 13:23:22 2013
@@ -664,7 +664,7 @@ Platform::LaunchProcess (ProcessLaunchIn
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,
More information about the lldb-commits
mailing list