PERFORCE change 56962 for review

David Xu davidxu at FreeBSD.org
Sat Jul 10 07:24:02 PDT 2004


http://perforce.freebsd.org/chv.cgi?CH=56962

Change 56962 by davidxu at 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


More information about the p4-projects mailing list