2011-05-23 Pedro Alves <pedro@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / infrun.c
index 4c5ea9b7aefd9aefcaf99c0167a8717b918dd068..1d8932ab21a6160fd26a0ff2b9024ca3d410089e 100644 (file)
@@ -99,6 +99,16 @@ void _initialize_infrun (void);
 
 void nullify_last_target_wait_ptid (void);
 
+static void insert_step_resume_breakpoint_at_frame (struct frame_info *);
+
+static void insert_step_resume_breakpoint_at_caller (struct frame_info *);
+
+static void insert_step_resume_breakpoint_at_sal (struct gdbarch *,
+                                                 struct symtab_and_line ,
+                                                 struct frame_id);
+
+static void insert_longjmp_resume_breakpoint (struct gdbarch *, CORE_ADDR);
+
 /* When set, stop the 'step' command if we enter a function which has
    no line number information.  The normal behavior is that we step
    over such function.  */
@@ -110,7 +120,7 @@ show_step_stop_if_no_debug (struct ui_file *file, int from_tty,
   fprintf_filtered (file, _("Mode of the step operation is %s.\n"), value);
 }
 
-/* In asynchronous mode, but simulating synchronous execution. */
+/* In asynchronous mode, but simulating synchronous execution.  */
 
 int sync_execution = 0;
 
@@ -276,6 +286,11 @@ static unsigned char *signal_stop;
 static unsigned char *signal_print;
 static unsigned char *signal_program;
 
+/* Table of signals that the target may silently handle.
+   This is automatically determined from the flags above,
+   and simply cached here.  */
+static unsigned char *signal_pass;
+
 #define SET_SIGS(nsigs,sigs,flags) \
   do { \
     int signum = (nsigs); \
@@ -292,7 +307,7 @@ static unsigned char *signal_program;
        (flags)[signum] = 0; \
   } while (0)
 
-/* Value to pass to target_resume() to cause all threads to resume */
+/* Value to pass to target_resume() to cause all threads to resume */
 
 #define RESUME_ALL minus_one_ptid
 
@@ -357,8 +372,9 @@ static void
 show_follow_fork_mode_string (struct ui_file *file, int from_tty,
                              struct cmd_list_element *c, const char *value)
 {
-  fprintf_filtered (file, _("\
-Debugger response to a program call of fork or vfork is \"%s\".\n"),
+  fprintf_filtered (file,
+                   _("Debugger response to a program "
+                     "call of fork or vfork is \"%s\".\n"),
                    value);
 }
 \f
@@ -472,7 +488,7 @@ follow_fork (void)
               over from WAIT_PID" logic above.  */
            nullify_last_target_wait_ptid ();
 
-           /* If we followed the child, switch to it... */
+           /* If we followed the child, switch to it...  */
            if (follow_child)
              {
                switch_to_thread (child);
@@ -498,8 +514,8 @@ follow_fork (void)
                       forked.  In that case, the resume command
                       issued is most likely not applicable to the
                       child, so just warn, and refuse to resume.  */
-                   warning (_("\
-Not resuming: switched threads before following fork child.\n"));
+                   warning (_("Not resuming: switched threads "
+                              "before following fork child.\n"));
                  }
 
                /* Reset breakpoints in the child as appropriate.  */
@@ -605,7 +621,7 @@ handle_vfork_child_exec_or_exit (int exec)
          struct program_space *pspace;
          struct address_space *aspace;
 
-         /* follow-fork child, detach-on-fork on */
+         /* follow-fork child, detach-on-fork on */
 
          old_chain = make_cleanup_restore_current_thread ();
 
@@ -636,11 +652,13 @@ handle_vfork_child_exec_or_exit (int exec)
 
              if (exec)
                fprintf_filtered (gdb_stdlog,
-                                 "Detaching vfork parent process %d after child exec.\n",
+                                 "Detaching vfork parent process "
+                                 "%d after child exec.\n",
                                  inf->vfork_parent->pid);
              else
                fprintf_filtered (gdb_stdlog,
-                                 "Detaching vfork parent process %d after child exit.\n",
+                                 "Detaching vfork parent process "
+                                 "%d after child exit.\n",
                                  inf->vfork_parent->pid);
            }
 
@@ -698,7 +716,7 @@ handle_vfork_child_exec_or_exit (int exec)
          inf->aspace = pspace->aspace;
 
          /* Put back inferior_ptid.  We'll continue mourning this
-            inferior. */
+            inferior.  */
          do_cleanups (old_chain);
 
          resume_parent = inf->vfork_parent->pid;
@@ -717,7 +735,8 @@ handle_vfork_child_exec_or_exit (int exec)
          struct cleanup *old_chain = make_cleanup_restore_current_thread ();
 
          if (debug_infrun)
-           fprintf_unfiltered (gdb_stdlog, "infrun: resuming vfork parent process %d\n",
+           fprintf_unfiltered (gdb_stdlog,
+                               "infrun: resuming vfork parent process %d\n",
                                resume_parent);
 
          iterate_over_threads (proceed_after_vfork_done, &resume_parent);
@@ -746,7 +765,7 @@ show_follow_exec_mode_string (struct ui_file *file, int from_tty,
   fprintf_filtered (file, _("Follow exec mode is \"%s\".\n"),  value);
 }
 
-/* EXECD_PATHNAME is assumed to be non-NULL. */
+/* EXECD_PATHNAME is assumed to be non-NULL.  */
 
 static void
 follow_exec (ptid_t pid, char *execd_pathname)
@@ -773,14 +792,14 @@ follow_exec (ptid_t pid, char *execd_pathname)
      And, we DON'T want to call delete_breakpoints() here, since
      that may write the bp's "shadow contents" (the instruction
      value that was overwritten witha TRAP instruction).  Since
-     we now have a new a.out, those shadow contents aren't valid. */
+     we now have a new a.out, those shadow contents aren't valid.  */
 
   mark_breakpoints_out ();
 
   update_breakpoints_after_exec ();
 
   /* If there was one, it's gone now.  We cannot truly step-to-next
-     statement through an exec(). */
+     statement through an exec().  */
   th->control.step_resume_breakpoint = NULL;
   th->control.exception_resume_breakpoint = NULL;
   th->control.step_range_start = 0;
@@ -794,13 +813,13 @@ follow_exec (ptid_t pid, char *execd_pathname)
      with scheduler-locking on in all-stop mode.  */
   th->stop_requested = 0;
 
-  /* What is this a.out's name? */
+  /* What is this a.out's name?  */
   printf_unfiltered (_("%s is executing new program: %s\n"),
                     target_pid_to_str (inferior_ptid),
                     execd_pathname);
 
   /* We've followed the inferior through an exec.  Therefore, the
-     inferior has essentially been killed & reborn. */
+     inferior has essentially been killed & reborn.  */
 
   gdb_flush (gdb_stdout);
 
@@ -845,7 +864,7 @@ follow_exec (ptid_t pid, char *execd_pathname)
 
   gdb_assert (current_program_space == inf->pspace);
 
