public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH v2 05/14] gdb: rename things related to step over chains
Date: Wed,  2 Dec 2020 10:47:56 -0500	[thread overview]
Message-ID: <20201202154805.1484317-6-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20201202154805.1484317-1-simon.marchi@polymtl.ca>

From: Simon Marchi <simon.marchi@efficios.com>

New in v2: comment and formatting fixes.

Rename step_over_queue_head to global_thread_step_over_chain_head, to
make it more obvious when reading code that we are touching the global
queue.  Rename all functions that operate on it to have "global" in
their name, to make it clear on which chain they operate on.  Also, in a
subsequent patch, we'll need both global and non-global versions of
these functions, so it will be easier to do the distinction if they are
named properly.

Normalize the naming to use "chain" everywhere instead of sometimes
"queue", sometimes "chain".

I also reworded a few comments in gdbthread.h.  They implied that the
step over chain is per-inferior, when in reality there is only one
global chain, not one per inferior, as far as I understand.

gdb/ChangeLog:

        * gdbthread.h (thread_step_over_chain_enqueue): Rename to...
        (global_thread_step_over_chain_enqueue): ... this.  Update all
	users.
        (thread_step_over_chain_remove): Rename to...
        (global_thread_step_over_chain_remove): ... this.  Update all
	users.
        (thread_step_over_chain_next): Rename to...
        (global_thread_step_over_chain_next): ... this.  Update all
	users.
        * infrun.h (step_over_queue_head): Rename to...
	(global_thread_step_over_chain_head): ... this.  Update all
	users.
        * infrun.c (step_over_queue_head): Rename to...
	(global_thread_step_over_chain_head): ... this.  Update all
	users.
        * thread.c (step_over_chain_remove): Rename to...
	(thread_step_over_chain_remove): ... this.  Update all users.
	(thread_step_over_chain_next): Rename to...
        (global_thread_step_over_chain_next): ... this.  Update all
	users.
        (thread_step_over_chain_enqueue): Rename to...
        (global_thread_step_over_chain_enqueue): ... this.  Update all
	users.
        (thread_step_over_chain_remove): Rename to...
        (global_thread_step_over_chain_remove): ... this.  Update all
	users.

Change-Id: Iabbf57d83c01321ca199d83fadb57f5b04e4d6d9
---
 gdb/gdbthread.h | 16 ++++++++--------
 gdb/infrun.c    | 26 +++++++++++++-------------
 gdb/infrun.h    |  4 ++--
 gdb/thread.c    | 20 ++++++++++----------
 4 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 630727e2fb50..1eecb989a79e 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -741,20 +741,20 @@ extern value *get_last_thread_stack_temporary (struct thread_info *tp);
 extern bool value_in_thread_stack_temporaries (struct value *,
 					       struct thread_info *thr);
 
-/* Add TP to the end of its inferior's pending step-over chain.  */
+/* Add TP to the end of the global pending step-over chain.  */
 
-extern void thread_step_over_chain_enqueue (struct thread_info *tp);
+extern void global_thread_step_over_chain_enqueue (thread_info *tp);
 
-/* Remove TP from its inferior's pending step-over chain.  */
+/* Remove TP from the global pending step-over chain.  */
 
-extern void thread_step_over_chain_remove (struct thread_info *tp);
+extern void global_thread_step_over_chain_remove (thread_info *tp);
 
-/* Return the next thread in the step-over chain starting at TP.  NULL
-   if TP is the last entry in the chain.  */
+/* Return the thread following TP in the global step-over chain, or NULL if TP
+   is the last entry in the chain.  */
 
-extern struct thread_info *thread_step_over_chain_next (struct thread_info *tp);
+extern thread_info *global_thread_step_over_chain_next (thread_info *tp);
 
-/* Return true if TP is in the step-over chain.  */
+/* Return true if TP is in any step-over chain.  */
 
 extern int thread_is_in_step_over_chain (struct thread_info *tp);
 
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 7bde61597d69..b965e702538c 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -1237,14 +1237,14 @@ follow_exec (ptid_t ptid, const char *exec_file_target)
      matically get reset there in the new process.).  */
 }
 
