blob: 05e4a725902aba1c528925ce7f8a06c0349b0e73 [file]
# Copyright 2026 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from dataclasses import dataclass, field
@dataclass
class Thread:
"""Represents a thread in a target process."""
id: int
name: str = field(default="", compare=False)
is_stopped: bool = field(default=False, compare=False)
process: "Process | None" = field(default=None, repr=False, compare=False)
def resume(self) -> None:
"""Marks the thread as resumed (is_stopped = False)."""
self.is_stopped = False
@dataclass
class Process:
"""Represents a debugged target process."""
id: int
name: str = field(default="", compare=False)
threads: dict[int, Thread] = field(
default_factory=dict, repr=False, compare=False
)
def resume(self) -> None:
"""Marks all threads in the process as resumed."""
for t in self.threads.values():
t.resume()
@property
def all_threads_stopped(self) -> bool:
return bool(self.threads) and all(
t.is_stopped for t in self.threads.values()
)