gas/testsuite/
[deliverable/binutils-gdb.git] / gdb / infrun.c
index dc6d8941ccf7220fe9c4e97b50b2913f7725ad69..1a8556775ac7afff589c4f78765bd18fb147549c 100644 (file)
@@ -9,7 +9,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -18,9 +18,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "gdb_string.h"
@@ -80,11 +78,10 @@ static int currently_stepping (struct execution_control_state *ecs);
 
 static void xdb_handle_command (char *args, int from_tty);
 
-static int prepare_to_proceed (void);
+static int prepare_to_proceed (int);
 
 void _initialize_infrun (void);
 
-int inferior_ignoring_startup_exec_events = 0;
 int inferior_ignoring_leading_exec_events = 0;
 
 /* When set, stop the 'step' command if we enter a function which has
@@ -448,6 +445,11 @@ static CORE_ADDR singlestep_pc;
    thread here so that we can resume single-stepping it later.  */
 static ptid_t saved_singlestep_ptid;
 static int stepping_past_singlestep_breakpoint;
+
+/* Similarly, if we are stepping another thread past a breakpoint,
+   save the original thread here so that we can resume stepping it later.  */
+static ptid_t stepping_past_breakpoint_ptid;
+static int stepping_past_breakpoint;
 \f
 
 /* Things to clean up if we QUIT out of resume ().  */
@@ -528,7 +530,8 @@ resume (int step, enum target_signal sig)
   if (breakpoint_here_p (read_pc ()) == permanent_breakpoint_here)
     {
       if (gdbarch_skip_permanent_breakpoint_p (current_gdbarch))
-       gdbarch_skip_permanent_breakpoint (current_gdbarch, current_regcache);
+       gdbarch_skip_permanent_breakpoint (current_gdbarch,
+                                          get_current_regcache ());
       else
        error (_("\
 The program is stopped at a permanent breakpoint, but GDB does not know\n\
@@ -536,10 +539,10 @@ how to step past a permanent breakpoint on this architecture.  Try using\n\
 a command like `return' or `jump' to continue execution."));
     }
 
-  if (SOFTWARE_SINGLE_STEP_P () && step)
+  if (step && gdbarch_software_single_step_p (current_gdbarch))
     {
       /* Do it the hard way, w/temp breakpoints */
-      if (SOFTWARE_SINGLE_STEP (current_regcache))
+      if (gdbarch_software_single_step (current_gdbarch, get_current_frame ()))
         {
           /* ...and don't ask hardware to do it.  */
           step = 0;
@@ -631,6 +634,12 @@ clear_proceed_status (void)
   proceed_to_finish = 0;
   breakpoint_proceeded = 1;    /* We're about to proceed... */
 
+  if (stop_registers)
+    {
+      regcache_xfree (stop_registers);
+      stop_registers = NULL;
+    }
+
   /* Discard any remaining commands or status from previous stop.  */
   bpstat_clear (&stop_bpstat);
 }
@@ -638,7 +647,7 @@ clear_proceed_status (void)
 /* This should be suitable for any targets that support threads. */
 
 static int
-prepare_to_proceed (void)
+prepare_to_proceed (int step)
 {
   ptid_t wait_ptid;
   struct target_waitstatus wait_status;
@@ -646,42 +655,35 @@ prepare_to_proceed (void)
   /* Get the last target status returned by target_wait().  */
   get_last_target_status (&wait_ptid, &wait_status);
 
-  /* Make sure we were stopped either at a breakpoint, or because
-     of a Ctrl-C.  */
+  /* Make sure we were stopped at a breakpoint.  */
   if (wait_status.kind != TARGET_WAITKIND_STOPPED
-      || (wait_status.value.sig != TARGET_SIGNAL_TRAP
-         && wait_status.value.sig != TARGET_SIGNAL_INT))
+      || wait_status.value.sig != TARGET_SIGNAL_TRAP)
     {
       return 0;
     }
 
+  /* Switched over from WAIT_PID.  */
   if (!ptid_equal (wait_ptid, minus_one_ptid)
-      && !ptid_equal (inferior_ptid, wait_ptid))
+      && !ptid_equal (inferior_ptid, wait_ptid)
+      && breakpoint_here_p (read_pc_pid (wait_ptid)))
     {
-      /* Switched over from WAIT_PID.  */
-      CORE_ADDR wait_pc = read_pc_pid (wait_ptid);
-
-      if (wait_pc != read_pc ())
+      /* If stepping, remember current thread to switch back to.  */
+      if (step)
        {
-         /* Switch back to WAIT_PID thread.  */
-         inferior_ptid = wait_ptid;
-
-         /* FIXME: This stuff came from switch_to_thread() in
-            thread.c (which should probably be a public function).  */
-         reinit_frame_cache ();
-         registers_changed ();
-         stop_pc = wait_pc;
+         stepping_past_breakpoint = 1;
+         stepping_past_breakpoint_ptid = inferior_ptid;
        }
 
+      /* Switch back to WAIT_PID thread.  */
+      switch_to_thread (wait_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. */
-      if (breakpoint_here_p (wait_pc))
-       return 1;
+        so we need to step over it before continuing to avoid
+        hitting it straight away. */
+      return 1;
     }
 
   return 0;
-
 }
 
 /* Record the pc of the program the last time it stopped.  This is
@@ -747,7 +749,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. */
-  if (prepare_to_proceed () && breakpoint_here_p (read_pc ()))
+  if (prepare_to_proceed (step))
     oneproc = 1;
 
   if (oneproc)
