This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH v2 1/3] remove all_lwps from gdbserver: rename head -> entry


Hi.
This patch just renames the "head" structure member of structs
that use inferior_list_entry to "entry" so that the same name is
used throughout.
[It also includes a bit of related simplification,
but I saw no real need in splitting that out.]

2014-01-28  Doug Evans  <dje@google.com>

	* dll.h (struct dll_info): Add comment.
	* gdbthread.h (struct thread_info): Add comment.
	(current_ptid): Simplify.
	* inferiors.c (add_process): Update.
	(remove_process): Update.
	* inferiors.h (struct process_info): Rename member "head" to "entry".
	* linux-low.c (delete_lwp): Update.
	(add_lwp): Update.
	(last_thread_of_process_p): Update.
	(kill_one_lwp_callback, linux_kill): Update.
	(status_pending_p_callback): Update.
	(wait_for_sigstop): Update.  Simplify read of ptid.
	(start_step_over): Update.
	* linux-low.h (ptid_of, pid_of, lwpid_of): Update.
	(get_lwp_thread): Update.
	(struct lwp_info): Rename member "head" to "entry".
	* regcache.h (inferior_list_entry): Delete.
	* server.c (kill_inferior_callback): Update.
	(detach_or_kill_inferior_callback): Update.
	(print_started_pid): Update.
	(print_attached_pid): Update.
	(process_serial_event): Simplify read of ptid.
	* thread-db.c (thread_db_create_event): Update.
	(thread_db_get_tls_address): Update.
	* win32-lo.c (current_inferior_ptid): Simplify.

diff --git a/gdb/gdbserver/dll.h b/gdb/gdbserver/dll.h
index 879f5ba..0d26bc6 100644
--- a/gdb/gdbserver/dll.h
+++ b/gdb/gdbserver/dll.h
@@ -20,7 +20,10 @@
 
 struct dll_info
 {
+  /* This must appear first.  See inferiors.h.
+     The list iterator functions assume it.  */
   struct inferior_list_entry entry;
+
   char *name;
   CORE_ADDR base_addr;
 };
diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h
index a1d9ca8..4c454a2 100644
--- a/gdb/gdbserver/gdbthread.h
+++ b/gdb/gdbserver/gdbthread.h
@@ -26,7 +26,10 @@ struct btrace_target_info;
 
 struct thread_info
 {
+  /* This must appear first.  See inferiors.h.
+     The list iterator functions assume it.  */
   struct inferior_list_entry entry;
+
   void *target_data;
   void *regcache_data;
 
@@ -76,6 +79,6 @@ void add_thread (ptid_t ptid, void *target_data);
 struct thread_info *find_thread_ptid (ptid_t ptid);
 
 /* Get current thread ID (Linux task ID).  */
-#define current_ptid ((struct inferior_list_entry *) current_inferior)->id
+#define current_ptid (current_inferior->entry.id)
 
 #endif /* GDB_THREAD_H */
diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c
index 0033958..e3d28ea 100644
--- a/gdb/gdbserver/inferiors.c
+++ b/gdb/gdbserver/inferiors.c
@@ -235,10 +235,10 @@ add_process (int pid, int attached)
 
   process = xcalloc (1, sizeof (*process));
 
-  process->head.id = pid_to_ptid (pid);
+  process->entry.id = pid_to_ptid (pid);
   process->attached = attached;
 
-  add_inferior_to_list (&all_processes, &process->head);
+  add_inferior_to_list (&all_processes, &process->entry);
 
   return process;
 }
@@ -252,7 +252,7 @@ remove_process (struct process_info *process)
 {
   clear_symbol_cache (&process->symbol_cache);
   free_all_breakpoints (process);
-  remove_inferior (&all_processes, &process->head);
+  remove_inferior (&all_processes, &process->entry);
   free (process);
 }
 
diff --git a/gdb/gdbserver/inferiors.h b/gdb/gdbserver/inferiors.h
index 5f99fbc..f02afdd 100644
--- a/gdb/gdbserver/inferiors.h
+++ b/gdb/gdbserver/inferiors.h
@@ -42,7 +42,9 @@ struct process_info_private;
 
 struct process_info
 {
-  struct inferior_list_entry head;
+  /* This must appear first.
+     The list iterator functions assume it.  */
+  struct inferior_list_entry entry;
 
   /* Nonzero if this child process was attached rather than
      spawned.  */
@@ -105,6 +107,7 @@ struct inferior_list_entry *find_inferior
       void *arg);
 struct inferior_list_entry *find_inferior_id (struct inferior_list *list,
 					      ptid_t id);
