aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-nat.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-08-28 10:58:45 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-09-27 22:30:11 -0400
commit901b98215e767bbffb1bfa869e02d7dc5ea786ec (patch)
tree31da2785d795cdf08419b11c6cfd701f1fa7b248 /gdb/linux-nat.h
parent676362df181a39a5c58bba15f4f7524bfd58b88d (diff)
downloadgdb-901b98215e767bbffb1bfa869e02d7dc5ea786ec.zip
gdb-901b98215e767bbffb1bfa869e02d7dc5ea786ec.tar.gz
gdb-901b98215e767bbffb1bfa869e02d7dc5ea786ec.tar.bz2
gdb: use intrusive_list for linux-nat lwp_list
Replace the manually maintained linked list of lwp_info objects with intrusive_list. Replace the ALL_LWPS macro with all_lwps, which returns a range. Add all_lwps_safe as well, for use in iterate_over_lwps, which currently iterates in a safe manner. Change-Id: I355313502510acc0103f5eaf2fbde80897d6376c
Diffstat (limited to 'gdb/linux-nat.h')
-rw-r--r--gdb/linux-nat.h35
1 files changed, 16 insertions, 19 deletions
diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h
index b1b168d..74b5edd 100644
--- a/gdb/linux-nat.h
+++ b/gdb/linux-nat.h
@@ -196,11 +196,9 @@ extern linux_nat_target *linux_target;
struct arch_lwp_info;
-/* Structure describing an LWP. This is public only for the purposes
- of ALL_LWPS; target-specific code should generally not access it
- directly. */
+/* Structure describing an LWP. */
-struct lwp_info
+struct lwp_info : intrusive_list_node<lwp_info>
{
lwp_info (ptid_t ptid)
: ptid (ptid)
@@ -283,27 +281,26 @@ struct lwp_info
/* Arch-specific additions. */
struct arch_lwp_info *arch_private = nullptr;
-
- /* Previous and next pointers in doubly-linked list of known LWPs,
- sorted by reverse creation order. */
- struct lwp_info *prev = nullptr;
- struct lwp_info *next = nullptr;
};
-/* The global list of LWPs, for ALL_LWPS. Unlike the threads list,
- there is always at least one LWP on the list while the GNU/Linux
- native target is active. */
-extern struct lwp_info *lwp_list;
+/* lwp_info iterator and range types. */
+
+using lwp_info_iterator
+ = reference_to_pointer_iterator<intrusive_list<lwp_info>::iterator>;
+using lwp_info_range = iterator_range<lwp_info_iterator>;
+using lwp_info_safe_range = basic_safe_range<lwp_info_range>;
+
+/* Get an iterable range over all lwps. */
+
+lwp_info_range all_lwps ();
+
+/* Same as the above, but safe against deletion while iterating. */
+
+lwp_info_safe_range all_lwps_safe ();
/* Does the current host support PTRACE_GETREGSET? */
extern enum tribool have_ptrace_getregset;
-/* Iterate over each active thread (light-weight process). */
-#define ALL_LWPS(LP) \
- for ((LP) = lwp_list; \
- (LP) != NULL; \
- (LP) = (LP)->next)
-
/* Called from the LWP layer to inform the thread_db layer that PARENT
spawned CHILD. Both LWPs are currently stopped. This function
does whatever is required to have the child LWP under the