-  /* That a.out is now the one to use. */
+  /* That a.out is now the one to use.  */
   exec_file_attach (execd_pathname, 0);
 
   /* SYMFILE_DEFER_BP_RESET is used as the proper displacement for PIE
@@ -870,13 +889,13 @@ follow_exec (ptid_t pid, char *execd_pathname)
 
   /* Reinsert all breakpoints.  (Those which were symbolic have
      been reset to the proper address in the new a.out, thanks
-     to symbol_file_command...) */
+     to symbol_file_command...) */
   insert_breakpoints ();
 
   /* The next resume of this inferior should bring it to the shlib
      startup breakpoints.  (If the user had also set bp's on
      "main" from the old (parent) process, then they'll auto-
-     matically get reset there in the new process.) */
+     matically get reset there in the new process.) */
 }
 
 /* Non-zero if we just simulating a single-step.  This is needed
@@ -899,7 +918,7 @@ static int stepping_past_singlestep_breakpoint;
    is finished, we need to switch to deferred_step_ptid, and step it.
 
    The use case is when one thread has hit a breakpoint, and then the user 
-   has switched to another thread and issued 'step'. We need to step over
+   has switched to another thread and issued 'step'.  We need to step over
    breakpoint in the thread which hit the breakpoint, but then continue
    stepping the thread user has selected.  */
 static ptid_t deferred_step_ptid;
@@ -1074,6 +1093,24 @@ add_displaced_stepping_state (int pid)
   return state;
 }
 
+/* If inferior is in displaced stepping, and ADDR equals to starting address
+   of copy area, return corresponding displaced_step_closure.  Otherwise,
+   return NULL.  */
+
+struct displaced_step_closure*
+get_displaced_step_closure_by_addr (CORE_ADDR addr)
+{
+  struct displaced_step_inferior_state *displaced
+    = get_displaced_stepping_state (ptid_get_pid (inferior_ptid));
+
+  /* If checking the mode of displaced instruction in copy area.  */
+  if (displaced && !ptid_equal (displaced->step_ptid, null_ptid)
+     && (displaced->step_copy == addr))
+    return displaced->step_closure;
+
+  return NULL;
+}
+
 /* Remove the displaced stepping state of process PID.  */
 
 static void
@@ -1135,14 +1172,14 @@ show_can_use_displaced_stepping (struct ui_file *file, int from_tty,
                                 const char *value)
 {
   if (can_use_displaced_stepping == can_use_displaced_stepping_auto)
-    fprintf_filtered (file, _("\
-Debugger's willingness to use displaced stepping to step over \
-breakpoints is %s (currently %s).\n"),
+    fprintf_filtered (file,
+                     _("Debugger's willingness to use displaced stepping "
+                       "to step over breakpoints is %s (currently %s).\n"),
                      value, non_stop ? "on" : "off");
   else
-    fprintf_filtered (file, _("\
-Debugger's willingness to use displaced stepping to step over \
-breakpoints is %s.\n"), value);
+    fprintf_filtered (file,
+                     _("Debugger's willingness to use displaced stepping "
+                       "to step over breakpoints is %s.\n"), value);
 }
 
 /* Return non-zero if displaced stepping can/should be used to step
@@ -1319,7 +1356,8 @@ displaced_step_prepare (ptid_t ptid)
 }
 
 static void
-write_memory_ptid (ptid_t ptid, CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
+write_memory_ptid (ptid_t ptid, CORE_ADDR memaddr,
+                  const gdb_byte *myaddr, int len)
 {
   struct cleanup *ptid_cleanup = save_inferior_ptid ();
 
@@ -1450,7 +1488,8 @@ displaced_step_fixup (ptid_t event_ptid, enum target_signal signal)
          step = currently_stepping (tp);
 
          if (debug_displaced)
-           fprintf_unfiltered (gdb_stdlog, "breakpoint is gone %s: step(%d)\n",
+           fprintf_unfiltered (gdb_stdlog,
+                               "breakpoint is gone %s: step(%d)\n",
                                target_pid_to_str (tp->ptid), step);
 
          target_resume (ptid, step, TARGET_SIGNAL_0);
@@ -1516,8 +1555,9 @@ static void
 show_scheduler_mode (struct ui_file *file, int from_tty,
                     struct cmd_list_element *c, const char *value)
 {
-  fprintf_filtered (file, _("\
-Mode for locking scheduler during execution is \"%s\".\n"),
+  fprintf_filtered (file,
+                   _("Mode for locking scheduler "
+                     "during execution is \"%s\".\n"),
                    value);
 }
 
@@ -1553,7 +1593,7 @@ maybe_software_singlestep (struct gdbarch *gdbarch, CORE_ADDR pc)
     {
       hw_step = 0;
       /* Do not pull these breakpoints until after a `wait' in
-        `wait_for_inferior' */
+        `wait_for_inferior' */
       singlestep_breakpoints_inserted_p = 1;
       singlestep_ptid = inferior_ptid;
       singlestep_pc = pc;
@@ -1561,6 +1601,45 @@ maybe_software_singlestep (struct gdbarch *gdbarch, CORE_ADDR pc)
   return hw_step;
 }
 
+/* Return a ptid representing the set of threads that we will proceed,
+   in the perspective of the user/frontend.  We may actually resume
+   fewer threads at first, e.g., if a thread is stopped at a
+   breakpoint that needs stepping-off, but that should not be visible
+   to the user/frontend, and neither should the frontend/user be
+   allowed to proceed any of the threads that happen to be stopped for
+   internal run control handling, if a previous command wanted them
+   resumed.  */
+
+ptid_t
+user_visible_resume_ptid (int step)
+{
+  /* By default, resume all threads of all processes.  */
+  ptid_t resume_ptid = RESUME_ALL;
+
+  /* Maybe resume only all threads of the current process.  */
+  if (!sched_multi && target_supports_multi_process ())
+    {
+      resume_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
+    }
+
+  /* Maybe resume a single thread after all.  */
+  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;
+    }
+
+  return resume_ptid;
+}
+
 /* Resume the inferior, but allow a QUIT.  This is useful if the user
    wants to interrupt some lengthy single-stepping operation
    (for child processes, the SIGINT goes to the inferior, and so
@@ -1604,8 +1683,10 @@ resume (int step, enum target_signal sig)
   if (debug_infrun)
     fprintf_unfiltered (gdb_stdlog,
                         "infrun: resume (step=%d, signal=%d), "
-                       "trap_expected=%d\n",
-                       step, sig, tp->control.trap_expected);
+                       "trap_expected=%d, current thread [%s] at %s\n",
+                       step, sig, tp->control.trap_expected,
+                       target_pid_to_str (inferior_ptid),
+                       paddress (gdbarch, pc));
 
   /* Normally, by the time we reach `resume', the breakpoints are either
      removed or inserted, as appropriate.  The exception is if we're sitting
@@ -1663,6 +1744,51 @@ a command like `return' or `jump' to continue execution."));
   else if (step)
     step = maybe_software_singlestep (gdbarch, pc);
 
+  /* Currently, our software single-step implementation leads to different
+     results than hardware single-stepping in one situation: when stepping
+     into delivering a signal which has an associated signal handler,
+     hardware single-step will stop at the first instruction of the handler,
+     while software single-step will simply skip execution of the handler.
+
+     For now, this difference in behavior is accepted since there is no
+     easy way to actually implement single-stepping into a signal handler
+     without kernel support.
+
+     However, there is one scenario where this difference leads to follow-on
+     problems: if we're stepping off a breakpoint by removing all breakpoints
+     and then single-stepping.  In this case, the software single-step
+     behavior means that even if there is a *breakpoint* in the signal
+     handler, GDB still would not stop.
+
+     Fortunately, we can at least fix this particular issue.  We detect
+     here the case where we are about to deliver a signal while software
+     single-stepping with breakpoints removed.  In this situation, we
+     revert the decisions to remove all breakpoints and insert single-
+     step breakpoints, and instead we install a step-resume breakpoint
+     at the current address, deliver the signal without stepping, and
+     once we arrive back at the step-resume breakpoint, actually step
+     over the breakpoint we originally wanted to step over.  */
+  if (singlestep_breakpoints_inserted_p
+      && tp->control.trap_expected && sig != TARGET_SIGNAL_0)
+    {
+      /* If we have nested signals or a pending signal is delivered
+        immediately after a handler returns, might might already have
+        a step-resume breakpoint set on the earlier handler.  We cannot
+        set another step-resume breakpoint; just continue on until the
+        original breakpoint is hit.  */
+      if (tp->control.step_resume_breakpoint == NULL)
+       {
+         insert_step_resume_breakpoint_at_frame (get_current_frame ());
+         tp->step_after_step_resume_breakpoint = 1;
+       }
+
+      remove_single_step_breakpoints ();
+      singlestep_breakpoints_inserted_p = 0;
+
+      insert_breakpoints ();
+      tp->control.trap_expected = 0;
+    }
+
   if (should_resume)
     {
       ptid_t resume_ptid;
@@ -1675,15 +1801,7 @@ a command like `return' or `jump' to continue execution."));
       /* Decide the set of threads to ask the target to resume.  Start
         by assuming everything will be resumed, than narrow the set
         by applying increasingly restricting conditions.  */
-
-      /* By default, resume all threads of all processes.  */
-      resume_ptid = RESUME_ALL;
-
-      /* Maybe resume only all threads of the current process.  */
-      if (!sched_multi && target_supports_multi_process ())
-       {
-         resume_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
-       }
+      resume_ptid = user_visible_resume_ptid (step);
 
       /* Maybe resume a single thread after all.  */
       if (singlestep_breakpoints_inserted_p
@@ -1717,19 +1835,6 @@ a command like `return' or `jump' to continue execution."));
             breakpoint, not just the one at PC.  */
          resume_ptid = inferior_ptid;
        }
-      else 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;
-       }
 
       if (gdbarch_cannot_step_breakpoint (gdbarch))
        {
@@ -1762,6 +1867,18 @@ a command like `return' or `jump' to continue execution."));
         happens to apply to another thread.  */
       tp->suspend.stop_signal = TARGET_SIGNAL_0;
 
+      /* Advise target which signals may be handled silently.  If we have
+        removed breakpoints because we are stepping over one (which can
+        happen only if we are not using displaced stepping), we need to
+        receive all signals to avoid accidentally skipping a breakpoint
+        during execution of a signal handler.  */
+      if ((step || singlestep_breakpoints_inserted_p)
+         && tp->control.trap_expected
+         && !use_displaced_stepping (gdbarch))
+       target_pass_signals (0, NULL);
+      else
+       target_pass_signals ((int) TARGET_SIGNAL_LAST, signal_pass);
+
       target_resume (resume_ptid, step, sig);
     }
 
@@ -1849,7 +1966,7 @@ clear_proceed_status (void)
    event.  If a step-over is required return TRUE and set the current thread
    to the old thread.  Otherwise return FALSE.
 
-   This should be suitable for any targets that support threads. */
+   This should be suitable for any targets that support threads.  */
 
 static int
 prepare_to_proceed (int step)
@@ -1904,9 +2021,15 @@ prepare_to_proceed (int step)
          /* Switch back to WAIT_PID thread.  */
          switch_to_thread (wait_ptid);
 
+         if (debug_infrun)
+           fprintf_unfiltered (gdb_stdlog,
+                               "infrun: prepare_to_proceed (step=%d), "
+                               "switched to [%s]\n",
+                               step, target_pid_to_str (inferior_ptid));
+
          /* We return 1 to indicate that there is a breakpoint here,
             so we need to step over it before continuing to avoid
-            hitting it straight away. */
+            hitting it straight away.  */
          return 1;
        }
     }
