Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Markus Metzger <markus.t.metzger@intel.com>
To: palves@redhat.com
Cc: gdb-patches@sourceware.org, Eli Zaretskii <eliz@gnu.org>
Subject: [PATCH v2 17/17] infrun: scheduler-locking reverse
Date: Fri, 11 Sep 2015 06:52:00 -0000	[thread overview]
Message-ID: <1441954298-25298-18-git-send-email-markus.t.metzger@intel.com> (raw)
In-Reply-To: <1441954298-25298-1-git-send-email-markus.t.metzger@intel.com>

Record targets behave as if scheduler-locking were on during replay/reverse
execution.  Add a new scheduler-locking option "reverse" to make this implicit
behaviour explicit.  It behaves like "on" during reverse/replay execution and
like "off" during normal execution.

By making the current behaviour a scheduler-locking option, we allow the user
to change it.  Since it is the current behaviour, this new option is also
the new default.

One caveat is that when resuming a thread that is at the end of its execution
history, record btrace implicitly stops replaying other threads and resumes
the entire process.  This is a convenience feature to not require the user
to explicitly move all other threads to the end of their execution histories
before being able to resume the process.

We mimick this behaviour with scheduler-locking reverse and move it from
record-btrace into infrun.  With all-stop on top of non-stop, we can't do
this in record-btrace anymore.

Record full does not really support multi-threading and is therefore not
impacted.  If it were extended to support multi-threading, it would 'benefit'
from this change.  The good thing is that all record targets will behave the
same with respect to scheduler-locking.

I put the code for this into clear_proceed_status.  It also sends the
about_to_proceed notification.

CC: Eli Zaretskii <eliz@gnu.org>

2015-09-11  Markus Metzger <markus.t.metzger@intel.com>

gdb/
	* NEWS: Announce new scheduler-locking mode.
	* infrun.c (schedlock_reverse): New.
	(scheduler_enums): Add schedlock_reverse.
	(scheduler_mode): Change default to schedlock_reverse.
	(user_visible_resume_ptid): Handle schedlock_reverse.
	(clear_proceed_status_thread): Stop replaying if resumed thread is
	not replaying.
	(schedlock_applies): Handle schedlock_reverse.
	(_initialize_infrun): Document new scheduler-locking mode.
	* record-btrace.c (record_btrace_resume): Remove code to stop other
	threads when not replaying the resumed thread.

doc/
	* gdb.texinfo (All-Stop Mode): Describe new scheduler-locking mode.
---
 gdb/NEWS            |  4 ++++
 gdb/doc/gdb.texinfo |  4 +++-
 gdb/infrun.c        | 35 ++++++++++++++++++++++++++++++-----
 gdb/record-btrace.c | 10 ++--------
 4 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index 1fa1862..896cdeb 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -45,6 +45,10 @@ show remote multiprocess-extensions-packet
   The "/m" option is now considered deprecated: its "source-centric"
   output hasn't proved useful in practice.
 
+* The "set scheduler-locking" command supports a new mode "reverse".
+  It behaves like "off" during normal execution and like "on" during
+  reverse or replay execution.
+
 * Support for various ROM monitors has been removed:
 
   target dbug		dBUG ROM monitor for Motorola ColdFire
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index cd0abad..36a6777 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -5846,7 +5846,9 @@ Other threads never get a chance to run when you step, and they are
 completely free to run when you use commands
 like @samp{continue}, @samp{until}, or @samp{finish}.  However, unless another
 thread hits a breakpoint during its timeslice, @value{GDBN} does not change
-the current thread away from the thread that you are debugging.
+the current thread away from the thread that you are debugging.  The
+@code{reverse} mode behaves like @code{off} during normal execution
+and like @code{on} during reverse or replay execution.
 
 @item show scheduler-locking
 Display the current scheduler locking mode.
diff --git a/gdb/infrun.c b/gdb/infrun.c
index c4a99d8..403dfcf 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -2167,13 +2167,15 @@ resume_cleanups (void *ignore)
 static const char schedlock_off[] = "off";
 static const char schedlock_on[] = "on";
 static const char schedlock_step[] = "step";
+static const char schedlock_reverse[] = "reverse";
 static const char *const scheduler_enums[] = {
   schedlock_off,
   schedlock_on,
   schedlock_step,
+  schedlock_reverse,
   NULL
 };
-static const char *scheduler_mode = schedlock_off;
+static const char *scheduler_mode = schedlock_reverse;
 static void
 show_scheduler_mode (struct ui_file *file, int from_tty,
 		     struct cmd_list_element *c, const char *value)
@@ -2239,6 +2241,14 @@ user_visible_resume_ptid (int step)
 	 resume.  */
       resume_ptid = inferior_ptid;
     }
