Skip to content

Commit

Permalink
Print gdb version to ease debugging (#12836)
Browse files Browse the repository at this point in the history
  • Loading branch information
srittau authored Oct 21, 2024
1 parent a6fb689 commit c020ccc
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions tests/stubtest_third_party.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import argparse
import os
import re
import subprocess
import sys
import tempfile
Expand Down Expand Up @@ -204,13 +205,7 @@ def setup_gdb_stubtest_command(venv_dir: Path, stubtest_cmd: list[str]) -> bool:
print_error("gdb is not supported on Windows")
return False

try:
gdb_version = subprocess.check_output(["gdb", "--version"], text=True, stderr=subprocess.STDOUT)
except FileNotFoundError:
print_error("gdb is not installed")
return False
if "Python scripting is not supported in this copy of GDB" in gdb_version:
print_error("Python scripting is not supported in this copy of GDB")
if not gdb_version_check():
return False

gdb_script = venv_dir / "gdb_stubtest.py"
Expand Down Expand Up @@ -277,6 +272,24 @@ def setup_gdb_stubtest_command(venv_dir: Path, stubtest_cmd: list[str]) -> bool:
return True


def gdb_version_check() -> bool:
try:
gdb_version_output = subprocess.check_output(["gdb", "--version"], text=True, stderr=subprocess.STDOUT)
except FileNotFoundError:
print_error("gdb is not installed")
return False
if "Python scripting is not supported in this copy of GDB" in gdb_version_output:
print_error("Python scripting is not supported in this copy of GDB")
return False
m = re.search(r"GNU gdb\s+.*?(\d+\.\d+(\.[\da-z-]+)+)", gdb_version_output)
if m is None:
print_error("Failed to determine gdb version:\n" + gdb_version_output)
return False
gdb_version = m.group(1)
print(f"({gdb_version}) ", end="", flush=True)
return True


def setup_uwsgi_stubtest_command(dist: Path, venv_dir: Path, stubtest_cmd: list[str]) -> bool:
"""Perform some black magic in order to run stubtest inside uWSGI.
Expand Down

0 comments on commit c020ccc

Please sign in to comment.