|
5 | 5 |
|
6 | 6 | import argparse |
7 | 7 | import os |
| 8 | +import re |
8 | 9 | import subprocess |
9 | 10 | import sys |
10 | 11 | import tempfile |
@@ -204,13 +205,7 @@ def setup_gdb_stubtest_command(venv_dir: Path, stubtest_cmd: list[str]) -> bool: |
204 | 205 | print_error("gdb is not supported on Windows") |
205 | 206 | return False |
206 | 207 |
|
207 | | - try: |
208 | | - gdb_version = subprocess.check_output(["gdb", "--version"], text=True, stderr=subprocess.STDOUT) |
209 | | - except FileNotFoundError: |
210 | | - print_error("gdb is not installed") |
211 | | - return False |
212 | | - if "Python scripting is not supported in this copy of GDB" in gdb_version: |
213 | | - print_error("Python scripting is not supported in this copy of GDB") |
| 208 | + if not gdb_version_check(): |
214 | 209 | return False |
215 | 210 |
|
216 | 211 | gdb_script = venv_dir / "gdb_stubtest.py" |
@@ -277,6 +272,24 @@ def setup_gdb_stubtest_command(venv_dir: Path, stubtest_cmd: list[str]) -> bool: |
277 | 272 | return True |
278 | 273 |
|
279 | 274 |
|
| 275 | +def gdb_version_check() -> bool: |
| 276 | + try: |
| 277 | + gdb_version_output = subprocess.check_output(["gdb", "--version"], text=True, stderr=subprocess.STDOUT) |
| 278 | + except FileNotFoundError: |
| 279 | + print_error("gdb is not installed") |
| 280 | + return False |
| 281 | + if "Python scripting is not supported in this copy of GDB" in gdb_version_output: |
| 282 | + print_error("Python scripting is not supported in this copy of GDB") |
| 283 | + return False |
| 284 | + m = re.search(r"GNU gdb\s+.*?(\d+\.\d+(\.[\da-z-]+)+)", gdb_version_output) |
| 285 | + if m is None: |
| 286 | + print_error("Failed to determine gdb version:\n" + gdb_version_output) |
| 287 | + return False |
| 288 | + gdb_version = m.group(1) |
| 289 | + print(f"({gdb_version}) ", end="", flush=True) |
| 290 | + return True |
| 291 | + |
| 292 | + |
280 | 293 | def setup_uwsgi_stubtest_command(dist: Path, venv_dir: Path, stubtest_cmd: list[str]) -> bool: |
281 | 294 | """Perform some black magic in order to run stubtest inside uWSGI. |
282 | 295 |
|
|
0 commit comments