Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [non-stop] 07/10 non-stop inferior control
@ 2008-06-15 21:06 Pedro Alves
  2008-06-25 20:06 ` Daniel Jacobowitz
  0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2008-06-15 21:06 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1152 bytes --]

This patch adds the base inferior control support for non-stop mode.

In non-stop mode, each thread is handled individually.  It should
behave close to having a separate debugger attached to each thread.
To accomplish that, as soon as we have an event, we context switch
to it, and go on handling it.  The cases of hiting a breakpoint
in another thread while we're stepping don't need to be handled
specially, as each thread will have its own stepping state.

Another difference in non-stop mode, is that exec commands
apply only to the selected thread; the target is never told
to resume all threads -- much like with scheduler locking
on.

It is also needed to have support to interrupt/suspend a simple
thread so a new target_stop_ptid method was added to request
the target to interrupt a single thread.

Several checks have been added so GDB doesn't try to do
things with running threads, which don't make sense,
like asking for the current PC of an executing thread.

"info threads" now shows "(running)" instead of info on the
selected frame, on running threads.  MI support will be
added on top.

-- 
Pedro Alves

[-- Attachment #2: 007-non_stop_core.diff --]
[-- Type: text/x-diff, Size: 22929 bytes --]

2008-06-15  Pedro Alves  <pedro@codesourcery.com>

	* infrun.c (resume): In non-stop mode, always resume just one
	thread.
	(proceed): Don't call prepare_to_proceed in non-stop mode.
	(fetch_inferior_event): In non-stop mode, switch context before
	handling the event.
	(error_is_running, ensure_not_running): New.
	(handle_inferior_event): In non-stop mode: Mark only the event
	thread as stopped.  Require that the target module manages adding
	threads to the thread list.  Don't switch to
	infwait_thread_hop_state.
	(normal_stop): Only mark not-running if inferior hasn't exited.
	In non-stop mode, only mark the event thread.

	* thread.c:Include "cli/cli-decode.h".
	(print_thread_info): Don't read from a running thread.
	Output "(running)" if thread is running.
	(switch_to_thread): Don't read stop_pc if thread is executing.
	(do_restore_current_thread_cleanup): Don't write to a running
	thread.
	(thread_apply_all_command): Don't read from a running thread.  In
	non-stop mode, do a full context-switch instead of just switching
	threads.
	(thread_apply_command): In non-stop mode, do a full context-switch
	instead of just switching threads.
	(do_captured_thread_select): Likewise.  Inform user if selected
	thread is running.
	(_initialize_thread): Mark "info threads" and "thread" and
	async_ok.

	* inf-loop.c (inferior_event_handler): In non-stop mode, don't
	unregister the target from the event loop.
	
	* infcmd.c (continue_command, step_1, jump_command)
	(signal_command): Ensure the selected thread isn't running.
	(interrupt_target_command): In non-stop mode, interrupt only the
	selected thread.

	* inferior.h (error_is_running, ensure_not_running): Declare.

	* target.h (struct target_ops): Add to_stop_ptid member.
	(target_stop_ptid): Define.
	* target.c (update_current_target): Inherit to_stop_ptid.  Default
	to_stop_ptid to target_ignore.
	(debug_to_stop_ptid): New.
	(debug_to_rcmd): Set to_stop_ptid.

	* Makefile.in (thread.o): Update.

---
 gdb/Makefile.in |    2 
 gdb/inf-loop.c  |   14 ++++--
 gdb/infcmd.c    |   10 ++++
 gdb/inferior.h  |    6 ++
 gdb/infrun.c    |  126 ++++++++++++++++++++++++++++++++++++++++++--------------
 gdb/target.c    |   13 +++++
 gdb/target.h    |    7 +++
 gdb/thread.c    |   97 +++++++++++++++++++++++++++++++------------
 8 files changed, 212 insertions(+), 63 deletions(-)

Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c	2008-06-15 20:06:41.000000000 +0100
+++ src/gdb/infrun.c	2008-06-15 20:26:51.000000000 +0100
@@ -1052,9 +1052,15 @@ a command like `return' or `jump' to con
 	  resume_ptid = inferior_ptid;
 	}
 
