From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50812 invoked by alias); 11 Sep 2015 06:52:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 50750 invoked by uid 89); 11 Sep 2015 06:52:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mga03.intel.com Received: from mga03.intel.com (HELO mga03.intel.com) (134.134.136.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 11 Sep 2015 06:51:53 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 10 Sep 2015 23:51:49 -0700 X-ExtLoop1: 1 Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 10 Sep 2015 23:51:44 -0700 Received: from ulvlx001.iul.intel.com (ulvlx001.iul.intel.com [172.28.207.17]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t8B6piMe021850; Fri, 11 Sep 2015 07:51:44 +0100 Received: from ulvlx001.iul.intel.com (localhost [127.0.0.1]) by ulvlx001.iul.intel.com with ESMTP id t8B6ph0s025692; Fri, 11 Sep 2015 08:51:43 +0200 Received: (from mmetzger@localhost) by ulvlx001.iul.intel.com with œ id t8B6phsU025688; Fri, 11 Sep 2015 08:51:43 +0200 From: Markus Metzger To: palves@redhat.com Cc: gdb-patches@sourceware.org, Eli Zaretskii Subject: [PATCH v2 17/17] infrun: scheduler-locking reverse Date: Fri, 11 Sep 2015 06:52:00 -0000 Message-Id: <1441954298-25298-18-git-send-email-markus.t.metzger@intel.com> In-Reply-To: <1441954298-25298-1-git-send-email-markus.t.metzger@intel.com> References: <1441954298-25298-1-git-send-email-markus.t.metzger@intel.com> X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg00199.txt.bz2 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 2015-09-11 Markus Metzger 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