@@ -821,7 +823,7 @@ start_remote (int from_tty)
 {
   init_thread_list ();
   init_wait_for_inferior ();
-  stop_soon = STOP_QUIETLY;
+  stop_soon = STOP_QUIETLY_REMOTE;
   trap_expected = 0;
 
   /* Always go on waiting for the target, regardless of the mode. */
@@ -868,6 +870,7 @@ init_wait_for_inferior (void)
   clear_proceed_status ();
 
   stepping_past_singlestep_breakpoint = 0;
+  stepping_past_breakpoint = 0;
 }
 \f
 /* This enum encodes possible reasons for doing a target_wait, so that
@@ -1137,8 +1140,8 @@ context_switch (struct execution_control_state *ecs)
                         &ecs->stepping_through_solib_catchpoints,
                         &ecs->current_line, &ecs->current_symtab);
     }
-  inferior_ptid = ecs->ptid;
-  reinit_frame_cache ();
+
+  switch_to_thread (ecs->ptid);
 }
 
 static void
@@ -1148,29 +1151,29 @@ adjust_pc_after_break (struct execution_control_state *ecs)
 
   /* If this target does not decrement the PC after breakpoints, then
      we have nothing to do.  */
-  if (DECR_PC_AFTER_BREAK == 0)
+  if (gdbarch_decr_pc_after_break (current_gdbarch) == 0)
     return;
 
   /* If we've hit a breakpoint, we'll normally be stopped with SIGTRAP.  If
      we aren't, just return.
 
      We assume that waitkinds other than TARGET_WAITKIND_STOPPED are not
-     affected by DECR_PC_AFTER_BREAK.  Other waitkinds which are implemented
-     by software breakpoints should be handled through the normal breakpoint
-     layer.
+     affected by gdbarch_decr_pc_after_break.  Other waitkinds which are
+     implemented by software breakpoints should be handled through the normal
+     breakpoint layer.
 
      NOTE drow/2004-01-31: On some targets, breakpoints may generate
      different signals (SIGILL or SIGEMT for instance), but it is less
      clear where the PC is pointing afterwards.  It may not match
-     DECR_PC_AFTER_BREAK.  I don't know any specific target that generates
-     these signals at breakpoints (the code has been in GDB since at least
-     1992) so I can not guess how to handle them here.
+     gdbarch_decr_pc_after_break.  I don't know any specific target that
+     generates these signals at breakpoints (the code has been in GDB since at
+     least 1992) so I can not guess how to handle them here.
 
      In earlier versions of GDB, a target with 
      gdbarch_have_nonsteppable_watchpoint would have the PC after hitting a
-     watchpoint affected by DECR_PC_AFTER_BREAK.  I haven't found any target
-     with both of these set in GDB history, and it seems unlikely to be correct,
-     so gdbarch_have_nonsteppable_watchpoint is not checked here.  */
+     watchpoint affected by gdbarch_decr_pc_after_break.  I haven't found any
+     target with both of these set in GDB history, and it seems unlikely to be
+     correct, so gdbarch_have_nonsteppable_watchpoint is not checked here.  */
 
   if (ecs->ws.kind != TARGET_WAITKIND_STOPPED)
     return;