-      if ((scheduler_mode == schedlock_on)
-	  || (scheduler_mode == schedlock_step
-	      && (step || singlestep_breakpoints_inserted_p)))
+      if (non_stop)
+	{
+	  /* With non-stop mode on, threads are always handled
+	     individually.  */
+	  resume_ptid = inferior_ptid;
+	}
+      else if ((scheduler_mode == schedlock_on)
+	       || (scheduler_mode == schedlock_step
+		   && (step || singlestep_breakpoints_inserted_p)))
 	{
 	  /* User-settable 'scheduler' mode requires solo thread resume. */
 	  resume_ptid = inferior_ptid;
@@ -1215,19 +1221,27 @@ proceed (CORE_ADDR addr, enum target_sig
 			"infrun: proceed (addr=0x%s, signal=%d, step=%d)\n",
 			paddr_nz (addr), siggnal, step);
 
-  /* In a multi-threaded task we may select another thread
-     and then continue or step.
+  if (non_stop)
+    /* In non-stop, each thread is handled individually.  The context
+       must already be set to the right thread here.  */
+    ;
+  else
+    {
+      /* In a multi-threaded task we may select another thread and
+	 then continue or step.
 
-     But if the old thread was stopped at a breakpoint, it
-     will immediately cause another breakpoint stop without
-     any execution (i.e. it will report a breakpoint hit
-     incorrectly).  So we must step over it first.
-
-     prepare_to_proceed checks the current thread against the thread
-     that reported the most recent event.  If a step-over is required
-     it returns TRUE and sets the current thread to the old thread. */
-  if (prepare_to_proceed (step))
-    oneproc = 1;
+	 But if the old thread was stopped at a breakpoint, it will
+	 immediately cause another breakpoint stop without any
+	 execution (i.e. it will report a breakpoint hit incorrectly).
+	 So we must step over it first.
+
+	 prepare_to_proceed checks the current thread against the
+	 thread that reported the most recent event.  If a step-over
+	 is required it returns TRUE and sets the current thread to
+	 the old thread. */
+      if (prepare_to_proceed (step))
+	oneproc = 1;
+    }
 
   if (oneproc)
     {
@@ -1529,6 +1543,15 @@ fetch_inferior_event (void *client_data)
   else
     ecs->ptid = target_wait (waiton_ptid, &ecs->ws);
 
+  if (non_stop
+      && ecs->ws.kind != TARGET_WAITKIND_IGNORE
+      && ecs->ws.kind != TARGET_WAITKIND_EXITED
+      && ecs->ws.kind != TARGET_WAITKIND_SIGNALLED)
+    /* In non-stop mode, each thread is handled individually.  Switch
+       early, so the global state is set correctly for this
+       thread.  */
+    context_switch (ecs->ptid);
+
   /* Now figure out what to do with the result of the result.  */
   handle_inferior_event (ecs);
 
@@ -1739,6 +1762,20 @@ init_infwait_state (void)
   infwait_state = infwait_normal_state;
 }
 
+void
+error_is_running (void)
+{
+  error (_("\
+Cannot execute this command while the selected thread is running."));
+}
+
+void
+ensure_not_running (void)
+{
+  if (is_running (inferior_ptid))
+    error_is_running ();
+}
+
 /* Given an execution control state that has been freshly filled in
    by an event from the inferior, figure out what it means and take
    appropriate action.  */
@@ -1810,11 +1847,16 @@ handle_inferior_event (struct execution_
       && ecs->ws.kind != TARGET_WAITKIND_SIGNALLED && ecs->new_thread_event)
     add_thread (ecs->ptid);
 
-  /* Mark all threads as not-executing.  In non-stop, this should be
-     adjusted to only mark ecs->ptid.  */
-  if (ecs->ws.kind != TARGET_WAITKIND_IGNORE
-      && stop_soon != STOP_QUIETLY)
-    set_executing (pid_to_ptid (-1), 0);
+  if (ecs->ws.kind != TARGET_WAITKIND_IGNORE)
+    {
+      /* Mark the stopped threads accordingly.  */
+      if (!non_stop
+	  || ecs->ws.kind == TARGET_WAITKIND_EXITED
+	  || ecs->ws.kind == TARGET_WAITKIND_SIGNALLED)
+	set_executing (pid_to_ptid (-1), 0);
+      else
+	set_executing (ecs->ptid, 0);
+    }
 
   switch (ecs->ws.kind)
     {
@@ -2052,15 +2094,22 @@ handle_inferior_event (struct execution_
       return;
     }
 
-  /* We may want to consider not doing a resume here in order to give
-     the user a chance to play with the new thread.  It might be good
-     to make that a user-settable option.  */
-
-  /* At this point, all threads are stopped (happens automatically in
-     either the OS or the native code).  Therefore we need to continue
-     all threads in order to make progress.  */
   if (ecs->new_thread_event)
     {
+      if (non_stop)
+	/* Non-stop assumes that the target handles adding new threads
+	   to the thread list.  */
+	internal_error (__FILE__, __LINE__, "\
+targets should add new threads to the thread list themselves in non-stop mode.");
+
+      /* We may want to consider not doing a resume here in order to
+	 give the user a chance to play with the new thread.  It might
+	 be good to make that a user-settable option.  */
+
+      /* At this point, all threads are stopped (happens automatically
+	 in either the OS or the native code).  Therefore we need to
+	 continue all threads in order to make progress.  */
+
       target_resume (RESUME_ALL, 0, TARGET_SIGNAL_0);
       prepare_to_wait (ecs);
       return;
@@ -2127,6 +2176,9 @@ handle_inferior_event (struct execution_
 
   if (!ptid_equal (deferred_step_ptid, null_ptid))
     {
+      /* In non-stop mode, there's never a deferred_step_ptid set.  */
+      gdb_assert (!non_stop);
+
       /* If we stopped for some other reason than single-stepping, ignore
 	 the fact that we were supposed to switch back.  */
       if (stop_signal == TARGET_SIGNAL_TRAP)
@@ -2275,8 +2327,13 @@ handle_inferior_event (struct execution_
 	      if (!ptid_equal (inferior_ptid, ecs->ptid))
 		context_switch (ecs->ptid);
 
-	      waiton_ptid = ecs->ptid;
-	      infwait_state = infwait_thread_hop_state;
+	      if (!non_stop)
+		{
+		  /* Only need to require the next event from this
+		     thread in all-stop mode.  */
+		  waiton_ptid = ecs->ptid;
+		  infwait_state = infwait_thread_hop_state;
+		}
 
 	      tss->stepping_over_breakpoint = 1;
 	      keep_going (ecs);
@@ -3831,7 +3888,16 @@ done:
   /* Delete the breakpoint we stopped at, if it wants to be deleted.
      Delete any breakpoint that is to be deleted at the next stop.  */
   breakpoint_auto_delete (stop_bpstat);
-  set_running (pid_to_ptid (-1), 0);
+
+  if (target_has_execution
+      && last.kind != TARGET_WAITKIND_SIGNALLED
+      && last.kind != TARGET_WAITKIND_EXITED)
+    {
+      if (!non_stop)
+	set_running (pid_to_ptid (-1), 0);
+      else
+	set_running (inferior_ptid, 0);
+    }
 }
 
 static int
Index: src/gdb/thread.c
===================================================================
--- src.orig/gdb/thread.c	2008-06-15 19:40:21.000000000 +0100
+++ src/gdb/thread.c	2008-06-15 20:25:39.000000000 +0100
@@ -42,6 +42,8 @@
 #include "observer.h"
 #include "annotate.h"
 
+#include "cli/cli-decode.h"
+
 /* Definition of struct thread_info exported to gdbthread.h */
 
 /* Prototypes for exported functions. */
@@ -613,9 +615,12 @@ print_thread_info (struct ui_out *uiout,
   int current_thread = -1;
 
   /* Backup current thread and selected frame.  */
-  saved_frame_id = get_frame_id (get_selected_frame (NULL));
-  old_chain = make_cleanup_restore_current_thread (inferior_ptid, saved_frame_id);
+  if (!is_running (inferior_ptid))
+    saved_frame_id = get_frame_id (get_selected_frame (NULL));
+  else
+    saved_frame_id = null_frame_id;
 
+  old_chain = make_cleanup_restore_current_thread (inferior_ptid, saved_frame_id);
   make_cleanup_ui_out_list_begin_end (uiout, "threads");
 
   prune_threads ();
@@ -650,12 +655,18 @@ print_thread_info (struct ui_out *uiout,
 	  ui_out_text (uiout, ")");
 	}
       ui_out_text (uiout, "  ");
-      /* That switch put us at the top of the stack (leaf frame).  */
-      switch_to_thread (tp->ptid);
-      print_stack_frame (get_selected_frame (NULL), 
-			 /* For MI output, print frame level.  */
-			 ui_out_is_mi_like_p (uiout),
-			 LOCATION);
+      if (tp->running_)
+	ui_out_text (uiout, "(running)\n");
+      else
+	{
+	  /* The switch below puts us at the top of the stack (leaf
+	     frame).  */
+	  switch_to_thread (tp->ptid);
+	  print_stack_frame (get_selected_frame (NULL),
+			     /* For MI output, print frame level.  */
+			     ui_out_is_mi_like_p (uiout),
+			     LOCATION);
+	}
 
       do_cleanups (chain2);
     }
@@ -671,6 +682,9 @@ print_thread_info (struct ui_out *uiout,
 	ui_out_field_int (uiout, "current-thread-id", current_thread);
     }
 
+  if (is_running (inferior_ptid))
+    return;
+
   /*  If case we were not able to find the original frame, print the
       new selected frame.  */
   if (frame_find_by_id (saved_frame_id) == NULL)
@@ -709,7 +723,11 @@ switch_to_thread (ptid_t ptid)
   inferior_ptid = ptid;
   reinit_frame_cache ();
   registers_changed ();
-  stop_pc = read_pc ();
+
+  if (!is_executing (ptid))
+    stop_pc = read_pc ();
+  else
+    stop_pc = ~(CORE_ADDR) 0;
 }
 
 static void
@@ -746,7 +764,12 @@ do_restore_current_thread_cleanup (void 
 {
   struct current_thread_cleanup *old = arg;
   restore_current_thread (old->inferior_ptid);
-  restore_selected_frame (old->selected_frame_id);
+
+  /* A command like 'thread apply all $exec_command&' may change the
+     running state of the originally selected thread, so we have to
+     recheck it here.  */
+  if (!is_running (old->inferior_ptid))
+    restore_selected_frame (old->selected_frame_id);
   xfree (old);
 }
 
@@ -774,8 +797,7 @@ static void
 thread_apply_all_command (char *cmd, int from_tty)
 {
   struct thread_info *tp;
-  struct cleanup *old_chain;
-  struct cleanup *saved_cmd_cleanup_chain;
+  struct cleanup *old_chain = make_cleanup (null_cleanup, 0);
   char *saved_cmd;
   struct frame_id saved_frame_id;
   ptid_t current_ptid;
@@ -785,8 +807,12 @@ thread_apply_all_command (char *cmd, int
     error (_("Please specify a command following the thread ID list"));
   
   current_ptid = inferior_ptid;
-  saved_frame_id = get_frame_id (get_selected_frame (NULL));
-  old_chain = make_cleanup_restore_current_thread (inferior_ptid, saved_frame_id);
+
+  if (!is_running (inferior_ptid))
+    saved_frame_id = get_frame_id (get_selected_frame (NULL));
+  else
+    saved_frame_id = null_frame_id;
+  make_cleanup_restore_current_thread (inferior_ptid, saved_frame_id);
 
   /* It is safe to update the thread list now, before
      traversing it for "thread apply all".  MVS */
@@ -795,11 +821,15 @@ thread_apply_all_command (char *cmd, int
   /* Save a copy of the command in case it is clobbered by
      execute_command */
   saved_cmd = xstrdup (cmd);
-  saved_cmd_cleanup_chain = make_cleanup (xfree, (void *) saved_cmd);
+  make_cleanup (xfree, saved_cmd);
   for (tp = thread_list; tp; tp = tp->next)
     if (thread_alive (tp))
       {
-	switch_to_thread (tp->ptid);
+	if (non_stop)
+	  context_switch_to (tp->ptid);
+	else
+	  switch_to_thread (tp->ptid);
+
 	printf_filtered (_("\nThread %d (%s):\n"),
 			 tp->num, target_tid_to_str (inferior_ptid));
 	execute_command (cmd, from_tty);
@@ -809,12 +839,10 @@ thread_apply_all_command (char *cmd, int
   if (!ptid_equal (current_ptid, inferior_ptid))
     thread_has_changed = 1;
 
-  do_cleanups (saved_cmd_cleanup_chain);
   do_cleanups (old_chain);
   /* Print stack frame only if we changed thread.  */
-  if (thread_has_changed)
+  if (thread_has_changed && !is_running (inferior_ptid))
     print_stack_frame (get_current_frame (), 1, SRC_LINE);
-
 }
 
 static void
@@ -838,7 +866,11 @@ thread_apply_command (char *tidlist, int
     error (_("Please specify a command following the thread ID list"));
 
   current_ptid = inferior_ptid;
-  saved_frame_id = get_frame_id (get_selected_frame (NULL));
+
+  if (!is_running (inferior_ptid))
+    saved_frame_id = get_frame_id (get_selected_frame (NULL));
+  else
+    saved_frame_id = null_frame_id;
   old_chain = make_cleanup_restore_current_thread (inferior_ptid, saved_frame_id);
 
   /* Save a copy of the command in case it is clobbered by
@@ -882,7 +914,10 @@ thread_apply_command (char *tidlist, int
 	    warning (_("Thread %d has terminated."), start);
 	  else
 	    {
-	      switch_to_thread (tp->ptid);
+	      if (non_stop)
+		context_switch_to (tp->ptid);
+	      else
+		switch_to_thread (tp->ptid);
 	      printf_filtered (_("\nThread %d (%s):\n"), tp->num,
 			       target_tid_to_str (inferior_ptid));
 	      execute_command (cmd, from_tty);
@@ -950,7 +985,10 @@ do_captured_thread_select (struct ui_out
   if (!thread_alive (tp))
     error (_("Thread ID %d has terminated."), num);
 
-  switch_to_thread (tp->ptid);
+  if (non_stop)
+    context_switch_to (tp->ptid);
+  else
+    switch_to_thread (tp->ptid);
 
   ui_out_text (uiout, "[Switching to thread ");
   ui_out_field_int (uiout, "new-thread-id", pid_to_thread_id (inferior_ptid));
@@ -958,7 +996,11 @@ do_captured_thread_select (struct ui_out
   ui_out_text (uiout, target_tid_to_str (inferior_ptid));
   ui_out_text (uiout, ")]");
 
-  print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+  if (!tp->running_)
+    print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+  else
+    ui_out_text (uiout, "(running)\n");
+
   return GDB_RC_OK;
 }
 
@@ -978,14 +1020,17 @@ void
 _initialize_thread (void)
 {
   static struct cmd_list_element *thread_apply_list = NULL;
+  struct cmd_list_element *c;
 
-  add_info ("threads", info_threads_command,
-	    _("IDs of currently known threads."));
+  c = add_info ("threads", info_threads_command,
+		_("IDs of currently known threads."));
+  set_cmd_async_ok (c);
 
-  add_prefix_cmd ("thread", class_run, thread_command, _("\
+  c = add_prefix_cmd ("thread", class_run, thread_command, _("\
 Use this command to switch between threads.\n\
 The new thread ID must be currently known."),
 		  &thread_cmd_list, "thread ", 1, &cmdlist);
+  set_cmd_async_ok (c);
 
   add_prefix_cmd ("apply", class_run, thread_apply_command,
 		  _("Apply a command to a list of threads."),
Index: src/gdb/inf-loop.c
===================================================================
--- src.orig/gdb/inf-loop.c	2008-06-15 17:57:52.000000000 +0100
+++ src/gdb/inf-loop.c	2008-06-15 20:06:52.000000000 +0100
@@ -73,11 +73,15 @@ inferior_event_handler (enum inferior_ev
       break;
 
     case INF_EXEC_COMPLETE:
-      /* Unregister the inferior from the event loop. This is done so that
-	 when the inferior is not running we don't get distracted by
-	 spurious inferior output.  */
-      if (target_has_execution)
-	target_async (NULL, 0);
+
+      if (!non_stop)
+	{
+	  /* Unregister the inferior from the event loop. This is done
+	     so that when the inferior is not running we don't get
+	     distracted by spurious inferior output.  */
+	  if (target_has_execution)
+	    target_async (NULL, 0);
+	}
 
       /* The call to async_enable_stdin below resets 'sync_execution'.
 	 However, if sync_execution is 1 now, we also need to show the
Index: src/gdb/infcmd.c
===================================================================
--- src.orig/gdb/infcmd.c	2008-06-15 17:57:46.000000000 +0100
+++ src/gdb/infcmd.c	2008-06-15 20:25:41.000000000 +0100
@@ -613,6 +613,7 @@ continue_command (char *proc_count_exp, 
 {
   int async_exec = 0;
   ERROR_NO_INFERIOR;
+  ensure_not_running ();
 
   /* Find out whether we must run in the background. */
   if (proc_count_exp != NULL)
@@ -714,6 +715,7 @@ step_1 (int skip_subroutines, int single
   int thread = -1;
 
   ERROR_NO_INFERIOR;
+  ensure_not_running ();
 
   if (count_string)
     async_exec = strip_bg_char (&count_string);
@@ -936,6 +938,7 @@ jump_command (char *arg, int from_tty)
   int async_exec = 0;
 
   ERROR_NO_INFERIOR;
+  ensure_not_running ();
 
   /* Find out whether we must run in the background. */
   if (arg != NULL)
@@ -1036,6 +1039,7 @@ signal_command (char *signum_exp, int fr
 
   dont_repeat ();		/* Too dangerous.  */
   ERROR_NO_INFERIOR;
+  ensure_not_running ();
 
   /* Find out whether we must run in the background.  */
   if (signum_exp != NULL)
@@ -2100,7 +2104,11 @@ interrupt_target_command (char *args, in
   if (target_can_async_p ())
     {
       dont_repeat ();		/* Not for the faint of heart */
-      target_stop ();
+
+      if (non_stop)
+	target_stop_ptid (inferior_ptid);
+      else
+	target_stop ();
     }
 }
 
Index: src/gdb/inferior.h
===================================================================
--- src.orig/gdb/inferior.h	2008-06-15 20:01:30.000000000 +0100
+++ src/gdb/inferior.h	2008-06-15 20:25:40.000000000 +0100
@@ -245,6 +245,12 @@ extern void get_last_target_status(ptid_
 
 extern void follow_inferior_reset_breakpoints (void);
 
+/* Throw an error indicating the current thread is running.  */
+extern void error_is_running (void);
+
+/* Calls error_is_running if the current thread is running.  */
+extern void ensure_not_running (void);
+
 /* From infcmd.c */
 
 extern void tty_command (char *, int);
Index: src/gdb/target.h
===================================================================
--- src.orig/gdb/target.h	2008-06-15 19:40:17.000000000 +0100
+++ src/gdb/target.h	2008-06-15 20:06:52.000000000 +0100
@@ -397,6 +397,7 @@ struct target_ops
     char *(*to_pid_to_str) (ptid_t);
     char *(*to_extra_thread_info) (struct thread_info *);
     void (*to_stop) (void);
+    void (*to_stop_ptid) (ptid_t ptid);
     void (*to_rcmd) (char *command, struct ui_file *output);
     char *(*to_pid_to_exec_file) (int pid);
     void (*to_log_command) (const char *);
@@ -895,6 +896,12 @@ int target_follow_fork (int follow_child
 
 #define target_stop current_target.to_stop
 
+/* Same as target_stop, but apply to PTID.  Used in non-stop mode to
+   stop a single thread without affecting the running state of the
+   others.  */
+#define target_stop_ptid(ptid) \
+     (*current_target.to_stop_ptid) (ptid)
+
 /* Send the specified COMMAND to the target's monitor
    (shell,interpreter) for execution.  The result of the query is
    placed in OUTBUF.  */
Index: src/gdb/target.c
===================================================================
--- src.orig/gdb/target.c	2008-06-15 17:57:52.000000000 +0100
+++ src/gdb/target.c	2008-06-15 20:25:40.000000000 +0100
@@ -456,6 +456,7 @@ update_current_target (void)
       INHERIT (to_pid_to_str, t);
       INHERIT (to_extra_thread_info, t);
       INHERIT (to_stop, t);
+      INHERIT (to_stop_ptid, t);
       /* Do not inherit to_xfer_partial.  */
       INHERIT (to_rcmd, t);
       INHERIT (to_pid_to_exec_file, t);
@@ -632,6 +633,9 @@ update_current_target (void)
   de_fault (to_stop,
 	    (void (*) (void))
 	    target_ignore);
+  de_fault (to_stop_ptid,
+	    (void (*) (ptid_t))
+	    target_ignore);
   current_target.to_xfer_partial = current_xfer_partial;
   de_fault (to_rcmd,
 	    (void (*) (char *, struct ui_file *))
@@ -2939,6 +2943,14 @@ debug_to_stop (void)
 }
 
 static void
+debug_to_stop_ptid (ptid_t ptid)
+{
+  debug_target.to_stop_ptid (ptid);
+
+  fprintf_unfiltered (gdb_stdlog, "target_stop_pid\n");
+}
+
+static void
 debug_to_rcmd (char *command,
 	       struct ui_file *outbuf)
 {
@@ -3012,6 +3024,7 @@ setup_target_debug (void)
   current_target.to_thread_alive = debug_to_thread_alive;
   current_target.to_find_new_threads = debug_to_find_new_threads;
   current_target.to_stop = debug_to_stop;
+  current_target.to_stop_ptid = debug_to_stop_ptid;
   current_target.to_rcmd = debug_to_rcmd;
   current_target.to_pid_to_exec_file = debug_to_pid_to_exec_file;
 }
Index: src/gdb/Makefile.in
===================================================================
--- src.orig/gdb/Makefile.in	2008-06-15 19:40:21.000000000 +0100
+++ src/gdb/Makefile.in	2008-06-15 20:06:52.000000000 +0100
@@ -2934,7 +2934,7 @@ target-memory.o: target-memory.c $(defs_
 thread.o: thread.c $(defs_h) $(symtab_h) $(frame_h) $(inferior_h) \
 	$(environ_h) $(value_h) $(target_h) $(gdbthread_h) $(exceptions_h) \
 	$(command_h) $(gdbcmd_h) $(regcache_h) $(gdb_h) $(gdb_string_h) \
-	$(ui_out_h) $(observer_h) $(annotate_h)
+	$(ui_out_h) $(observer_h) $(annotate_h) $(cli_decode_h)
 top.o: top.c $(defs_h) $(gdbcmd_h) $(call_cmds_h) $(cli_cmds_h) \
 	$(cli_script_h) $(cli_setshow_h) $(cli_decode_h) $(symtab_h) \
 	$(inferior_h) $(exceptions_h) $(target_h) $(breakpoint_h) \

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

* Re: [non-stop] 07/10 non-stop inferior control
  2008-06-15 21:06 [non-stop] 07/10 non-stop inferior control Pedro Alves
@ 2008-06-25 20:06 ` Daniel Jacobowitz
  2008-06-25 20:20   ` Pedro Alves
                     ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Daniel Jacobowitz @ 2008-06-25 20:06 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Sun, Jun 15, 2008 at 10:05:16PM +0100, Pedro Alves wrote:
> It is also needed to have support to interrupt/suspend a simple
> thread so a new target_stop_ptid method was added to request
> the target to interrupt a single thread.

How about adding a ptid argument to to_stop instead?  I think the code
will be shared in most cases.

> @@ -1810,11 +1847,16 @@ handle_inferior_event (struct execution_
>        && ecs->ws.kind != TARGET_WAITKIND_SIGNALLED && ecs->new_thread_event)
>      add_thread (ecs->ptid);
>  
> -  /* Mark all threads as not-executing.  In non-stop, this should be
> -     adjusted to only mark ecs->ptid.  */
> -  if (ecs->ws.kind != TARGET_WAITKIND_IGNORE
> -      && stop_soon != STOP_QUIETLY)
> -    set_executing (pid_to_ptid (-1), 0);
> +  if (ecs->ws.kind != TARGET_WAITKIND_IGNORE)
> +    {
> +      /* Mark the stopped threads accordingly.  */
> +      if (!non_stop
> +	  || ecs->ws.kind == TARGET_WAITKIND_EXITED
> +	  || ecs->ws.kind == TARGET_WAITKIND_SIGNALLED)
> +	set_executing (pid_to_ptid (-1), 0);
> +      else
> +	set_executing (ecs->ptid, 0);
> +    }
>  
>    switch (ecs->ws.kind)
>      {

Are we going to miss the stop_soon check here?

> -	switch_to_thread (tp->ptid);
> +	if (non_stop)
> +	  context_switch_to (tp->ptid);
> +	else
> +	  switch_to_thread (tp->ptid);
> +

Ow ow my head, I really wish we didn't need both of these.  We'll
never keep track of which is which.  Will we eventually be able to
merge them?

> -  add_prefix_cmd ("thread", class_run, thread_command, _("\
> +  c = add_prefix_cmd ("thread", class_run, thread_command, _("\
>  Use this command to switch between threads.\n\
>  The new thread ID must be currently known."),
>  		  &thread_cmd_list, "thread ", 1, &cmdlist);

Indentation on that last line.

Otherwise OK.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [non-stop] 07/10 non-stop inferior control
  2008-06-25 20:06 ` Daniel Jacobowitz
@ 2008-06-25 20:20   ` Pedro Alves
  2008-07-02  3:34   ` Pedro Alves
  2008-07-02  3:34   ` [non-stop v2] 07.2/10 update all targets to target_stop change Pedro Alves
  2 siblings, 0 replies; 7+ messages in thread
From: Pedro Alves @ 2008-06-25 20:20 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

A Wednesday 25 June 2008 20:44:09, Daniel Jacobowitz wrote:
> On Sun, Jun 15, 2008 at 10:05:16PM +0100, Pedro Alves wrote:
> > It is also needed to have support to interrupt/suspend a simple
> > thread so a new target_stop_ptid method was added to request
> > the target to interrupt a single thread.
>
> How about adding a ptid argument to to_stop instead?  I think the code
> will be shared in most cases.
>

Sure, I'll do that.  It was a way to not have to update all
targets before review.  :-)

> > @@ -1810,11 +1847,16 @@ handle_inferior_event (struct execution_
> >        && ecs->ws.kind != TARGET_WAITKIND_SIGNALLED &&
> > ecs->new_thread_event) add_thread (ecs->ptid);
> >
> > -  /* Mark all threads as not-executing.  In non-stop, this should be
> > -     adjusted to only mark ecs->ptid.  */
> > -  if (ecs->ws.kind != TARGET_WAITKIND_IGNORE
> > -      && stop_soon != STOP_QUIETLY)
> > -    set_executing (pid_to_ptid (-1), 0);
> > +  if (ecs->ws.kind != TARGET_WAITKIND_IGNORE)
> > +    {
> > +      /* Mark the stopped threads accordingly.  */
> > +      if (!non_stop
> > +	  || ecs->ws.kind == TARGET_WAITKIND_EXITED
> > +	  || ecs->ws.kind == TARGET_WAITKIND_SIGNALLED)
> > +	set_executing (pid_to_ptid (-1), 0);
> > +      else
> > +	set_executing (ecs->ptid, 0);
> > +    }
> >
> >    switch (ecs->ws.kind)
> >      {
>
> Are we going to miss the stop_soon check here?

Indeed, I'll recheck carefully.  It used to be needed, and the
symptom was a nice internal_error.  It isn't happening, which
probably means I either fixed the real issue, or I missed
something.  :-)

>
> > -	switch_to_thread (tp->ptid);
> > +	if (non_stop)
> > +	  context_switch_to (tp->ptid);
> > +	else
> > +	  switch_to_thread (tp->ptid);
> > +
>
> Ow ow my head, I really wish we didn't need both of these.  We'll
> never keep track of which is which.  

Easy, It's always both, except when it's a temporary switch to another
thread and back.  :-)

> Will we eventually be able to merge them?

Oh, yeah.  context_switch(_to) is a dying species.  I'm working on getting
rid  of it.  Then we'll only have switch_to_thread (which should go to,
if/when we switch to have a frame cache per thread).  stop_pc (the other
job of switch_to_thread) isn't doing its job in some cases either,
and we could remove it.  Say:

<stop at thread 1> (sets stop_pc)
p $pc = xxx
thread 2 (sets stop_pc)
thread 1 (sets stop_pc, but it's no longer the original...)

We can switch to always using read_pc() (or equivalent).

I have all-stop mode / linux mostly covered, now I'm making sure remote
always has a thread, monitor targets will be easy, and win32-nat.c
is also taken care of.  Will need to convert non-stop too, but
that'll take a bit.  I prefer that this series goes in first,
otherwise, we'll never get this done.  Baby steps, please.  :-)

>
> > -  add_prefix_cmd ("thread", class_run, thread_command, _("\
> > +  c = add_prefix_cmd ("thread", class_run, thread_command, _("\
> >  Use this command to switch between threads.\n\
> >  The new thread ID must be currently known."),
> >  		  &thread_cmd_list, "thread ", 1, &cmdlist);
>
> Indentation on that last line.
>
> Otherwise OK.

Thanks a bunch.  I'll get back once I resolve the issues
you mentioned.

-- 
Pedro Alves


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

* Re: [non-stop] 07/10 non-stop inferior control
  2008-06-25 20:06 ` Daniel Jacobowitz
  2008-06-25 20:20   ` Pedro Alves
@ 2008-07-02  3:34   ` Pedro Alves
  2008-07-07 18:10     ` Daniel Jacobowitz
  2008-07-02  3:34   ` [non-stop v2] 07.2/10 update all targets to target_stop change Pedro Alves
  2 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2008-07-02  3:34 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 2014 bytes --]

A Wednesday 25 June 2008 20:44:09, Daniel Jacobowitz wrote:
> On Sun, Jun 15, 2008 at 10:05:16PM +0100, Pedro Alves wrote:
> > It is also needed to have support to interrupt/suspend a simple
> > thread so a new target_stop_ptid method was added to request
> > the target to interrupt a single thread.
>
> How about adding a ptid argument to to_stop instead?  I think the code
> will be shared in most cases.

Here it is, then.

>
> > @@ -1810,11 +1847,16 @@ handle_inferior_event (struct execution_
> >        && ecs->ws.kind != TARGET_WAITKIND_SIGNALLED &&
> > ecs->new_thread_event) add_thread (ecs->ptid);
> >
> > -  /* Mark all threads as not-executing.  In non-stop, this should be
> > -     adjusted to only mark ecs->ptid.  */
> > -  if (ecs->ws.kind != TARGET_WAITKIND_IGNORE
> > -      && stop_soon != STOP_QUIETLY)
> > -    set_executing (pid_to_ptid (-1), 0);
> > +  if (ecs->ws.kind != TARGET_WAITKIND_IGNORE)
> > +    {
> > +      /* Mark the stopped threads accordingly.  */
> > +      if (!non_stop
> > +	  || ecs->ws.kind == TARGET_WAITKIND_EXITED
> > +	  || ecs->ws.kind == TARGET_WAITKIND_SIGNALLED)
> > +	set_executing (pid_to_ptid (-1), 0);
> > +      else
> > +	set_executing (ecs->ptid, 0);
> > +    }
> >
> >    switch (ecs->ws.kind)
> >      {
>
> Are we going to miss the stop_soon check here?

AFAICT, we're not.  I dropped it in the patch that was
introducing it.

> > -  add_prefix_cmd ("thread", class_run, thread_command, _("\
> > +  c = add_prefix_cmd ("thread", class_run, thread_command, _("\
> >  Use this command to switch between threads.\n\
> >  The new thread ID must be currently known."),
> >  		  &thread_cmd_list, "thread ", 1, &cmdlist);
>
> Indentation on that last line.
>
> Otherwise OK.

Thanks.  Updated patch adds a ptid_t argument to target_stop, and
fixes enough targets to build on linux.  Patch to update all other
targets to the new target_stop interface comming up.  Nothing else
changed.

Still OK, in combination with the next patch (7.2)?

-- 
Pedro Alves

[-- Attachment #2: 007-non_stop_core.diff --]
[-- Type: text/x-diff, Size: 24336 bytes --]

2008-07-02  Pedro Alves  <pedro@codesourcery.com>

	Non-stop inferior control.

	* infrun.c (resume): In non-stop mode, always resume just one
	thread.
	(proceed): Don't call prepare_to_proceed in non-stop mode.
	(fetch_inferior_event): In non-stop mode, switch context before
	handling the event.
	(error_is_running, ensure_not_running): New.
	(handle_inferior_event): In non-stop mode: Mark only the event
	thread as stopped.  Require that the target module manages adding
	threads to the thread list.  Assert that there isn't a
	deferred_step_ptid set.  Don't switch to infwait_thread_hop_state.
	(normal_stop): Only mark not-running if inferior hasn't exited.
	In non-stop mode, only mark the event thread.

	* thread.c:Include "cli/cli-decode.h".
	(print_thread_info): Don't read from a running thread.
	Output "(running)" if thread is running.
	(switch_to_thread): Don't read stop_pc if thread is executing.
	(do_restore_current_thread_cleanup): Don't write to a running
	thread.
	(thread_apply_all_command): Don't read from a running thread.  In
	non-stop mode, do a full context-switch instead of just switching
	threads.
	(thread_apply_command): In non-stop mode, do a full context-switch
	instead of just switching threads.
	(do_captured_thread_select): Likewise.  Inform user if selected
	thread is running.
	(_initialize_thread): Mark "info threads" and "thread" and
	async_ok.

	* inf-loop.c (inferior_event_handler): In non-stop mode, don't
	unregister the target from the event loop.

	* infcmd.c (continue_command, step_1, jump_command)
	(signal_command): Ensure the selected thread isn't running.
	(interrupt_target_command): In non-stop mode, interrupt only the
	selected thread.

	* inferior.h (error_is_running, ensure_not_running): Declare.

	* target.h (struct target_ops): Add ptid argument to the to_stop
	member.
	(target_stop): Add ptid_t argument.

	* target.c (update_current_target): Add ptid argument to to_stop's
	type.
	(debug_to_stop): Add ptid_t argument.
	(debug_to_rcmd): Set to_stop_ptid.

	* remote.c (remote_stop): Add ptid_t argument.
	(async_remote_interrupt): Add inferior_ptid to target_stop.
	* inf-ptrace.c (inf_ptrace_stop): Add ptid argument.

	* Makefile.in (thread.o): Depend on $(cli_decode_h).

---
 gdb/Makefile.in  |    2 
 gdb/inf-loop.c   |   14 ++++--
 gdb/inf-ptrace.c |    2 
 gdb/infcmd.c     |    7 ++-
 gdb/inferior.h   |    6 ++
 gdb/infrun.c     |  123 ++++++++++++++++++++++++++++++++++++++++++-------------
 gdb/remote.c     |    6 +-
 gdb/target.c     |   11 ++--
 gdb/target.h     |    4 -
 gdb/thread.c     |   99 ++++++++++++++++++++++++++++++++------------
 10 files changed, 201 insertions(+), 73 deletions(-)

Index: src/gdb/infrun.c
===================================================================
--- src.orig/gdb/infrun.c	2008-07-01 23:03:30.000000000 +0100
+++ src/gdb/infrun.c	2008-07-01 23:03:37.000000000 +0100
@@ -1052,9 +1052,15 @@ a command like `return' or `jump' to con
 	  resume_ptid = inferior_ptid;
 	}
 
-      if ((scheduler_mode == schedlock_on)
-	  || (scheduler_mode == schedlock_step
-	      && (step || singlestep_breakpoints_inserted_p)))
+      if (non_stop)
+	{
+	  /* With non-stop mode on, threads are always handled
+	     individually.  */
+	  resume_ptid = inferior_ptid;
+	}
+      else if ((scheduler_mode == schedlock_on)
+	       || (scheduler_mode == schedlock_step
+		   && (step || singlestep_breakpoints_inserted_p)))
 	{
 	  /* User-settable 'scheduler' mode requires solo thread resume. */
 	  resume_ptid = inferior_ptid;
@@ -1215,19 +1221,27 @@ proceed (CORE_ADDR addr, enum target_sig
 			"infrun: proceed (addr=0x%s, signal=%d, step=%d)\n",
 			paddr_nz (addr), siggnal, step);
 
-  /* In a multi-threaded task we may select another thread
-     and then continue or step.
+  if (non_stop)
+    /* In non-stop, each thread is handled individually.  The context
+       must already be set to the right thread here.  */
+    ;
+  else
+    {
+      /* In a multi-threaded task we may select another thread and
+	 then continue or step.
 
-     But if the old thread was stopped at a breakpoint, it
-     will immediately cause another breakpoint stop without
-     any execution (i.e. it will report a breakpoint hit
-     incorrectly).  So we must step over it first.
-
-     prepare_to_proceed checks the current thread against the thread
-     that reported the most recent event.  If a step-over is required
-     it returns TRUE and sets the current thread to the old thread. */
-  if (prepare_to_proceed (step))
-    oneproc = 1;
+	 But if the old thread was stopped at a breakpoint, it will
+	 immediately cause another breakpoint stop without any
+	 execution (i.e. it will report a breakpoint hit incorrectly).
+	 So we must step over it first.
+
+	 prepare_to_proceed checks the current thread against the
+	 thread that reported the most recent event.  If a step-over
+	 is required it returns TRUE and sets the current thread to
+	 the old thread. */
+      if (prepare_to_proceed (step))
+	oneproc = 1;
+    }
 
   if (oneproc)
     {
@@ -1531,6 +1545,15 @@ fetch_inferior_event (void *client_data)
   else
     ecs->ptid = target_wait (waiton_ptid, &ecs->ws);
 
+  if (non_stop
+      && ecs->ws.kind != TARGET_WAITKIND_IGNORE
+      && ecs->ws.kind != TARGET_WAITKIND_EXITED
+      && ecs->ws.kind != TARGET_WAITKIND_SIGNALLED)
+    /* In non-stop mode, each thread is handled individually.  Switch
+       early, so the global state is set correctly for this
+       thread.  */
+    context_switch (ecs->ptid);
+
   /* Now figure out what to do with the result of the result.  */
   handle_inferior_event (ecs);
 
@@ -1741,6 +1764,20 @@ init_infwait_state (void)
   infwait_state = infwait_normal_state;
 }
 
+void
+error_is_running (void)
+{
+  error (_("\
+Cannot execute this command while the selected thread is running."));
+}
+
+void
+ensure_not_running (void)
+{
+  if (is_running (inferior_ptid))
+    error_is_running ();
+}
+
 /* Given an execution control state that has been freshly filled in
    by an event from the inferior, figure out what it means and take
    appropriate action.  */
@@ -1814,10 +1851,16 @@ handle_inferior_event (struct execution_
       && ecs->ws.kind != TARGET_WAITKIND_SIGNALLED && ecs->new_thread_event)
     add_thread (ecs->ptid);
 
-  /* Mark all threads as not-executing.  In non-stop, this should be
-     adjusted to only mark ecs->ptid.  */
   if (ecs->ws.kind != TARGET_WAITKIND_IGNORE)
-    set_executing (pid_to_ptid (-1), 0);
+    {
+      /* Mark the non-executing threads accordingly.  */
+      if (!non_stop
+ 	  || ecs->ws.kind == TARGET_WAITKIND_EXITED
+ 	  || ecs->ws.kind == TARGET_WAITKIND_SIGNALLED)
+ 	set_executing (pid_to_ptid (-1), 0);
+      else
+ 	set_executing (ecs->ptid, 0);
+    }
 
   switch (ecs->ws.kind)
     {
@@ -2055,15 +2098,22 @@ handle_inferior_event (struct execution_
       return;
     }
 
-  /* We may want to consider not doing a resume here in order to give
-     the user a chance to play with the new thread.  It might be good
-     to make that a user-settable option.  */
-
-  /* At this point, all threads are stopped (happens automatically in
-     either the OS or the native code).  Therefore we need to continue
-     all threads in order to make progress.  */
   if (ecs->new_thread_event)
     {
+      if (non_stop)
+	/* Non-stop assumes that the target handles adding new threads
+	   to the thread list.  */
+	internal_error (__FILE__, __LINE__, "\
+targets should add new threads to the thread list themselves in non-stop mode.");
+
+      /* We may want to consider not doing a resume here in order to
+	 give the user a chance to play with the new thread.  It might
+	 be good to make that a user-settable option.  */
+
+      /* At this point, all threads are stopped (happens automatically
+	 in either the OS or the native code).  Therefore we need to
+	 continue all threads in order to make progress.  */
+
       target_resume (RESUME_ALL, 0, TARGET_SIGNAL_0);
       prepare_to_wait (ecs);
       return;
@@ -2130,6 +2180,9 @@ handle_inferior_event (struct execution_
 
   if (!ptid_equal (deferred_step_ptid, null_ptid))
     {
+      /* In non-stop mode, there's never a deferred_step_ptid set.  */
+      gdb_assert (!non_stop);
+
       /* If we stopped for some other reason than single-stepping, ignore
 	 the fact that we were supposed to switch back.  */
       if (stop_signal == TARGET_SIGNAL_TRAP)
@@ -2278,8 +2331,13 @@ handle_inferior_event (struct execution_
 	      if (!ptid_equal (inferior_ptid, ecs->ptid))
 		context_switch (ecs->ptid);
 
-	      waiton_ptid = ecs->ptid;
-	      infwait_state = infwait_thread_hop_state;
+	      if (!non_stop)
+		{
+		  /* Only need to require the next event from this
+		     thread in all-stop mode.  */
+		  waiton_ptid = ecs->ptid;
+		  infwait_state = infwait_thread_hop_state;
+		}
 
 	      tss->stepping_over_breakpoint = 1;
 	      keep_going (ecs);
@@ -3834,7 +3892,16 @@ done:
   /* Delete the breakpoint we stopped at, if it wants to be deleted.
      Delete any breakpoint that is to be deleted at the next stop.  */
   breakpoint_auto_delete (stop_bpstat);
-  set_running (pid_to_ptid (-1), 0);
+
+  if (target_has_execution
+      && last.kind != TARGET_WAITKIND_SIGNALLED
+      && last.kind != TARGET_WAITKIND_EXITED)
+    {
+      if (!non_stop)
+	set_running (pid_to_ptid (-1), 0);
+      else
+	set_running (inferior_ptid, 0);
+    }
 }
 
 static int
Index: src/gdb/thread.c
===================================================================
--- src.orig/gdb/thread.c	2008-07-01 23:03:30.000000000 +0100
+++ src/gdb/thread.c	2008-07-01 23:03:37.000000000 +0100
@@ -42,6 +42,8 @@
 #include "observer.h"
 #include "annotate.h"
 
+#include "cli/cli-decode.h"
+
 /* Definition of struct thread_info exported to gdbthread.h */
 
 /* Prototypes for exported functions. */
@@ -625,9 +627,12 @@ print_thread_info (struct ui_out *uiout,
   int current_thread = -1;
 
   /* Backup current thread and selected frame.  */
-  saved_frame_id = get_frame_id (get_selected_frame (NULL));
-  old_chain = make_cleanup_restore_current_thread (inferior_ptid, saved_frame_id);
+  if (!is_running (inferior_ptid))
+    saved_frame_id = get_frame_id (get_selected_frame (NULL));
+  else
+    saved_frame_id = null_frame_id;
 
+  old_chain = make_cleanup_restore_current_thread (inferior_ptid, saved_frame_id);
   make_cleanup_ui_out_list_begin_end (uiout, "threads");
 
   prune_threads ();
@@ -662,12 +667,18 @@ print_thread_info (struct ui_out *uiout,
 	  ui_out_text (uiout, ")");
 	}
       ui_out_text (uiout, "  ");
-      /* That switch put us at the top of the stack (leaf frame).  */
-      switch_to_thread (tp->ptid);
-      print_stack_frame (get_selected_frame (NULL), 
-			 /* For MI output, print frame level.  */
-			 ui_out_is_mi_like_p (uiout),
-			 LOCATION);
+      if (tp->running_)
+	ui_out_text (uiout, "(running)\n");
+      else
+	{
+	  /* The switch below puts us at the top of the stack (leaf
+	     frame).  */
+	  switch_to_thread (tp->ptid);
+	  print_stack_frame (get_selected_frame (NULL),
+			     /* For MI output, print frame level.  */
+			     ui_out_is_mi_like_p (uiout),
+			     LOCATION);
+	}
 
       do_cleanups (chain2);
     }
@@ -683,6 +694,9 @@ print_thread_info (struct ui_out *uiout,
 	ui_out_field_int (uiout, "current-thread-id", current_thread);
     }
 
+  if (is_running (inferior_ptid))
+    return;
+
   /*  If case we were not able to find the original frame, print the
       new selected frame.  */
   if (frame_find_by_id (saved_frame_id) == NULL)
@@ -721,7 +735,11 @@ switch_to_thread (ptid_t ptid)
   inferior_ptid = ptid;
   reinit_frame_cache ();
   registers_changed ();
-  stop_pc = read_pc ();
+
+  if (!is_executing (ptid))
+    stop_pc = read_pc ();
+  else
+    stop_pc = ~(CORE_ADDR) 0;
 }
 
 static void
@@ -758,7 +776,12 @@ do_restore_current_thread_cleanup (void 
 {
   struct current_thread_cleanup *old = arg;
   restore_current_thread (old->inferior_ptid);
-  restore_selected_frame (old->selected_frame_id);
+
+  /* A command like 'thread apply all $exec_command&' may change the
+     running state of the originally selected thread, so we have to
+     recheck it here.  */
+  if (!is_running (old->inferior_ptid))
+    restore_selected_frame (old->selected_frame_id);
   xfree (old);
 }
 
@@ -786,8 +809,7 @@ static void
 thread_apply_all_command (char *cmd, int from_tty)
 {
   struct thread_info *tp;
-  struct cleanup *old_chain;
-  struct cleanup *saved_cmd_cleanup_chain;
+  struct cleanup *old_chain = make_cleanup (null_cleanup, 0);
   char *saved_cmd;
   struct frame_id saved_frame_id;
   ptid_t current_ptid;
@@ -797,8 +819,12 @@ thread_apply_all_command (char *cmd, int
     error (_("Please specify a command following the thread ID list"));
   
   current_ptid = inferior_ptid;
-  saved_frame_id = get_frame_id (get_selected_frame (NULL));
-  old_chain = make_cleanup_restore_current_thread (inferior_ptid, saved_frame_id);
+
+  if (!is_running (inferior_ptid))
+    saved_frame_id = get_frame_id (get_selected_frame (NULL));
+  else
+    saved_frame_id = null_frame_id;
+  make_cleanup_restore_current_thread (inferior_ptid, saved_frame_id);
 
   /* It is safe to update the thread list now, before
      traversing it for "thread apply all".  MVS */
@@ -807,11 +833,15 @@ thread_apply_all_command (char *cmd, int
   /* Save a copy of the command in case it is clobbered by
      execute_command */
   saved_cmd = xstrdup (cmd);
-  saved_cmd_cleanup_chain = make_cleanup (xfree, (void *) saved_cmd);
+  make_cleanup (xfree, saved_cmd);
   for (tp = thread_list; tp; tp = tp->next)
     if (thread_alive (tp))
       {
-	switch_to_thread (tp->ptid);
+	if (non_stop)
+	  context_switch_to (tp->ptid);
+	else
+	  switch_to_thread (tp->ptid);
+
 	printf_filtered (_("\nThread %d (%s):\n"),
 			 tp->num, target_tid_to_str (inferior_ptid));
 	execute_command (cmd, from_tty);
@@ -821,12 +851,10 @@ thread_apply_all_command (char *cmd, int
   if (!ptid_equal (current_ptid, inferior_ptid))
     thread_has_changed = 1;
 
-  do_cleanups (saved_cmd_cleanup_chain);
   do_cleanups (old_chain);
   /* Print stack frame only if we changed thread.  */
-  if (thread_has_changed)
+  if (thread_has_changed && !is_running (inferior_ptid))
     print_stack_frame (get_current_frame (), 1, SRC_LINE);
-
 }
 
 static void
@@ -850,7 +878,11 @@ thread_apply_command (char *tidlist, int
     error (_("Please specify a command following the thread ID list"));
 
   current_ptid = inferior_ptid;
-  saved_frame_id = get_frame_id (get_selected_frame (NULL));
+
+  if (!is_running (inferior_ptid))
+    saved_frame_id = get_frame_id (get_selected_frame (NULL));
+  else
+    saved_frame_id = null_frame_id;
   old_chain = make_cleanup_restore_current_thread (inferior_ptid, saved_frame_id);
 
   /* Save a copy of the command in case it is clobbered by
@@ -894,7 +926,10 @@ thread_apply_command (char *tidlist, int
 	    warning (_("Thread %d has terminated."), start);
 	  else
 	    {
-	      switch_to_thread (tp->ptid);
+	      if (non_stop)
+		context_switch_to (tp->ptid);
+	      else
+		switch_to_thread (tp->ptid);
 	      printf_filtered (_("\nThread %d (%s):\n"), tp->num,
 			       target_tid_to_str (inferior_ptid));
 	      execute_command (cmd, from_tty);
@@ -962,7 +997,10 @@ do_captured_thread_select (struct ui_out
   if (!thread_alive (tp))
     error (_("Thread ID %d has terminated."), num);
 
-  switch_to_thread (tp->ptid);
+  if (non_stop)
+    context_switch_to (tp->ptid);
+  else
+    switch_to_thread (tp->ptid);
 
   ui_out_text (uiout, "[Switching to thread ");
   ui_out_field_int (uiout, "new-thread-id", pid_to_thread_id (inferior_ptid));
@@ -970,7 +1008,11 @@ do_captured_thread_select (struct ui_out
   ui_out_text (uiout, target_tid_to_str (inferior_ptid));
   ui_out_text (uiout, ")]");
 
-  print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+  if (!tp->running_)
+    print_stack_frame (get_selected_frame (NULL), 1, SRC_AND_LOC);
+  else
+    ui_out_text (uiout, "(running)\n");
+
   return GDB_RC_OK;
 }
 
@@ -990,14 +1032,17 @@ void
 _initialize_thread (void)
 {
   static struct cmd_list_element *thread_apply_list = NULL;
+  struct cmd_list_element *c;
 
-  add_info ("threads", info_threads_command,
-	    _("IDs of currently known threads."));
+  c = add_info ("threads", info_threads_command,
+		_("IDs of currently known threads."));
+  set_cmd_async_ok (c);
 
-  add_prefix_cmd ("thread", class_run, thread_command, _("\
+  c = add_prefix_cmd ("thread", class_run, thread_command, _("\
 Use this command to switch between threads.\n\
 The new thread ID must be currently known."),
-		  &thread_cmd_list, "thread ", 1, &cmdlist);
+		      &thread_cmd_list, "thread ", 1, &cmdlist);
+  set_cmd_async_ok (c);
 
   add_prefix_cmd ("apply", class_run, thread_apply_command,
 		  _("Apply a command to a list of threads."),
Index: src/gdb/inf-loop.c
===================================================================
--- src.orig/gdb/inf-loop.c	2008-07-01 23:03:30.000000000 +0100
+++ src/gdb/inf-loop.c	2008-07-01 23:03:37.000000000 +0100
@@ -73,11 +73,15 @@ inferior_event_handler (enum inferior_ev
       break;
 
     case INF_EXEC_COMPLETE:
-      /* Unregister the inferior from the event loop. This is done so that
-	 when the inferior is not running we don't get distracted by
-	 spurious inferior output.  */
-      if (target_has_execution)
-	target_async (NULL, 0);
+
+      if (!non_stop)
+	{
+	  /* Unregister the inferior from the event loop. This is done
+	     so that when the inferior is not running we don't get
+	     distracted by spurious inferior output.  */
+	  if (target_has_execution)
+	    target_async (NULL, 0);
+	}
 
       /* The call to async_enable_stdin below resets 'sync_execution'.
 	 However, if sync_execution is 1 now, we also need to show the
Index: src/gdb/infcmd.c
===================================================================
--- src.orig/gdb/infcmd.c	2008-07-01 23:03:30.000000000 +0100
+++ src/gdb/infcmd.c	2008-07-01 23:03:37.000000000 +0100
@@ -613,6 +613,7 @@ continue_command (char *proc_count_exp, 
 {
   int async_exec = 0;
   ERROR_NO_INFERIOR;
+  ensure_not_running ();
 
   /* Find out whether we must run in the background. */
   if (proc_count_exp != NULL)
@@ -714,6 +715,7 @@ step_1 (int skip_subroutines, int single
   int thread = -1;
 
   ERROR_NO_INFERIOR;
+  ensure_not_running ();
 
   if (count_string)
     async_exec = strip_bg_char (&count_string);
@@ -936,6 +938,7 @@ jump_command (char *arg, int from_tty)
   int async_exec = 0;
 
   ERROR_NO_INFERIOR;
+  ensure_not_running ();
 
   /* Find out whether we must run in the background. */
   if (arg != NULL)
@@ -1036,6 +1039,7 @@ signal_command (char *signum_exp, int fr
 
   dont_repeat ();		/* Too dangerous.  */
   ERROR_NO_INFERIOR;
+  ensure_not_running ();
 
   /* Find out whether we must run in the background.  */
   if (signum_exp != NULL)
@@ -2100,7 +2104,8 @@ interrupt_target_command (char *args, in
   if (target_can_async_p ())
     {
       dont_repeat ();		/* Not for the faint of heart */
-      target_stop ();
+
+      target_stop (inferior_ptid);
     }
 }
 
Index: src/gdb/inferior.h
===================================================================
--- src.orig/gdb/inferior.h	2008-07-01 23:03:30.000000000 +0100
+++ src/gdb/inferior.h	2008-07-01 23:03:37.000000000 +0100
@@ -245,6 +245,12 @@ extern void get_last_target_status(ptid_
 
 extern void follow_inferior_reset_breakpoints (void);
 
+/* Throw an error indicating the current thread is running.  */
+extern void error_is_running (void);
+
+/* Calls error_is_running if the current thread is running.  */
+extern void ensure_not_running (void);
+
 /* From infcmd.c */
 
 extern void tty_command (char *, int);
Index: src/gdb/target.h
===================================================================
--- src.orig/gdb/target.h	2008-07-01 23:03:30.000000000 +0100
+++ src/gdb/target.h	2008-07-01 23:03:37.000000000 +0100
@@ -401,7 +401,7 @@ struct target_ops
     void (*to_find_new_threads) (void);
     char *(*to_pid_to_str) (ptid_t);
     char *(*to_extra_thread_info) (struct thread_info *);
-    void (*to_stop) (void);
+    void (*to_stop) (ptid_t);
     void (*to_rcmd) (char *command, struct ui_file *output);
     char *(*to_pid_to_exec_file) (int pid);
     void (*to_log_command) (const char *);
@@ -898,7 +898,7 @@ int target_follow_fork (int follow_child
    Unix, this should act like SIGSTOP).  This function is normally
    used by GUIs to implement a stop button.  */
 
-#define target_stop current_target.to_stop
+#define target_stop(ptid) (*current_target.to_stop) (ptid)
 
 /* Send the specified COMMAND to the target's monitor
    (shell,interpreter) for execution.  The result of the query is
Index: src/gdb/target.c
===================================================================
--- src.orig/gdb/target.c	2008-07-01 23:03:30.000000000 +0100
+++ src/gdb/target.c	2008-07-01 23:03:37.000000000 +0100
@@ -165,7 +165,7 @@ static void debug_to_notice_signals (pti
 
 static int debug_to_thread_alive (ptid_t);
 
-static void debug_to_stop (void);
+static void debug_to_stop (ptid_t);
 
 /* NOTE: cagney/2004-09-29: Many targets reference this variable in
    wierd and mysterious ways.  Putting the variable here lets those
@@ -629,7 +629,7 @@ update_current_target (void)
 	    (char *(*) (struct thread_info *))
 	    return_zero);
   de_fault (to_stop,
-	    (void (*) (void))
+	    (void (*) (ptid_t))
 	    target_ignore);
   current_target.to_xfer_partial = current_xfer_partial;
   de_fault (to_rcmd,
@@ -2996,11 +2996,12 @@ debug_to_find_new_threads (void)
 }
 
 static void
-debug_to_stop (void)
+debug_to_stop (ptid_t ptid)
 {
-  debug_target.to_stop ();
+  debug_target.to_stop (ptid);
 
-  fprintf_unfiltered (gdb_stdlog, "target_stop ()\n");
+  fprintf_unfiltered (gdb_stdlog, "target_stop (%s)\n",
+		      target_pid_to_str (ptid));
 }
 
 static void
Index: src/gdb/Makefile.in
===================================================================
--- src.orig/gdb/Makefile.in	2008-07-01 23:03:30.000000000 +0100
+++ src/gdb/Makefile.in	2008-07-01 23:03:37.000000000 +0100
@@ -2921,7 +2921,7 @@ target-memory.o: target-memory.c $(defs_
 thread.o: thread.c $(defs_h) $(symtab_h) $(frame_h) $(inferior_h) \
 	$(environ_h) $(value_h) $(target_h) $(gdbthread_h) $(exceptions_h) \
 	$(command_h) $(gdbcmd_h) $(regcache_h) $(gdb_h) $(gdb_string_h) \
-	$(ui_out_h) $(observer_h) $(annotate_h)
+	$(ui_out_h) $(observer_h) $(annotate_h) $(cli_decode_h)
 top.o: top.c $(defs_h) $(gdbcmd_h) $(call_cmds_h) $(cli_cmds_h) \
 	$(cli_script_h) $(cli_setshow_h) $(cli_decode_h) $(symtab_h) \
 	$(inferior_h) $(exceptions_h) $(target_h) $(breakpoint_h) \
Index: src/gdb/inf-ptrace.c
===================================================================
--- src.orig/gdb/inf-ptrace.c	2008-07-01 23:03:30.000000000 +0100
+++ src/gdb/inf-ptrace.c	2008-07-01 23:03:37.000000000 +0100
@@ -297,7 +297,7 @@ inf_ptrace_kill (void)
 /* Stop the inferior.  */
 
 static void
-inf_ptrace_stop (void)
+inf_ptrace_stop (ptid_t ptid)
 {
   /* Send a SIGINT to the process group.  This acts just like the user
      typed a ^C on the controlling terminal.  Note that using a
Index: src/gdb/remote.c
===================================================================
--- src.orig/gdb/remote.c	2008-07-01 23:03:30.000000000 +0100
+++ src/gdb/remote.c	2008-07-01 23:03:37.000000000 +0100
@@ -155,7 +155,7 @@ static void init_remote_ops (void);
 
 static void init_extended_remote_ops (void);
 
-static void remote_stop (void);
+static void remote_stop (ptid_t);
 
 static int ishex (int ch, int *val);
 
@@ -3269,7 +3269,7 @@ async_remote_interrupt (gdb_client_data 
   if (remote_debug)
     fprintf_unfiltered (gdb_stdlog, "remote_interrupt called\n");
 
-  target_stop ();
+  target_stop (inferior_ptid);
 }
 
 /* Perform interrupt, if the first attempt did not succeed. Just give
@@ -3323,7 +3323,7 @@ remote_interrupt_twice (int signo)
    interrupt is requested, either by the command line or the GUI, we
    will eventually end up here.  */
 static void
-remote_stop (void)
+remote_stop (ptid_t ptid)
 {
   /* Send a break or a ^C, depending on user preference.  */
   if (remote_debug)

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

* [non-stop v2] 07.2/10 update all targets to target_stop change
  2008-06-25 20:06 ` Daniel Jacobowitz
  2008-06-25 20:20   ` Pedro Alves
  2008-07-02  3:34   ` Pedro Alves
@ 2008-07-02  3:34   ` Pedro Alves
  2008-07-07 18:10     ` Daniel Jacobowitz
  2 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2008-07-02  3:34 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 513 bytes --]

I wrote:
> Wednesday 25 June 2008 20:44:09, Daniel Jacobowitz wrote:
>> How about adding a ptid argument to to_stop instead?  I think the code
>> will be shared in most cases.
>Updated patch adds a ptid_t argument to target_stop, and
>fixes enough targets to build on linux.  Patch to update all other
>targets to the new target_stop interface comming up.  Nothing else
>changed.
>

Here it is.  grepping for "to_stop = " and target_stop didn't find
any other cases.  OK with the previous patch?

-- 
Pedro Alves

[-- Attachment #2: 007_2-to_stop_change_arg.diff --]
[-- Type: text/x-diff, Size: 8319 bytes --]

2008-07-02  Pedro Alves  <pedro@codesourcery.com>

	Adjust all targets to new target_stop interface.

	* gnu-nat.c (gnu_stop): Add ptid argument.
	* go32-nat.c (go32_stop): Add ptid argument.
	(go32_create_inferior): Pass inferior_ptid to go32_stop.
	* hpux-thread.c (hpux_thread_stop): Add ptid argument.
	* monitor.c (monitor_stop): Add ptid argument.
	(monitor_open): Pass inferior_ptid to monitor_stop.
	(monitor_interrupt): Pass inferior_ptid to target_stop.
	(monitor_stop): Add ptid argument.
	* nto-procfs.c (nto_interrupt): Pass inferior_ptid to target_stop.
	(procfs_create_inferior): Add ptid argument.
	* procfs.c (procfs_stop): Add ptid argument.
	* remote-m32r-sdi.c (m32r_stop): Add ptid argument.
	* remote-sim.c (gdbsim_stop): Add ptid argument.
	* sol-thread.c (sol_thread_stop): Add ptid argument.
	* win32-nat.c (win32_stop): Add ptid argument.

---
 gdb/gnu-nat.c         |    2 +-
 gdb/go32-nat.c        |    6 +++---
 gdb/hpux-thread.c     |    4 ++--
 gdb/monitor.c         |    8 ++++----
 gdb/nto-procfs.c      |    4 ++--
 gdb/procfs.c          |    4 ++--
 gdb/remote-m32r-sdi.c |    2 +-
 gdb/remote-sim.c      |    4 ++--
 gdb/sol-thread.c      |    4 ++--
 gdb/win32-nat.c       |    4 ++--
 10 files changed, 21 insertions(+), 21 deletions(-)

Index: src/gdb/gnu-nat.c
===================================================================
--- src.orig/gdb/gnu-nat.c	2008-07-01 22:42:50.000000000 +0100
+++ src/gdb/gnu-nat.c	2008-07-01 22:43:05.000000000 +0100
@@ -2216,7 +2216,7 @@ gnu_open (char *arg, int from_tty)
 }
 
 static void
-gnu_stop (void)
+gnu_stop (ptid_t ptid)
 {
   error (_("to_stop target function not implemented"));
 }
Index: src/gdb/go32-nat.c
===================================================================
--- src.orig/gdb/go32-nat.c	2008-07-01 22:42:50.000000000 +0100
+++ src/gdb/go32-nat.c	2008-07-01 22:43:05.000000000 +0100
@@ -181,7 +181,7 @@ static int go32_xfer_memory (CORE_ADDR m
 			     struct mem_attrib *attrib,
 			     struct target_ops *target);
 static void go32_files_info (struct target_ops *target);
-static void go32_stop (void);
+static void go32_stop (ptid_t);
 static void go32_kill_inferior (void);
 static void go32_create_inferior (char *exec_file, char *args, char **env, int from_tty);
 static void go32_mourn_inferior (void);
@@ -560,7 +560,7 @@ go32_files_info (struct target_ops *targ
 }
 
 static void
-go32_stop (void)
+go32_stop (ptid_t ptid)
 {
   normal_stop ();
   cleanup_client ();
@@ -593,7 +593,7 @@ go32_create_inferior (char *exec_file, c
 
   if (prog_has_started)
     {
-      go32_stop ();
+      go32_stop (inferior_ptid);
       go32_kill_inferior ();
     }
   resume_signal = -1;
Index: src/gdb/hpux-thread.c
===================================================================
--- src.orig/gdb/hpux-thread.c	2008-07-01 22:42:50.000000000 +0100
+++ src/gdb/hpux-thread.c	2008-07-01 22:43:05.000000000 +0100
@@ -505,9 +505,9 @@ hpux_thread_alive (ptid_t ptid)
 }
 
 static void
-hpux_thread_stop (void)
+hpux_thread_stop (ptid_t ptid)
 {
-  deprecated_child_ops.to_stop ();
+  deprecated_child_ops.to_stop (ptid);
 }
 \f
 /* Convert a pid to printable form. */
Index: src/gdb/monitor.c
===================================================================
--- src.orig/gdb/monitor.c	2008-07-01 22:42:50.000000000 +0100
+++ src/gdb/monitor.c	2008-07-01 22:43:05.000000000 +0100
@@ -61,7 +61,7 @@ static struct target_ops *targ_ops;
 
 static void monitor_interrupt_query (void);
 static void monitor_interrupt_twice (int);
-static void monitor_stop (void);
+static void monitor_stop (ptid_t);
 static void monitor_dump_regs (struct regcache *regcache);
 
 #if 0
@@ -759,7 +759,7 @@ monitor_open (char *args, struct monitor
 
   if (current_monitor->stop)
     {
-      monitor_stop ();
+      monitor_stop (inferior_ptid);
       if ((current_monitor->flags & MO_NO_ECHO_ON_OPEN) == 0)
 	{
 	  monitor_debug ("EXP Open echo\n");
@@ -972,7 +972,7 @@ monitor_interrupt (int signo)
   if (monitor_debug_p || remote_debug)
     fprintf_unfiltered (gdb_stdlog, "monitor_interrupt called\n");
 
-  target_stop ();
+  target_stop (inferior_ptid);
 }
 
 /* The user typed ^C twice.  */
@@ -2156,7 +2156,7 @@ monitor_load (char *file, int from_tty)
 }
 
 static void
-monitor_stop (void)
+monitor_stop (ptid_t ptid)
 {
   monitor_debug ("MON stop\n");
   if ((current_monitor->flags & MO_SEND_BREAK_ON_STOP) != 0)
Index: src/gdb/nto-procfs.c
===================================================================
--- src.orig/gdb/nto-procfs.c	2008-07-01 22:42:50.000000000 +0100
+++ src/gdb/nto-procfs.c	2008-07-01 22:43:05.000000000 +0100
@@ -607,7 +607,7 @@ nto_interrupt (int signo)
   /* If this doesn't work, try more severe steps.  */
   signal (signo, nto_interrupt_twice);
 
-  target_stop ();
+  target_stop (inferior_ptid);
 }
 
 static ptid_t
@@ -1094,7 +1094,7 @@ procfs_create_inferior (char *exec_file,
 }
 
 static void
-procfs_stop (void)
+procfs_stop (ptid_t ptid)
 {
   devctl (ctl_fd, DCMD_PROC_STOP, NULL, 0, 0);
 }
Index: src/gdb/procfs.c
===================================================================
--- src.orig/gdb/procfs.c	2008-07-01 22:42:50.000000000 +0100
+++ src/gdb/procfs.c	2008-07-01 22:43:05.000000000 +0100
@@ -116,7 +116,7 @@ static void procfs_attach (char *, int);
 static void procfs_detach (char *, int);
 static void procfs_resume (ptid_t, int, enum target_signal);
 static int procfs_can_run (void);
-static void procfs_stop (void);
+static void procfs_stop (ptid_t);
 static void procfs_files_info (struct target_ops *);
 static void procfs_fetch_registers (struct regcache *, int);
 static void procfs_store_registers (struct regcache *, int);
@@ -4756,7 +4756,7 @@ procfs_can_run (void)
  */
 
 static void
-procfs_stop (void)
+procfs_stop (ptid_t ptid)
 {
   kill (-inferior_process_group, SIGINT);
 }
Index: src/gdb/remote-m32r-sdi.c
===================================================================
--- src.orig/gdb/remote-m32r-sdi.c	2008-07-01 22:42:50.000000000 +0100
+++ src/gdb/remote-m32r-sdi.c	2008-07-01 22:43:05.000000000 +0100
@@ -1391,7 +1391,7 @@ m32r_load (char *args, int from_tty)
 }
 
 static void
-m32r_stop (void)
+m32r_stop (ptid_t ptid)
 {
   if (remote_debug)
     fprintf_unfiltered (gdb_stdlog, "m32r_stop()\n");
Index: src/gdb/remote-sim.c
===================================================================
--- src.orig/gdb/remote-sim.c	2008-07-01 22:42:50.000000000 +0100
+++ src/gdb/remote-sim.c	2008-07-01 22:43:05.000000000 +0100
@@ -95,7 +95,7 @@ static void gdbsim_files_info (struct ta
 
 static void gdbsim_mourn_inferior (void);
 
-static void gdbsim_stop (void);
+static void gdbsim_stop (ptid_t ptid);
 
 void simulator_command (char *args, int from_tty);
 
@@ -632,7 +632,7 @@ gdbsim_resume (ptid_t ptid, int step, en
    For simulators that do not support this operation, just abort */
 
 static void
-gdbsim_stop (void)
+gdbsim_stop (ptid_t ptid)
 {
   if (!sim_stop (gdbsim_desc))
     {
Index: src/gdb/sol-thread.c
===================================================================
--- src.orig/gdb/sol-thread.c	2008-07-01 22:42:50.000000000 +0100
+++ src/gdb/sol-thread.c	2008-07-01 22:43:05.000000000 +0100
@@ -881,9 +881,9 @@ sol_thread_alive (ptid_t ptid)
 }
 
 static void
-sol_thread_stop (void)
+sol_thread_stop (ptid_t ptid)
 {
-  procfs_ops.to_stop ();
+  procfs_ops.to_stop (ptid);
 }
 \f
 /* These routines implement the lower half of the thread_db interface,
Index: src/gdb/win32-nat.c
===================================================================
--- src.orig/gdb/win32-nat.c	2008-07-01 22:42:50.000000000 +0100
+++ src/gdb/win32-nat.c	2008-07-01 22:43:05.000000000 +0100
@@ -105,7 +105,7 @@ static int debug_registers_used;
 #define DEBUG_MEM(x)	if (debug_memory)	printf_unfiltered x
 #define DEBUG_EXCEPT(x)	if (debug_exceptions)	printf_unfiltered x
 
-static void win32_stop (void);
+static void win32_stop (ptid_t);
 static int win32_win32_thread_alive (ptid_t);
 static void win32_kill_inferior (void);
 
@@ -1928,7 +1928,7 @@ win32_mourn_inferior (void)
    ^C on the controlling terminal. */
 
 static void
-win32_stop (void)
+win32_stop (ptid_t ptid)
 {
   DEBUG_EVENTS (("gdb: GenerateConsoleCtrlEvent (CTRLC_EVENT, 0)\n"));
   CHECK (GenerateConsoleCtrlEvent (CTRL_C_EVENT, current_event.dwProcessId));

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

* Re: [non-stop v2] 07.2/10 update all targets to target_stop change
  2008-07-02  3:34   ` [non-stop v2] 07.2/10 update all targets to target_stop change Pedro Alves
@ 2008-07-07 18:10     ` Daniel Jacobowitz
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Jacobowitz @ 2008-07-07 18:10 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Wed, Jul 02, 2008 at 04:34:19AM +0100, Pedro Alves wrote:
> I wrote:
> > Wednesday 25 June 2008 20:44:09, Daniel Jacobowitz wrote:
> >> How about adding a ptid argument to to_stop instead?  I think the code
> >> will be shared in most cases.
> >Updated patch adds a ptid_t argument to target_stop, and
> >fixes enough targets to build on linux.  Patch to update all other
> >targets to the new target_stop interface comming up.  Nothing else
> >changed.
> >
> 
> Here it is.  grepping for "to_stop = " and target_stop didn't find
> any other cases.  OK with the previous patch?

OK.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [non-stop] 07/10 non-stop inferior control
  2008-07-02  3:34   ` Pedro Alves
@ 2008-07-07 18:10     ` Daniel Jacobowitz
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Jacobowitz @ 2008-07-07 18:10 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On Wed, Jul 02, 2008 at 04:33:52AM +0100, Pedro Alves wrote:
> Thanks.  Updated patch adds a ptid_t argument to target_stop, and
> fixes enough targets to build on linux.  Patch to update all other
> targets to the new target_stop interface comming up.  Nothing else
> changed.
> 
> Still OK, in combination with the next patch (7.2)?

OK.

-- 
Daniel Jacobowitz
CodeSourcery


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

end of thread, other threads:[~2008-07-07 18:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-15 21:06 [non-stop] 07/10 non-stop inferior control Pedro Alves
2008-06-25 20:06 ` Daniel Jacobowitz
2008-06-25 20:20   ` Pedro Alves
2008-07-02  3:34   ` Pedro Alves
2008-07-07 18:10     ` Daniel Jacobowitz
2008-07-02  3:34   ` [non-stop v2] 07.2/10 update all targets to target_stop change Pedro Alves
2008-07-07 18:10     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox