From 9179355e655d78cf44ffdfb432e134eabceaebab Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sat, 14 Oct 2017 09:10:42 -0400 Subject: gdbserver: Use std::list for all_processes Remove the usage of inferior_list for the all_processes list in gdbserver, replace it with an std::list. The entry field in process_info is removed, and replaced by a simple pid field. The pid_of macro, used for both processes and threads, is replaced with separate functions. For completeness, I changed ptid_of and lwpid_of to functions as well. gdb/gdbserver/ChangeLog: * gdbthread.h (ptid_of, pid_of, lwpid_of): New functions. * inferiors.h: Include . (struct process_info) : Remove field. : New field. (pid_of): Change macro to function. (ptid_of, lwpid_of): Remove macro. (all_processes): Change type to std::list. (ALL_PROCESSES): Remove macro. (for_each_process, find_process): New function. * inferiors.c (all_processes): Change type to std::list. (find_thread_process): Adjust. (add_process): Likewise. (remove_process): Likewise. (find_process_pid): Likewise. (get_first_process): Likewise. (started_inferior_callback): Remove. (have_started_inferiors_p): Adjust. (attached_inferior_callback): Remove. (have_attached_inferiors_p): Adjust. * linux-low.c (check_zombie_leaders): Likewise. * linux-x86-low.c (x86_arch_setup_process_callback): Remove. (x86_linux_update_xmltarget): Adjust. * server.c (handle_query): Likewise. (gdb_reattached_process): Remove. (handle_status): Adjust. (kill_inferior_callback): Likewise. (detach_or_kill_inferior): Remove. (print_started_pid): Likewise. (print_attached_pid): Likewise. (detach_or_kill_for_exit): Update. (process_serial_event): Likewise. * linux-arm-low.c (arm_new_fork): Likewise. --- gdb/gdbserver/gdbthread.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'gdb/gdbserver/gdbthread.h') diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h index a864f95..93688a3 100644 --- a/gdb/gdbserver/gdbthread.h +++ b/gdb/gdbserver/gdbthread.h @@ -88,6 +88,30 @@ struct thread_info *find_any_thread_of_pid (int pid); /* Get current thread ID (Linux task ID). */ #define current_ptid (current_thread->entry.id) +/* Get the ptid of THREAD. */ + +static inline ptid_t +ptid_of (const thread_info *thread) +{ + return thread->entry.id; +} + +/* Get the pid of THREAD. */ + +static inline int +pid_of (const thread_info *thread) +{ + return thread->entry.id.pid (); +} + +/* Get the lwp of THREAD. */ + +static inline long +lwpid_of (const thread_info *thread) +{ + return thread->entry.id.lwp (); +} + /* Create a cleanup to restore current_thread. */ struct cleanup *make_cleanup_restore_current_thread (void); -- cgit v1.1