diff --git a/cross-project-tests/debuginfo-tests/llgdb-tests/llgdb.py b/cross-project-tests/debuginfo-tests/llgdb-tests/llgdb.py index 6795d3b989a3..f3146f794e1e 100755 --- a/cross-project-tests/debuginfo-tests/llgdb-tests/llgdb.py +++ b/cross-project-tests/debuginfo-tests/llgdb-tests/llgdb.py @@ -8,6 +8,11 @@ commands to run the tests in the debuginfo-tests repository with lldb. # Auto-detect lldb python module. import subprocess, platform, os, sys +# Set the path to look first for the built lldb (in case it exists). +lldb_python_path = os.environ["LLDB_PYTHON_PATH"] +if len(lldb_python_path) > 0: + sys.path.insert(0, lldb_python_path) + try: # Just try for LLDB in case PYTHONPATH is already correctly setup. import lldb diff --git a/cross-project-tests/debuginfo-tests/llgdb-tests/test_debuginfo.pl b/cross-project-tests/debuginfo-tests/llgdb-tests/test_debuginfo.pl index fa52a5037c21..9c922bc8ac92 100755 --- a/cross-project-tests/debuginfo-tests/llgdb-tests/test_debuginfo.pl +++ b/cross-project-tests/debuginfo-tests/llgdb-tests/test_debuginfo.pl @@ -56,7 +56,11 @@ my $my_debugger = $ENV{'DEBUGGER'}; if (!$my_debugger) { if ($use_lldb) { my $path = dirname(Cwd::abs_path($0)); - $my_debugger = "/usr/bin/xcrun python3 $path/llgdb.py"; + my $python_exec_path = $ENV{'PYTHON_EXEC_PATH'}; + if (!$python_exec_path) { + $python_exec_path = 'python3'; + } + $my_debugger = "LLDB_PYTHON_PATH=$ENV{'LLDB_PYTHON_PATH'} /usr/bin/xcrun $python_exec_path $path/llgdb.py"; } else { $my_debugger = "gdb"; } diff --git a/cross-project-tests/lit.cfg.py b/cross-project-tests/lit.cfg.py index 66fdd6363288..ccd3d01023c9 100644 --- a/cross-project-tests/lit.cfg.py +++ b/cross-project-tests/lit.cfg.py @@ -34,10 +34,21 @@ config.test_exec_root = config.cross_project_tests_obj_root llvm_config.use_default_substitutions() +lldb_python_path = os.path.join( + config.llvm_libs_dir, + f"python{sys.version_info.major}.{sys.version_info.minor}", + "site-packages", +) +python_exec_path = sys.executable tools = [ ToolSubst( "%test_debuginfo", - command=os.path.join( + command="PYTHON_EXEC_PATH=" + + python_exec_path + + " LLDB_PYTHON_PATH=" + + lldb_python_path + + " " + + os.path.join( config.cross_project_tests_src_root, "debuginfo-tests", "llgdb-tests",