Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Jul 2004 13:58:28 GMT
From:      David Xu <davidxu@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 56958 for review
Message-ID:  <200407101358.i6ADwSvM027328@repoman.freebsd.org>

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

Change 56958 by davidxu@davidxu_alona on 2004/07/10 13:58:25

	Introduce PT_SUSPEND to suspend thread, PT_RESUME to resume a thread
	previously suspended by debugger. Call thread_continued() hook after
	continued a process.

Affected files ...

.. //depot/projects/davidxu_ksedbg/src/sys/kern/sys_process.c#8 edit
.. //depot/projects/davidxu_ksedbg/src/sys/sys/ptrace.h#3 edit

Differences ...

==== //depot/projects/davidxu_ksedbg/src/sys/kern/sys_process.c#8 (text+ko) ====

@@ -559,6 +559,25 @@
 			goto fail;
 		PROC_UNLOCK(p);
 		return (0);
+
+	case PT_SUSPEND:
+		_PHOLD(p);
+		mtx_lock_spin(&sched_lock);
+		td2->td_flags |= TDF_DBSUSPEND;
+		mtx_unlock_spin(&sched_lock);
+		_PRELE(p);
+		PROC_UNLOCK(p);
+		return (0);
+
+	case PT_RESUME:
+		_PHOLD(p);
+		mtx_lock_spin(&sched_lock);
+		td2->td_flags &= ~TDF_DBSUSPEND;
+		mtx_unlock_spin(&sched_lock);
+		_PRELE(p);
+		PROC_UNLOCK(p);
+		return (0);
+
 	case PT_STEP:
 	case PT_CONTINUE:
 	case PT_TO_SCE:
@@ -640,14 +659,19 @@
 					p->p_xthread->td_xsig = data;
 					p->p_xthread = NULL;
 				}
-				thread_unsuspend(p);
 			} else {
 				td2->td_flags &= ~TDF_XSIG;
 				td2->td_xsig = data;
 				if (p->p_xthread == td2)
 					p->p_xthread = NULL;
-				thread_unsuspend_one(td2);
 			}
+			/*
+			 * unsuspend all threads, to not let a thread run,
+			 * you should use PT_SUSPEND to suspend it before
+			 * continuing process.
+			 */
+			thread_unsuspend(p);
+			thread_continued(p);
 			mtx_unlock_spin(&sched_lock);
 		} else if (data) {
 			psignal(p, data);

==== //depot/projects/davidxu_ksedbg/src/sys/sys/ptrace.h#3 (text+ko) ====

@@ -63,6 +63,8 @@
 #define PT_GETTHRLIST   41	/* get thread list */
 #define PT_CLEARSTEP    42	/* turn off single step */
 #define PT_SETSTEP      43	/* turn on single step */
+#define PT_SUSPEND      44	/* suspend a thread */
+#define PT_RESUME       45	/* resume a thread */
 #define PT_FIRSTMACH    64	/* for machine-specific requests */
 #include <machine/ptrace.h>	/* machine-specific requests, if any */
 



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