@@ -1943,9 +2066,14 @@ proceed (CORE_ADDR addr, enum target_signal siggnal, int step)
     {
       /* The target for some reason decided not to resume.  */
       normal_stop ();
+      if (target_can_async_p ())
+       inferior_event_handler (INF_EXEC_COMPLETE, NULL);
       return;
     }
 
+  /* We'll update this if & when we switch to a new thread.  */
+  previous_inferior_ptid = inferior_ptid;
+
   regcache = get_current_regcache ();
   gdbarch = get_regcache_arch (regcache);
   aspace = get_regcache_aspace (regcache);
@@ -1987,16 +2115,6 @@ proceed (CORE_ADDR addr, enum target_signal siggnal, int step)
                        "infrun: proceed (addr=%s, signal=%d, step=%d)\n",
                        paddress (gdbarch, addr), siggnal, step);
 
-  /* We're handling a live event, so make sure we're doing live
-     debugging.  If we're looking at traceframes while the target is
-     running, we're going to need to get back to that mode after
-     handling the event.  */
-  if (non_stop)
-    {
-      make_cleanup_restore_current_traceframe ();
-      set_traceframe_number (-1);
-    }
-
   if (non_stop)
     /* In non-stop, each thread is handled individually.  The context
        must already be set to the right thread here.  */
@@ -2014,7 +2132,7 @@ proceed (CORE_ADDR addr, enum target_signal siggnal, int step)
         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. */
+        the old thread.  */
       if (prepare_to_proceed (step))
        oneproc = 1;
     }
@@ -2115,10 +2233,10 @@ proceed (CORE_ADDR addr, enum target_signal siggnal, int step)
   /* Wait for it to stop (if not standalone)
      and in any case decode why it stopped, and act accordingly.  */
   /* Do this only if we are not using the event loop, or if the target
-     does not support asynchronous execution. */
+     does not support asynchronous execution.  */
   if (!target_can_async_p ())
     {
-      wait_for_inferior (0);
+      wait_for_inferior ();
       normal_stop ();
     }
 }
@@ -2135,21 +2253,21 @@ start_remote (int from_tty)
   inferior = current_inferior ();
   inferior->control.stop_soon = STOP_QUIETLY_REMOTE;
 
-  /* Always go on waiting for the target, regardless of the mode. */
+  /* Always go on waiting for the target, regardless of the mode.  */
   /* FIXME: cagney/1999-09-23: At present it isn't possible to
      indicate to wait_for_inferior that a target should timeout if
      nothing is returned (instead of just blocking).  Because of this,
      targets expecting an immediate response need to, internally, set
      things up so that the target_wait() is forced to eventually
-     timeout. */
+     timeout.  */
   /* FIXME: cagney/1999-09-24: It isn't possible for target_open() to
      differentiate to its caller what the state of the target is after
      the initial open has been performed.  Here we're assuming that
      the target has stopped.  It should be possible to eventually have
      target_open() return to the caller an indication that the target
      is currently running and GDB state should be set to the same as
-     for an async run. */
-  wait_for_inferior (0);
+     for an async run.  */
+  wait_for_inferior ();
 
   /* Now that the inferior has stopped, do any bookkeeping like
      loading shared libraries.  We want to do this before normal_stop,
@@ -2175,7 +2293,7 @@ init_wait_for_inferior (void)
 
   target_last_wait_ptid = minus_one_ptid;
 
-  previous_inferior_ptid = null_ptid;
+  previous_inferior_ptid = inferior_ptid;
   init_infwait_state ();
 
   /* Discard any skipped inlined frames.  */
@@ -2225,12 +2343,6 @@ static void handle_step_into_function (struct gdbarch *gdbarch,
                                       struct execution_control_state *ecs);
 static void handle_step_into_function_backward (struct gdbarch *gdbarch,
                                                struct execution_control_state *ecs);
-static void insert_step_resume_breakpoint_at_frame (struct frame_info *step_frame);
-static void insert_step_resume_breakpoint_at_caller (struct frame_info *);
-static void insert_step_resume_breakpoint_at_sal (struct gdbarch *gdbarch,
-                                                 struct symtab_and_line sr_sal,
-                                                 struct frame_id sr_id);
-static void insert_longjmp_resume_breakpoint (struct gdbarch *, CORE_ADDR);
 static void check_exception_resume (struct execution_control_state *,
                                    struct frame_info *, struct symbol *);
 
