-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Swift REPL] Inherit the environment for the Swift REPL #9853
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,23 +188,18 @@ lldb::REPLSP SwiftREPL::CreateInstanceFromDebugger(Status &err, | |
// breakpoint above, it better | ||
// say it is internal | ||
|
||
lldb_private::ProcessLaunchInfo launch_info; | ||
llvm::StringRef target_settings_argv0 = target_sp->GetArg0(); | ||
|
||
if (target_sp->GetDisableASLR()) | ||
launch_info.GetFlags().Set(eLaunchFlagDisableASLR); | ||
|
||
if (target_sp->GetDisableSTDIO()) | ||
launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO); | ||
lldb_private::ProcessLaunchInfo launch_info = | ||
target_sp->GetProcessLaunchInfo(); | ||
|
||
// FIXME: Why is this necessary? Document or change once we know the answer. | ||
llvm::StringRef target_settings_argv0 = target_sp->GetArg0(); | ||
if (!target_settings_argv0.empty()) { | ||
launch_info.GetArguments().AppendArgument(target_settings_argv0); | ||
launch_info.SetExecutableFile(exe_module_sp->GetPlatformFileSpec(), false); | ||
} else { | ||
launch_info.SetExecutableFile(exe_module_sp->GetPlatformFileSpec(), true); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you get the LaunchEnvironment from the target, these should also be properly set already. I don't think you want to override them here either. The benefit of this change is it allows you to set everything you need to set for the REPL execution in the Target you make for it, then we don't have to overwrite anything here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought the same thing, but All the REPL test fail without this code. I didn't want to get sidetracked so I left a FIXME to figure out why this is necessary and document it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. Looking more closely, if you have set up the arguments properly in the Target, we won't muck with them, so I guess having a "If you don't, we'll fix it for you..." is okay for now. |
||
launch_info.GetEnvironment() = target_sp->GetTargetEnvironment(); | ||
debugger.SetAsyncExecution(false); | ||
err = target_sp->Launch(launch_info, nullptr); | ||
debugger.SetAsyncExecution(true); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Test inheriting environment variables in the REPL. | ||
// REQUIRES: system-darwin | ||
// REQUIRES: swift | ||
|
||
// RUN: FOO=foo %lldb --repl -O 'settings set target.inherit-env true' < %s 2>&1 \ | ||
// RUN: | FileCheck %s | ||
|
||
import Foundation | ||
ProcessInfo.processInfo.environment["FOO"] | ||
// CHECK: $R0: String? = "foo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this dead code anyway?