Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 6 additions & 4 deletions tests/framework/microvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,10 +1101,12 @@ def thread_backtraces(self):
backtraces = []
for thread_name, thread_pids in utils.get_threads(self.firecracker_pid).items():
for pid in thread_pids:
backtraces.append(
f"{thread_name} ({pid=}):\n"
f"{utils.check_output(f'cat /proc/{pid}/stack').stdout}"
)
try:
stack = Path(f"/proc/{pid}/stack").read_text("UTF-8")
except FileNotFoundError:
continue # process might've gone away between get_threads() call and here

backtraces.append(f"{thread_name} ({pid=}):\n{stack}")
return "\n".join(backtraces)

def _dump_debug_information(self, what: str):
Expand Down
14 changes: 9 additions & 5 deletions tests/framework/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@

def get_threads(pid: int) -> dict:
"""Return dict consisting of child threads."""
threads_map = defaultdict(list)
proc = psutil.Process(pid)
for thread in proc.threads():
threads_map[psutil.Process(thread.id).name()].append(thread.id)
return threads_map
try:
proc = psutil.Process(pid)

threads_map = defaultdict(list)
for thread in proc.threads():
threads_map[psutil.Process(thread.id).name()].append(thread.id)
return threads_map
except psutil.NoSuchProcess:
return {}


def get_cpu_affinity(pid: int) -> list:
Expand Down