@@ -2387,7 +2499,7 @@ delete_step_thread_step_resume_breakpoint (void)
     iterate_over_threads (delete_step_resume_breakpoint_callback, NULL);
 }
 
-/* A cleanup wrapper. */
+/* A cleanup wrapper.  */
 
 static void
 delete_step_thread_step_resume_breakpoint_cleanup (void *arg)
@@ -2476,7 +2588,7 @@ prepare_for_detach (void)
         target_wait because they can be loaded from the target while
         in target_wait.  This makes remote debugging a bit more
         efficient for those targets that provide critical registers
-        as part of their normal status mechanism. */
+        as part of their normal status mechanism.  */
 
       registers_changed ();
 
@@ -2491,7 +2603,8 @@ prepare_for_detach (void)
       /* If an error happens while handling the event, propagate GDB's
         knowledge of the executing state to the frontend/user running
         state.  */
-      old_chain_2 = make_cleanup (finish_thread_state_cleanup, &minus_one_ptid);
+      old_chain_2 = make_cleanup (finish_thread_state_cleanup,
+                                 &minus_one_ptid);
 
       /* In non-stop mode, each thread is handled individually.
         Switch early, so the global state is set correctly for this
@@ -2522,18 +2635,13 @@ prepare_for_detach (void)
 
 /* Wait for control to return from inferior to debugger.
 
-   If TREAT_EXEC_AS_SIGTRAP is non-zero, then handle EXEC signals
-   as if they were SIGTRAP signals.  This can be useful during
-   the startup sequence on some targets such as HP/UX, where
-   we receive an EXEC event instead of the expected SIGTRAP.
-
    If inferior gets a signal, we may decide to start it up again
    instead of returning.  That is why there is a loop in this function.
    When this function actually returns it means the inferior
    should be left stopped and GDB should read more commands.  */
 
 void
