public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3 00/23] All-stop on top of non-stop
@ 2015-04-17 10:47 Pedro Alves
  2015-04-17 10:45 ` [PATCH v3 08/17] Factor out code to re-resume stepped thread Pedro Alves
                   ` (18 more replies)
  0 siblings, 19 replies; 62+ messages in thread
From: Pedro Alves @ 2015-04-17 10:47 UTC (permalink / raw)
  To: gdb-patches

This is v3 of the series first posted at:
  https://sourceware.org/ml/gdb-patches/2015-04/msg00073.html
v2 here:
  https://sourceware.org/ml/gdb-patches/2015-04/msg00198.html

Compared to v2, this version:

- Fixes problems on software single-step targets, first exposed by
  Yao's ARM testing.

- Makes the per-inferior displaced stepping queue work correctly
  again.  v1 and v2 has borked that.

- General cleanups.

A few patches in v2 were pushed to master meanwhile.  This one in v2
was dropped in v3:

  https://sourceware.org/ml/gdb-patches/2015-04/msg00207.html
  PPC64: symbol-file + exec-file results in broken displaced stepping

because we now don't trip on that issue anymore, since this went in:

  https://sourceware.org/ml/gdb-patches/2015-04/msg00341.html
  [PATCH][AT_ENTRY version] PR13858 - Can't do displaced stepping with no symbols

The bug is still present, but is now latent, so I'll probably resend
that one out separately at some point.

I tried to mention the differences to v2 in each patch that had
changes, if any (scroll past ChangeLog).

Documentation changes have not changed, and have already been
approved.

Note most of these patches can go in without the final bits that
actually do all-stop-on-top-of-non-stop, as they fix problems that
exist e.g., with "set non-stop on" or "set displaced-stepping on" too.

I've (force) pushed this to users/palves/all-stop-non-stop for review
and testing convenience.

Tested on:

     x86-64 GNU/Linux
     x86-64 GNU/Linux on top of software single-step branch
     PPC64 GNU/Linux
     S/390 GNU/Linux

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Series-intro proper follows:

This series implements user-visible all-stop mode running with the
target_ops backend always in non-stop mode.  This is a stepping stone
towards finer-grained control of threads, being able to do interesting
things like inferior and thread groups/sets (itsets), associating
groups with breakpoints (which threads cause a stop, which threads are
implicitly paused when a breakpoint triggers), etc.  From the user's
perspective, all-stop mode is really just a special case of being able
to stop and resume specific sets of threads, so it makes sense to do
this step first.

After this series, even in all-stop mode ("set non-stop off", the
default) the target is no longer in charge of stopping all threads
before reporting an event to the core -- the core takes care of it
when it sees fit.  For example, when "next"- or "step"-ing, we can
avoid stopping and resuming all threads at each internal single-step,
and instead only stop all threads when we're about to present the stop
to the user.

In order to get there, the series teaches GDB to do non-stop mode even
without displaced stepping (stop all threads, step over breakpoint,
restart threads), as displaced stepping isn't implemented everywhere,
and doesn't work in some scenarios (as in, we can't use it, not that
it's buggy).

