Fix gprof build
[deliverable/binutils-gdb.git] / gdb / infrun.c
index 4f224562259ed87214cb3914a7308b3713f64ed4..c9e2fe22f48d23b067099246f999013c63d5a58b 100644 (file)
@@ -2439,6 +2439,7 @@ static void check_exception_resume (struct execution_control_state *,
 static void stop_stepping (struct execution_control_state *ecs);
 static void prepare_to_wait (struct execution_control_state *ecs);
 static void keep_going (struct execution_control_state *ecs);
+static void process_event_stop_test (struct execution_control_state *ecs);
 static int switch_back_to_stepped_thread (struct execution_control_state *ecs);
 
 /* Callback for iterate over threads.  If the thread is stopped, but
@@ -3104,19 +3105,17 @@ handle_syscall_event (struct execution_control_state *ecs)
                              stop_pc, ecs->ptid, &ecs->ws);
 
       sval = bpstat_explains_signal (ecs->event_thread->control.stop_bpstat,
-                                    GDB_SIGNAL_TRAP);
+                                    GDB_SIGNAL_0);
       ecs->random_signal = sval == BPSTAT_SIGNAL_NO;
 
       if (!ecs->random_signal)
        {
          /* Catchpoint hit.  */
-         ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_TRAP;
          return 0;
        }
     }
 
   /* If no catchpoint triggered for this, then keep going.  */
-  ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_0;
   keep_going (ecs);
   return 1;
 }
@@ -3151,7 +3150,6 @@ handle_inferior_event (struct execution_control_state *ecs)
   struct gdbarch *gdbarch;
   int stopped_by_watchpoint;
   int stepped_after_stopped_by_watchpoint = 0;
-  struct symtab_and_line stop_pc_sal;
   enum stop_kind stop_soon;
 
   if (ecs->ws.kind == TARGET_WAITKIND_IGNORE)
@@ -3344,14 +3342,14 @@ handle_inferior_event (struct execution_control_state *ecs)
 
          sval
            = bpstat_explains_signal (ecs->event_thread->control.stop_bpstat,
-                                     GDB_SIGNAL_TRAP);
+                                     GDB_SIGNAL_0);
          ecs->random_signal = sval == BPSTAT_SIGNAL_NO;
 
          if (!ecs->random_signal)
            {
              /* A catchpoint triggered.  */
-             ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_TRAP;
-             goto process_event_stop_test;
+             process_event_stop_test (ecs);
+             return;
            }
 
          /* If requested, stop when the dynamic linker notifies
@@ -3628,8 +3626,8 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
            stop_stepping (ecs);
          return;
        }
-      ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_TRAP;
-      goto process_event_stop_test;
+      process_event_stop_test (ecs);
+      return;
 
     case TARGET_WAITKIND_VFORK_DONE:
       /* Done with the shared memory region.  Re-insert breakpoints in
@@ -3674,7 +3672,7 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
                              stop_pc, ecs->ptid, &ecs->ws);
       ecs->random_signal
        = (bpstat_explains_signal (ecs->event_thread->control.stop_bpstat,
-                                  GDB_SIGNAL_TRAP)
+                                  GDB_SIGNAL_0)
           == BPSTAT_SIGNAL_NO);
 
       /* Note that this may be referenced from inside
@@ -3689,8 +3687,8 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
          keep_going (ecs);
          return;
        }
-      ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_TRAP;
-      goto process_event_stop_test;
+      process_event_stop_test (ecs);
+      return;
 
       /* Be careful not to try to gather much state about a thread
          that's in a syscall.  It's frequently a losing proposition.  */
@@ -3699,9 +3697,9 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
         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;
+      if (handle_syscall_event (ecs) == 0)
+       process_event_stop_test (ecs);
+      return;
 
       /* Before examining the threads further, step this thread to
          get it entirely out of the syscall.  (We get notice of the
@@ -3712,9 +3710,9 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
       if (debug_infrun)
         fprintf_unfiltered (gdb_stdlog,
                            "infrun: TARGET_WAITKIND_SYSCALL_RETURN\n");
-      if (handle_syscall_event (ecs) != 0)
-        return;
-      goto process_event_stop_test;
+      if (handle_syscall_event (ecs) == 0)
+       process_event_stop_test (ecs);
+      return;
 
     case TARGET_WAITKIND_STOPPED:
       if (debug_infrun)
@@ -4285,7 +4283,7 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
       ecs->random_signal = (sval == BPSTAT_SIGNAL_NO);
 
       if (sval == BPSTAT_SIGNAL_HIDE)
-       ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_TRAP;
+       ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_0;
     }
 
   /* For the program's own signals, act according to
@@ -4403,239 +4401,245 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
        }
       return;
     }
-  else
-    {
-      /* Handle cases caused by hitting a breakpoint.  */
 
-      CORE_ADDR jmp_buf_pc;
-      struct bpstat_what what;
+  process_event_stop_test (ecs);
+}
 
-process_event_stop_test:
+/* Come here when we've got some debug event / signal we can explain
+   (IOW, not a random signal), and test whether it should cause a
+   stop, or whether we should resume the inferior (transparently).
+   E.g., could be a breakpoint whose condition evaluates false; we
+   could be still stepping within the line; etc.  */
 