@@ -1180,54 +1183,36 @@ adjust_pc_after_break (struct execution_control_state *ecs)
 
   /* Find the location where (if we've hit a breakpoint) the
      breakpoint would be.  */
-  breakpoint_pc = read_pc_pid (ecs->ptid) - DECR_PC_AFTER_BREAK;
-
-  if (SOFTWARE_SINGLE_STEP_P ())
-    {
-      /* When using software single-step, a SIGTRAP can only indicate
-         an inserted breakpoint.  This actually makes things
-         easier.  */
-      if (singlestep_breakpoints_inserted_p)
-       /* When software single stepping, the instruction at [prev_pc]
-          is never a breakpoint, but the instruction following
-          [prev_pc] (in program execution order) always is.  Assume
-          that following instruction was reached and hence a software
-          breakpoint was hit.  */
-       write_pc_pid (breakpoint_pc, ecs->ptid);
-      else if (software_breakpoint_inserted_here_p (breakpoint_pc))
-       /* The inferior was free running (i.e., no single-step
-          breakpoints inserted) and it hit a software breakpoint.  */
-       write_pc_pid (breakpoint_pc, ecs->ptid);
-    }
-  else
-    {
-      /* When using hardware single-step, a SIGTRAP is reported for
-         both a completed single-step and a software breakpoint.  Need
-         to differentiate between the two as the latter needs
-         adjusting but the former does not.
+  breakpoint_pc = read_pc_pid (ecs->ptid) - gdbarch_decr_pc_after_break
+                                           (current_gdbarch);
 
-         When the thread to be examined does not match the current thread
-         context we can't use currently_stepping, so assume no
-         single-stepping in this case.  */
-      if (ptid_equal (ecs->ptid, inferior_ptid) && currently_stepping (ecs))
-       {
-         if (prev_pc == breakpoint_pc
-             && software_breakpoint_inserted_here_p (breakpoint_pc))
-           /* Hardware single-stepped a software breakpoint (as
-              occures when the inferior is resumed with PC pointing
-              at not-yet-hit software breakpoint).  Since the
-              breakpoint really is executed, the inferior needs to be
-              backed up to the breakpoint address.  */
-           write_pc_pid (breakpoint_pc, ecs->ptid);
-       }
-      else
-       {
-         if (software_breakpoint_inserted_here_p (breakpoint_pc))
-           /* The inferior was free running (i.e., no hardware
-              single-step and no possibility of a false SIGTRAP) and
-              hit a software breakpoint.  */
-           write_pc_pid (breakpoint_pc, ecs->ptid);
-       }
+  /* Check whether there actually is a software breakpoint inserted
+     at that location.  */
+  if (software_breakpoint_inserted_here_p (breakpoint_pc))
+    {
+      /* When using hardware single-step, a SIGTRAP is reported for both
+        a completed single-step and a software breakpoint.  Need to
+        differentiate between the two, as the latter needs adjusting
+        but the former does not.
+
+        The SIGTRAP can be due to a completed hardware single-step only if 
+         - we didn't insert software single-step breakpoints
+         - the thread to be examined is still the current thread
+         - this thread is currently being stepped
+
+        If any of these events did not occur, we must have stopped due
+        to hitting a software breakpoint, and have to back up to the
+        breakpoint address.
+
+        As a special case, we could have hardware single-stepped a
+        software breakpoint.  In this case (prev_pc == breakpoint_pc),
+        we also need to back up to the breakpoint address.  */
+
+      if (singlestep_breakpoints_inserted_p
+         || !ptid_equal (ecs->ptid, inferior_ptid)
+         || !currently_stepping (ecs)
+         || prev_pc == breakpoint_pc)
+       write_pc_pid (breakpoint_pc, ecs->ptid);
     }
 }
 