And then it fixes all testsuite regressions (on native x86-64, ppc64
and s390 GNU/Linux) this new mode causes, compared to all-stop ("set
non-stop off") with the target backend in all-stop mode too (i.e., the
current default).  Making "target remote" work in always non-stop mode
is deferred for later (this will be even more useful for remote as the
all-stop mode RSP variant can't really do asynchronous debugging).

Tested on x86_64 Fedora 20, native, with and without "set displaced
off", and with and without "maint set target-non-stop on"; and also
against gdbserver.  Tested on x86-64 GNU/Linux native on top of x86
software single-step branch.  Tested on PPC64 Fedora 18.  Tested on
S/390 RHEL 7.1.

Pedro Alves (17):
  Fix and test "checkpoint" in non-stop mode
  Change adjust_pc_after_break's prototype
  remote.c/all-stop: Implement TARGET_WAITKIND_NO_RESUMED and
    TARGET_WNOHANG
  Make thread_still_needs_step_over consider stepping_over_watchpoint
    too
  Embed the pending step-over chain in thread_info objects
  Use keep_going in proceed and start_step_over too
  Misc switch_back_to_stepped_thread cleanups
  Factor out code to re-resume stepped thread
  Teach non-stop to do in-line step-overs (stop all, step, restart)
  Implement all-stop on top of a target running non-stop mode
  Fix signal-while-stepping-over-bp-other-thread.exp on targets always
    in non-stop
  Fix interrupt-noterm.exp on targets always in non-stop
  Fix step-over-{trips-on-watchpoint|lands-on-breakpoint}.exp race
  Disable displaced stepping if trying it fails
  PPC64: Fix gdb.arch/ppc64-atomic-inst.exp with displaced stepping
  S/390: displaced stepping and PC-relative RIL-b/RIL-c instructions
  native Linux: enable always non-stop by default

 gdb/NEWS                                           |    6 +
 gdb/breakpoint.c                                   |   11 +-
 gdb/darwin-nat.c                                   |    6 +-
 gdb/doc/gdb.texinfo                                |   24 +
 gdb/gdbarch.h                                      |    6 +-
 gdb/gdbarch.sh                                     |    4 +
 gdb/gdbthread.h                                    |   60 +-
 gdb/gnu-nat.c                                      |    7 -
 gdb/inf-ptrace.c                                   |    6 +-
 gdb/infcmd.c                                       |    6 +-
 gdb/infrun.c                                       | 2290 +++++++++++++++-----
 gdb/infrun.h                                       |    7 +
 gdb/linux-nat.c                                    |   33 +-
 gdb/monitor.c                                      |    4 +-
 gdb/nto-procfs.c                                   |   14 +-
 gdb/procfs.c                                       |    4 +-
 gdb/remote-m32r-sdi.c                              |    6 +-
 gdb/remote-sim.c                                   |   20 +-
 gdb/remote.c                                       |   57 +-
 gdb/rs6000-tdep.c                                  |   68 +-
 gdb/s390-linux-tdep.c                              |  115 +-
 gdb/target-delegates.c                             |   59 +
 gdb/target.c                                       |   83 +
 gdb/target.h                                       |   24 +-
 gdb/target/waitstatus.h                            |    5 +-
 gdb/testsuite/gdb.arch/ppc64-atomic-inst.exp       |   50 +-
 gdb/testsuite/gdb.base/checkpoint-ns.exp           |   27 +
 gdb/testsuite/gdb.base/checkpoint.exp              |   31 +-
 gdb/testsuite/gdb.base/valgrind-disp-step.c        |   32 +
 gdb/testsuite/gdb.base/valgrind-disp-step.exp      |  131 ++
 .../signal-while-stepping-over-bp-other-thread.exp |    2 +-
 .../gdb.threads/step-over-lands-on-breakpoint.c    |   17 +-
 .../gdb.threads/step-over-lands-on-breakpoint.exp  |    6 +-
 .../gdb.threads/step-over-trips-on-watchpoint.c    |   17 +-
 .../gdb.threads/step-over-trips-on-watchpoint.exp  |    9 +-
 gdb/thread.c                                       |  197 +-
 gdb/windows-nat.c                                  |    6 +-
 37 files changed, 2741 insertions(+), 709 deletions(-)
 create mode 100644 gdb/testsuite/gdb.base/checkpoint-ns.exp
 create mode 100644 gdb/testsuite/gdb.base/valgrind-disp-step.c
 create mode 100644 gdb/testsuite/gdb.base/valgrind-disp-step.exp

-- 
1.9.3

^ permalink raw reply	[flat|nested] 62+ messages in thread
* Re: [PATCH v3 10/17] Implement all-stop on top of a target running non-stop mode
@ 2015-05-18 21:27 Doug Evans
  2015-05-19 19:19 ` Pedro Alves
  0 siblings, 1 reply; 62+ messages in thread
From: Doug Evans @ 2015-05-18 21:27 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

Pedro Alves writes:
> ...
  > gdb/ChangeLog:
  > 2015-04-17  Pedro Alves  <palves@redhat.com>
  >
  > 	* NEWS: Mention "maint set/show target-non-stop".
  > 	* breakpoint.c (update_global_location_list): Check
  > 	target_is_non_stop_p instead of non_stop.
  > 	* infcmd.c (attach_command_post_wait, attach_command): Likewise.
  > 	* infrun.c (show_can_use_displaced_stepping)
  > 	(can_use_displaced_stepping_p, start_step_over_inferior):
  > 	Likewise.
  > 	(resume): Always resume a single thread if the target is in
  > 	non-stop mode.
  > 	(proceed): Check target_is_non_stop_p instead of non_stop.  If in
  > 	all-mode but the target is always in non-stop mode, start all the
  > 	other threads that are implicitly resumed too.
  > 	(for_each_just_stopped_thread, fetch_inferior_event)
  > 	(adjust_pc_after_break, stop_all_threads): Check
  > 	target_is_non_stop_p instead of non_stop.
  > 	(handle_inferior_event): Likewise.  Handle detach-fork in all-stop
  > 	with the target always in non-stop mode.
  > 	(handle_signal_stop) <random signal>: If we get a signal while
  > 	stepping over a breakpoint, and the target is always in non-stop
  > 	mode, restart all threads.
  > 	(switch_back_to_stepped_thread): Check target_is_non_stop_p
  > 	instead of non_stop.
  > 	(keep_going_stepped_thread): Always resume a single thread if the
  > 	target is in non-stop mode.
  > 	(stop_waiting): If in all-stop mode, and the target is in non-stop
  > 	mode, stop all threads.
  > 	(keep_going_pass): Likewise, when starting a new in-line step-over
  > 	sequence.
  > 	* linux-nat.c (get_pending_status, select_event_lwp)
  > 	(linux_nat_filter_event, linux_nat_wait_1, linux_nat_wait): Check
  > 	target_is_non_stop_p instead of non_stop.
  > 	(linux_nat_always_non_stop_p): New function.
  > 	(linux_nat_stop): Check target_is_non_stop_p instead of non_stop.
  > 	(linux_nat_add_target): Install linux_nat_always_non_stop_p.
  > 	* target-delegates.c: Regenerate.
  > 	* target.c (target_is_non_stop_p): New function.
  > 	(target_non_stop_enabled, target_non_stop_enabled_1): New globals.
  > 	(maint_set_target_non_stop_command)
  > 	(maint_show_target_non_stop_command): New functions.
  > 	(_initilize_target): Install "maint set/show target-non-stop"
  > 	commands.
  > 	* target.h (struct target_ops) <to_always_non_stop_p>: New field.
  > 	(target_non_stop_enabled): New declaration.
  > 	(target_is_non_stop_p): New declaration.
  >
  > gdb/doc/ChangeLog:
  > 2015-04-07  Pedro Alves  <palves@redhat.com>
  >
  > 	* gdb.texinfo (Maintenance Commands): Document "maint set/show
  > 	target-non-stop".
  >
> ...
  > diff --git a/gdb/infrun.c b/gdb/infrun.c
  > index 8859b9f..f6d3e07 100644
  > --- a/gdb/infrun.c
  > +++ b/gdb/infrun.c
  > @@ -1632,7 +1632,7 @@ show_can_use_displaced_stepping (struct ui_file  
*file, int from_tty,
  >      fprintf_filtered (file,
  >  		      _("Debugger's willingness to use displaced stepping "
  >  			"to step over breakpoints is %s (currently %s).\n"),
  > -		      value, non_stop ? "on" : "off");
  > +		      value, target_is_non_stop_p () ? "on" : "off");
  >    else
  >      fprintf_filtered (file,
  >  		      _("Debugger's willingness to use displaced stepping "
  > @@ -1645,7 +1645,8 @@ show_can_use_displaced_stepping (struct ui_file  
*file, int from_tty,
  >  static int
  >  use_displaced_stepping (struct gdbarch *gdbarch)
  >  {
  > -  return (((can_use_displaced_stepping == AUTO_BOOLEAN_AUTO && non_stop)
  > +  return (((can_use_displaced_stepping == AUTO_BOOLEAN_AUTO
  > +	    && target_is_non_stop_p ())
  >  	   || can_use_displaced_stepping == AUTO_BOOLEAN_TRUE)
  >  	  && gdbarch_displaced_step_copy_insn_p (gdbarch)
  >  	  && find_record_target () == NULL);
  > @@ -2016,7 +2017,7 @@ start_step_over (void)
  >  	 wouldn't be able to resume anything else until the target
  >  	 stops again.  In non-stop, the resume always resumes only TP,
  >  	 so it's OK to let the thread resume freely.  */
  > -      if (!non_stop && !step_what)
  > +      if (!target_is_non_stop_p () && !step_what)
  >  	continue;
  >
  >        switch_to_thread (tp->ptid);
  > @@ -2035,7 +2036,7 @@ start_step_over (void)
  >  	  return 1;
  >  	}
  >
  > -      if (!non_stop)
  > +      if (!target_is_non_stop_p ())
  >  	{
  >  	  /* On all-stop, shouldn't have resumed unless we needed a
  >  	     step over.  */
  > @@ -2383,7 +2384,10 @@ resume (enum gdb_signal sig)
  >  	      insert_single_step_breakpoint (gdbarch, aspace, pc);
  >  	      insert_breakpoints ();
  >
  > -	      resume_ptid = user_visible_resume_ptid (user_step);
  > +	      if (target_is_non_stop_p ())
  > +		resume_ptid = inferior_ptid;
  > +	      else
  > +		resume_ptid = user_visible_resume_ptid (user_step);

Hi.
For my own education, why is this change needed?

  >  	      do_target_resume (resume_ptid, 0, GDB_SIGNAL_0);
  >  	      discard_cleanups (old_cleanups);
  >  	      tp->resumed = 1;
  > @@ -2498,8 +2502,14 @@ resume (enum gdb_signal sig)
  >    resume_ptid = user_visible_resume_ptid (user_step);
  >
  >    /* Maybe resume a single thread after all.  */
  > -  if ((step || thread_has_single_step_breakpoints_set (tp))
  > -      && tp->control.trap_expected)
  > +  if (target_is_non_stop_p ())
  > +    {
  > +      /* If non-stop mode, threads are always controlled
  > +	 individually.  */
  > +      resume_ptid = inferior_ptid;
  > +    }
  > +  else if ((step || thread_has_single_step_breakpoints_set (tp))
  > +	   && tp->control.trap_expected)
  >      {
  >        /* We're allowing a thread to run past a breakpoint it has
  >  	 hit, by single-stepping the thread with the breakpoint
  > @@ -2935,11 +2945,51 @@ proceed (CORE_ADDR addr, enum gdb_signal siggnal)
  >  	 other thread was already doing one.  In either case, don't
  >  	 resume anything else until the step-over is finished.  */
  >      }
  > -  else if (started && !non_stop)
  > +  else if (started && !target_is_non_stop_p ())
  >      {
  >        /* A new displaced stepping sequence was started.  In all-stop,
  >  	 we can't talk to the target anymore until it next stops.  */
  >      }
  > +  else if (!non_stop && target_is_non_stop_p ())

This takes a bit of reading to grok (the difference
b/w non_stop and target_is_non_stop_p).
Can you copy the comment below (marked XYZ) here?

  > +    {
  > +      /* Start all other threads that are implicitly resumed too.  */
  > +      ALL_NON_EXITED_THREADS (tp)
  > +        {
  > +	  /* Ignore threads of processes we're not resuming.  */
  > +	  if (!ptid_match (tp->ptid, resume_ptid))
  > +	    continue;
  > +
  > +	  if (tp->resumed)
  > +	    {
  > +	      if (debug_infrun)
  > +		fprintf_unfiltered (gdb_stdlog,
  > +				    "infrun: proceed: [%s] resumed\n",
  > +				    target_pid_to_str (tp->ptid));
  > +	      gdb_assert (tp->executing || tp->suspend.waitstatus_pending_p);
  > +	      continue;
  > +	    }
  > +
  > +	  if (thread_is_in_step_over_chain (tp))
  > +	    {
  > +	      if (debug_infrun)
  > +		fprintf_unfiltered (gdb_stdlog,
  > +				    "infrun: proceed: [%s] needs step-over\n",
  > +				    target_pid_to_str (tp->ptid));
  > +	      continue;
  > +	    }
  > +
  > +	  if (debug_infrun)
  > +	    fprintf_unfiltered (gdb_stdlog,
  > +				"infrun: proceed: resuming %s\n",
  > +				target_pid_to_str (tp->ptid));
  > +
  > +	  reset_ecs (ecs, tp);
  > +	  switch_to_thread (tp->ptid);
  > +	  keep_going_pass (ecs);
  > +	  if (!ecs->wait_some_more)
  > +	    error ("Command aborted.");
  > +	}
  > +    }
  >    else if (!tp->resumed && !thread_is_in_step_over_chain (tp))
  >      {
  >        /* The thread wasn't started, and isn't queued, run it now.  */
> ...
  > @@ -5037,7 +5089,7 @@ finish_step_over (struct execution_control_state  
*ecs)
  >  	clear_step_over_info ();
  >      }
  >
  > -  if (!non_stop)
  > +  if (!target_is_non_stop_p ())
  >      return 0;
  >
  >    /* Start a new step-over in another thread if there's one that
  > @@ -5614,6 +5666,17 @@ handle_signal_stop (struct  
execution_control_state *ecs)
  >  	  /* Reset trap_expected to ensure breakpoints are re-inserted.  */
  >  	  ecs->event_thread->control.trap_expected = 0;
  >
  > +	  if (!non_stop && target_is_non_stop_p ())

Ditto. Copy XYZ here?

  > +	    {
  > +	      keep_going (ecs);
  > +
  > +	      /* We've canceled the step-over temporarily while the
  > +		 signal handler executes.  Let other threads run,
  > +		 according to schedlock.  */
  > +	      restart_threads (ecs->event_thread);
  > +	      return;
  > +	    }
  > +
  >  	  /* If we were nexting/stepping some other thread, switch to
  >  	     it, so that we don't continue it, losing control.  */
  >  	  if (!switch_back_to_stepped_thread (ecs))
> ...
  > @@ -7153,6 +7220,11 @@ stop_waiting (struct execution_control_state *ecs)
  >
  >    /* Let callers know we don't want to wait for the inferior anymore.   
*/
  >    ecs->wait_some_more = 0;
  > +
  > +  /* If all-stop, but the target is always in non-stop mode, stop all
  > +     threads now that we're presenting the stop to the user.  */

XYZ^^^
"If all-stop, but the target is always in non-stop mode, ..."

  > +  if (!non_stop && target_is_non_stop_p ())
  > +    stop_all_threads ();
  >  }
  >
  >  /* Like keep_going, but passes the signal to the inferior, even if the
  > @@ -7267,7 +7339,7 @@ keep_going_pass (struct execution_control_state  
*ecs)
  >  	 insert_breakpoints below, because that removes the breakpoint
  >  	 we're about to step over, otherwise other threads could miss
  >  	 it.  */
  > -      if (step_over_info_valid_p () && non_stop)
  > +      if (step_over_info_valid_p () && target_is_non_stop_p ())
  >  	stop_all_threads ();
  >
  >        /* Stop stepping if inserting breakpoints fails.  */

^ permalink raw reply	[flat|nested] 62+ messages in thread

end of thread, other threads:[~2015-05-21  9:17 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-17 10:47 [PATCH v3 00/23] All-stop on top of non-stop Pedro Alves
2015-04-17 10:45 ` [PATCH v3 08/17] Factor out code to re-resume stepped thread Pedro Alves
2015-04-17 10:45 ` [PATCH v3 11/17] Fix signal-while-stepping-over-bp-other-thread.exp on targets always in non-stop Pedro Alves
2015-04-17 10:45 ` [PATCH v3 05/17] Embed the pending step-over chain in thread_info objects Pedro Alves
2015-04-21  8:28   ` Yao Qi
2015-04-22 20:14     ` Pedro Alves
2015-04-21  9:53   ` Yao Qi
2015-04-22 19:07     ` Pedro Alves
2015-04-22  4:25   ` Doug Evans
2015-04-22 22:19     ` Pedro Alves
2015-04-17 10:45 ` [PATCH v3 15/17] PPC64: Fix gdb.arch/ppc64-atomic-inst.exp with displaced stepping Pedro Alves
2015-04-21 11:21   ` Yao Qi
2015-04-22 20:04     ` Pedro Alves
2015-04-17 10:45 ` [PATCH v3 02/17] Change adjust_pc_after_break's prototype Pedro Alves
2015-04-17 10:45 ` [PATCH v3 06/17] Use keep_going in proceed and start_step_over too Pedro Alves
2015-04-22  5:09   ` Doug Evans
2015-04-22 22:22     ` Pedro Alves
2015-04-17 10:45 ` [PATCH v3 13/17] Fix step-over-{trips-on-watchpoint|lands-on-breakpoint}.exp race Pedro Alves
2015-04-17 10:45 ` [PATCH v3 03/17] remote.c/all-stop: Implement TARGET_WAITKIND_NO_RESUMED and TARGET_WNOHANG Pedro Alves
2015-04-17 10:45 ` [PATCH v3 04/17] Make thread_still_needs_step_over consider stepping_over_watchpoint too Pedro Alves
2015-04-17 10:47 ` [PATCH v3 07/17] Misc switch_back_to_stepped_thread cleanups Pedro Alves
2015-04-21  9:50   ` Yao Qi
2015-04-22 20:04     ` Pedro Alves
2015-04-22  5:23   ` Doug Evans
2015-04-22 20:05     ` Pedro Alves
2015-04-28 20:28       ` Doug Evans
2015-04-17 10:47 ` [PATCH v3 17/17] native Linux: enable always non-stop by default Pedro Alves
2015-04-17 10:47 ` [PATCH v3 01/17] Fix and test "checkpoint" in non-stop mode Pedro Alves
2015-04-21  2:36   ` Doug Evans
2015-04-22 17:48     ` Pedro Alves
2015-04-28 18:18       ` Doug Evans
2015-04-29  4:56         ` Doug Evans
2015-05-19 18:08           ` Pedro Alves
2015-04-17 10:52 ` [PATCH v3 09/17] Teach non-stop to do in-line step-overs (stop all, step, restart) Pedro Alves
2015-04-17 11:01   ` Pedro Alves
2015-04-21 15:01   ` Yao Qi
2015-04-22 20:03     ` Pedro Alves
2015-04-24  9:06       ` Yao Qi
2015-04-27 20:17   ` Doug Evans
2015-05-19 18:09     ` Pedro Alves
2015-05-19 18:49       ` Pedro Alves
2015-04-17 10:52 ` [PATCH v3 12/17] Fix interrupt-noterm.exp on targets always in non-stop Pedro Alves
2015-04-21 11:40   ` Yao Qi
2015-04-22 20:03     ` Pedro Alves
2015-04-17 10:56 ` [PATCH v3 14/17] Disable displaced stepping if trying it fails Pedro Alves
2015-04-17 11:06 ` [PATCH v3 16/17] S/390: displaced stepping and PC-relative RIL-b/RIL-c instructions Pedro Alves
2015-04-17 11:38 ` [PATCH v3 10/17] Implement all-stop on top of a target running non-stop mode Pedro Alves
2015-04-21 11:09   ` Yao Qi
2015-04-22 20:16     ` Pedro Alves
2015-04-24  7:39       ` Yao Qi
2015-05-19 18:08         ` Pedro Alves
2015-05-21  9:17           ` Yao Qi
2015-04-20 12:02 ` [PATCH v3 00/23] All-stop on top of non-stop Yao Qi
2015-04-20 16:54   ` Sergio Durigan Junior
2015-04-20 16:43     ` Pedro Alves
2015-04-21  7:48       ` Yao Qi
2015-04-21 15:05         ` Yao Qi
2015-04-22 22:27           ` Pedro Alves
2015-04-20 17:35 ` Simon Marchi
2015-05-19 18:14   ` Pedro Alves
2015-05-18 21:27 [PATCH v3 10/17] Implement all-stop on top of a target running non-stop mode Doug Evans
2015-05-19 19:19 ` Pedro Alves

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).