]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Make the stop_soon global be per-inferior instead.
authorPedro Alves <palves@redhat.com>
Mon, 22 Sep 2008 15:20:08 +0000 (15:20 +0000)
committerPedro Alves <palves@redhat.com>
Mon, 22 Sep 2008 15:20:08 +0000 (15:20 +0000)
* infcmd.c (attach_command_post_wait): Adjust.
(attach_command): Likewise.

* inferior.h (stop_soon): Delete.
(struct inferior): Add stop_soon member.

* infrun.c (stop_soon): Delete.
(clear_proceed_status, start_remote)
(fetch_inferior_event, handle_inferior_event): Adjust.
(signal_stop_state): Don't check stop_soon here.  Check in callers
instead.
(save_inferior_status, restore_inferior_status): Adjust.

* linux-nat.c (linux_nat_resume, linux_nat_wait): Always pass
signals to common code if starting up the inferior.

* inferior.h (struct inferior_info): Added stop_soon member.
* inferior.c (add_inferior) Clear stop_soon.

* mips-tdep.c (heuristic_proc_start): Adjust.
* nto-procfs.c (procfs_create_inferior): Adjust.
* solib-irix.c (irix_solib_create_inferior_hook): Adjust.
* solib-osf.c (osf_solib_create_inferior_hook): Adjust.
* solib-sunos.c (sunos_solib_create_inferior_hook): Adjust.
* solib-svr4.c (svr4_solib_create_inferior_hook): Adjust.

* win32-nat.c (do_initial_win32_stuff): Adjust.

* alpha-tdep.c (alpha_heuristic_proc_start): Adjust.

15 files changed:
gdb/ChangeLog
gdb/alpha-tdep.c
gdb/infcmd.c
gdb/inferior.c
gdb/inferior.h
gdb/infrun.c
gdb/linux-nat.c
gdb/mips-tdep.c
gdb/nto-procfs.c
gdb/solib-irix.c
gdb/solib-osf.c
gdb/solib-sunos.c
gdb/solib-svr4.c
gdb/win32-nat.c
gdb/windows-nat.c

index b508f6733d5d00fc4ef45c7b8bde6d17c134ad39..753757dd1b4d74f31307bbafbf384cbe7c1d044f 100644 (file)
@@ -1,3 +1,37 @@
+2008-09-22  Pedro Alves  <pedro@codesourcery.com>
+
+       Make the stop_soon global be per-inferior instead.
+
+       * infcmd.c (attach_command_post_wait): Adjust.
+       (attach_command): Likewise.
+
+       * inferior.h (stop_soon): Delete.
+       (struct inferior): Add stop_soon member.
+
+       * infrun.c (stop_soon): Delete.
+       (clear_proceed_status, start_remote)
+       (fetch_inferior_event, handle_inferior_event): Adjust.
+       (signal_stop_state): Don't check stop_soon here.  Check in callers
+       instead.
+       (save_inferior_status, restore_inferior_status): Adjust.
+
+       * linux-nat.c (linux_nat_resume, linux_nat_wait): Always pass
+       signals to common code if starting up the inferior.
+       
+       * inferior.h (struct inferior_info): Added stop_soon member.
+       * inferior.c (add_inferior) Clear stop_soon.
+
+       * mips-tdep.c (heuristic_proc_start): Adjust.
+       * nto-procfs.c (procfs_create_inferior): Adjust.
+       * solib-irix.c (irix_solib_create_inferior_hook): Adjust.
+       * solib-osf.c (osf_solib_create_inferior_hook): Adjust.
+       * solib-sunos.c (sunos_solib_create_inferior_hook): Adjust.
+       * solib-svr4.c (svr4_solib_create_inferior_hook): Adjust.
+
+       * win32-nat.c (do_initial_win32_stuff): Adjust.
+
+       * alpha-tdep.c (alpha_heuristic_proc_start): Adjust.
+
 2008-09-22  Pedro Alves  <pedro@codesourcery.com>
 
        Implement remote multi-process extensions.
index 27137d90382b3e9212562b11b5ed147a9ee6bc35..ede74c5a1f67f4650af4b2137c7a1d57903fe82a 100644 (file)
@@ -909,6 +909,7 @@ alpha_heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
   CORE_ADDR fence = pc - heuristic_fence_post;
   CORE_ADDR orig_pc = pc;
   CORE_ADDR func;