@@ -1308,16 +1293,22 @@ handle_inferior_event (struct execution_control_state *ecs)
     case TARGET_WAITKIND_LOADED:
       if (debug_infrun)
         fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_LOADED\n");
-      /* Ignore gracefully during startup of the inferior, as it
-         might be the shell which has just loaded some objects,
-         otherwise add the symbols for the newly loaded objects.  */
-#ifdef SOLIB_ADD
+      /* Ignore gracefully during startup of the inferior, as it might
+         be the shell which has just loaded some objects, otherwise
+         add the symbols for the newly loaded objects.  Also ignore at
+         the beginning of an attach or remote session; we will query
+         the full list of libraries once the connection is
+         established.  */
       if (stop_soon == NO_STOP_QUIETLY)
        {
+         int breakpoints_were_inserted;
+
          /* Remove breakpoints, SOLIB_ADD might adjust
             breakpoint addresses via breakpoint_re_set.  */
+         breakpoints_were_inserted = breakpoints_inserted;
          if (breakpoints_inserted)
            remove_breakpoints ();
+         breakpoints_inserted = 0;
 
          /* Check for any newly added shared libraries if we're
             supposed to be adding them automatically.  Switch
@@ -1339,17 +1330,50 @@ handle_inferior_event (struct execution_control_state *ecs)
             exec/process stratum, instead relying on the target stack
             to propagate relevant changes (stop, section table
             changed, ...) up to other layers.  */
+#ifdef SOLIB_ADD
          SOLIB_ADD (NULL, 0, &current_target, auto_solib_add);
+#else
+         solib_add (NULL, 0, &current_target, auto_solib_add);
+#endif
          target_terminal_inferior ();
 
+         /* Try to reenable shared library breakpoints, additional
+            code segments in shared libraries might be mapped in now. */
+         re_enable_breakpoints_in_shlibs ();
+
+         /* If requested, stop when the dynamic linker notifies
+            gdb of events.  This allows the user to get control
+            and place breakpoints in initializer routines for
+            dynamically loaded objects (among other things).  */
+         if (stop_on_solib_events)
+           {
+             stop_stepping (ecs);
+             return;
+           }
+
+         /* NOTE drow/2007-05-11: This might be a good place to check
+            for "catch load".  */
+
          /* Reinsert breakpoints and continue.  */
-         if (breakpoints_inserted)
-           insert_breakpoints ();
+         if (breakpoints_were_inserted)
+           {
+             insert_breakpoints ();
+             breakpoints_inserted = 1;
+           }
        }
-#endif
-      resume (0, TARGET_SIGNAL_0);
-      prepare_to_wait (ecs);
-      return;
+
+      /* If we are skipping through a shell, or through shared library
+        loading that we aren't interested in, resume the program.  If
+        we're running the program normally, also resume.  But stop if
+        we're attaching or setting up a remote connection.  */
+      if (stop_soon == STOP_QUIETLY || stop_soon == NO_STOP_QUIETLY)
+       {
+         resume (0, TARGET_SIGNAL_0);
+         prepare_to_wait (ecs);
+         return;
+       }
+
+      break;
 
     case TARGET_WAITKIND_SPURIOUS:
       if (debug_infrun)
