Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Jul 2004 14:24:01 GMT
From:      David Xu <davidxu@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 56962 for review
Message-ID:  <200407101424.i6AEO1Vj027951@repoman.freebsd.org>

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

Change 56962 by davidxu@davidxu_alona on 2004/07/10 14:23:47

	Implement td_thr_suspend/td_thr_resume, not tested, not finished yet.

Affected files ...

.. //depot/projects/davidxu_ksedbg/src/lib/libthread_db/pthread/pthread_db.c#6 edit

Differences ...

==== //depot/projects/davidxu_ksedbg/src/lib/libthread_db/pthread/pthread_db.c#6 (text+ko) ====

@@ -799,17 +799,88 @@
 }
 
 static td_err_e
+pt_dbsuspend(const td_thrhandle_t *th, int suspend)
+{
+	pt_thragent_t *ta = (pt_thragent_t *)th->th_ta_p;
+	psaddr_t tcb_addr, tmbx_addr, ptr;
+	lwpid_t lwp;
+	uint32_t dflags;
+	int attrflags;
+	int ret;
+
+	TDBG_FUNC();
+
+	ret = pt_validate(th);
+	if (ret)
+		return (ret);
+
+	if (ta->map[th->th_unique].type == PT_LWP) {
+#if 0
+		if (suspend)
+			ret = ps_lstop(ta->ph, ta->map[th->th_unique].lwp);
+		else
+			ret = ps_lcontinue(ta->ph, ta->map[th->th_unique].lwp);
+#else
+		ret = 0;
+#endif
+		return (P2T(ret));
+	}
+
+	ret = ps_pdread(ta->ph, ta->map[th->th_unique].thr +
+		offsetof(struct pthread, attr.flags),
+		&attrflags, sizeof(attrflags));
+	if (ret != 0)
+		return (P2T(ret));
+	ret = ps_pdread(ta->ph, ta->map[th->th_unique].thr +
+	                offsetof(struct pthread, tcb),
+	                &tcb_addr, sizeof(tcb_addr));
+	if (ret != 0)
+		return (P2T(ret));
+	tmbx_addr = tcb_addr + offsetof(struct tcb, tcb_tmbx);
+	ptr = tmbx_addr + offsetof(struct kse_thr_mailbox, tm_lwp);
+	ret = ps_pdread(ta->ph, ptr, &lwp, sizeof(lwpid_t));
+	if (ret != 0)
+		return (P2T(ret));
+	if (lwp != 0 && (attrflags & PTHREAD_SCOPE_SYSTEM)) {
+#if 0
+		if (suspend)
+			ret = ps_lstop(ta->ph, lwp);
+		else
+			ret = ps_lcontinue(ta->ph, lwp);
+#else
+		ret = 0;
+#endif
+		return (P2T(ret));
+	}
+
+	ret = ps_pdread(ta->ph,
+		tmbx_addr + offsetof(struct kse_thr_mailbox, tm_dflags),
+		&dflags, sizeof(dflags));
+	if (ret != 0)
+		return (P2T(ret));
+
+	if (suspend)
+		dflags |= TMDF_DONOTRUNUSER;
+	else
+		dflags &= ~TMDF_DONOTRUNUSER;
+	ret = ps_pdwrite(ta->ph,
+	       tmbx_addr + offsetof(struct kse_thr_mailbox, tm_dflags),
+	       &dflags, sizeof(dflags));
+	return (P2T(ret));
+}
+
+static td_err_e
 pt_thr_dbsuspend(const td_thrhandle_t *th)
 {
 	TDBG_FUNC();
-	return (TD_ERR);
+	return pt_dbsuspend(th, 1);
 }
 
 static td_err_e
 pt_thr_dbresume(const td_thrhandle_t *th)
 {
 	TDBG_FUNC();
-	return (TD_ERR);
+	return pt_dbsuspend(th, 0);
 }
 
 static td_err_e



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