+  struct inferior *inf;
 
   if (pc == 0)
     return 0;
@@ -946,10 +947,12 @@ alpha_heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
        }
     }
 
+  inf = current_inferior ();
+
   /* It's not clear to me why we reach this point when stopping quietly,
      but with this test, at least we don't print out warnings for every
      child forked (eg, on decstation).  22apr93 rich@cygnus.com.  */
-  if (stop_soon == NO_STOP_QUIETLY)
+  if (inf->stop_soon == NO_STOP_QUIETLY)
     {
       static int blurb_printed = 0;
 
index 6ffc97f307e38025e3656193c8ffdee23cd25c35..6ed6341fa2b730c140b2cabfc28224ea4adc0737 100644 (file)
@@ -1956,8 +1956,10 @@ attach_command_post_wait (char *args, int from_tty, int async_exec)
 {
   char *exec_file;
   char *full_exec_path = NULL;
+  struct inferior *inferior;
 
-  stop_soon = NO_STOP_QUIETLY;
+  inferior = current_inferior ();
+  inferior->stop_soon = NO_STOP_QUIETLY;
 
   /* If no exec file is yet known, try to determine it from the
      process itself.  */
@@ -2087,12 +2089,14 @@ attach_command (char *args, int from_tty)
      E.g. Mach 3 or GNU hurd.  */
   if (!target_attach_no_wait)
     {
+      struct inferior *inferior = current_inferior ();
+
       /* Careful here. See comments in inferior.h.  Basically some
         OSes don't ignore SIGSTOPs on continue requests anymore.  We
         need a way for handle_inferior_event to reset the stop_signal
         variable after an attach, and this is what
         STOP_QUIETLY_NO_SIGSTOP is for.  */
-      stop_soon = STOP_QUIETLY_NO_SIGSTOP;
+      inferior->stop_soon = STOP_QUIETLY_NO_SIGSTOP;
 
       if (target_can_async_p ())
        {
index 128e8fc50a68b3b95d35072846fe8dd90975da96..4233a51dfac572d353ea672ad83f5bef0fc25ee0 100644 (file)
@@ -76,6 +76,8 @@ add_inferior_silent (int pid)
   memset (inf, 0, sizeof (*inf));
   inf->pid = pid;
 
+  inf->stop_soon = NO_STOP_QUIETLY;
+
   inf->num = ++highest_inferior_num;
   inf->next = inferior_list;
   inferior_list = inf;
index 51bee346649f565f323343092db60f5c1fe59734..66e7d4754c547deb258ed07ec24f9bc3c68017bc 100644 (file)
@@ -339,8 +339,6 @@ enum stop_kind
     STOP_QUIETLY_NO_SIGSTOP
   };
 
-extern enum stop_kind stop_soon;
-
 /* Nonzero if proceed is being used for a "finish" command or a similar
    situation when stop_registers should be saved.  */
 
@@ -423,6 +421,9 @@ struct inferior
      the ptid_t.pid member of threads of this inferior.  */
   int pid;
 
+  /* See the definition of stop_kind above.  */
+  enum stop_kind stop_soon;
+
   /* Private data used by the target vector implementation.  */
   struct private_inferior *private;
 };
index c7fdd613af14cf0d61599d922d354d41a72b0e1f..93487e3e7c4756dca2631ba28210b2a71c76ffa9 100644 (file)
@@ -230,13 +230,6 @@ show_stop_on_solib_events (struct ui_file *file, int from_tty,
 
 int stop_after_trap;
 
-/* Nonzero means expecting a trap and caller will handle it themselves.
-   It is used after attach, due to attaching to a process;
-   when running in the shell before the child program has been exec'd;
-   and when running some kinds of remote stuff (FIXME?).  */
-
-enum stop_kind stop_soon;
-
 /* Save register contents here when about to pop a stack dummy frame,
    if-and-only-if proceed_to_finish is set.
    Thus this contains the return value from the called function (assuming
@@ -1097,7 +1090,10 @@ clear_proceed_status (void)
 {
   if (!ptid_equal (inferior_ptid, null_ptid))
     {
-      struct thread_info *tp = inferior_thread ();
+      struct thread_info *tp;
+      struct inferior *inferior;
+
+      tp = inferior_thread ();
 
       tp->trap_expected = 0;
       tp->step_range_start = 0;
@@ -1112,10 +1108,12 @@ clear_proceed_status (void)
       /* Discard any remaining commands or status from previous
         stop.  */
       bpstat_clear (&tp->stop_bpstat);
+
+      inferior = current_inferior ();
+      inferior->stop_soon = NO_STOP_QUIETLY;
     }
 
   stop_after_trap = 0;
-  stop_soon = NO_STOP_QUIETLY;
   breakpoint_proceeded = 1;    /* We're about to proceed... */
 
   if (stop_registers)
@@ -1351,8 +1349,11 @@ proceed (CORE_ADDR addr, enum target_signal siggnal, int step)
 void
 start_remote (int from_tty)
 {
+  struct inferior *inferior;
   init_wait_for_inferior ();
-  stop_soon = STOP_QUIETLY_REMOTE;
+
+  inferior = current_inferior ();
+  inferior->stop_soon = STOP_QUIETLY_REMOTE;
 
   /* Always go on waiting for the target, regardless of the mode. */
   /* FIXME: cagney/1999-09-23: At present it isn't possible to
@@ -1648,9 +1649,12 @@ fetch_inferior_event (void *client_data)
 
   if (!ecs->wait_some_more)
     {
+      struct inferior *inf = find_inferior_pid (ptid_get_pid (ecs->ptid));
+
       delete_step_thread_step_resume_breakpoint ();
 
-      if (stop_soon == NO_STOP_QUIETLY)
+      /* We may not find an inferior if this was a process exit.  */
+      if (inf == NULL || inf->stop_soon == NO_STOP_QUIETLY)
        normal_stop ();
 
       if (target_has_execution
@@ -1840,6 +1844,18 @@ handle_inferior_event (struct execution_control_state *ecs)
   int stopped_by_watchpoint;
   int stepped_after_stopped_by_watchpoint = 0;
   struct symtab_and_line stop_pc_sal;
+  enum stop_kind stop_soon;
+
+  if (ecs->ws.kind != TARGET_WAITKIND_EXITED
+      && ecs->ws.kind != TARGET_WAITKIND_SIGNALLED
+      && ecs->ws.kind != TARGET_WAITKIND_IGNORE)
+    {
+      struct inferior *inf = find_inferior_pid (ptid_get_pid (ecs->ptid));
+      gdb_assert (inf);
+      stop_soon = inf->stop_soon;
+    }
+  else
+    stop_soon = NO_STOP_QUIETLY;
 
   breakpoint_retire_moribund ();
 
@@ -2673,7 +2689,10 @@ process_event_stop_test:
          target_terminal_ours_for_output ();
          print_stop_reason (SIGNAL_RECEIVED, ecs->event_thread->stop_signal);
        }
-      if (signal_stop_state (ecs->event_thread->stop_signal))
+      /* Always stop on signals if we're just gaining control of the
+        program.  */
+      if (stop_soon != NO_STOP_QUIETLY
+         || signal_stop_state (ecs->event_thread->stop_signal))
        {
          stop_stepping (ecs);
          return;
@@ -3972,9 +3991,7 @@ hook_stop_stub (void *cmd)
 int
 signal_stop_state (int signo)
 {
-  /* Always stop on signals if we're just gaining control of the
-     program.  */
-  return signal_stop[signo] || stop_soon != NO_STOP_QUIETLY;
+  return signal_stop[signo];
 }
 
 int
@@ -4376,6 +4393,7 @@ save_inferior_status (int restore_stack_info)
 {
   struct inferior_status *inf_status = XMALLOC (struct inferior_status);
   struct thread_info *tp = inferior_thread ();
+  struct inferior *inf = current_inferior ();
 
   inf_status->stop_signal = tp->stop_signal;
   inf_status->stop_pc = stop_pc;
@@ -4388,7 +4406,7 @@ save_inferior_status (int restore_stack_info)
   inf_status->step_frame_id = tp->step_frame_id;
   inf_status->step_over_calls = tp->step_over_calls;
   inf_status->stop_after_trap = stop_after_trap;
-  inf_status->stop_soon = stop_soon;
+  inf_status->stop_soon = inf->stop_soon;
   /* Save original bpstat chain here; replace it with copy of chain.
      If caller's caller is walking the chain, they'll be happier if we
      hand them back the original chain when restore_inferior_status is
@@ -4430,6 +4448,7 @@ void
 restore_inferior_status (struct inferior_status *inf_status)
 {
   struct thread_info *tp = inferior_thread ();
+  struct inferior *inf = current_inferior ();
 
   tp->stop_signal = inf_status->stop_signal;
   stop_pc = inf_status->stop_pc;
@@ -4442,7 +4461,7 @@ restore_inferior_status (struct inferior_status *inf_status)
   tp->step_frame_id = inf_status->step_frame_id;
   tp->step_over_calls = inf_status->step_over_calls;
   stop_after_trap = inf_status->stop_after_trap;
-  stop_soon = inf_status->stop_soon;
+  inf->stop_soon = inf_status->stop_soon;
   bpstat_clear (&tp->stop_bpstat);
   tp->stop_bpstat = inf_status->stop_bpstat;
   breakpoint_proceeded = inf_status->breakpoint_proceeded;
index c1cb563d09a0c6bcbfa630f4c35e9dc8ed4e2b28..5ff4bceadd11ebd150be35924f00c98d597e10e8 100644 (file)
@@ -1708,9 +1708,17 @@ linux_nat_resume (ptid_t ptid, int step, enum target_signal signo)
 
   if (lp->status && WIFSTOPPED (lp->status))
     {
-      int saved_signo = target_signal_from_host (WSTOPSIG (lp->status));
+      int saved_signo;
+      struct inferior *inf;
 
-      if (signal_stop_state (saved_signo) == 0
+      inf = find_inferior_pid (ptid_get_pid (ptid));
+      gdb_assert (inf);
+      saved_signo = target_signal_from_host (WSTOPSIG (lp->status));
+
+      /* Defer to common code if we're gaining control of the
+        inferior.  */
+      if (inf->stop_soon == NO_STOP_QUIETLY
+         && signal_stop_state (saved_signo) == 0
          && signal_print_state (saved_signo) == 0
          && signal_pass_state (saved_signo) == 1)
        {
@@ -2926,10 +2934,17 @@ retry:
   if (WIFSTOPPED (status))
     {
       int signo = target_signal_from_host (WSTOPSIG (status));
+      struct inferior *inf;
+
+      inf = find_inferior_pid (ptid_get_pid (lp->ptid));
+      gdb_assert (inf);
 
-      /* If we get a signal while single-stepping, we may need special
-        care, e.g. to skip the signal handler.  Defer to common code.  */
+      /* Defer to common code if we get a signal while
+        single-stepping, since that may need special care, e.g. to
+        skip the signal handler, or, if we're gaining control of the
+        inferior.  */
       if (!lp->step
+         && inf->stop_soon == NO_STOP_QUIETLY
          && signal_stop_state (signo) == 0
          && signal_print_state (signo) == 0
          && signal_pass_state (signo) == 1)
index 1cc34489d3f5ff3b70aaebf63395c2cd3b2537e4..2556e0e80ec9eddc0fbb69dc05bfd0b52c440386 100644 (file)
@@ -2493,6 +2493,7 @@ heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
   CORE_ADDR fence;
   int instlen;
   int seen_adjsp = 0;
+  struct inferior *inf;
 
   pc = gdbarch_addr_bits_remove (gdbarch, pc);
   start_pc = pc;
@@ -2505,6 +2506,8 @@ heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
 
   instlen = mips_pc_is_mips16 (pc) ? MIPS_INSN16_SIZE : MIPS_INSN32_SIZE;
 
+  inf = current_inferior ();
+
   /* search back for previous return */
   for (start_pc -= instlen;; start_pc -= instlen)
     if (start_pc < fence)
@@ -2513,7 +2516,7 @@ heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
           stop_soon, but with this test, at least we
           don't print out warnings for every child forked (eg, on
           decstation).  22apr93 rich@cygnus.com.  */
-       if (stop_soon == NO_STOP_QUIETLY)
+       if (inf->stop_soon == NO_STOP_QUIETLY)
          {
            static int blurb_printed = 0;
 
index 9e569c590af8c9f7e0461bde27a080946adf4c3f..130eb9572a58f855e45c5dc9c015f5246d296fc1 100644 (file)
@@ -1101,7 +1101,6 @@ procfs_create_inferior (char *exec_file, char *allargs, char **env,
   if (exec_bfd != NULL
       || (symfile_objfile != NULL && symfile_objfile->obfd != NULL))
     solib_create_inferior_hook ();
-  stop_soon = 0;
 }
 
 static void
index 5b612ec6c62fe7b8366dd5a7330b1dbb7f6bced5..49bd200543b55abec803472fd9a3a429f82b51bb 100644 (file)
@@ -422,6 +422,7 @@ enable_break (void)
 static void
 irix_solib_create_inferior_hook (void)
 {
+  struct inferior *inf;
   struct thread_info *tp;
 
   if (!enable_break ())
@@ -435,10 +436,14 @@ irix_solib_create_inferior_hook (void)
      can go groveling around in the dynamic linker structures to find
      out what we need to know about them. */
 
+  inf = current_inferior ();
   tp = inferior_thread ();
+
   clear_proceed_status ();
-  stop_soon = STOP_QUIETLY;
+
+  inf->stop_soon = STOP_QUIETLY;
   tp->stop_signal = TARGET_SIGNAL_0;
+
   do
     {
       target_resume (pid_to_ptid (-1), 0, tp->stop_signal);
@@ -463,7 +468,7 @@ irix_solib_create_inferior_hook (void)
      Delaying the resetting of stop_soon until after symbol loading
      suppresses the warning.  */
   solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add);
-  stop_soon = NO_STOP_QUIETLY;
+  inf->stop_soon = NO_STOP_QUIETLY;
 }
 
 /* LOCAL FUNCTION
index b83a8ec8ea4132f0ab4fa457ca07fc0ee8a65c50..031d59882af5907d702c496b7258fac18c4ff820 100644 (file)
@@ -307,6 +307,7 @@ osf_clear_solib (void)
 static void
 osf_solib_create_inferior_hook (void)
 {
+  struct inferior *inf;
   struct thread_info *tp;
 
   /* If we are attaching to the inferior, the shared libraries
@@ -333,9 +334,10 @@ osf_solib_create_inferior_hook (void)
   if (!target_can_run (&current_target))
     return;
 
+  inf = current_inferior ();
   tp = inferior_thread ();
   clear_proceed_status ();
-  stop_soon = STOP_QUIETLY;
+  inf->stop_soon = STOP_QUIETLY;
   tp->stop_signal = TARGET_SIGNAL_0;
   do
     {
@@ -351,7 +353,7 @@ osf_solib_create_inferior_hook (void)
      Delaying the resetting of stop_soon until after symbol loading
      suppresses the warning.  */
   solib_add ((char *) 0, 0, (struct target_ops *) 0, auto_solib_add);
-  stop_soon = NO_STOP_QUIETLY;
+  inf->stop_soon = NO_STOP_QUIETLY;
 }
 
 /* target_so_ops callback.  Do additional symbol handling, lookup, etc. after
index c83b0577eed53b2da6adab4bbbc9ef5811e50a4c..e18d9a5c7483acebe9e5bba79f84eb289e53164a 100644 (file)
@@ -739,6 +739,7 @@ static void
 sunos_solib_create_inferior_hook (void)
 {
   struct thread_info *tp;
+  struct inferior *inf;
 
   if ((debug_base = locate_base ()) == 0)
     {
@@ -761,9 +762,12 @@ sunos_solib_create_inferior_hook (void)
      can go groveling around in the dynamic linker structures to find
      out what we need to know about them. */
 
+  inf = current_inferior ();
   tp = inferior_thread ();
+
   clear_proceed_status ();
-  stop_soon = STOP_QUIETLY;
+
+  inf->stop_soon = STOP_QUIETLY;
   tp->stop_signal = TARGET_SIGNAL_0;
   do
     {
@@ -771,7 +775,7 @@ sunos_solib_create_inferior_hook (void)
       wait_for_inferior (0);
     }
   while (tp->stop_signal != TARGET_SIGNAL_TRAP);
-  stop_soon = NO_STOP_QUIETLY;
+  inf->stop_soon = NO_STOP_QUIETLY;
 
   /* We are now either at the "mapping complete" breakpoint (or somewhere
      else, a condition we aren't prepared to deal with anyway), so adjust
index 3ba22acf91c6498ffa00082cafa16b4496ddd874..250f87d8db0a4b13206a34f4bfe9c2df9f31d3bf 100644 (file)
@@ -1570,6 +1570,7 @@ svr4_relocate_main_executable (void)
 static void
 svr4_solib_create_inferior_hook (void)
 {
+  struct inferior *inf;
   struct thread_info *tp;
 
   /* Relocate the main executable if necessary.  */
@@ -1591,10 +1592,11 @@ svr4_solib_create_inferior_hook (void)
      can go groveling around in the dynamic linker structures to find
      out what we need to know about them. */
 
+  inf = current_inferior ();
   tp = inferior_thread ();
 
   clear_proceed_status ();
-  stop_soon = STOP_QUIETLY;
+  inf->stop_soon = STOP_QUIETLY;
   tp->stop_signal = TARGET_SIGNAL_0;
   do
     {
@@ -1602,7 +1604,7 @@ svr4_solib_create_inferior_hook (void)
       wait_for_inferior (0);
     }
   while (tp->stop_signal != TARGET_SIGNAL_TRAP);
-  stop_soon = NO_STOP_QUIETLY;
+  inf->stop_soon = NO_STOP_QUIETLY;
 #endif /* defined(_SCO_DS) */
 }
 
index becd3ca8e2b7542bfbe54523089346176707bea3..8365cba0630f63f77fa3cc3a17b5d98519c1abd1 100644 (file)
@@ -1523,6 +1523,7 @@ do_initial_win32_stuff (DWORD pid)
 {
   extern int stop_after_trap;
   int i;
+  struct inferior *inf;
   struct thread_info *tp;
 
   last_sig = TARGET_SIGNAL_0;
@@ -1544,12 +1545,12 @@ do_initial_win32_stuff (DWORD pid)
   clear_proceed_status ();
   init_wait_for_inferior ();
 
-  add_inferior (pid);
+  inf = add_inferior (pid);
 
   terminal_init_inferior_with_pgrp (pid);
   target_terminal_inferior ();
 
-  stop_soon = STOP_QUIETLY;
+  inf->stop_soon = STOP_QUIETLY;
   while (1)
     {
       stop_after_trap = 1;
@@ -1561,7 +1562,7 @@ do_initial_win32_stuff (DWORD pid)
        break;
     }
 
-  stop_soon = NO_STOP_QUIETLY;
+  inf->stop_soon = NO_STOP_QUIETLY;
   stop_after_trap = 0;
   return;
 }
index becd3ca8e2b7542bfbe54523089346176707bea3..8365cba0630f63f77fa3cc3a17b5d98519c1abd1 100644 (file)
@@ -1523,6 +1523,7 @@ do_initial_win32_stuff (DWORD pid)
 {
   extern int stop_after_trap;
   int i;
+  struct inferior *inf;
   struct thread_info *tp;
 
   last_sig = TARGET_SIGNAL_0;
@@ -1544,12 +1545,12 @@ do_initial_win32_stuff (DWORD pid)
   clear_proceed_status ();
   init_wait_for_inferior ();
 
-  add_inferior (pid);
+  inf = add_inferior (pid);
 
   terminal_init_inferior_with_pgrp (pid);
   target_terminal_inferior ();
 
-  stop_soon = STOP_QUIETLY;
+  inf->stop_soon = STOP_QUIETLY;
   while (1)
     {
       stop_after_trap = 1;
@@ -1561,7 +1562,7 @@ do_initial_win32_stuff (DWORD pid)
        break;
     }
 
-  stop_soon = NO_STOP_QUIETLY;
+  inf->stop_soon = NO_STOP_QUIETLY;
   stop_after_trap = 0;
   return;
 }