Skip to content

[debuginfo-tests] Use built lldb for testing if available #131681

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

Merged
merged 2 commits into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cross-project-tests/debuginfo-tests/llgdb-tests/llgdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
# 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@
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";
}
Expand Down
13 changes: 12 additions & 1 deletion cross-project-tests/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,21 @@

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(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't we pass in the right python executable and the full path to the LLDB python packages here, then there doesn't need to be any guesswork in the other two files.

config.cross_project_tests_src_root,
"debuginfo-tests",
"llgdb-tests",
Expand Down