+
 void *inferior_target_data (struct thread_info *);
 void set_inferior_target_data (struct thread_info *, void *);
 void *inferior_regcache_data (struct thread_info *);
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index c72d681..011ee58 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -347,7 +347,7 @@ static void
 delete_lwp (struct lwp_info *lwp)
 {
   remove_thread (get_lwp_thread (lwp));
-  remove_inferior (&all_lwps, &lwp->head);
+  remove_inferior (&all_lwps, &lwp->entry);
   free (lwp->arch_private);
   free (lwp);
 }
@@ -533,12 +533,12 @@ add_lwp (ptid_t ptid)
   lwp = (struct lwp_info *) xmalloc (sizeof (*lwp));
   memset (lwp, 0, sizeof (*lwp));
 
-  lwp->head.id = ptid;
+  lwp->entry.id = ptid;
 
   if (the_low_target.new_thread != NULL)
     lwp->arch_private = the_low_target.new_thread ();
 
-  add_inferior_to_list (&all_lwps, &lwp->head);
+  add_inferior_to_list (&all_lwps, &lwp->entry);
 
   return lwp;
 }
@@ -865,7 +865,7 @@ second_thread_of_pid_p (struct inferior_list_entry *entry, void *args)
 static int
 last_thread_of_process_p (struct thread_info *thread)
 {
-  ptid_t ptid = ((struct inferior_list_entry *)thread)->id;
+  ptid_t ptid = thread->entry.id;
   int pid = ptid_get_pid (ptid);
   struct counter counter = { pid , 0 };
 
@@ -941,7 +941,7 @@ kill_one_lwp_callback (struct inferior_list_entry *entry, void *args)
       linux_kill_one_lwp (lwp);
 
       /* Make sure it died.  The loop is most likely unnecessary.  */
-      pid = linux_wait_for_event (lwp->head.id, &wstat, __WALL);
+      pid = linux_wait_for_event (lwp->entry.id, &wstat, __WALL);
     } while (pid > 0 && WIFSTOPPED (wstat));
 
   return 0;
@@ -986,7 +986,7 @@ linux_kill (int pid)
 	  linux_kill_one_lwp (lwp);
 
 	  /* Make sure it died.  The loop is most likely unnecessary.  */
-	  lwpid = linux_wait_for_event (lwp->head.id, &wstat, __WALL);
+	  lwpid = linux_wait_for_event (lwp->entry.id, &wstat, __WALL);
 	} while (lwpid > 0 && WIFSTOPPED (wstat));
     }
 
@@ -1223,7 +1223,7 @@ status_pending_p_callback (struct inferior_list_entry *entry, void *arg)
   /* Check if we're only interested in events from a specific process
      or its lwps.  */
   if (!ptid_equal (minus_one_ptid, ptid)
-      && ptid_get_pid (ptid) != ptid_get_pid (lwp->head.id))
+      && ptid_get_pid (ptid) != ptid_get_pid (lwp->entry.id))
     return 0;
 
   thread = get_lwp_thread (lwp);
@@ -2929,11 +2929,11 @@ wait_for_sigstop (struct inferior_list_entry *entry)
 
   saved_inferior = current_inferior;
   if (saved_inferior != NULL)
-    saved_tid = ((struct inferior_list_entry *) saved_inferior)->id;
+    saved_tid = saved_inferior->entry.id;
   else
     saved_tid = null_ptid; /* avoid bogus unused warning */
 
-  ptid = lwp->head.id;
+  ptid = lwp->entry.id;
 
   if (debug_threads)
     debug_printf ("wait_for_sigstop: pulling one event\n");
@@ -3610,7 +3610,7 @@ start_step_over (struct lwp_info *lwp)
   linux_resume_one_lwp (lwp, step, 0, NULL);
 
   /* Require next event from this LWP.  */
-  step_over_bkpt = lwp->head.id;
+  step_over_bkpt = lwp->entry.id;
   return 1;
 }
 
diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h
index f2477d9..3b7ec21 100644
--- a/gdb/gdbserver/linux-low.h
+++ b/gdb/gdbserver/linux-low.h
@@ -223,19 +223,19 @@ struct linux_target_ops
 
 extern struct linux_target_ops the_low_target;
 