-/* The queue of threads that need to do a step-over operation to get
+/* The chain of threads that need to do a step-over operation to get
    past e.g., a breakpoint.  What technique is used to step over the
    breakpoint/watchpoint does not matter -- all threads end up in the
    same queue, to maintain rough temporal order of execution, in order
    to avoid starvation, otherwise, we could e.g., find ourselves
    constantly stepping the same couple threads past their breakpoints
    over and over, if the single-step finish fast enough.  */
-struct thread_info *step_over_queue_head;
+struct thread_info *global_thread_step_over_chain_head;
 
 /* Bit flags indicating what the thread needs to step over.  */
 
@@ -1689,7 +1689,7 @@ displaced_step_prepare_throw (thread_info *tp)
       displaced_debug_printf ("deferring step of %s",
 			      target_pid_to_str (tp->ptid).c_str ());
 
-      thread_step_over_chain_enqueue (tp);
+      global_thread_step_over_chain_enqueue (tp);
       return 0;
     }
   else
@@ -1940,7 +1940,7 @@ start_step_over (void)
   if (step_over_info_valid_p ())
     return false;
 
-  for (tp = step_over_queue_head; tp != NULL; tp = next)
+  for (tp = global_thread_step_over_chain_head; tp != NULL; tp = next)
     {
       struct execution_control_state ecss;
       struct execution_control_state *ecs = &ecss;
@@ -1949,7 +1949,7 @@ start_step_over (void)
 
       gdb_assert (!tp->stop_requested);
 
-      next = thread_step_over_chain_next (tp);
+      next = global_thread_step_over_chain_next (tp);
 
       /* If this inferior already has a displaced step in process,
 	 don't start a new one.  */
@@ -1967,9 +1967,9 @@ start_step_over (void)
       if (must_be_in_line && displaced_step_in_progress_any_inferior ())
 	return false;
 
-      thread_step_over_chain_remove (tp);
+      global_thread_step_over_chain_remove (tp);
 
-      if (step_over_queue_head == NULL)
+      if (global_thread_step_over_chain_head == NULL)
 	infrun_debug_printf ("step-over queue now empty");
 
       if (tp->control.trap_expected
@@ -3026,7 +3026,7 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal)
 	  infrun_debug_printf ("need to step-over [%s] first",
 			       target_pid_to_str (tp->ptid).c_str ());
 
-	  thread_step_over_chain_enqueue (tp);
+	  global_thread_step_over_chain_enqueue (tp);
 	}
 
       switch_to_thread (cur_thr);
@@ -3035,7 +3035,7 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal)
   /* Enqueue the current thread last, so that we move all other
      threads over their breakpoints first.  */
   if (cur_thr->stepping_over_breakpoint)
-    thread_step_over_chain_enqueue (cur_thr);
+    global_thread_step_over_chain_enqueue (cur_thr);
 
   /* If the thread isn't started, we'll still need to set its prev_pc,
      so that switch_back_to_stepped_thread knows the thread hasn't
@@ -3219,7 +3219,7 @@ infrun_thread_stop_requested (ptid_t ptid)
 	 start_step_over doesn't try to resume them
 	 automatically.  */
       if (thread_is_in_step_over_chain (tp))
-	thread_step_over_chain_remove (tp);
+	global_thread_step_over_chain_remove (tp);
 
       /* If the thread is stopped, but the user/frontend doesn't
 	 know about that yet, queue a pending event, as if the
@@ -4823,7 +4823,7 @@ stop_all_threads (void)
 			      target_pid_to_str (t->ptid).c_str ());
 
 			  t->control.trap_expected = 0;
-			  thread_step_over_chain_enqueue (t);
+			  global_thread_step_over_chain_enqueue (t);
 			}
 		    }
 		  else
@@ -4846,7 +4846,7 @@ stop_all_threads (void)
 			{
 			  /* Add it back to the step-over queue.  */
 			  t->control.trap_expected = 0;