-wait_for_inferior (int treat_exec_as_sigtrap)
+wait_for_inferior (void)
 {
   struct cleanup *old_cleanups;
   struct execution_control_state ecss;
@@ -2541,8 +2649,7 @@ wait_for_inferior (int treat_exec_as_sigtrap)
 
   if (debug_infrun)
     fprintf_unfiltered
-      (gdb_stdlog, "infrun: wait_for_inferior (treat_exec_as_sigtrap=%d)\n",
-       treat_exec_as_sigtrap);
+      (gdb_stdlog, "infrun: wait_for_inferior ()\n");
 
   old_cleanups =
     make_cleanup (delete_step_thread_step_resume_breakpoint_cleanup, NULL);
@@ -2550,9 +2657,6 @@ wait_for_inferior (int treat_exec_as_sigtrap)
   ecs = &ecss;
   memset (ecs, 0, sizeof (*ecs));
 
-  /* We'll update this if & when we switch to a new thread.  */
-  previous_inferior_ptid = inferior_ptid;
-
   while (1)
     {
       struct cleanup *old_chain;
@@ -2561,7 +2665,7 @@ wait_for_inferior (int treat_exec_as_sigtrap)
         because they can be loaded from the target while in target_wait.
         This makes remote debugging a bit more efficient for those
         targets that provide critical registers as part of their normal
-        status mechanism. */
+        status mechanism.  */
 
       overlay_cache_invalid = 1;
       registers_changed ();
@@ -2574,13 +2678,6 @@ wait_for_inferior (int treat_exec_as_sigtrap)
       if (debug_infrun)
        print_target_wait_results (waiton_ptid, ecs->ptid, &ecs->ws);
 
-      if (treat_exec_as_sigtrap && ecs->ws.kind == TARGET_WAITKIND_EXECD)
-        {
-          xfree (ecs->ws.value.execd_pathname);
-          ecs->ws.kind = TARGET_WAITKIND_STOPPED;
-          ecs->ws.value.sig = TARGET_SIGNAL_TRAP;
-        }
-
       /* If an error happens while handling the event, propagate GDB's
         knowledge of the executing state to the frontend/user running
         state.  */
@@ -2603,14 +2700,14 @@ wait_for_inferior (int treat_exec_as_sigtrap)
   do_cleanups (old_cleanups);
 }
 
-/* Asynchronous version of wait_for_inferior. It is called by the
+/* Asynchronous version of wait_for_inferior.  It is called by the
    event loop whenever a change of state is detected on the file
-   descriptor corresponding to the target. It can be called more than
-   once to complete a single execution command. In such cases we need
-   to keep the state in a global variable ECSS. If it is the last time
+   descriptor corresponding to the target.  It can be called more than
+   once to complete a single execution command.  In such cases we need
+   to keep the state in a global variable ECSS.  If it is the last time
    that this function is called for a single execution command, then
    report to the user that the inferior has stopped, and do the
-   necessary cleanups. */
+   necessary cleanups.  */
 
 void
 fetch_inferior_event (void *client_data)
@@ -2623,8 +2720,15 @@ fetch_inferior_event (void *client_data)
 
   memset (ecs, 0, sizeof (*ecs));
 
-  /* We'll update this if & when we switch to a new thread.  */
-  previous_inferior_ptid = inferior_ptid;
+  /* We're handling a live event, so make sure we're doing live
+     debugging.  If we're looking at traceframes while the target is
+     running, we're going to need to get back to that mode after
+     handling the event.  */
+  if (non_stop)
+    {
+      make_cleanup_restore_current_traceframe ();
+      set_current_traceframe (-1);
+    }
 
   if (non_stop)
     /* In non-stop mode, the user/frontend should not notice a thread
@@ -2637,7 +2741,7 @@ fetch_inferior_event (void *client_data)
      because they can be loaded from the target while in target_wait.
      This makes remote debugging a bit more efficient for those
      targets that provide critical registers as part of their normal
-     status mechanism. */
+     status mechanism.  */
 
   overlay_cache_invalid = 1;
   registers_changed ();
@@ -2894,8 +2998,8 @@ init_infwait_state (void)
 void
 error_is_running (void)
 {
-  error (_("\
-Cannot execute this command while the selected thread is running."));
+  error (_("Cannot execute this command while "
+          "the selected thread is running."));
 }
 
 void
@@ -3013,14 +3117,14 @@ handle_inferior_event (struct execution_control_state *ecs)
   else
     stop_soon = NO_STOP_QUIETLY;
 
-  /* Cache the last pid/waitstatus. */
+  /* Cache the last pid/waitstatus.  */
   target_last_wait_ptid = ecs->ptid;
   target_last_waitstatus = ecs->ws;
 
   /* Always clear state belonging to the previous time we stopped.  */
   stop_stack_dummy = STOP_NONE;
 
-  /* If it's a new process, add it to the thread database */
+  /* If it's a new process, add it to the thread database */
 
   ecs->new_thread_event = (!ptid_equal (ecs->ptid, inferior_ptid)
                           && !ptid_equal (ecs->ptid, minus_one_ptid)
@@ -3199,7 +3303,7 @@ handle_inferior_event (struct execution_control_state *ecs)
       set_current_inferior (find_inferior_pid (ptid_get_pid (ecs->ptid)));
       set_current_program_space (current_inferior ()->pspace);
       handle_vfork_child_exec_or_exit (0);
-      target_terminal_ours (); /* Must do this before mourn anyway */
+      target_terminal_ours (); /* Must do this before mourn anyway */
       print_exited_reason (ecs->ws.value.integer);
 
       /* Record the exit code in the convenience variable $_exitcode, so
@@ -3222,13 +3326,13 @@ handle_inferior_event (struct execution_control_state *ecs)
       set_current_program_space (current_inferior ()->pspace);
       handle_vfork_child_exec_or_exit (0);
       stop_print_frame = 0;
-      target_terminal_ours (); /* Must do this before mourn anyway */
+      target_terminal_ours (); /* Must do this before mourn anyway */
 
       /* Note: By definition of TARGET_WAITKIND_SIGNALLED, we shouldn't
          reach here unless the inferior is dead.  However, for years
          target_kill() was called here, which hints that fatal signals aren't
          really fatal on some systems.  If that's true, then some changes
-         may be needed. */
+         may be needed.  */
       target_mourn_inferior ();
 
       print_signal_exited_reason (ecs->ws.value.sig);
@@ -3238,7 +3342,7 @@ handle_inferior_event (struct execution_control_state *ecs)
       return;
 
       /* The following are the only cases in which we keep going;
-         the above cases end in a continue or goto. */
+         the above cases end in a continue or goto.  */
     case TARGET_WAITKIND_FORKED:
     case TARGET_WAITKIND_VFORKED:
       if (debug_infrun)
@@ -3273,7 +3377,7 @@ handle_inferior_event (struct execution_control_state *ecs)
 
       if (singlestep_breakpoints_inserted_p)
        {
-         /* Pull the single step breakpoints out of the target. */
+         /* Pull the single step breakpoints out of the target.  */
          remove_single_step_breakpoints ();
          singlestep_breakpoints_inserted_p = 0;
        }
@@ -3302,7 +3406,8 @@ handle_inferior_event (struct execution_control_state *ecs)
          ptid_t parent;
          ptid_t child;
          int should_resume;
-         int follow_child = (follow_fork_mode_string == follow_fork_mode_child);
+         int follow_child
+           = (follow_fork_mode_string == follow_fork_mode_child);
 
          ecs->event_thread->suspend.stop_signal = TARGET_SIGNAL_0;
 
@@ -3346,7 +3451,8 @@ handle_inferior_event (struct execution_control_state *ecs)
         the parent, and keep going.  */
 
       if (debug_infrun)
-       fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_VFORK_DONE\n");
+       fprintf_unfiltered (gdb_stdlog,
+                           "infrun: TARGET_WAITKIND_VFORK_DONE\n");
 
       if (!ptid_equal (ecs->ptid, inferior_ptid))
        context_switch (ecs->ptid);
@@ -3406,8 +3512,9 @@ handle_inferior_event (struct execution_control_state *ecs)
          that's in a syscall.  It's frequently a losing proposition.  */
     case TARGET_WAITKIND_SYSCALL_ENTRY:
       if (debug_infrun)
-        fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_SYSCALL_ENTRY\n");
-      /* Getting the current syscall number */
+        fprintf_unfiltered (gdb_stdlog,
+                           "infrun: TARGET_WAITKIND_SYSCALL_ENTRY\n");
+      /* Getting the current syscall number.  */
       if (handle_syscall_event (ecs) != 0)
         return;
       goto process_event_stop_test;
@@ -3419,7 +3526,8 @@ handle_inferior_event (struct execution_control_state *ecs)
          into user code.)  */
     case TARGET_WAITKIND_SYSCALL_RETURN:
       if (debug_infrun)
-        fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_SYSCALL_RETURN\n");
+        fprintf_unfiltered (gdb_stdlog,
+                           "infrun: TARGET_WAITKIND_SYSCALL_RETURN\n");
       if (handle_syscall_event (ecs) != 0)
         return;
       goto process_event_stop_test;
@@ -3443,8 +3551,9 @@ handle_inferior_event (struct execution_control_state *ecs)
       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.");
+       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
@@ -3522,7 +3631,9 @@ targets should add new threads to the thread list themselves in non-stop mode.")
       if (ecs->event_thread->suspend.stop_signal == TARGET_SIGNAL_TRAP)
        {
          if (debug_infrun)
-           fprintf_unfiltered (gdb_stdlog, "infrun: stepping_past_singlestep_breakpoint\n");
+           fprintf_unfiltered (gdb_stdlog,
+                               "infrun: stepping_past_"
+                               "singlestep_breakpoint\n");
          /* Pull the single step breakpoints out of the target.  */
          remove_single_step_breakpoints ();
          singlestep_breakpoints_inserted_p = 0;
@@ -3560,6 +3671,8 @@ targets should add new threads to the thread list themselves in non-stop mode.")
              singlestep_breakpoints_inserted_p = 0;
            }
 
+         ecs->event_thread->control.trap_expected = 0;
+
          /* Note: We do not call context_switch at this point, as the
             context is already set up for stepping the original thread.  */
          switch_to_thread (deferred_step_ptid);
@@ -3586,7 +3699,7 @@ targets should add new threads to the thread list themselves in non-stop mode.")
        get_regcache_aspace (get_thread_regcache (ecs->ptid));
 
       /* Check if a regular breakpoint has been hit before checking
-         for a potential single step breakpoint. Otherwise, GDB will
+         for a potential single step breakpoint.  Otherwise, GDB will
          not see this breakpoint hit when stepping onto breakpoints.  */
       if (regular_breakpoint_inserted_here_p (aspace, stop_pc))
        {
@@ -3679,11 +3792,11 @@ targets should add new threads to the thread list themselves in non-stop mode.")
            context_switch (ecs->ptid);
 
          /* Saw a breakpoint, but it was hit by the wrong thread.
-            Just continue. */
+            Just continue.  */
 
          if (singlestep_breakpoints_inserted_p)
            {
-             /* Pull the single step breakpoints out of the target. */
+             /* Pull the single step breakpoints out of the target.  */
              remove_single_step_breakpoints ();
              singlestep_breakpoints_inserted_p = 0;
            }
@@ -3700,7 +3813,7 @@ targets should add new threads to the thread list themselves in non-stop mode.")
             the bp's: On HP-UX's that use ttrace, we can't
             change the address space of a vforking child
             process until the child exits (well, okay, not
-            then either :-) or execs. */
+            then either :-) or execs.  */
          if (remove_status != 0)
            error (_("Cannot step over breakpoint hit in wrong thread"));
          else
@@ -3746,7 +3859,7 @@ targets should add new threads to the thread list themselves in non-stop mode.")
 
   if (singlestep_breakpoints_inserted_p)
     {
-      /* Pull the single step breakpoints out of the target. */
+      /* Pull the single step breakpoints out of the target.  */
       remove_single_step_breakpoints ();
       singlestep_breakpoints_inserted_p = 0;
     }
@@ -3785,7 +3898,12 @@ targets should add new threads to the thread list themselves in non-stop mode.")
       int hw_step = 1;
 
       if (!target_have_steppable_watchpoint)
-       remove_breakpoints ();
+       {
+         remove_breakpoints ();
+         /* See comment in resume why we need to stop bypassing signals
+            while breakpoints have been removed.  */
+         target_pass_signals (0, NULL);
+       }
        /* Single step */
       hw_step = maybe_software_singlestep (gdbarch, stop_pc);
       target_resume (ecs->ptid, hw_step, TARGET_SIGNAL_0);
@@ -3827,7 +3945,7 @@ targets should add new threads to the thread list themselves in non-stop mode.")
     {
       /* We're trying to step off a breakpoint.  Turns out that we're
         also on an instruction that needs to be stepped multiple
-        times before it's been fully executing. E.g., architectures
+        times before it's been fully executing.  E.g., architectures
         with a delay slot.  It needs to be stepped twice, once for
         the instruction and once for the delay slot.  */
       int step_through_delay
@@ -3939,8 +4057,9 @@ targets should add new threads to the thread list themselves in non-stop mode.")
          && ecs->event_thread->suspend.stop_signal == TARGET_SIGNAL_TRAP
          && !bpstat_explains_signal (ecs->event_thread->control.stop_bpstat)
          && stopped_by_watchpoint)
-       fprintf_unfiltered (gdb_stdlog, "\
-infrun: no user watchpoint explains watchpoint SIGTRAP, ignoring\n");
+       fprintf_unfiltered (gdb_stdlog,
+                           "infrun: no user watchpoint explains "
+                           "watchpoint SIGTRAP, ignoring\n");
 
       /* NOTE: cagney/2003-03-29: These two checks for a random signal
          at one stage in the past included checks for an inferior
@@ -3981,7 +4100,7 @@ infrun: no user watchpoint explains watchpoint SIGTRAP, ignoring\n");
 
   /* When we reach this point, we've pretty much decided
      that the reason for stopping must've been a random
-     (unexpected) signal. */
+     (unexpected) signal.  */
 
   else
     ecs->random_signal = 1;
@@ -4056,6 +4175,8 @@ process_event_stop_test:
 
          insert_step_resume_breakpoint_at_frame (frame);
          ecs->event_thread->step_after_step_resume_breakpoint = 1;
+         /* Reset trap_expected to ensure breakpoints are re-inserted.  */
+         ecs->event_thread->control.trap_expected = 0;
          keep_going (ecs);
          return;
        }
@@ -4083,6 +4204,8 @@ process_event_stop_test:
                                 "single-step range\n");
 
          insert_step_resume_breakpoint_at_frame (frame);
+         /* Reset trap_expected to ensure breakpoints are re-inserted.  */
+         ecs->event_thread->control.trap_expected = 0;
          keep_going (ecs);
          return;
        }
@@ -4135,8 +4258,9 @@ process_event_stop_test:
                                                frame, &jmp_buf_pc))
              {
                if (debug_infrun)
-                 fprintf_unfiltered (gdb_stdlog, "\
-infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n");
+                 fprintf_unfiltered (gdb_stdlog,
+                                     "infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME "
+                                     "(!gdbarch_get_longjmp_target)\n");
                keep_going (ecs);
                return;
              }
@@ -4330,8 +4454,9 @@ infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME (!gdbarch_get_longjmp_target)\n");
              || !target_thread_alive (tp->ptid))
            {
              if (debug_infrun)
-               fprintf_unfiltered (gdb_stdlog, "\
-infrun: not switching back to stepped thread, it has vanished\n");
+               fprintf_unfiltered (gdb_stdlog,
+                                   "infrun: not switching back to "
+                                   "stepped thread, it has vanished\n");
 
              delete_thread (tp->ptid);
              keep_going (ecs);
@@ -4361,11 +4486,12 @@ infrun: not switching back to stepped thread, it has vanished\n");
   if (ecs->event_thread->stepping_through_solib_after_catch)
     {
 #if defined(SOLIB_ADD)
-      /* Have we reached our destination?  If not, keep going. */
+      /* Have we reached our destination?  If not, keep going.  */
       if (SOLIB_IN_DYNAMIC_LINKER (PIDGET (ecs->ptid), stop_pc))
        {
           if (debug_infrun)
-           fprintf_unfiltered (gdb_stdlog, "infrun: stepping in dynamic linker\n");
+           fprintf_unfiltered (gdb_stdlog,
+                               "infrun: stepping in dynamic linker\n");
          ecs->event_thread->stepping_over_breakpoint = 1;
          keep_going (ecs);
          return;
@@ -4374,7 +4500,7 @@ infrun: not switching back to stepped thread, it has vanished\n");
       if (debug_infrun)
         fprintf_unfiltered (gdb_stdlog, "infrun: step past dynamic linker\n");
       /* Else, stop and report the catchpoint(s) whose triggering
-         caused us to begin stepping. */
+         caused us to begin stepping.  */
       ecs->event_thread->stepping_through_solib_after_catch = 0;
       bpstat_clear (&ecs->event_thread->control.stop_bpstat);
       ecs->event_thread->control.stop_bpstat
@@ -4474,7 +4600,8 @@ infrun: not switching back to stepped thread, it has vanished\n");
        gdbarch_skip_solib_resolver (gdbarch, stop_pc);
 
       if (debug_infrun)
-        fprintf_unfiltered (gdb_stdlog, "infrun: stepped into dynsym resolve code\n");
+        fprintf_unfiltered (gdb_stdlog,
+                            "infrun: stepped into dynsym resolve code\n");
 
       if (pc_after_resolver)
        {
@@ -4500,7 +4627,8 @@ infrun: not switching back to stepped thread, it has vanished\n");
       && get_frame_type (frame) == SIGTRAMP_FRAME)
     {
       if (debug_infrun)
-        fprintf_unfiltered (gdb_stdlog, "infrun: stepped into signal trampoline\n");
+        fprintf_unfiltered (gdb_stdlog,
+                            "infrun: stepped into signal trampoline\n");
       /* The inferior, while doing a "step" or "next", has ended up in
          a signal trampoline (either by a signal being delivered or by
          the signal handler returning).  Just single-step until the
@@ -4641,7 +4769,6 @@ infrun: not switching back to stepped thread, it has vanished\n");
        struct symtab_and_line tmp_sal;
 
        tmp_sal = find_pc_line (ecs->stop_func_start, 0);
-       tmp_sal.pspace = get_frame_program_space (frame);
        if (tmp_sal.line != 0)
          {
            if (execution_direction == EXEC_REVERSE)
@@ -4730,12 +4857,13 @@ infrun: not switching back to stepped thread, it has vanished\n");
       real_stop_pc = gdbarch_skip_trampoline_code (gdbarch, frame, stop_pc);
 
       if (debug_infrun)
-        fprintf_unfiltered (gdb_stdlog, "infrun: stepped into solib return tramp\n");
+        fprintf_unfiltered (gdb_stdlog,
+                            "infrun: stepped into solib return tramp\n");
 
       /* Only proceed through if we know where it's going.  */
       if (real_stop_pc)
        {
-         /* And put the step-breakpoint there and go until there. */
+         /* And put the step-breakpoint there and go until there.  */
          struct symtab_and_line sr_sal;
 
          init_sal (&sr_sal);   /* initialize to zeroes */
@@ -4766,7 +4894,8 @@ infrun: not switching back to stepped thread, it has vanished\n");
       && stop_pc_sal.line == 0)
     {
       if (debug_infrun)
-        fprintf_unfiltered (gdb_stdlog, "infrun: stepped into undebuggable function\n");
+        fprintf_unfiltered (gdb_stdlog,
+                            "infrun: stepped into undebuggable function\n");
 
       /* The inferior just stepped into, or returned to, an
          undebuggable function (where there is no debugging information
@@ -4908,7 +5037,8 @@ infrun: not switching back to stepped thread, it has vanished\n");
          That is said to make things like for (;;) statements work
          better.  */
       if (debug_infrun)
-        fprintf_unfiltered (gdb_stdlog, "infrun: stepped to a different line\n");
+        fprintf_unfiltered (gdb_stdlog,
+                            "infrun: stepped to a different line\n");
       ecs->event_thread->control.stop_step = 1;
       print_end_stepping_range_reason ();
       stop_stepping (ecs);
@@ -5283,7 +5413,7 @@ stop_stepping (struct execution_control_state *ecs)
 
 /* This function handles various cases where we need to continue
    waiting for the inferior.  */
-/* (Used to be the keep_going: label in the old wait_for_inferior) */
+/* (Used to be the keep_going: label in the old wait_for_inferior) */
 
 static void
 keep_going (struct execution_control_state *ecs)
@@ -5366,7 +5496,7 @@ keep_going (struct execution_control_state *ecs)
          halts the simulation handing control to GDB; GDB, noteing
          that the break-point isn't valid, returns control back to the
          simulator; the simulator then delivers the hardware
-         equivalent of a SIGNAL_TRAP to the program being debugged. */
+         equivalent of a SIGNAL_TRAP to the program being debugged.  */
 
       if (ecs->event_thread->suspend.stop_signal == TARGET_SIGNAL_TRAP
          && !signal_program[ecs->event_thread->suspend.stop_signal])
@@ -5446,29 +5576,40 @@ print_signal_exited_reason (enum target_signal siggnal)
 static void
 print_exited_reason (int exitstatus)
 {
+  struct inferior *inf = current_inferior ();
+  const char *pidstr = target_pid_to_str (pid_to_ptid (inf->pid));
+
   annotate_exited (exitstatus);
   if (exitstatus)
     {
       if (ui_out_is_mi_like_p (uiout))
        ui_out_field_string (uiout, "reason", 
                             async_reason_lookup (EXEC_ASYNC_EXITED));
-      ui_out_text (uiout, "\nProgram exited with code ");
+      ui_out_text (uiout, "[Inferior ");
+      ui_out_text (uiout, plongest (inf->num));
+      ui_out_text (uiout, " (");
+      ui_out_text (uiout, pidstr);
+      ui_out_text (uiout, ") exited with code ");
       ui_out_field_fmt (uiout, "exit-code", "0%o", (unsigned int) exitstatus);
-      ui_out_text (uiout, ".\n");
+      ui_out_text (uiout, "]\n");
     }
   else
     {
       if (ui_out_is_mi_like_p (uiout))
        ui_out_field_string
          (uiout, "reason", async_reason_lookup (EXEC_ASYNC_EXITED_NORMALLY));
-      ui_out_text (uiout, "\nProgram exited normally.\n");
+      ui_out_text (uiout, "[Inferior ");
+      ui_out_text (uiout, plongest (inf->num));
+      ui_out_text (uiout, " (");
+      ui_out_text (uiout, pidstr);
+      ui_out_text (uiout, ") exited normally]\n");
     }
   /* Support the --return-child-result option.  */
   return_child_result_value = exitstatus;
 }
 
 /* Signal received, print why the inferior has stopped.  The signal table
-   tells us to print about it. */
+   tells us to print about it.  */
 
 static void
 print_signal_received_reason (enum target_signal siggnal)
@@ -5570,9 +5711,9 @@ normal_stop (void)
       if (remove_breakpoints ())
        {
          target_terminal_ours_for_output ();
-         printf_filtered (_("\
-Cannot remove breakpoints because program is no longer writable.\n\
-Further execution is probably impossible.\n"));
+         printf_filtered (_("Cannot remove breakpoints because "
+                            "program is no longer writable.\nFurther "
+                            "execution is probably impossible.\n"));
        }
     }
 
@@ -5618,7 +5759,7 @@ Further execution is probably impossible.\n"));
   /* Select innermost stack frame - i.e., current frame is frame 0,
      and current location is based on that.
      Don't do this on return from a stack dummy routine,
-     or if the program has exited. */
+     or if the program has exited.  */
 
   if (!stop_stack_dummy)
     {
@@ -5628,7 +5769,7 @@ Further execution is probably impossible.\n"));
          we have changed functions or hit a breakpoint.
          Print source line if we have one.
          bpstat_print() contains the logic deciding in detail
-         what to print, based on the event(s) that just occurred. */
+         what to print, based on the event(s) that just occurred.  */
 
       /* If --batch-silent is enabled then there's no need to print the current
         source location, and to try risks causing an error message about
@@ -5663,12 +5804,15 @@ Further execution is probably impossible.\n"));
                  && frame_id_eq (tp->control.step_frame_id,
                                  get_frame_id (get_current_frame ()))
                  && step_start_function == find_pc_function (stop_pc))
-               source_flag = SRC_LINE; /* finished step, just print source line */
+               source_flag = SRC_LINE;         /* Finished step, just
+                                                  print source line.  */
              else
-               source_flag = SRC_AND_LOC;      /* print location and source line */
+               source_flag = SRC_AND_LOC;      /* Print location and
+                                                  source line.  */
              break;
            case PRINT_SRC_AND_LOC:
-             source_flag = SRC_AND_LOC;        /* print location and source line */
+             source_flag = SRC_AND_LOC;        /* Print location and
+                                                  source line.  */
              break;
            case PRINT_SRC_ONLY:
              source_flag = SRC_LINE;
@@ -5685,7 +5829,7 @@ Further execution is probably impossible.\n"));
             flag is:
             SRC_LINE: Print only source line
             LOCATION: Print only location
-            SRC_AND_LOC: Print location and source line */
+            SRC_AND_LOC: Print location and source line */
          if (do_frame_printing)
            print_stack_frame (get_selected_frame (NULL), 0, source_flag);
 
@@ -5716,14 +5860,15 @@ Further execution is probably impossible.\n"));
 
       gdb_assert (get_frame_type (frame) == DUMMY_FRAME);
       frame_pop (frame);
-      /* frame_pop() calls reinit_frame_cache as the last thing it does
-        which means there's currently no selected frame.  We don't need
-        to re-establish a selected frame if the dummy call returns normally,
-        that will be done by restore_infcall_control_state.  However, we do have
-        to handle the case where the dummy call is returning after being
-        stopped (e.g. the dummy call previously hit a breakpoint).  We
-        can't know which case we have so just always re-establish a
-        selected frame here.  */
+      /* frame_pop() calls reinit_frame_cache as the last thing it
+        does which means there's currently no selected frame.  We
+        don't need to re-establish a selected frame if the dummy call
+        returns normally, that will be done by
+        restore_infcall_control_state.  However, we do have to handle
+        the case where the dummy call is returning after being
+        stopped (e.g. the dummy call previously hit a breakpoint).
+        We can't know which case we have so just always re-establish
+        a selected frame here.  */
       select_frame (get_current_frame ());
     }
 
@@ -5797,12 +5942,29 @@ signal_pass_state (int signo)
   return signal_program[signo];
 }
 
+static void
+signal_cache_update (int signo)
+{
+  if (signo == -1)
+    {
+      for (signo = 0; signo < (int) TARGET_SIGNAL_LAST; signo++)
+       signal_cache_update (signo);
+
+      return;
+    }
+
+  signal_pass[signo] = (signal_stop[signo] == 0
+                       && signal_print[signo] == 0
+                       && signal_program[signo] == 1);
+}
+
 int
 signal_stop_update (int signo, int state)
 {
   int ret = signal_stop[signo];
 
   signal_stop[signo] = state;
+  signal_cache_update (signo);
   return ret;
 }
 
@@ -5812,6 +5974,7 @@ signal_print_update (int signo, int state)
   int ret = signal_print[signo];
 
   signal_print[signo] = state;
+  signal_cache_update (signo);
   return ret;
 }
 
@@ -5821,14 +5984,15 @@ signal_pass_update (int signo, int state)
   int ret = signal_program[signo];
 
   signal_program[signo] = state;
+  signal_cache_update (signo);
   return ret;
 }
 
 static void
 sig_print_header (void)
 {
-  printf_filtered (_("\
-Signal        Stop\tPrint\tPass to program\tDescription\n"));
+  printf_filtered (_("Signal        Stop\tPrint\tPass "
+                    "to program\tDescription\n"));
 }
 
 static void
@@ -5867,13 +6031,13 @@ handle_command (char *args, int from_tty)
       error_no_arg (_("signal to handle"));
     }
 
