Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Jul 2004 07:57:00 GMT
From:      David Xu <davidxu@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 57771 for review
Message-ID:  <200407200757.i6K7v034085399@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=57771

Change 57771 by davidxu@davidxu_celeron on 2004/07/20 07:56:28

	Don't forget to unbind the temporarily bound thread.

Affected files ...

.. //depot/projects/davidxu_ksedbg/src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c#16 edit

Differences ...

==== //depot/projects/davidxu_ksedbg/src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c#16 (text+ko) ====

@@ -72,6 +72,8 @@
 /* The last thread we are single stepping */
 static lwpid_t last_single_step_lwp;
 
+static ptid_t last_single_step_ptid;
+
 /* Pointers to the libthread_db functions.  */
 
 static td_err_e (*td_init_p) (void);
@@ -115,6 +117,7 @@
 
 /* Prototypes for local functions.  */
 static void fbsd_thread_find_new_threads (void);
+static int fbsd_thread_alive (ptid_t ptid);
 
 /* Building process ids.  */
 
@@ -409,6 +412,26 @@
       work_ptid = inferior_ptid;
     }
 
+  /*
+   * For KSE thread, if last time we were single stepping
+   * a thread, first we unbind thread because we had bound it,
+   * may rebind it in following code.
+   */
+  if (!ptid_equal(last_single_step_ptid, null_ptid))
+    {
+      ret = td_ta_map_id2thr_p (thread_agent,
+                                GET_THREAD(last_single_step_ptid), &th);
+      if (ret == TD_OK)
+        {
+          /* 
+           * keep stepping flag (may be cleared in following code),
+           * but unbind the thread
+           */
+          td_thr_sstep_p (&th, 1);
+        }
+      	last_single_step_ptid = null_ptid;
+    }
+
   lwp = GET_LWP (work_ptid);
   if (lwp == 0)
     {
@@ -418,13 +441,13 @@
         error (thread_db_err_str (ret));
 
       /*
-       * For M:N thread, we need to tell UTS to set/unset single step
+       * For KSE thread, we need to tell UTS to set/unset single step
        * flag at context switch time, the flag will be written into
        * thread mailbox. This becauses some architecture may not have
        * machine single step flag in ucontext, so we put the flag in mailbox,
        * when the thread switches back, kse_switchin restores the single step
        * state.
-       */ 
+       */
       ret = td_thr_sstep_p (&th, resume_all ? step : 2);
       if (ret)
         error (thread_db_err_str (ret));
@@ -432,6 +455,8 @@
       if (ret)
         error (thread_db_err_str (ret));
       lwp = ti.ti_lid;
+      if (!resume_all)
+      	last_single_step_ptid = work_ptid;
     }
 
   if (!resume_all && lwp == 0)
@@ -457,6 +482,14 @@
       free (lwps);
     }
 
+  /*
+   * FIX ME! if we can let PT_CONTINUE continue a single lwp,
+   * we needn't to iterate through lwp list to suspend/resume them,
+   * we just let the lwp run, this frees PT_SUSPEND PT_RESUME to user,
+   * so td_thr_dbsuspend/resume can be used to suspend or resume
+   * thread by user on command line...
+   */
+ 
   int i;
   if (last_single_step_lwp != 0)
     {
@@ -483,10 +516,9 @@
     last_single_step_lwp = 0;
 
   free (lwps);
-/*  ret = ptrace(PT_RESUME, lwp, 0, 0); */
 
   /* now continue the process, suspended thread wont run */
-  if (ptrace (PT_CONTINUE, proc_handle.pid , (caddr_t)1,
+  if (ptrace (PT_CONTINUE, proc_handle.pid, (caddr_t)1,
 	      target_signal_to_host(signo)))
     perror_with_name ("PT_CONTINUE");
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200407200757.i6K7v034085399>