File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -450,6 +450,29 @@ def for_each_task_in_state(prog: drgn.Program, state: str) -> Iterable[Object]:
450450 yield task
451451
452452
453+ def for_each_task_in_group (
454+ task : Object , include_self : bool = False
455+ ) -> Iterable [Object ]:
456+ """
457+ Iterate over all tasks in the thread group
458+
459+ Or, in the more common userspace terms, iterate over all threads of a
460+ process.
461+
462+ :param task: a task whose group to iterate over
463+ :param include_self: should ``task`` itself be returned
464+ :returns: an iterable of every thread in the thread group
465+ """
466+ if include_self :
467+ yield task
468+ for gtask in list_for_each_entry (
469+ "struct task_struct" ,
470+ task .thread_group .address_of_ (),
471+ "thread_group" ,
472+ ):
473+ yield gtask
474+
475+
453476def count_tasks_in_state (prog : drgn .Program , state : str ) -> int :
454477 """
455478 Count all tasks in a given state.
You can’t perform that action at this time.
0 commit comments