-      /* Re-fetch current thread's frame in case we did a
-        "goto process_event_stop_test" above.  */
-      frame = get_current_frame ();
-      gdbarch = get_frame_arch (frame);
+static void
+process_event_stop_test (struct execution_control_state *ecs)
+{
+  struct symtab_and_line stop_pc_sal;
+  struct frame_info *frame;
+  struct gdbarch *gdbarch;
+  CORE_ADDR jmp_buf_pc;
+  struct bpstat_what what;
 
-      what = bpstat_what (ecs->event_thread->control.stop_bpstat);
+  /* Handle cases caused by hitting a breakpoint.  */
 
-      if (what.call_dummy)
-       {
-         stop_stack_dummy = what.call_dummy;
-       }
+  frame = get_current_frame ();
+  gdbarch = get_frame_arch (frame);
 
-      /* If we hit an internal event that triggers symbol changes, the
-        current frame will be invalidated within bpstat_what (e.g.,
-        if we hit an internal solib event).  Re-fetch it.  */
-      frame = get_current_frame ();
-      gdbarch = get_frame_arch (frame);
+  what = bpstat_what (ecs->event_thread->control.stop_bpstat);
 
-      switch (what.main_action)
-       {
-       case BPSTAT_WHAT_SET_LONGJMP_RESUME:
-         /* If we hit the breakpoint at longjmp while stepping, we
-            install a momentary breakpoint at the target of the
-            jmp_buf.  */
+  if (what.call_dummy)
+    {
+      stop_stack_dummy = what.call_dummy;
+    }
 
-         if (debug_infrun)
-           fprintf_unfiltered (gdb_stdlog,
-                               "infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME\n");
+  /* If we hit an internal event that triggers symbol changes, the
+     current frame will be invalidated within bpstat_what (e.g., if we
+     hit an internal solib event).  Re-fetch it.  */
+  frame = get_current_frame ();
+  gdbarch = get_frame_arch (frame);
 
-         ecs->event_thread->stepping_over_breakpoint = 1;
+  switch (what.main_action)
+    {
+    case BPSTAT_WHAT_SET_LONGJMP_RESUME:
+      /* If we hit the breakpoint at longjmp while stepping, we
+        install a momentary breakpoint at the target of the
+        jmp_buf.  */
 
-         if (what.is_longjmp)
-           {
-             struct value *arg_value;
-
-             /* If we set the longjmp breakpoint via a SystemTap
-                probe, then use it to extract the arguments.  The
-                destination PC is the third argument to the
-                probe.  */
-             arg_value = probe_safe_evaluate_at_pc (frame, 2);
-             if (arg_value)
-               jmp_buf_pc = value_as_address (arg_value);
-             else if (!gdbarch_get_longjmp_target_p (gdbarch)
-                      || !gdbarch_get_longjmp_target (gdbarch,
-                                                      frame, &jmp_buf_pc))
-               {
-                 if (debug_infrun)
-                   fprintf_unfiltered (gdb_stdlog,
-                                       "infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME "
-                                       "(!gdbarch_get_longjmp_target)\n");
-                 keep_going (ecs);
-                 return;
-               }
+      if (debug_infrun)
+       fprintf_unfiltered (gdb_stdlog,
+                           "infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME\n");
 
-             /* Insert a breakpoint at resume address.  */
-             insert_longjmp_resume_breakpoint (gdbarch, jmp_buf_pc);
-           }
-         else
-           check_exception_resume (ecs, frame);
-         keep_going (ecs);
-         return;
+      ecs->event_thread->stepping_over_breakpoint = 1;
 
-       case BPSTAT_WHAT_CLEAR_LONGJMP_RESUME:
-         {
-           struct frame_info *init_frame;
+      if (what.is_longjmp)
+       {
+         struct value *arg_value;
+
+         /* If we set the longjmp breakpoint via a SystemTap probe,
+            then use it to extract the arguments.  The destination PC
+            is the third argument to the probe.  */
+         arg_value = probe_safe_evaluate_at_pc (frame, 2);
+         if (arg_value)
+           jmp_buf_pc = value_as_address (arg_value);
+         else if (!gdbarch_get_longjmp_target_p (gdbarch)
+                  || !gdbarch_get_longjmp_target (gdbarch,
+                                                  frame, &jmp_buf_pc))
+           {
+             if (debug_infrun)
+               fprintf_unfiltered (gdb_stdlog,
+                                   "infrun: BPSTAT_WHAT_SET_LONGJMP_RESUME "
+                                   "(!gdbarch_get_longjmp_target)\n");
+             keep_going (ecs);
+             return;
+           }
 
-           /* There are several cases to consider.
+         /* Insert a breakpoint at resume address.  */
+         insert_longjmp_resume_breakpoint (gdbarch, jmp_buf_pc);
+       }
+      else
+       check_exception_resume (ecs, frame);
+      keep_going (ecs);
+      return;
 
-              1. The initiating frame no longer exists.  In this case
-              we must stop, because the exception or longjmp has gone
-              too far.
+    case BPSTAT_WHAT_CLEAR_LONGJMP_RESUME:
+      {
+       struct frame_info *init_frame;
 
-              2. The initiating frame exists, and is the same as the
-              current frame.  We stop, because the exception or
-              longjmp has been caught.
+       /* There are several cases to consider.
 
-              3. The initiating frame exists and is different from
-              the current frame.  This means the exception or longjmp
-              has been caught beneath the initiating frame, so keep
-              going.
+          1. The initiating frame no longer exists.  In this case we
+          must stop, because the exception or longjmp has gone too
+          far.
 
-              4. longjmp breakpoint has been placed just to protect
-              against stale dummy frames and user is not interested
-              in stopping around longjmps.  */
+          2. The initiating frame exists, and is the same as the
+          current frame.  We stop, because the exception or longjmp
+          has been caught.
 
-           if (debug_infrun)
-             fprintf_unfiltered (gdb_stdlog,
-                                 "infrun: BPSTAT_WHAT_CLEAR_LONGJMP_RESUME\n");
+          3. The initiating frame exists and is different from the
+          current frame.  This means the exception or longjmp has
+          been caught beneath the initiating frame, so keep going.
 
-           gdb_assert (ecs->event_thread->control.exception_resume_breakpoint
-                       != NULL);
-           delete_exception_resume_breakpoint (ecs->event_thread);
+          4. longjmp breakpoint has been placed just to protect
+          against stale dummy frames and user is not interested in
+          stopping around longjmps.  */
 
-           if (what.is_longjmp)
-             {
-               check_longjmp_breakpoint_for_call_dummy (ecs->event_thread->num);
+       if (debug_infrun)
+         fprintf_unfiltered (gdb_stdlog,
+                             "infrun: BPSTAT_WHAT_CLEAR_LONGJMP_RESUME\n");
 
-               if (!frame_id_p (ecs->event_thread->initiating_frame))
-                 {
-                   /* Case 4.  */
-                   keep_going (ecs);
-                   return;
-                 }
-             }
+       gdb_assert (ecs->event_thread->control.exception_resume_breakpoint
+                   != NULL);
+       delete_exception_resume_breakpoint (ecs->event_thread);
 
-           init_frame = frame_find_by_id (ecs->event_thread->initiating_frame);
+       if (what.is_longjmp)
+         {
+           check_longjmp_breakpoint_for_call_dummy (ecs->event_thread->num);
 
-           if (init_frame)
+           if (!frame_id_p (ecs->event_thread->initiating_frame))
              {
-               struct frame_id current_id
-                 = get_frame_id (get_current_frame ());
-               if (frame_id_eq (current_id,
-                                ecs->event_thread->initiating_frame))
-                 {
-                   /* Case 2.  Fall through.  */
-                 }
-               else
-                 {
-                   /* Case 3.  */
-                   keep_going (ecs);
-                   return;
-                 }
+               /* Case 4.  */
+               keep_going (ecs);
+               return;
              }
+         }
 
-           /* For Cases 1 and 2, remove the step-resume breakpoint,
-              if it exists.  */
-           delete_step_resume_breakpoint (ecs->event_thread);
+       init_frame = frame_find_by_id (ecs->event_thread->initiating_frame);
 
-           ecs->event_thread->control.stop_step = 1;
-           print_end_stepping_range_reason ();
-           stop_stepping (ecs);
+       if (init_frame)
+         {
+           struct frame_id current_id
+             = get_frame_id (get_current_frame ());
+           if (frame_id_eq (current_id,
+                            ecs->event_thread->initiating_frame))
+             {
+               /* Case 2.  Fall through.  */
+             }
+           else
+             {
+               /* Case 3.  */
+               keep_going (ecs);
+               return;
+             }
          }
-         return;
 
-       case BPSTAT_WHAT_SINGLE:
-         if (debug_infrun)
-           fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_SINGLE\n");
-         ecs->event_thread->stepping_over_breakpoint = 1;
-         /* Still need to check other stuff, at least the case where
-            we are stepping and step out of the right range.  */
-         break;
+       /* For Cases 1 and 2, remove the step-resume breakpoint, if it
+          exists.  */
+       delete_step_resume_breakpoint (ecs->event_thread);
 
-       case BPSTAT_WHAT_STEP_RESUME:
-         if (debug_infrun)
-           fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_STEP_RESUME\n");
-
-         delete_step_resume_breakpoint (ecs->event_thread);
-         if (ecs->event_thread->control.proceed_to_finish
-             && execution_direction == EXEC_REVERSE)
-           {
-             struct thread_info *tp = ecs->event_thread;
-
-             /* We are finishing a function in reverse, and just hit
-                the step-resume breakpoint at the start address of
-                the function, and we're almost there -- just need to
-                back up by one more single-step, which should take us
-                back to the function call.  */
-             tp->control.step_range_start = tp->control.step_range_end = 1;
-             keep_going (ecs);
-             return;
-           }
-         fill_in_stop_func (gdbarch, ecs);
-         if (stop_pc == ecs->stop_func_start
-             && execution_direction == EXEC_REVERSE)
-           {
-             /* We are stepping over a function call in reverse, and
-                just hit the step-resume breakpoint at the start
-                address of the function.  Go back to single-stepping,
-                which should take us back to the function call.  */
-             ecs->event_thread->stepping_over_breakpoint = 1;
-             keep_going (ecs);
-             return;
-           }
-         break;
+       ecs->event_thread->control.stop_step = 1;
+       print_end_stepping_range_reason ();
+       stop_stepping (ecs);
+      }
+      return;
 
-       case BPSTAT_WHAT_STOP_NOISY:
-         if (debug_infrun)
-           fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_STOP_NOISY\n");
-         stop_print_frame = 1;
+    case BPSTAT_WHAT_SINGLE:
+      if (debug_infrun)
+       fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_SINGLE\n");
+      ecs->event_thread->stepping_over_breakpoint = 1;
+      /* Still need to check other stuff, at least the case where we
+        are stepping and step out of the right range.  */
+      break;
 
-         /* We are about to nuke the step_resume_breakpointt via the
-            cleanup chain, so no need to worry about it here.  */
+    case BPSTAT_WHAT_STEP_RESUME:
+      if (debug_infrun)
+       fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_STEP_RESUME\n");
 
-         stop_stepping (ecs);
+      delete_step_resume_breakpoint (ecs->event_thread);
+      if (ecs->event_thread->control.proceed_to_finish
+         && execution_direction == EXEC_REVERSE)
+       {
+         struct thread_info *tp = ecs->event_thread;
+
+         /* We are finishing a function in reverse, and just hit the
+            step-resume breakpoint at the start address of the
+            function, and we're almost there -- just need to back up
+            by one more single-step, which should take us back to the
+            function call.  */
+         tp->control.step_range_start = tp->control.step_range_end = 1;
+         keep_going (ecs);
+         return;
+       }
+      fill_in_stop_func (gdbarch, ecs);
+      if (stop_pc == ecs->stop_func_start
+         && execution_direction == EXEC_REVERSE)
+       {
+         /* We are stepping over a function call in reverse, and just
+            hit the step-resume breakpoint at the start address of
+            the function.  Go back to single-stepping, which should
+            take us back to the function call.  */
+         ecs->event_thread->stepping_over_breakpoint = 1;
+         keep_going (ecs);
          return;
+       }
+      break;
 
-       case BPSTAT_WHAT_STOP_SILENT:
-         if (debug_infrun)
-           fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_STOP_SILENT\n");
-         stop_print_frame = 0;
+    case BPSTAT_WHAT_STOP_NOISY:
+      if (debug_infrun)
+       fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_STOP_NOISY\n");
+      stop_print_frame = 1;
 
-         /* We are about to nuke the step_resume_breakpoin via the
-            cleanup chain, so no need to worry about it here.  */
+      /* We are about to nuke the step_resume_breakpointt via the
+        cleanup chain, so no need to worry about it here.  */
 
-         stop_stepping (ecs);
-         return;
+      stop_stepping (ecs);
+      return;
 
-       case BPSTAT_WHAT_HP_STEP_RESUME:
-         if (debug_infrun)
-           fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_HP_STEP_RESUME\n");
+    case BPSTAT_WHAT_STOP_SILENT:
+      if (debug_infrun)
+       fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_STOP_SILENT\n");
+      stop_print_frame = 0;
 
-         delete_step_resume_breakpoint (ecs->event_thread);
-         if (ecs->event_thread->step_after_step_resume_breakpoint)
-           {
-             /* Back when the step-resume breakpoint was inserted, we
-                were trying to single-step off a breakpoint.  Go back
-                to doing that.  */
-             ecs->event_thread->step_after_step_resume_breakpoint = 0;
-             ecs->event_thread->stepping_over_breakpoint = 1;
-             keep_going (ecs);
-             return;
-           }
-         break;
+      /* We are about to nuke the step_resume_breakpoin via the
+        cleanup chain, so no need to worry about it here.  */
 
-       case BPSTAT_WHAT_KEEP_CHECKING:
-         break;
+      stop_stepping (ecs);
+      return;
+
+    case BPSTAT_WHAT_HP_STEP_RESUME:
+      if (debug_infrun)
+       fprintf_unfiltered (gdb_stdlog, "infrun: BPSTAT_WHAT_HP_STEP_RESUME\n");
+
+      delete_step_resume_breakpoint (ecs->event_thread);
+      if (ecs->event_thread->step_after_step_resume_breakpoint)
+       {
+         /* Back when the step-resume breakpoint was inserted, we
+            were trying to single-step off a breakpoint.  Go back to
+            doing that.  */
+         ecs->event_thread->step_after_step_resume_breakpoint = 0;
+         ecs->event_thread->stepping_over_breakpoint = 1;
+         keep_going (ecs);
+         return;
        }
+      break;
+
+    case BPSTAT_WHAT_KEEP_CHECKING:
+      break;
     }
 
-  /* We come here if we hit a breakpoint but should not
-     stop for it.  Possibly we also were stepping
-     and should stop for that.  So fall through and
-     test for stepping.  But, if not stepping,
-     do not stop.  */
+  /* We come here if we hit a breakpoint but should not stop for it.
+     Possibly we also were stepping and should stop for that.  So fall
+     through and test for stepping.  But, if not stepping, do not
+     stop.  */
 
   /* In all-stop mode, if we're currently stepping but have stopped in
      some other thread, we need to switch back to the stepped thread.  */
This page took 0.030962 seconds and 4 git commands to generate.