Skip to content
Open
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
51 changes: 32 additions & 19 deletions ci/timeout_with_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import argparse
import os
import shutil
import signal
import subprocess
import sys
Expand Down Expand Up @@ -109,26 +110,38 @@ 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}:")
proc = subprocess.run(
[
"gdb",
"--quiet",
"--pid",
str(pid),
"-ex",
"set pagination off",
"-ex",
"set confirm off",
"-ex",
bt_command,
"-ex",
"quit",
],
capture_output=True,
text=True,
check=False,
)
gdb = shutil.which("gdb")
if gdb is None:
print(f"Skipping stack trace for process {pid}: gdb not found")
return

try:
proc = subprocess.run(
[
gdb,
"--quiet",
"--pid",
str(pid),
"-ex",
"set pagination off",
"-ex",
"set confirm off",
"-ex",
bt_command,
"-ex",
"quit",
],
capture_output=True,
text=True,
check=False,
)
except FileNotFoundError:
print(f"Skipping stack trace for process {pid}: gdb not found")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure how we'll get filenotfounderror here given we just checked for gdb above?

return

print(proc.stdout)
if proc.stderr:
print(proc.stderr, file=sys.stderr)


def capture_all_stacks(pid: int, *, enable_python: bool = False) -> None:
Expand Down
Loading