Skip to content

Commit c8a924f

Browse files
committed
Use the correct Python executable to match LLDB
The linux-fatal-backtrace script needs to run with an LLDB module loaded into Python. This in turn requires that the test be run with the exact same Python version as was used by LLDB (not just the same Python module directory). This can get confused on systems with multiple versions of Python installed. This replaces `lldb-python-path` (the Python module directory path) with `lldb-python` (which is the correct Python version run with the LLDB path). This should ensure that this test is always run with the same Python version and module that LLDB used.
1 parent 6e7c6fd commit c8a924f

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

test/Runtime/linux-fatal-backtrace.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-build-swift %s -o %t/a.out
3-
// RUN: %{python} %S/../Inputs/not.py "%target-run %t/a.out" 2>&1 | PYTHONPATH=%lldb-python-path %{python} %utils/symbolicate-linux-fatal %t/a.out - | %{python} %utils/backtrace-check -u
3+
// RUN: %{python} %S/../Inputs/not.py "%target-run %t/a.out" 2>&1 | %{lldb-python} %utils/symbolicate-linux-fatal %t/a.out - | %{python} %utils/backtrace-check -u
44
// REQUIRES: executable_test
55
// REQUIRES: OS=linux-gnu
66
// REQUIRES: lldb

test/lit.cfg

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ def get_lldb_python_path(lldb_build_root):
104104
return None
105105
return subprocess.check_output([lldb_path, "-P"]).rstrip().decode('utf-8')
106106

107+
def get_lldb_python_from_path(lldb_path):
108+
for c in lldb_path.split('/'):
109+
if re.match('^python[23].[0-9][0-9]*$', c):
110+
return c
111+
return None
112+
107113
###
108114

109115
# Check that the object root is known.
@@ -1953,8 +1959,15 @@ if config.lldb_build_root != "":
19531959
Specified lldb_build_root, but could not find lldb in that build root
19541960
""")
19551961
else:
1956-
config.available_features.add('lldb')
1957-
config.substitutions.append(('%lldb-python-path', lldb_python_path))
1962+
lldb_python = get_lldb_python_from_path(lldb_python_path)
1963+
if lldb_python == None:
1964+
lit_config.warning("""
1965+
Unable to determine python version from LLDB Python path %s
1966+
""" % lldb_python_path)
1967+
else:
1968+
config.available_features.add('lldb')
1969+
config.substitutions.append(('%lldb-python-path', lldb_python_path))
1970+
config.substitutions.append(('%lldb-python', 'PYTHONPATH=%s %s' % (lldb_python_path, lldb_python)))
19581971

19591972
# Disable randomized hash seeding by default. Tests need to manually opt in to
19601973
# random seeds by unsetting the SWIFT_DETERMINISTIC_HASHING environment

0 commit comments

Comments
 (0)