-#define ptid_of(proc) ((proc)->head.id)
-#define pid_of(proc) ptid_get_pid ((proc)->head.id)
-#define lwpid_of(proc) ptid_get_lwp ((proc)->head.id)
+#define ptid_of(proc) ((proc)->entry.id)
+#define pid_of(proc) ptid_get_pid ((proc)->entry.id)
+#define lwpid_of(proc) ptid_get_lwp ((proc)->entry.id)
 
 #define get_lwp(inf) ((struct lwp_info *)(inf))
 #define get_thread_lwp(thr) (get_lwp (inferior_target_data (thr)))
 #define get_lwp_thread(proc) ((struct thread_info *)			\
 			      find_inferior_id (&all_threads,		\
-						get_lwp (proc)->head.id))
+						get_lwp (proc)->entry.id))
 
 struct lwp_info
 {
-  struct inferior_list_entry head;
+  struct inferior_list_entry entry;
 
   /* If this flag is set, the next SIGSTOP will be ignored (the
      process will be immediately resumed).  This means that either we
diff --git a/gdb/gdbserver/regcache.h b/gdb/gdbserver/regcache.h
index 6d18d1e..891fead 100644
--- a/gdb/gdbserver/regcache.h
+++ b/gdb/gdbserver/regcache.h
@@ -19,7 +19,6 @@
 #ifndef REGCACHE_H
 #define REGCACHE_H
 
-struct inferior_list_entry;
 struct thread_info;
 struct target_desc;
 
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 88354be..2dc14e8 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -2879,7 +2879,7 @@ static void
 kill_inferior_callback (struct inferior_list_entry *entry)
 {
   struct process_info *process = (struct process_info *) entry;
-  int pid = ptid_get_pid (process->head.id);
+  int pid = ptid_get_pid (process->entry.id);
 
   kill_inferior (pid);
   discard_queued_stop_replies (pid);
@@ -2894,7 +2894,7 @@ static void
 detach_or_kill_inferior_callback (struct inferior_list_entry *entry)
 {
   struct process_info *process = (struct process_info *) entry;
-  int pid = ptid_get_pid (process->head.id);
+  int pid = ptid_get_pid (process->entry.id);
 
   if (process->attached)
     detach_inferior (pid);
@@ -2914,7 +2914,7 @@ print_started_pid (struct inferior_list_entry *entry)
 
   if (! process->attached)
     {
-      int pid = ptid_get_pid (process->head.id);
+      int pid = ptid_get_pid (process->entry.id);
       fprintf (stderr, " %d", pid);
     }
 }
@@ -2929,7 +2929,7 @@ print_attached_pid (struct inferior_list_entry *entry)
 
   if (process->attached)
     {
-      int pid = ptid_get_pid (process->head.id);
+      int pid = ptid_get_pid (process->entry.id);
       fprintf (stderr, " %d", pid);
     }
 }
@@ -3516,7 +3516,7 @@ process_serial_event (void)
 		  break;
 		}
 
-	      thread_id = ((struct inferior_list_entry *)thread)->id;
+	      thread_id = thread->entry.id;
 	    }
 	  else
 	    {
diff --git a/gdb/gdbserver/thread-db.c b/gdb/gdbserver/thread-db.c
index df06b9d..f63e39e 100644
--- a/gdb/gdbserver/thread-db.c
+++ b/gdb/gdbserver/thread-db.c
@@ -210,7 +210,7 @@ thread_db_create_event (CORE_ADDR where)
      created threads.  */
   lwp = get_thread_lwp (current_inferior);
   if (lwp->thread_known == 0)
-    find_one_thread (lwp->head.id);
+    find_one_thread (current_inferior->entry.id);
 
   /* msg.event == TD_EVENT_CREATE */
 
@@ -502,7 +502,7 @@ thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset,
 
   lwp = get_thread_lwp (thread);
   if (!lwp->thread_known)
-    find_one_thread (lwp->head.id);
+    find_one_thread (thread->entry.id);
   if (!lwp->thread_known)
     return TD_NOTHR;
 
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 92b001f..f2620a5 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -114,7 +114,7 @@ static void win32_ensure_ntdll_loaded (void);
 static ptid_t
 current_inferior_ptid (void)
 {
-  return ((struct inferior_list_entry*) current_inferior)->id;
+  return current_ptid;
 }
 
 /* The current debug event from WaitForDebugEvent.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]