diff options
Diffstat (limited to 'gdb/gdbserver/linux-low.c')
-rw-r--r-- | gdb/gdbserver/linux-low.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 7a12b4f..0c74e11 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -1397,6 +1397,60 @@ num_lwps (int pid) return count; } +/* The arguments passed to iterate_over_lwps. */ + +struct iterate_over_lwps_args +{ + /* The FILTER argument passed to iterate_over_lwps. */ + ptid_t filter; + + /* The CALLBACK argument passed to iterate_over_lwps. */ + iterate_over_lwps_ftype *callback; + + /* The DATA argument passed to iterate_over_lwps. */ + void *data; +}; + +/* Callback for find_inferior used by iterate_over_lwps to filter + calls to the callback supplied to that function. Returning a + nonzero value causes find_inferiors to stop iterating and return + the current inferior_list_entry. Returning zero indicates that + find_inferiors should continue iterating. */ + +static int +iterate_over_lwps_filter (struct inferior_list_entry *entry, void *args_p) +{ + struct iterate_over_lwps_args *args + = (struct iterate_over_lwps_args *) args_p; + + if (ptid_match (entry->id, args->filter)) + { + struct thread_info *thr = (struct thread_info *) entry; + struct lwp_info *lwp = get_thread_lwp (thr); + + return (*args->callback) (lwp, args->data); + } + + return 0; +} + +/* See nat/linux-nat.h. */ + +struct lwp_info * +iterate_over_lwps (ptid_t filter, + iterate_over_lwps_ftype callback, + void *data) +{ + struct iterate_over_lwps_args args = {filter, callback, data}; + struct inferior_list_entry *entry; + + entry = find_inferior (&all_threads, iterate_over_lwps_filter, &args); + if (entry == NULL) + return NULL; + + return get_thread_lwp ((struct thread_info *) entry); +} + /* Detect zombie thread group leaders, and "exit" them. We can't reap their exits until all other threads in the group have exited. */ |