+  else if ((scheduler_mode == schedlock_reverse)
+	   && ((execution_direction == EXEC_REVERSE)
+	       || target_record_is_replaying (minus_one_ptid)))
+    {
+      /* User-settable 'scheduler' mode requires solo thread resume during
+	 reverse/replay stepping.  */
+      resume_ptid = inferior_ptid;
+    }
   else if (!sched_multi && target_supports_multi_process ())
     {
       /* Resume all threads of the current process (and none of other
@@ -2777,6 +2787,18 @@ clear_proceed_status_thread (struct thread_info *tp)
 void
 clear_proceed_status (int step)
 {
+  /* With scheduler-locking reverse, stop replaying other threads if we're
+     not replaying the user-visible resume ptid.
+
+     This is a convenience feature to not require the user to explicitly
+     stop replaying the other threads.  We're assuming that the user's
+     intent is to resume tracing the recorded process.  */
+  if (!non_stop && (scheduler_mode == schedlock_reverse)
+      && (execution_direction != EXEC_REVERSE)
+      && target_record_is_replaying (minus_one_ptid)
+      && !target_record_is_replaying (user_visible_resume_ptid (step)))
+    target_record_stop_replaying ();
+
   if (!non_stop)
     {
       struct thread_info *tp;
@@ -2864,7 +2886,9 @@ schedlock_applies (struct thread_info *tp)
 {
   return (scheduler_mode == schedlock_on
 	  || (scheduler_mode == schedlock_step
-	      && tp->control.stepping_command));
+	      && tp->control.stepping_command)
+	  || (scheduler_mode == schedlock_reverse
+	      && target_record_is_replaying (minus_one_ptid)));
 }
 
 /* Basic routine for continuing the program in various fashions.
@@ -9066,9 +9090,10 @@ By default, the debugger will use the same inferior."),
 			scheduler_enums, &scheduler_mode, _("\
 Set mode for locking scheduler during execution."), _("\
 Show mode for locking scheduler during execution."), _("\
-off  == no locking (threads may preempt at any time)\n\
-on   == full locking (no thread except the current thread may run)\n\
-step == scheduler locked during stepping commands (step, next, stepi, nexti).\n\
+off     == no locking (threads may preempt at any time)\n\
+on      == full locking (no thread except the current thread may run)\n\
+step    == scheduler locked during stepping commands (step, next, stepi, nexti).\n\
+reverse == scheduler locked during reverse/replay execution.\n\
 	In this mode, other threads may run during other commands."),
 			set_schedlock_func,	/* traps on target vector */
 			show_scheduler_mode,
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index e0b79a8..b8e6466 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1895,22 +1895,16 @@ record_btrace_resume (struct target_ops *ops, ptid_t ptid, int step,
      to not change the execution direction in-between.  */
   record_btrace_resume_exec_dir = execution_direction;
 
-  /* For all-stop targets...  */
+  /* For all-stop targets we pick the current thread when asked to resume an
+     entire process or everything.  */
   if (!target_is_non_stop_p ())
     {
-      /* ...we pick the current thread when asked to resume an entire process
-	 or everything.  */
       if (ptid_equal (minus_one_ptid, ptid) || ptid_is_pid (ptid))
 	ptid = inferior_ptid;
 
       tp = find_thread_ptid (ptid);
       if (tp == NULL)
 	error (_("Cannot find thread to resume."));
-
-      /* ...and we stop replaying other threads if the thread to resume is not
-	 replaying.  */
-      if (!btrace_is_replaying (tp) && execution_direction != EXEC_REVERSE)
-	target_record_stop_replaying ();
     }
 
   /* As long as we're not replaying, just forward the request.
-- 
1.8.3.1


  parent reply	other threads:[~2015-09-11  6:52 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-11  6:52 [PATCH v2 00/17] record btrace: non-stop and ASNS Markus Metzger
2015-09-11  6:51 ` [PATCH v2 01/17] btrace: fix non-stop check in to_wait Markus Metzger
2015-09-11  6:51 ` [PATCH v2 08/17] btrace: lock-step Markus Metzger
2015-09-11  6:51 ` [PATCH v2 12/17] infrun: switch to NO_HISTORY thread Markus Metzger
2015-09-11  6:51 ` [PATCH v2 04/17] btrace: extract the breakpoint check from record_btrace_step_thread Markus Metzger
2015-09-11  6:51 ` [PATCH v2 11/17] btrace: async Markus Metzger
2015-09-11  6:51 ` [PATCH v2 07/17] btrace: add missing NO_HISTORY Markus Metzger
2015-09-11  6:51 ` [PATCH v2 03/17] btrace: improve stepping debugging Markus Metzger
2015-09-11  6:51 ` [PATCH v2 05/17] btrace: split record_btrace_step_thread Markus Metzger
2015-09-11  6:51 ` [PATCH v2 06/17] btrace: move breakpoint checking into stepping functions Markus Metzger
2015-09-11  6:52 ` [PATCH v2 13/17] btrace: non-stop Markus Metzger
2015-09-11  6:58   ` Eli Zaretskii
2015-09-11  6:52 ` Markus Metzger [this message]
2015-09-11  7:01   ` [PATCH v2 17/17] infrun: scheduler-locking reverse Eli Zaretskii
2015-09-11  8:55     ` Pedro Alves
2015-09-11  9:02       ` Eli Zaretskii
2015-09-16 12:28         ` Metzger, Markus T
2015-09-16 12:54           ` Pedro Alves
2015-09-16 13:32             ` Pedro Alves
2015-09-16 13:56               ` Metzger, Markus T
2015-09-16 14:25                 ` Pedro Alves
2015-09-11  6:52 ` [PATCH v2 16/17] target: add to_record_stop_replaying target method Markus Metzger
2015-09-11  6:52 ` [PATCH v2 14/17] target, record: add PTID argument to to_record_is_replaying Markus Metzger
2015-09-11  6:52 ` [PATCH v2 02/17] btrace: support to_stop Markus Metzger
2015-09-11  6:52 ` [PATCH v2 10/17] btrace: temporarily set inferior_ptid in record_btrace_start_replaying Markus Metzger
2015-09-11  6:52 ` [PATCH v2 09/17] btrace: resume all requested threads Markus Metzger
2015-09-11  6:52 ` [PATCH v2 15/17] btrace: allow full memory and register access for non-replaying threads Markus Metzger
2015-09-11  7:56 ` [PATCH v2 00/17] record btrace: non-stop and ASNS Pedro Alves
2015-09-11  8:02   ` Metzger, Markus T

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=1441954298-25298-18-git-send-email-markus.t.metzger@intel.com \
    --to=markus.t.metzger@intel.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.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