Skip to content

Commit 4c00dbf

Browse files
committed
lldbutil: Forward ASan launch info to test inferiors
This allows an unsanitized test process which loads a sanitized DSO (the motivating example is a Swift runtime dylib) to launch on Darwin. rdar://57290132 Differential Revision: https://reviews.llvm.org/D71379
1 parent c5adcdc commit 4c00dbf

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lldb/packages/Python/lldbsuite/test/lldbutil.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
# LLDB modules
2121
import lldb
22+
from . import lldbtest_config
2223

2324

2425
# ===================================================
@@ -758,14 +759,20 @@ def run_to_breakpoint_make_target(test, exe_name = "a.out", in_cwd = True):
758759
# Create the target
759760
target = test.dbg.CreateTarget(exe)
760761
test.assertTrue(target, "Target: %s is not valid."%(exe_name))
762+
763+
# Set environment variables for the inferior.
764+
if lldbtest_config.inferior_env:
765+
test.runCmd('settings set target.env-vars {}'.format(
766+
lldbtest_config.inferior_env))
767+
761768
return target
762769

763770
def run_to_breakpoint_do_run(test, target, bkpt, launch_info = None,
764771
only_one_thread = True, extra_images = None):
765772

766773
# Launch the process, and do not stop at the entry point.
767774
if not launch_info:
768-
launch_info = lldb.SBLaunchInfo(None)
775+
launch_info = target.GetLaunchInfo()
769776
launch_info.SetWorkingDirectory(test.get_process_working_directory())
770777

771778
if extra_images and lldb.remote_platform:

lldb/test/API/lit.cfg.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ def find_shlibpath_var():
8787
if config.llvm_libs_dir:
8888
dotest_cmd += ['--env', 'LLVM_LIBS_DIR=' + config.llvm_libs_dir]
8989

90+
# Forward ASan-specific environment variables to tests, as a test may load an
91+
# ASan-ified dylib.
92+
for env_var in ('ASAN_OPTIONS', 'DYLD_INSERT_LIBRARIES'):
93+
if env_var in config.environment:
94+
dotest_cmd += ['--inferior-env', env_var + '=' + config.environment[env_var]]
95+
9096
if config.lldb_build_directory:
9197
dotest_cmd += ['--build-dir', config.lldb_build_directory]
9298

0 commit comments

Comments
 (0)