diff --git a/ci/timeout_with_stack.py b/ci/timeout_with_stack.py index c38f729f..d2dfa700 100644 --- a/ci/timeout_with_stack.py +++ b/ci/timeout_with_stack.py @@ -23,6 +23,7 @@ import argparse import os +import shutil import signal import subprocess import sys @@ -109,9 +110,14 @@ def capture_stack_trace(pid: int, stack_type=StackType.C) -> None: else: bt_command = "thread apply all py-bt" print(f"\nCapturing Python stack trace for process {pid}:") + gdb = shutil.which("gdb") + if gdb is None: + print(f"Skipping stack trace for process {pid}: gdb not found") + return + proc = subprocess.run( [ - "gdb", + gdb, "--quiet", "--pid", str(pid), @@ -128,7 +134,10 @@ def capture_stack_trace(pid: int, stack_type=StackType.C) -> None: text=True, check=False, ) + print(proc.stdout) + if proc.stderr: + print(proc.stderr, file=sys.stderr) def capture_all_stacks(pid: int, *, enable_python: bool = False) -> None: