* python/py-autoload.c (print_script): Print "Missing" instead of
[deliverable/binutils-gdb.git] / gdb / infrun.c
index dd6fe6cd740e367507f431ada38f095adfab2f82..3b779de823c2c46aebdc7230d86991d8390d5354 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
 
@@ -473,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);
@@ -606,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 ();
 
@@ -701,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;
@@ -750,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)
@@ -777,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;
@@ -798,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);
 
@@ -849,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
@@ -874,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
@@ -903,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;
@@ -1078,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
@@ -1560,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;
@@ -1623,11 +1656,10 @@ resume (int step, enum target_signal sig)
       if (gdbarch_skip_permanent_breakpoint_p (gdbarch))
        gdbarch_skip_permanent_breakpoint (gdbarch, regcache);
       else
-       error (_("The program is stopped at a permanent "
-                "breakpoint, but GDB does not know\n"
-                "how to step past a permanent breakpoint "
-                "on this architecture.  Try using\na command "
-                "like `return' or `jump' to continue execution."));
+       error (_("\
+The program is stopped at a permanent breakpoint, but GDB does not know\n\
+how to step past a permanent breakpoint on this architecture.  Try using\n\
+a command like `return' or `jump' to continue execution."));
     }
 
   /* If enabled, step over breakpoints by executing a copy of the
@@ -1671,6 +1703,51 @@ resume (int step, enum target_signal sig)
   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;
@@ -1735,7 +1812,7 @@ resume (int step, enum target_signal sig)
               || (scheduler_mode == schedlock_step
                   && (step || singlestep_breakpoints_inserted_p)))
        {
-         /* User-settable 'scheduler' mode requires solo thread resume. */
+         /* User-settable 'scheduler' mode requires solo thread resume.  */
          resume_ptid = inferior_ptid;
        }
 
@@ -1770,6 +1847,18 @@ resume (int step, enum target_signal sig)
         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);
     }
 
@@ -1857,7 +1946,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)
@@ -1914,7 +2003,7 @@ prepare_to_proceed (int step)
 
          /* 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;
        }
     }
@@ -1995,16 +2084,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.  */
@@ -2022,7 +2101,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;
     }
@@ -2123,10 +2202,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 ();
     }
 }
@@ -2143,21 +2222,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,
@@ -2233,12 +2312,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 *);
-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);
 static void check_exception_resume (struct execution_control_state *,
                                    struct frame_info *, struct symbol *);
 
@@ -2395,7 +2468,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)
@@ -2484,7 +2557,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 ();
 
@@ -2531,18 +2604,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;
@@ -2550,8 +2618,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);
@@ -2570,7 +2637,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 ();
@@ -2583,13 +2650,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.  */
@@ -2612,14 +2672,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)
@@ -2635,6 +2695,16 @@ fetch_inferior_event (void *client_data)
   /* 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
        switch due to internal events.  Make sure we reverse to the
@@ -2646,7 +2716,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 ();
@@ -3022,14 +3092,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)
@@ -3208,7 +3278,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
@@ -3231,13 +3301,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);
@@ -3247,7 +3317,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)
@@ -3282,7 +3352,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;
        }
@@ -3419,7 +3489,7 @@ handle_inferior_event (struct execution_control_state *ecs)
       if (debug_infrun)
         fprintf_unfiltered (gdb_stdlog,
                            "infrun: TARGET_WAITKIND_SYSCALL_ENTRY\n");
-      /* Getting the current syscall number */
+      /* Getting the current syscall number */
       if (handle_syscall_event (ecs) != 0)
         return;
       goto process_event_stop_test;
@@ -3602,7 +3672,7 @@ handle_inferior_event (struct execution_control_state *ecs)
        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))
        {
@@ -3695,11 +3765,11 @@ handle_inferior_event (struct execution_control_state *ecs)
            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;
            }
@@ -3716,7 +3786,7 @@ handle_inferior_event (struct execution_control_state *ecs)
             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
@@ -3762,7 +3832,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;
     }
@@ -3801,7 +3871,12 @@ handle_inferior_event (struct execution_control_state *ecs)
       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);
@@ -3843,7 +3918,7 @@ handle_inferior_event (struct execution_control_state *ecs)
     {
       /* 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
@@ -3998,7 +4073,7 @@ handle_inferior_event (struct execution_control_state *ecs)
 
   /* 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;
@@ -4073,6 +4148,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;
        }
@@ -4100,6 +4177,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;
        }
@@ -4380,7 +4459,7 @@ process_event_stop_test:
   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)
@@ -4394,7 +4473,7 @@ process_event_stop_test:
       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
@@ -4663,7 +4742,6 @@ process_event_stop_test:
        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)
@@ -4758,7 +4836,7 @@ process_event_stop_test:
       /* 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 */
@@ -5308,7 +5386,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)
@@ -5391,7 +5469,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])
@@ -5471,29 +5549,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)
@@ -5643,7 +5732,7 @@ normal_stop (void)
   /* 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)
     {
@@ -5653,7 +5742,7 @@ normal_stop (void)
          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
@@ -5688,15 +5777,15 @@ normal_stop (void)
                  && 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;
@@ -5713,7 +5802,7 @@ normal_stop (void)
             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);
 
@@ -5826,12 +5915,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;
 }
 
@@ -5841,6 +5947,7 @@ signal_print_update (int signo, int state)
   int ret = signal_print[signo];
 
   signal_print[signo] = state;
+  signal_cache_update (signo);
   return ret;
 }
 
@@ -5850,6 +5957,7 @@ signal_pass_update (int signo, int state)
   int ret = signal_program[signo];
 
   signal_program[signo] = state;
+  signal_cache_update (signo);
   return ret;
 }
 
@@ -5896,13 +6004,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);
@@ -5910,7 +6018,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)
     {
@@ -5924,7 +6032,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;
@@ -5980,7 +6088,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;
@@ -6001,7 +6109,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++)
        {
@@ -6041,7 +6149,8 @@ Are you sure you want to change it? "),
   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)
          {
@@ -6067,7 +6176,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);
@@ -6169,7 +6278,7 @@ signals_info (char *signum_exp, int from_tty)
 
 /* 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
@@ -6516,7 +6625,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);
@@ -6669,11 +6778,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)
@@ -6898,6 +7002,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;
@@ -6941,6 +7047,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.040034 seconds and 4 git commands to generate.