-  /* Allocate and zero an array of flags for which signals to handle. */
+  /* Allocate and zero an array of flags for which signals to handle.  */
 
   nsigs = (int) TARGET_SIGNAL_LAST;
   sigs = (unsigned char *) alloca (nsigs);
   memset (sigs, 0, nsigs);
 
-  /* Break the command line up into args. */
+  /* Break the command line up into args.  */
 
   argv = gdb_buildargv (args);
   old_chain = make_cleanup_freeargv (argv);
@@ -5881,7 +6045,7 @@ handle_command (char *args, int from_tty)
   /* Walk through the args, looking for signal oursigs, signal names, and
      actions.  Signal numbers and signal names may be interspersed with
      actions, with the actions being performed for all signals cumulatively
-     specified.  Signal ranges can be specified as <LOW>-<HIGH>. */
+     specified.  Signal ranges can be specified as <LOW>-<HIGH>.  */
 
   while (*argv != NULL)
     {
@@ -5895,7 +6059,7 @@ handle_command (char *args, int from_tty)
       if (wordlen >= 1 && !strncmp (*argv, "all", wordlen))
        {
          /* Apply action to all signals except those used by the
-            debugger.  Silently skip those. */
+            debugger.  Silently skip those.  */
          allsigs = 1;
          sigfirst = 0;
          siglast = nsigs - 1;
@@ -5951,7 +6115,7 @@ handle_command (char *args, int from_tty)
            }
          if (sigfirst > siglast)
            {
-             /* Bet he didn't figure we'd think of this case... */
+             /* Bet he didn't figure we'd think of this case...  */
              signum = sigfirst;
              sigfirst = siglast;
              siglast = signum;
@@ -5972,7 +6136,7 @@ handle_command (char *args, int from_tty)
        }
 
       /* If any signal numbers or symbol names were found, set flags for
-         which signals to apply actions to. */
+         which signals to apply actions to.  */
 
       for (signum = sigfirst; signum >= 0 && signum <= siglast; signum++)
        {
@@ -5983,7 +6147,8 @@ handle_command (char *args, int from_tty)
              if (!allsigs && !sigs[signum])
                {
                  if (query (_("%s is used by the debugger.\n\
-Are you sure you want to change it? "), target_signal_to_name ((enum target_signal) signum)))
+Are you sure you want to change it? "),
+                            target_signal_to_name ((enum target_signal) signum)))
                    {
                      sigs[signum] = 1;
                    }
@@ -6011,7 +6176,8 @@ Are you sure you want to change it? "), target_signal_to_name ((enum target_sign
   for (signum = 0; signum < nsigs; signum++)
     if (sigs[signum])
       {
-       target_notice_signals (inferior_ptid);
+       signal_cache_update (-1);
+       target_pass_signals ((int) TARGET_SIGNAL_LAST, signal_pass);
 
        if (from_tty)
          {
@@ -6037,7 +6203,7 @@ xdb_handle_command (char *args, int from_tty)
   if (args == NULL)
     error_no_arg (_("xdb command"));
 
-  /* Break the command line up into args. */
+  /* Break the command line up into args.  */
 
   argv = gdb_buildargv (args);
   old_chain = make_cleanup_freeargv (argv);
@@ -6133,12 +6299,13 @@ signals_info (char *signum_exp, int from_tty)
        sig_print_info (oursig);
     }
 
-  printf_filtered (_("\nUse the \"handle\" command to change these tables.\n"));
+  printf_filtered (_("\nUse the \"handle\" command "
+                    "to change these tables.\n"));
 }
 
 /* The $_siginfo convenience variable is a bit special.  We don't know
    for sure the type of the value until we actually have a chance to
-   fetch the data.  The type can change depending on gdbarch, so it it
+   fetch the data.  The type can change depending on gdbarch, so it is
    also dependent on which thread you have selected.
 
      1. making $_siginfo be an internalvar that creates a new value on
@@ -6485,7 +6652,7 @@ discard_infcall_control_state (struct infcall_control_state *inf_status)
     inf_status->thread_control.exception_resume_breakpoint->disposition
       = disp_del_at_next_stop;
 
-  /* See save_infcall_control_state for info on stop_bpstat. */
+  /* See save_infcall_control_state for info on stop_bpstat.  */
   bpstat_clear (&inf_status->thread_control.stop_bpstat);
 
   xfree (inf_status);
@@ -6638,11 +6805,6 @@ ptid_is_pid (ptid_t ptid)
 int
 ptid_match (ptid_t ptid, ptid_t filter)
 {
-  /* Since both parameters have the same type, prevent easy mistakes
-     from happening.  */
-  gdb_assert (!ptid_equal (ptid, minus_one_ptid)
-             && !ptid_equal (ptid, null_ptid));
-
   if (ptid_equal (filter, minus_one_ptid))
     return 1;
   if (ptid_is_pid (filter)
@@ -6727,8 +6889,8 @@ show_exec_direction_func (struct ui_file *out, int from_tty,
     break;
   case EXEC_ERROR:
   default:
-    fprintf_filtered (out, 
-                     _("Forward (target `%s' does not support exec-direction).\n"),
+    fprintf_filtered (out, _("Forward (target `%s' does not "
+                            "support exec-direction).\n"),
                      target_shortname);
     break;
   }
@@ -6764,8 +6926,8 @@ static void
 show_schedule_multiple (struct ui_file *file, int from_tty,
                        struct cmd_list_element *c, const char *value)
 {
-  fprintf_filtered (file, _("\
-Resuming the execution of threads of all processes is %s.\n"), value);
+  fprintf_filtered (file, _("Resuming the execution of threads "
+                           "of all processes is %s.\n"), value);
 }
 
 void
@@ -6832,7 +6994,8 @@ When non-zero, inferior specific debugging is enabled."),
                            show_debug_infrun,
                            &setdebuglist, &showdebuglist);
 
-  add_setshow_boolean_cmd ("displaced", class_maintenance, &debug_displaced, _("\
+  add_setshow_boolean_cmd ("displaced", class_maintenance,
+                          &debug_displaced, _("\
 Set displaced stepping debugging."), _("\
 Show displaced stepping debugging."), _("\
 When non-zero, displaced stepping specific debugging is enabled."),
@@ -6866,6 +7029,8 @@ leave it stopped or free to run as needed."),
     xmalloc (sizeof (signal_print[0]) * numsigs);
   signal_program = (unsigned char *)
     xmalloc (sizeof (signal_program[0]) * numsigs);
+  signal_pass = (unsigned char *)
+    xmalloc (sizeof (signal_program[0]) * numsigs);
   for (i = 0; i < numsigs; i++)
     {
       signal_stop[i] = 1;
@@ -6895,6 +7060,8 @@ leave it stopped or free to run as needed."),
   signal_print[TARGET_SIGNAL_URG] = 0;
   signal_stop[TARGET_SIGNAL_WINCH] = 0;
   signal_print[TARGET_SIGNAL_WINCH] = 0;
+  signal_stop[TARGET_SIGNAL_PRIO] = 0;
+  signal_print[TARGET_SIGNAL_PRIO] = 0;
 
   /* These signals are used internally by user-level thread
      implementations.  (See signal(5) on Solaris.)  Like the above
@@ -6907,6 +7074,9 @@ leave it stopped or free to run as needed."),
   signal_stop[TARGET_SIGNAL_CANCEL] = 0;
   signal_print[TARGET_SIGNAL_CANCEL] = 0;
 
+  /* Update cached state.  */
+  signal_cache_update (-1);
+
   add_setshow_zinteger_cmd ("stop-on-solib-events", class_support,
                            &stop_on_solib_events, _("\
 Set stopping for shared library events."), _("\
This page took 0.044843 seconds and 4 git commands to generate.