Skip to content

Commit 6aecf56

Browse files
authored
Merge pull request #9859 from swiftlang/rdar143212617
[Swift REPL] Inherit the environment for the Swift REPL
2 parents 46b1149 + f8b3289 commit 6aecf56

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

lldb/source/Plugins/ExpressionParser/Swift/SwiftREPL.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,23 +188,18 @@ lldb::REPLSP SwiftREPL::CreateInstanceFromDebugger(Status &err,
188188
// breakpoint above, it better
189189
// say it is internal
190190

191-
lldb_private::ProcessLaunchInfo launch_info;
192-
llvm::StringRef target_settings_argv0 = target_sp->GetArg0();
193-
194-
if (target_sp->GetDisableASLR())
195-
launch_info.GetFlags().Set(eLaunchFlagDisableASLR);
196-
197-
if (target_sp->GetDisableSTDIO())
198-
launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO);
191+
lldb_private::ProcessLaunchInfo launch_info =
192+
target_sp->GetProcessLaunchInfo();
199193

194+
// FIXME: Why is this necessary? Document or change once we know the answer.
195+
llvm::StringRef target_settings_argv0 = target_sp->GetArg0();
200196
if (!target_settings_argv0.empty()) {
201197
launch_info.GetArguments().AppendArgument(target_settings_argv0);
202198
launch_info.SetExecutableFile(exe_module_sp->GetPlatformFileSpec(), false);
203199
} else {
204200
launch_info.SetExecutableFile(exe_module_sp->GetPlatformFileSpec(), true);
205201
}
206202

207-
launch_info.GetEnvironment() = target_sp->GetTargetEnvironment();
208203
debugger.SetAsyncExecution(false);
209204
err = target_sp->Launch(launch_info, nullptr);
210205
debugger.SetAsyncExecution(true);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Test inheriting environment variables in the REPL.
2+
// REQUIRES: system-darwin
3+
// REQUIRES: swift
4+
5+
// RUN: FOO=foo %lldb --repl -O 'settings set target.inherit-env true' < %s 2>&1 \
6+
// RUN: | FileCheck %s
7+
8+
import Foundation
9+
ProcessInfo.processInfo.environment["FOO"]
10+
// CHECK: $R0: String? = "foo"

0 commit comments

Comments
 (0)