@@ -1371,7 +1395,7 @@ handle_inferior_event (struct execution_control_state *ecs)
                                           (LONGEST) ecs->ws.value.integer));
       gdb_flush (gdb_stdout);
       target_mourn_inferior ();
-      singlestep_breakpoints_inserted_p = 0;   /* SOFTWARE_SINGLE_STEP_P() */
+      singlestep_breakpoints_inserted_p = 0;
       stop_print_frame = 0;
       stop_stepping (ecs);
       return;
@@ -1391,7 +1415,7 @@ handle_inferior_event (struct execution_control_state *ecs)
       target_mourn_inferior ();
 
       print_stop_reason (SIGNAL_EXITED, stop_signal);
-      singlestep_breakpoints_inserted_p = 0;   /* SOFTWARE_SINGLE_STEP_P() */
+      singlestep_breakpoints_inserted_p = 0;
       stop_stepping (ecs);
       return;
 
@@ -1547,8 +1571,7 @@ handle_inferior_event (struct execution_control_state *ecs)
 
   if (stepping_past_singlestep_breakpoint)
     {
-      gdb_assert (SOFTWARE_SINGLE_STEP_P ()
-                 && singlestep_breakpoints_inserted_p);
+      gdb_assert (singlestep_breakpoints_inserted_p);
       gdb_assert (ptid_equal (singlestep_ptid, ecs->ptid));
       gdb_assert (!ptid_equal (singlestep_ptid, saved_singlestep_ptid));
 
@@ -1580,6 +1603,37 @@ handle_inferior_event (struct execution_control_state *ecs)
 
   stepping_past_singlestep_breakpoint = 0;
 
+  if (stepping_past_breakpoint)
+    {
+      stepping_past_breakpoint = 0;
+
+      /* If we stopped for some other reason than single-stepping, ignore
+        the fact that we were supposed to switch back.  */
+      if (stop_signal == TARGET_SIGNAL_TRAP)
+       {
+         if (debug_infrun)
+           fprintf_unfiltered (gdb_stdlog,
+                               "infrun: stepping_past_breakpoint\n");
+
+         /* Pull the single step breakpoints out of the target.  */
+         if (singlestep_breakpoints_inserted_p)
+           {
+             remove_single_step_breakpoints ();
+             singlestep_breakpoints_inserted_p = 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 (stepping_past_breakpoint_ptid);
+         /* Suppress spurious "Switching to ..." message.  */
+         previous_inferior_ptid = inferior_ptid;
+
+         resume (1, TARGET_SIGNAL_0);
+         prepare_to_wait (ecs);
+         return;
+       }
+    }
+
   /* See if a thread hit a thread-specific breakpoint that was meant for
      another thread.  If so, then step that thread past the breakpoint,
      and continue it.  */
@@ -1597,7 +1651,7 @@ handle_inferior_event (struct execution_control_state *ecs)
          if (!breakpoint_thread_match (stop_pc, ecs->ptid))
            thread_hop_needed = 1;
        }
-      else if (SOFTWARE_SINGLE_STEP_P () && singlestep_breakpoints_inserted_p)
+      else if (singlestep_breakpoints_inserted_p)
        {
          /* We have not context switched yet, so this should be true
             no matter which thread hit the singlestep breakpoint.  */
@@ -1668,7 +1722,7 @@ handle_inferior_event (struct execution_control_state *ecs)
          /* Saw a breakpoint, but it was hit by the wrong thread.
             Just continue. */
 
-         if (SOFTWARE_SINGLE_STEP_P () && singlestep_breakpoints_inserted_p)
+         if (singlestep_breakpoints_inserted_p)
            {
              /* Pull the single step breakpoints out of the target. */
              remove_single_step_breakpoints ();
@@ -1717,7 +1771,7 @@ handle_inferior_event (struct execution_control_state *ecs)
              return;
            }
        }
-      else if (SOFTWARE_SINGLE_STEP_P () && singlestep_breakpoints_inserted_p)
+      else if (singlestep_breakpoints_inserted_p)
        {
          sw_single_step_trap_p = 1;
          ecs->random_signal = 0;
@@ -1739,7 +1793,7 @@ handle_inferior_event (struct execution_control_state *ecs)
        deprecated_context_hook (pid_to_thread_id (ecs->ptid));
     }
 
-  if (SOFTWARE_SINGLE_STEP_P () && singlestep_breakpoints_inserted_p)
+  if (singlestep_breakpoints_inserted_p)
     {
       /* Pull the single step breakpoints out of the target. */
       remove_single_step_breakpoints ();
@@ -1805,7 +1859,8 @@ handle_inferior_event (struct execution_control_state *ecs)
      will both be 0 if it doesn't work.  */
   find_pc_partial_function (stop_pc, &ecs->stop_func_name,
                            &ecs->stop_func_start, &ecs->stop_func_end);
-  ecs->stop_func_start += DEPRECATED_FUNCTION_START_OFFSET;
+  ecs->stop_func_start
+    += gdbarch_deprecated_function_start_offset (current_gdbarch);
   ecs->another_trap = 0;
   bpstat_clear (&stop_bpstat);
   stop_step = 0;
@@ -1873,7 +1928,8 @@ handle_inferior_event (struct execution_control_state *ecs)
          && (stop_signal == TARGET_SIGNAL_ILL
              || stop_signal == TARGET_SIGNAL_SEGV
              || stop_signal == TARGET_SIGNAL_EMT))
-      || stop_soon == STOP_QUIETLY || stop_soon == STOP_QUIETLY_NO_SIGSTOP)
+      || stop_soon == STOP_QUIETLY || stop_soon == STOP_QUIETLY_NO_SIGSTOP
+      || stop_soon == STOP_QUIETLY_REMOTE)
     {
       if (stop_signal == TARGET_SIGNAL_TRAP && stop_after_trap)
        {
@@ -1886,7 +1942,7 @@ handle_inferior_event (struct execution_control_state *ecs)
 
       /* This is originated from start_remote(), start_inferior() and
          shared libraries hook functions.  */
-      if (stop_soon == STOP_QUIETLY)
+      if (stop_soon == STOP_QUIETLY || stop_soon == STOP_QUIETLY_REMOTE)
        {
           if (debug_infrun)
            fprintf_unfiltered (gdb_stdlog, "infrun: quietly stopped\n");
@@ -2076,7 +2132,8 @@ process_event_stop_test:
        remove_breakpoints ();
        breakpoints_inserted = 0;
        if (!gdbarch_get_longjmp_target_p (current_gdbarch)
-           || !gdbarch_get_longjmp_target (current_gdbarch, &jmp_buf_pc))
+           || !gdbarch_get_longjmp_target (current_gdbarch,
+                                           get_current_frame (), &jmp_buf_pc))
          {
            keep_going (ecs);
            return;
@@ -2455,9 +2512,10 @@ process_event_stop_test:
          function.  That's what tells us (a) whether we want to step
          into it at all, and (b) what prologue we want to run to the
          end of, if we do step into it.  */
-      real_stop_pc = skip_language_trampoline (stop_pc);
+      real_stop_pc = skip_language_trampoline (get_current_frame (), stop_pc);
       if (real_stop_pc == 0)
-       real_stop_pc = SKIP_TRAMPOLINE_CODE (stop_pc);
+       real_stop_pc = gdbarch_skip_trampoline_code
+                        (current_gdbarch, get_current_frame (), stop_pc);
       if (real_stop_pc != 0)
        ecs->stop_func_start = real_stop_pc;
 
@@ -2515,10 +2573,13 @@ process_event_stop_test:
 
   /* If we're in the return path from a shared library trampoline,
      we want to proceed through the trampoline when stepping.  */
-  if (IN_SOLIB_RETURN_TRAMPOLINE (stop_pc, ecs->stop_func_name))
+  if (gdbarch_in_solib_return_trampoline (current_gdbarch,
+                                         stop_pc, ecs->stop_func_name))
     {
       /* Determine where this trampoline returns.  */
-      CORE_ADDR real_stop_pc = SKIP_TRAMPOLINE_CODE (stop_pc);
+      CORE_ADDR real_stop_pc;
+      real_stop_pc = gdbarch_skip_trampoline_code
+                      (current_gdbarch, get_current_frame (), stop_pc);
 
       if (debug_infrun)
         fprintf_unfiltered (gdb_stdlog, "infrun: stepped into solib return tramp\n");
@@ -2708,7 +2769,8 @@ step_into_function (struct execution_control_state *ecs)
 
   s = find_pc_symtab (stop_pc);
   if (s && s->language != language_asm)
-    ecs->stop_func_start = SKIP_PROLOGUE (ecs->stop_func_start);
+    ecs->stop_func_start = gdbarch_skip_prologue
+                            (current_gdbarch, ecs->stop_func_start);
 
   ecs->sal = find_pc_line (ecs->stop_func_start, 0);
   /* Use the step_resume_break to step until the end of the prologue,
@@ -2806,9 +2868,11 @@ insert_step_resume_breakpoint_at_frame (struct frame_info *return_frame)
 {
   struct symtab_and_line sr_sal;
 
+  gdb_assert (return_frame != NULL);
   init_sal (&sr_sal);          /* initialize to zeros */
 
-  sr_sal.pc = ADDR_BITS_REMOVE (get_frame_pc (return_frame));
+  sr_sal.pc = gdbarch_addr_bits_remove
+               (current_gdbarch, get_frame_pc (return_frame));
   sr_sal.section = find_pc_overlay (sr_sal.pc);
 
   insert_step_resume_breakpoint_at_sal (sr_sal, get_frame_id (return_frame));
@@ -2840,7 +2904,8 @@ insert_step_resume_breakpoint_at_caller (struct frame_info *next_frame)
 
   init_sal (&sr_sal);          /* initialize to zeros */
 
-  sr_sal.pc = ADDR_BITS_REMOVE (frame_pc_unwind (next_frame));
+  sr_sal.pc = gdbarch_addr_bits_remove
+               (current_gdbarch, frame_pc_unwind (next_frame));
   sr_sal.section = find_pc_overlay (sr_sal.pc);
 
   insert_step_resume_breakpoint_at_sal (sr_sal, frame_unwind_id (next_frame));
@@ -3081,12 +3146,12 @@ normal_stop (void)
   /* NOTE drow/2004-01-17: Is this still necessary?  */
   /* Make sure that the current_frame's pc is correct.  This
      is a correction for setting up the frame info before doing
-     DECR_PC_AFTER_BREAK */
+     gdbarch_decr_pc_after_break */
   if (target_has_execution)
     /* FIXME: cagney/2002-12-06: Has the PC changed?  Thanks to
-       DECR_PC_AFTER_BREAK, the program counter can change.  Ask the
+       gdbarch_decr_pc_after_break, the program counter can change.  Ask the
        frame code to check for this and sort out any resultant mess.
-       DECR_PC_AFTER_BREAK needs to just go away.  */
+       gdbarch_decr_pc_after_break needs to just go away.  */
     deprecated_update_frame_pc_hack (get_current_frame (), read_pc ());
 
   if (target_has_execution && breakpoints_inserted)
@@ -3163,6 +3228,18 @@ Further execution is probably impossible.\n"));
          switch (bpstat_ret)
            {
            case PRINT_UNKNOWN:
+             /* If we had hit a shared library event breakpoint,
+                bpstat_print would print out this message.  If we hit
+                an OS-level shared library event, do the same
+                thing.  */
+             if (last.kind == TARGET_WAITKIND_LOADED)
+               {
+                 printf_filtered (_("Stopped due to shared library event\n"));
+                 source_flag = SRC_LINE;       /* something bogus */
+                 do_frame_printing = 0;
+                 break;
+               }
+
              /* FIXME: cagney/2002-12-01: Given that a frame ID does
                 (or should) carry around the function and does (or
                 should) use that when doing a frame comparison.  */
@@ -3207,9 +3284,15 @@ Further execution is probably impossible.\n"));
   /* Save the function value return registers, if we care.
      We might be about to restore their previous contents.  */
   if (proceed_to_finish)
-    /* NB: The copy goes through to the target picking up the value of
-       all the registers.  */
-    regcache_cpy (stop_registers, current_regcache);
+    {
+      /* This should not be necessary.  */
+      if (stop_registers)
+       regcache_xfree (stop_registers);
+
+      /* NB: The copy goes through to the target picking up the value of
+        all the registers.  */
+      stop_registers = regcache_dup (get_current_regcache ());
+    }
 
   if (stop_stack_dummy)
     {
@@ -3608,7 +3691,6 @@ struct inferior_status
   CORE_ADDR step_resume_break_address;
   int stop_after_trap;
   int stop_soon;
-  struct regcache *stop_registers;
 
   /* These are here because if call_function_by_hand has written some
      registers and then decides to call error(), we better not have changed
@@ -3664,9 +3746,7 @@ save_inferior_status (int restore_stack_info)
   inf_status->restore_stack_info = restore_stack_info;
   inf_status->proceed_to_finish = proceed_to_finish;
 
-  inf_status->stop_registers = regcache_dup_no_passthrough (stop_registers);
-
-  inf_status->registers = regcache_dup (current_regcache);
+  inf_status->registers = regcache_dup (get_current_regcache ());
 
   inf_status->selected_frame_id = get_frame_id (get_selected_frame (NULL));
   return inf_status;
@@ -3713,15 +3793,11 @@ restore_inferior_status (struct inferior_status *inf_status)
   breakpoint_proceeded = inf_status->breakpoint_proceeded;
   proceed_to_finish = inf_status->proceed_to_finish;
 
-  /* FIXME: Is the restore of stop_registers always needed. */
-  regcache_xfree (stop_registers);
-  stop_registers = inf_status->stop_registers;
-
   /* The inferior can be gone if the user types "print exit(0)"
      (and perhaps other times).  */
   if (target_has_execution)
     /* NB: The register write goes through to the target.  */
-    regcache_cpy (current_regcache, inf_status->registers);
+    regcache_cpy (get_current_regcache (), inf_status->registers);
   regcache_xfree (inf_status->registers);
 
   /* FIXME: If we are being called after stopping in a function which
@@ -3767,7 +3843,6 @@ discard_inferior_status (struct inferior_status *inf_status)
   /* See save_inferior_status for info on stop_bpstat. */
   bpstat_clear (&inf_status->stop_bpstat);
   regcache_xfree (inf_status->registers);
-  regcache_xfree (inf_status->stop_registers);
   xfree (inf_status);
 }
 
@@ -3910,12 +3985,6 @@ save_inferior_ptid (void)
 }
 \f
 
-static void
-build_infrun (void)
-{
-  stop_registers = regcache_xmalloc (current_gdbarch);
-}
-
 void
 _initialize_infrun (void)
 {
@@ -3923,9 +3992,6 @@ _initialize_infrun (void)
   int numsigs;
   struct cmd_list_element *c;
 
-  DEPRECATED_REGISTER_GDBARCH_SWAP (stop_registers);
-  deprecated_register_gdbarch_swap (NULL, 0, build_infrun);
-
   add_info ("signals", signals_info, _("\
 What debugger does when program gets various signals.\n\
 Specify a signal as argument to print info on that signal only."));
This page took 0.03468 seconds and 4 git commands to generate.