2001-06-01 Michael Snyder <msnyder@redhat.com>
[deliverable/binutils-gdb.git] / gdb / infrun.c
index a62a72c069cc673e16f22eee8cfa48808ce0011e..aa93cf56a02e0d76b36b3ea675210676624e2b5a 100644 (file)
@@ -1472,12 +1472,16 @@ handle_inferior_event (struct execution_control_state *ecs)
 
        /* We need to restart all the threads now,
         * unless we're running in scheduler-locked mode. 
-        * FIXME: shouldn't we look at currently_stepping ()?
+        * Use currently_stepping to determine whether to 
+        * step or continue.
         */
+
        if (scheduler_mode == schedlock_on)
-         target_resume (ecs->ptid, 0, TARGET_SIGNAL_0);
+         target_resume (ecs->ptid, 
+                        currently_stepping (ecs), TARGET_SIGNAL_0);
        else
-         target_resume (RESUME_ALL, 0, TARGET_SIGNAL_0);
+         target_resume (RESUME_ALL, 
+                        currently_stepping (ecs), TARGET_SIGNAL_0);
        ecs->infwait_state = infwait_normal_state;
        prepare_to_wait (ecs);
        return;
@@ -1879,6 +1883,21 @@ handle_inferior_event (struct execution_control_state *ecs)
                if (remove_status != 0)
                  {
                    write_pc_pid (stop_pc - DECR_PC_AFTER_BREAK + 4, ecs->ptid);
+                   /* We need to restart all the threads now,
+                    * unles we're running in scheduler-locked mode. 
+                    * Use currently_stepping to determine whether to 
+                    * step or continue.
+                    */
+                   if (scheduler_mode == schedlock_on)
+                     target_resume (ecs->ptid, 
+                                    currently_stepping (ecs), 
+                                    TARGET_SIGNAL_0);
+                   else
+                     target_resume (RESUME_ALL, 
+                                    currently_stepping (ecs), 
+                                    TARGET_SIGNAL_0);
+                   prepare_to_wait (ecs);
+                   return;
                  }
                else
                  {             /* Single step */
@@ -1892,17 +1911,6 @@ handle_inferior_event (struct execution_control_state *ecs)
                    prepare_to_wait (ecs);
                    return;
                  }
-
-               /* We need to restart all the threads now,
-                * unles we're running in scheduler-locked mode. 
-                * FIXME: shouldn't we look at currently_stepping ()?
-                */
-               if (scheduler_mode == schedlock_on)
-                 target_resume (ecs->ptid, 0, TARGET_SIGNAL_0);
-               else
-                 target_resume (RESUME_ALL, 0, TARGET_SIGNAL_0);
-               prepare_to_wait (ecs);
-               return;
              }
            else
              {
@@ -4192,6 +4200,90 @@ discard_inferior_status (struct inferior_status *inf_status)
   free_inferior_status (inf_status);
 }
 
+/* Oft used ptids */
+ptid_t null_ptid;
+ptid_t minus_one_ptid;
+
+/* Create a ptid given the necessary PID, LWP, and TID components.  */
+   
+ptid_t
+ptid_build (int pid, long lwp, long tid)
+{
+  ptid_t ptid;
+
+  ptid.pid = pid;
+  ptid.lwp = lwp;
+  ptid.tid = tid;
+  return ptid;
+}
+
+/* Create a ptid from just a pid.  */
+
+ptid_t
+pid_to_ptid (int pid)
+{
+  return ptid_build (pid, 0, 0);
+}
+
+/* Fetch the pid (process id) component from a ptid.  */
+
+int
+ptid_get_pid (ptid_t ptid)
+{
+  return ptid.pid;
+}
+
+/* Fetch the lwp (lightweight process) component from a ptid.  */
+
+long
+ptid_get_lwp (ptid_t ptid)
+{
+  return ptid.lwp;
+}
+
+/* Fetch the tid (thread id) component from a ptid.  */
+
+long
+ptid_get_tid (ptid_t ptid)
+{
+  return ptid.tid;
+}
+
+/* ptid_equal() is used to test equality of two ptids.  */
+
+int
+ptid_equal (ptid_t ptid1, ptid_t ptid2)
+{
+  return (ptid1.pid == ptid2.pid && ptid1.lwp == ptid2.lwp
+          && ptid1.tid == ptid2.tid);
+}
+
+/* restore_inferior_ptid() will be used by the cleanup machinery
+   to restore the inferior_ptid value saved in a call to
+   save_inferior_ptid().  */
+
+static void
+restore_inferior_ptid (void *arg)
+{
+  ptid_t *saved_ptid_ptr = arg;
+  inferior_ptid = *saved_ptid_ptr;
+  xfree (arg);
+}
+
+/* Save the value of inferior_ptid so that it may be restored by a
+   later call to do_cleanups().  Returns the struct cleanup pointer
+   needed for later doing the cleanup.  */
+
+struct cleanup *
+save_inferior_ptid (void)
+{
+  ptid_t *saved_ptid_ptr;
+
+  saved_ptid_ptr = xmalloc (sizeof (ptid_t));
+  *saved_ptid_ptr = inferior_ptid;
+  return make_cleanup (restore_inferior_ptid, saved_ptid_ptr);
+}
+
 \f
 static void
 build_infrun (void)
@@ -4376,4 +4468,10 @@ instruction of that function. Otherwise, the function is skipped and\n\
 the step command stops at a different source line.",
                        &setlist);
   add_show_from_set (c, &showlist);
+
+  /* ptid initializations */
+  null_ptid = ptid_build (0, 0, 0);
+  minus_one_ptid = ptid_build (-1, 0, 0);
+  inferior_ptid = null_ptid;
+  target_last_wait_ptid = minus_one_ptid;
 }
This page took 0.025534 seconds and 4 git commands to generate.