-			  thread_step_over_chain_enqueue (t);
+			  global_thread_step_over_chain_enqueue (t);
 			}
 
 		      regcache = get_thread_regcache (t);
@@ -7776,7 +7776,7 @@ keep_going_pass_signal (struct execution_control_state *ecs)
 	  infrun_debug_printf ("step-over already in progress: "
 			       "step-over for %s deferred",
 			       target_pid_to_str (tp->ptid).c_str ());
-	  thread_step_over_chain_enqueue (tp);
+	  global_thread_step_over_chain_enqueue (tp);
 	}
       else
 	{
diff --git a/gdb/infrun.h b/gdb/infrun.h
index 2084d3d16b56..ca0774e8e6b9 100644
--- a/gdb/infrun.h
+++ b/gdb/infrun.h
@@ -262,9 +262,9 @@ extern void infrun_async (int enable);
    loop.  */
 extern void mark_infrun_async_event_handler (void);
 
-/* The global queue of threads that need to do a step-over operation
+/* The global chain of threads that need to do a step-over operation
    to get past e.g., a breakpoint.  */
-extern struct thread_info *step_over_queue_head;
+extern struct thread_info *global_thread_step_over_chain_head;
 
 /* Remove breakpoints if possible (usually that means, if everything
    is stopped).  On failure, print a message.  */
diff --git a/gdb/thread.c b/gdb/thread.c
index 32d14e8662c5..2bbb016d4d98 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -205,9 +205,9 @@ clear_thread_inferior_resources (struct thread_info *tp)
 static void
 set_thread_exited (thread_info *tp, bool silent)
 {
-  /* Dead threads don't need to step-over.  Remove from queue.  */
+  /* Dead threads don't need to step-over.  Remove from chain.  */
   if (tp->step_over_next != NULL)
-    thread_step_over_chain_remove (tp);
+    global_thread_step_over_chain_remove (tp);
 
   if (tp->state != THREAD_EXITED)
     {
@@ -365,7 +365,7 @@ step_over_chain_enqueue (struct thread_info **list_p, struct thread_info *tp)
 /* Remove TP from step-over chain LIST_P.  */
 
 static void
-step_over_chain_remove (struct thread_info **list_p, struct thread_info *tp)
+thread_step_over_chain_remove (struct thread_info **list_p, struct thread_info *tp)
 {
   gdb_assert (tp->step_over_next != NULL);
   gdb_assert (tp->step_over_prev != NULL);
@@ -386,11 +386,11 @@ step_over_chain_remove (struct thread_info **list_p, struct thread_info *tp)
 /* See gdbthread.h.  */
 
 struct thread_info *
-thread_step_over_chain_next (struct thread_info *tp)
+global_thread_step_over_chain_next (struct thread_info *tp)
 {
   struct thread_info *next = tp->step_over_next;
 
-  return (next == step_over_queue_head ? NULL : next);
+  return (next == global_thread_step_over_chain_head ? NULL : next);
 }
 
 /* See gdbthread.h.  */
@@ -404,17 +404,17 @@ thread_is_in_step_over_chain (struct thread_info *tp)
 /* See gdbthread.h.  */
 
 void
-thread_step_over_chain_enqueue (struct thread_info *tp)
+global_thread_step_over_chain_enqueue (struct thread_info *tp)
 {
-  step_over_chain_enqueue (&step_over_queue_head, tp);
+  step_over_chain_enqueue (&global_thread_step_over_chain_head, tp);
 }
 
 /* See gdbthread.h.  */
 
 void
-thread_step_over_chain_remove (struct thread_info *tp)
+global_thread_step_over_chain_remove (struct thread_info *tp)
 {
-  step_over_chain_remove (&step_over_queue_head, tp);
+  thread_step_over_chain_remove (&global_thread_step_over_chain_head, tp);
 }
 
 /* Delete the thread referenced by THR.  If SILENT, don't notify
@@ -805,7 +805,7 @@ set_running_thread (struct thread_info *tp, bool running)
 	 the step-over queue, so that we don't try to resume
 	 it until the user wants it to.  */
       if (tp->step_over_next != NULL)
-	thread_step_over_chain_remove (tp);
+	global_thread_step_over_chain_remove (tp);
     }
 
   return started;
-- 
2.29.2


  parent reply	other threads:[~2020-12-02 15:48 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02 15:47 [PATCH v2 00/14] Concurrent displaced stepping Simon Marchi
2020-12-02 15:47 ` [PATCH v2 01/14] gdb: add inferior_execd observable Simon Marchi
2020-12-04  1:45   ` Pedro Alves
2020-12-02 15:47 ` [PATCH v2 02/14] gdb: clear inferior displaced stepping state and in-line step-over info on exec Simon Marchi
2020-12-02 17:16   ` Simon Marchi
2020-12-04  1:54     ` Pedro Alves
2020-12-04 20:49       ` Simon Marchi
2020-12-04  1:48   ` Pedro Alves
2020-12-04 21:03     ` Simon Marchi
2020-12-02 15:47 ` [PATCH v2 03/14] gdb: restore displaced step buffer bytes when another thread forks Simon Marchi
2020-12-04  1:48   ` Pedro Alves
2020-12-02 15:47 ` [PATCH v2 04/14] gdb: get rid of get_displaced_stepping_state Simon Marchi
2020-12-04  1:48   ` Pedro Alves
2020-12-04 21:06     ` Simon Marchi
2020-12-02 15:47 ` Simon Marchi [this message]
2020-12-04  1:49   ` [PATCH v2 05/14] gdb: rename things related to step over chains Pedro Alves
2020-12-04 21:04     ` Simon Marchi
2020-12-02 15:47 ` [PATCH v2 06/14] gdb: rename displaced_step_closure to displaced_step_copy_insn_closure Simon Marchi
2020-12-04  1:49   ` Pedro Alves
2020-12-02 15:47 ` [PATCH v2 07/14] gdb: rename displaced_step_fixup to displaced_step_finish Simon Marchi
2020-12-04  1:49   ` Pedro Alves
2020-12-02 15:47 ` [PATCH v2 08/14] gdb: introduce status enum for displaced step prepare/finish Simon Marchi
2020-12-04  1:49   ` Pedro Alves
2020-12-04 21:08     ` Simon Marchi
2020-12-02 15:48 ` [PATCH v2 09/14] gdb: pass inferior to get_linux_inferior_data Simon Marchi
2020-12-04  1:50   ` Pedro Alves
2020-12-02 15:48 ` [PATCH v2 10/14] gdb: move displaced stepping types to displaced-stepping.{h, c} Simon Marchi
2020-12-04  1:50   ` Pedro Alves
2020-12-02 15:48 ` [PATCH v2 11/14] gdb: move displaced stepping logic to gdbarch, allow starting concurrent displaced steps Simon Marchi
2020-12-04  1:50   ` Pedro Alves
2020-12-04 21:11     ` Simon Marchi
2020-12-02 15:48 ` [PATCH v2 12/14] gdb: change linux gdbarch data from post to pre-init Simon Marchi
2020-12-04  1:50   ` Pedro Alves
2020-12-02 15:48 ` [PATCH v2 13/14] gdb: make displaced stepping implementation capable of managing multiple buffers Simon Marchi
2020-12-04  1:51   ` Pedro Alves
2020-12-04 21:14     ` Simon Marchi
2020-12-02 15:48 ` [PATCH v2 14/14] gdb: use two displaced step buffers on amd64/Linux Simon Marchi
2020-12-04  1:51   ` Pedro Alves
2020-12-04  1:56 ` [PATCH v2 00/14] Concurrent displaced stepping Pedro Alves
2020-12-04 21:52   ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201202154805.1484317-6-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).