Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Jul 2004 00:17:39 GMT
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 57663 for review
Message-ID:  <200407190017.i6J0Hdhg008901@repoman.freebsd.org>

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

Change 57663 by marcel@marcel_nfs on 2004/07/19 00:17:28

	Resolve merge conflicts by making these files identical to
	CVS.

Affected files ...

.. //depot/projects/gdb/lib/libthread_db/arch/i386/libc_r_md.c#3 edit
.. //depot/projects/gdb/lib/libthread_db/libc_r_db.c#5 edit
.. //depot/projects/gdb/lib/libthread_db/libpthread_db.c#3 edit
.. //depot/projects/gdb/lib/libthread_db/libthr_db.c#4 edit
.. //depot/projects/gdb/lib/libthread_db/thread_db.c#3 edit
.. //depot/projects/gdb/lib/libthread_db/thread_db_int.h#5 edit

Differences ...

==== //depot/projects/gdb/lib/libthread_db/arch/i386/libc_r_md.c#3 (text+ko) ====

@@ -25,13 +25,13 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libthread_db/arch/i386/libc_r_md.c,v 1.1 2004/07/18 04:17:14 marcel Exp $");
 
 #include <sys/procfs.h>
 #include <machine/setjmp.h>
 
 void
-libc_r_md_getgregs(jmp_buf jb, prgregset_t *r)
+libc_r_md_getgregs(jmp_buf jb, prgregset_t r)
 {
 	r->r_eip = jb->_jb[0];
 	r->r_ebx = jb->_jb[1];

==== //depot/projects/gdb/lib/libthread_db/libc_r_db.c#5 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libthread_db/libc_r_db.c,v 1.1 2004/07/18 04:17:13 marcel Exp $");
 
 #include <machine/setjmp.h>
 #include <proc_service.h>
@@ -36,7 +36,7 @@
 #include "thread_db_int.h"
 
 void libc_r_md_getfpregs(jmp_buf jb, prfpregset_t *);
-void libc_r_md_getgregs(jmp_buf jb, prgregset_t *);
+void libc_r_md_getgregs(jmp_buf jb, prgregset_t);
 
 struct td_thragent {
 	TD_THRAGENT_FIELDS;
@@ -215,7 +215,7 @@
 	ps_err_e err;
 
 	ta = th->th_ta;
-	ti->ti_ta = ta;
+	ti->ti_ta_p = ta;
 	err = ps_pread(ta->ta_ph, ta->ta_thread_run, &current,
 	    sizeof(psaddr_t));
 	if (err != PS_OK)
@@ -254,7 +254,7 @@
 }
 
 static td_err_e
-libc_r_db_thr_getgregs(const td_thrhandle_t *th, prgregset_t *r)
+libc_r_db_thr_getgregs(const td_thrhandle_t *th, prgregset_t r)
 {
 	jmp_buf jb;
 	const td_thragent_t *ta;
@@ -291,7 +291,7 @@
 }
 
 static td_err_e
-libc_r_db_thr_setgregs(const td_thrhandle_t *th, const prgregset_t *r)
+libc_r_db_thr_setgregs(const td_thrhandle_t *th, const prgregset_t r)
 {
 	return (TD_ERR);
 }

==== //depot/projects/gdb/lib/libthread_db/libpthread_db.c#3 (text+ko) ====

@@ -25,41 +25,25 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libthread_db/libpthread_db.c,v 1.1 2004/07/18 04:17:13 marcel Exp $");
 
 #include <stddef.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 #include <pthread.h>
-#include <thr_private.h>
 #include <sys/types.h>
 #include <sys/kse.h>
 #include <sys/ptrace.h>
 #include <proc_service.h>
 #include <thread_db.h>
 
-#include "pthread_db.h"
+#include "libpthread.h"
+#include "libpthread_db.h"
 
-struct pt_map {
-	enum {
-		PT_NONE,
-		PT_USER,
-		PT_LWP
-	} type;
-
-	union {
-		lwpid_t  lwp;
-		psaddr_t thr; 
-	};
-};
-
 #define P2T(c) ps2td(c)
 
-static td_err_e pt_ta_activated(pt_thragent_t *ta, int *a);
-static long pt_map_thread(const pt_thragent_t *ta, psaddr_t pt);
-static long pt_map_lwp(const pt_thragent_t *ta, lwpid_t lwp);
-static void pt_unmap_lwp(const pt_thragent_t *ta, lwpid_t lwp);
+static void pt_unmap_lwp(const td_thragent_t *ta, lwpid_t lwp);
 static int pt_validate(const td_thrhandle_t *th);
 
 static int
@@ -85,6 +69,48 @@
 	}
 }
 
+static long
+pt_map_thread(const td_thragent_t *const_ta, psaddr_t pt, int type)
+{
+	td_thragent_t *ta = __DECONST(td_thragent_t *, const_ta);
+	struct pt_map *new;
+	int i, first = -1;
+
+	/* leave zero out */
+	for (i = 1; i < ta->map_len; ++i) {
+		if (ta->map[i].type == PT_NONE) {
+			if (first == -1)
+				first = i;
+		} else if (ta->map[i].type == type && ta->map[i].thr == pt) {
+				return (i);
+		}
+	}
+
+	if (first == -1) {
+		if (ta->map_len == 0) {
+			ta->map = calloc(20, sizeof(struct pt_map));
+			if (ta->map == NULL)
+				return (-1);
+			ta->map_len = 20;
+			first = 1;
+		} else {
+			new = realloc(ta->map,
+			              sizeof(struct pt_map) * ta->map_len * 2);
+			if (new == NULL)
+				return (-1);
+			memset(new + ta->map_len, '\0', sizeof(struct pt_map) *
+			       ta->map_len);
+			first = ta->map_len;
+			ta->map = new;
+			ta->map_len *= 2;
+		}
+	}
+
+	ta->map[first].type = type;
+	ta->map[first].thr = pt;
+	return (first);
+}
+
 static td_err_e
 pt_init(void)
 {
@@ -93,7 +119,7 @@
 }
 
 static td_err_e
-pt_ta_new(struct ps_prochandle *ph, pt_thragent_t **pta)
+pt_ta_new(struct ps_prochandle *ph, td_thragent_t **pta)
 {
 #define LOOKUP_SYM(proc, sym, addr) 			\
 	ret = ps_pglobal_lookup(proc, NULL, sym, addr);	\
@@ -103,13 +129,13 @@
 		goto error;				\
 	}
 
-	pt_thragent_t *ta;
+	td_thragent_t *ta;
 	int dbg;
 	int ret;
 
 	TDBG_FUNC();
 
-	ta = malloc(sizeof(pt_thragent_t));
+	ta = malloc(sizeof(td_thragent_t));
 	if (ta == NULL)
 		return (TD_MALLOC);
 
@@ -139,7 +165,7 @@
 }
 
 static td_err_e
-pt_ta_delete(pt_thragent_t *ta)
+pt_ta_delete(td_thragent_t *ta)
 {
 	int dbg;
 
@@ -158,28 +184,7 @@
 }
 
 static td_err_e
-pt_ta_get_nthreads (const pt_thragent_t *ta, int *np)
-{
-	int ret;
-
-	TDBG_FUNC();
-
-	ret = ps_pread(ta->ph, ta->thread_active_threads_addr, np,
-	                sizeof(int));
-	return (P2T(ret));
-}
-
-static td_err_e
-pt_ta_get_ph(const pt_thragent_t *ta, struct ps_prochandle **ph)
-{
-	TDBG_FUNC();
-
-	*ph = ta->ph;
-	return (TD_OK);
-}
-
-static td_err_e
-pt_ta_map_id2thr(const pt_thragent_t *ta, thread_t id, td_thrhandle_t *th)
+pt_ta_map_id2thr(const td_thragent_t *ta, thread_t id, td_thrhandle_t *th)
 {
 	prgregset_t gregs;
 	TAILQ_HEAD(, pthread) thread_list;
@@ -256,13 +261,13 @@
 			return (TD_NOTHR);
 		}
 	}
-	th->th_ta_p = (td_thragent_t *)ta;
-	th->th_unique = id;
+	th->th_ta = ta;
+	th->th_tid = id;
 	return (TD_OK);
 }
 
 static td_err_e
-pt_ta_map_lwp2thr(const pt_thragent_t *ta, lwpid_t lwp, td_thrhandle_t *th)
+pt_ta_map_lwp2thr(const td_thragent_t *ta, lwpid_t lwp, td_thrhandle_t *th)
 {
 	TAILQ_HEAD(, pthread) thread_list;
 	psaddr_t pt, ptr;
@@ -286,9 +291,9 @@
 		if (ret != 0)
 			return (P2T(ret));
 		if (tmp_lwp == lwp) {
-			th->th_ta_p = (td_thragent_t *)ta;
-			th->th_unique = pt_map_thread(ta, pt);
-			if (th->th_unique == -1)
+			th->th_ta = ta;
+			th->th_tid = pt_map_thread(ta, pt, PT_USER);
+			if (th->th_tid == -1)
 				return (TD_MALLOC);
 			pt_unmap_lwp(ta, lwp);
 			return (TD_OK);
@@ -306,7 +311,7 @@
 }
 
 static td_err_e
-pt_ta_thr_iter(const pt_thragent_t *ta,
+pt_ta_thr_iter(const td_thragent_t *ta,
                td_thr_iter_f *callback, void *cbdata_p,
                td_thr_state_e state, int ti_pri,
                sigset_t *ti_sigmask_p,
@@ -315,40 +320,43 @@
 	TAILQ_HEAD(, pthread) thread_list;
 	td_thrhandle_t th;
 	psaddr_t pt;
-	int ret, activated;
-	
+	ps_err_e pserr;
+	int activated;
+
 	TDBG_FUNC();
 
-	ret = pt_ta_activated((pt_thragent_t *)ta, &activated);
-	if (ret != 0)
-		return (P2T(ret));
+	pserr = ps_pread(ta->ph, ta->thread_activated_addr, &activated,
+	    sizeof(int));
+	if (pserr != PS_OK)
+		return (P2T(pserr));
 	if (!activated)
-		return (0);
-	ret = ps_pread(ta->ph, ta->thread_list_addr, &thread_list,
-	                sizeof(thread_list));
-	if (ret != 0)
-		return (P2T(ret));
+		return (TD_OK);
+
+	pserr = ps_pread(ta->ph, ta->thread_list_addr, &thread_list,
+	    sizeof(thread_list));
+	if (pserr != 0)
+		return (P2T(pserr));
 	pt = (psaddr_t)thread_list.tqh_first;
 	while (pt != 0) {
-		th.th_ta_p = (td_thragent_t *)ta;
-		th.th_unique = pt_map_thread(ta, pt);
+		th.th_ta = ta;
+		th.th_tid = pt_map_thread(ta, pt, PT_USER);
 		/* should we unmap lwp here ? */
-		if (th.th_unique == -1)
+		if (th.th_tid == -1)
 			return (TD_MALLOC);
 		if ((*callback)(&th, cbdata_p))
 			return (TD_DBERR);
 		/* get next thread */
-		ret = ps_pread(ta->ph,
-		                pt + offsetof(struct pthread, tle.tqe_next),
-	                        &pt, sizeof(pt));
-		if (ret != 0)
-			return (P2T(ret));
+		pserr = ps_pread(ta->ph,
+		    pt + offsetof(struct pthread, tle.tqe_next), &pt,
+		    sizeof(pt));
+		if (pserr != PS_OK)
+			return (P2T(pserr));
 	}
 	return (TD_OK);
 }
 
 static td_err_e
-pt_ta_tsd_iter(const pt_thragent_t *ta, td_key_iter_f *ki, void *arg)
+pt_ta_tsd_iter(const td_thragent_t *ta, td_key_iter_f *ki, void *arg)
 {
 	struct pthread_key keytable[PTHREAD_KEYS_MAX];
 	int i, ret;
@@ -371,59 +379,45 @@
 }
 
 static td_err_e
-pt_ta_event_addr(const pt_thragent_t *ta, td_event_e event, td_notify_t *ptr)
+pt_ta_event_addr(const td_thragent_t *ta, td_event_e event, td_notify_t *ptr)
 {
 	TDBG_FUNC();
 	return (TD_NOEVENT);
 }
 
 static td_err_e
-pt_ta_set_event(const pt_thragent_t *ta, td_thr_events_t *events)
+pt_ta_set_event(const td_thragent_t *ta, td_thr_events_t *events)
 {
 	TDBG_FUNC();
 	return (TD_ERR);
 }
 
 static td_err_e
-pt_ta_clear_event(const pt_thragent_t *ta, td_thr_events_t *events)
+pt_ta_clear_event(const td_thragent_t *ta, td_thr_events_t *events)
 {
 	TDBG_FUNC();
 	return (TD_ERR);
 }
 
 static td_err_e
-pt_ta_event_getmsg(const pt_thragent_t *ta, td_event_msg_t *msg)
+pt_ta_event_getmsg(const td_thragent_t *ta, td_event_msg_t *msg)
 {
 	TDBG_FUNC();
 	return (TD_NOMSG);
 }
 
 static td_err_e
-pt_ta_setconcurrency(const pt_thragent_t *ta, int level)
+pt_thr_dbresume(const td_thrhandle_t *th)
 {
 	TDBG_FUNC();
-	return (TD_OK);
+	return (TD_ERR);
 }
 
 static td_err_e
-pt_ta_enable_stats(const pt_thragent_t *ta, int enable)
+pt_thr_dbsuspend(const td_thrhandle_t *th)
 {
 	TDBG_FUNC();
-	return (TD_OK);
-}
-
-static td_err_e
-pt_ta_reset_stats(const pt_thragent_t *ta)
-{
-	TDBG_FUNC();
-	return (TD_OK);
-}
-
-static td_err_e
-pt_ta_get_stats(const pt_thragent_t *ta, td_ta_stats_t *statsp)
-{
-	TDBG_FUNC();
-	return (TD_OK);
+	return (TD_ERR);
 }
 
 static td_err_e
@@ -434,7 +428,7 @@
 
 	TDBG_FUNC();
 
-	ret = pt_ta_map_id2thr((pt_thragent_t *)th->th_ta_p, th->th_unique,
+	ret = pt_ta_map_id2thr(th->th_ta, th->th_tid,
 	                       &temp);
 	return (P2T(ret));
 }
@@ -442,8 +436,8 @@
 static td_err_e
 pt_thr_get_info(const td_thrhandle_t *th, td_thrinfo_t *info)
 {
+	const td_thragent_t *ta = th->th_ta;
 	struct pthread pt;
-	pt_thragent_t *ta = (pt_thragent_t *)th->th_ta_p;
 	int ret;
 
 	TDBG_FUNC();
@@ -453,16 +447,16 @@
 		return (ret);
 
 	memset(info, 0, sizeof(*info));
-	if (ta->map[th->th_unique].type == PT_LWP) {
+	if (ta->map[th->th_tid].type == PT_LWP) {
 		info->ti_type = TD_THR_SYSTEM;
-		info->ti_lid = ta->map[th->th_unique].lwp;
-		info->ti_tid = th->th_unique;
+		info->ti_lid = ta->map[th->th_tid].lwp;
+		info->ti_tid = th->th_tid;
 		info->ti_state = TD_THR_RUN;
 		info->ti_type = TD_THR_SYSTEM;
 		return (TD_OK);
 	}
 
-	ret = ps_pread(ta->ph, (psaddr_t)(ta->map[th->th_unique].thr),
+	ret = ps_pread(ta->ph, (psaddr_t)(ta->map[th->th_tid].thr),
 	                &pt, sizeof(pt));
 	if (ret != 0)
 		return (P2T(ret));
@@ -474,8 +468,8 @@
 	if (ret != 0)
 		return (P2T(ret));
 
-	info->ti_ta_p = th->th_ta_p;
-	info->ti_tid = th->th_unique;
+	info->ti_ta_p = th->th_ta;
+	info->ti_tid = th->th_tid;
 	info->ti_tls = (char *)pt.specific; 
 	info->ti_startfunc = (psaddr_t)pt.start_routine;
 	info->ti_stkbase = (psaddr_t) pt.attr.stackaddr_attr;
@@ -516,8 +510,8 @@
 static td_err_e
 pt_thr_getfpregs(const td_thrhandle_t *th, prfpregset_t *fpregs)
 {
+	const td_thragent_t *ta = th->th_ta;
 	struct kse_thr_mailbox tmbx;
-	pt_thragent_t *ta = (pt_thragent_t *)th->th_ta_p;
 	psaddr_t tcb_addr, tmbx_addr, ptr;
 	lwpid_t lwp;
 	int ret;
@@ -528,12 +522,12 @@
 	if (ret)
 		return (ret);
 
-	if (ta->map[th->th_unique].type == PT_LWP) {
-		ret = ps_lgetfpregs(ta->ph, ta->map[th->th_unique].lwp, fpregs);
+	if (ta->map[th->th_tid].type == PT_LWP) {
+		ret = ps_lgetfpregs(ta->ph, ta->map[th->th_tid].lwp, fpregs);
 		return (P2T(ret));
 	}
 
-	ret = ps_pread(ta->ph, ta->map[th->th_unique].thr +
+	ret = ps_pread(ta->ph, ta->map[th->th_tid].thr +
  	                offsetof(struct pthread, tcb),
                         &tcb_addr, sizeof(tcb_addr));
 	if (ret != 0)
@@ -558,8 +552,8 @@
 static td_err_e
 pt_thr_getgregs(const td_thrhandle_t *th, prgregset_t gregs)
 {
+	const td_thragent_t *ta = th->th_ta;
 	struct kse_thr_mailbox tmbx;
-	pt_thragent_t *ta = (pt_thragent_t *)th->th_ta_p;
 	psaddr_t tcb_addr, tmbx_addr, ptr;
 	lwpid_t lwp;
 	int ret;
@@ -570,13 +564,13 @@
 	if (ret)
 		return (ret);
 
-	if (ta->map[th->th_unique].type == PT_LWP) {
+	if (ta->map[th->th_tid].type == PT_LWP) {
 		ret = ps_lgetregs(ta->ph,
-		                  ta->map[th->th_unique].lwp, gregs);
+		                  ta->map[th->th_tid].lwp, gregs);
 		return (P2T(ret));
 	}
 
-	ret = ps_pread(ta->ph, ta->map[th->th_unique].thr +
+	ret = ps_pread(ta->ph, ta->map[th->th_tid].thr +
 	                offsetof(struct pthread, tcb),
 			&tcb_addr, sizeof(tcb_addr));
 	if (ret != 0)
@@ -598,22 +592,10 @@
 }
 
 static td_err_e
-pt_thr_getxregs (const td_thrhandle_t *th, void *xregs)
-{
-	return (TD_NOXREGS);
-}
-
-static td_err_e
-pt_thr_getxregsize (const td_thrhandle_t *th, int *sizep)
-{
-	return (TD_NOXREGS);
-}
-
-static td_err_e
 pt_thr_setfpregs(const td_thrhandle_t *th, const prfpregset_t *fpregs)
 {
+	const td_thragent_t *ta = th->th_ta;
 	struct kse_thr_mailbox tmbx;
-	pt_thragent_t *ta = (pt_thragent_t *)th->th_ta_p;
 	psaddr_t tcb_addr, tmbx_addr, ptr;
 	lwpid_t lwp;
 	int ret;
@@ -624,12 +606,12 @@
 	if (ret)
 		return (ret);
 
-	if (ta->map[th->th_unique].type == PT_LWP) {
-		ret = ps_lsetfpregs(ta->ph, ta->map[th->th_unique].lwp, fpregs);
+	if (ta->map[th->th_tid].type == PT_LWP) {
+		ret = ps_lsetfpregs(ta->ph, ta->map[th->th_tid].lwp, fpregs);
 		return (P2T(ret));
 	}
 
-	ret = ps_pread(ta->ph, ta->map[th->th_unique].thr +
+	ret = ps_pread(ta->ph, ta->map[th->th_tid].thr +
 	                offsetof(struct pthread, tcb),
                         &tcb_addr, sizeof(tcb_addr));
 	if (ret != 0)
@@ -657,10 +639,10 @@
 }
 
 static td_err_e
-pt_thr_setgregs(const td_thrhandle_t *th, prgregset_t gregs)
+pt_thr_setgregs(const td_thrhandle_t *th, const prgregset_t gregs)
 {
+	const td_thragent_t *ta = th->th_ta;
 	struct kse_thr_mailbox tmbx;
-	pt_thragent_t *ta = (pt_thragent_t *)th->th_ta_p;
 	psaddr_t tcb_addr, tmbx_addr, ptr;
 	lwpid_t lwp;
 	int ret;
@@ -671,12 +653,12 @@
 	if (ret)
 		return (ret);
 
-	if (ta->map[th->th_unique].type == PT_LWP) {
-		ret = ps_lsetregs(ta->ph, ta->map[th->th_unique].lwp, gregs);
+	if (ta->map[th->th_tid].type == PT_LWP) {
+		ret = ps_lsetregs(ta->ph, ta->map[th->th_tid].lwp, gregs);
 		return (P2T(ret));
 	}
 
-	ret = ps_pread(ta->ph, ta->map[th->th_unique].thr +
+	ret = ps_pread(ta->ph, ta->map[th->th_tid].thr +
 	                offsetof(struct pthread, tcb),
 	                &tcb_addr, sizeof(tcb_addr));
 	if (ret != 0)
@@ -704,13 +686,6 @@
 }
 
 static td_err_e
-pt_thr_setxregs(const td_thrhandle_t *th, const void *addr)
-{
-	TDBG_FUNC();
-	return (TD_NOXREGS);
-}
-
-static td_err_e
 pt_thr_event_enable(const td_thrhandle_t *th, int en)
 {
 	TDBG_FUNC();
@@ -739,103 +714,11 @@
 }
 
 static td_err_e
-pt_thr_setprio(const td_thrhandle_t *th, int pri)
+pt_thr_sstep(const td_thrhandle_t *th, int step)
 {
-	TDBG_FUNC();
-	return (TD_OK);
-}
-
-static td_err_e
-pt_thr_setsigpending(const td_thrhandle_t *th, unsigned char n,
-	const sigset_t *set)
-{
-	TDBG_FUNC();
-	return (TD_OK);
-}
-
-static td_err_e
-pt_thr_sigsetmask(const td_thrhandle_t *th, const sigset_t *set)
-{
-	TDBG_FUNC();
-	return (TD_OK);
-}
-
-static td_err_e
-pt_thr_tsd(const td_thrhandle_t *th, const thread_key_t key, void **data)
-{
-	pt_thragent_t *ta = (pt_thragent_t *)th->th_ta_p;
-	struct pthread_specific_elem *spec, elem;
-	int ret;
-
-	TDBG_FUNC();
-
-	ret = pt_validate(th);
-	if (ret)
-		return (ret);
-
-	if (key < 0 || key >= PTHREAD_KEYS_MAX)
-		return (TD_BADKEY);
-
-	if (ta->map[th->th_unique].type == PT_LWP) {
-		*data = NULL;
-		return (TD_OK);
-	}
-
-	ret = ps_pread(ta->ph,
-	                ta->map[th->th_unique].thr +
-	                  offsetof(struct pthread, specific),
-	                &spec, sizeof(spec));
-	if (ret == 0) {
-		if (spec == NULL) {
-			*data = NULL;
-			return (0);
-		}
-		ret = ps_pread(ta->ph, (psaddr_t)&spec[key],
-			&elem, sizeof(elem));
-		if (ret == 0)
-			*data = (void *)elem.data;
-	}
-	return (P2T(ret));
-}
-
-static td_err_e
-pt_thr_dbsuspend(const td_thrhandle_t *th)
-{
-	TDBG_FUNC();
-	return (TD_ERR);
-}
-
-static td_err_e
-pt_thr_dbresume(const td_thrhandle_t *th)
-{
-	TDBG_FUNC();
-	return (TD_ERR);
-}
-
-static td_err_e
-pt_ta_activated(pt_thragent_t *ta, int *a)
-{
-	int ret;
-
-	TDBG_FUNC();
-
-	if (ta->thread_activated) {
-		*a = ta->thread_activated;
-		return (TD_OK);
-	}
-	ret = ps_pread(ta->ph, ta->thread_activated_addr,
-		  &ta->thread_activated, sizeof(int));
-	if (ret == 0)
-		*a = ta->thread_activated;
-	return (P2T(ret));
-}
-
-static td_err_e
-pt_thr_sstep(td_thrhandle_t *th, int step)
-{
+	const td_thragent_t *ta = th->th_ta;
 	struct kse_thr_mailbox tmbx;
 	struct reg regs;
-	pt_thragent_t *ta = (pt_thragent_t *)th->th_ta_p;
 	psaddr_t tcb_addr, tmbx_addr;
 	uint32_t tmp;
 	lwpid_t lwp;
@@ -847,12 +730,10 @@
 	if (ret)
 		return (ret);
 
-	if (ta->map[th->th_unique].type == PT_LWP) {
-		ret = ps_lsetstep(ta->ph, ta->map[th->th_unique].lwp, step);
-		return (P2T(ret));
-	}
+	if (ta->map[th->th_tid].type == PT_LWP)
+		return (TD_BADTH);
 
-	ret = ps_pread(ta->ph, ta->map[th->th_unique].thr + 
+	ret = ps_pread(ta->ph, ta->map[th->th_tid].thr + 
 	                offsetof(struct pthread, tcb),
 	                &tcb_addr, sizeof(tcb_addr));
 	if (ret != 0)
@@ -869,10 +750,8 @@
 	                tcb_tmbx.tm_lwp), &lwp, sizeof(lwpid_t));
 	if (ret != 0)
 		return (P2T(ret));
-	if (lwp != 0) {
-		ret = ps_lsetstep(ta->ph, lwp, step);
-		return (P2T(ret));
-	}
+	if (lwp != 0)
+		return (TD_BADTH);
 
 	tmbx_addr = tcb_addr + offsetof(struct tcb, tcb_tmbx);
 	/*
@@ -893,61 +772,8 @@
 	return (P2T(ret));
 }
 
-static long
-_map_thread(pt_thragent_t *ta, psaddr_t pt, int type)
-{
-	struct pt_map *new;
-	int i, first = -1;
-
-	/* leave zero out */
-	for (i = 1; i < ta->map_len; ++i) {
-		if (ta->map[i].type == PT_NONE) {
-			if (first == -1)
-				first = i;
-		} else if (ta->map[i].type == type && ta->map[i].thr == pt) {
-				return (i);
-		}
-	}
-
-	if (first == -1) {
-		if (ta->map_len == 0) {
-			ta->map = calloc(20, sizeof(struct pt_map));
-			if (ta->map == NULL)
-				return (-1);
-			ta->map_len = 20;
-			first = 1;
-		} else {
-			new = realloc(ta->map,
-			              sizeof(struct pt_map) * ta->map_len * 2);
-			if (new == NULL)
-				return (-1);
-			memset(new + ta->map_len, '\0', sizeof(struct pt_map) *
-			       ta->map_len);
-			first = ta->map_len;
-			ta->map = new;
-			ta->map_len *= 2;
-		}
-	}
-
-	ta->map[first].type = type;
-	ta->map[first].thr = pt;
-	return (first);
-}
-
-static long
-pt_map_thread(const pt_thragent_t *ta, psaddr_t pt)
-{
-	return _map_thread((pt_thragent_t *)ta, pt, PT_USER);
-}
-
-static long
-pt_map_lwp(const pt_thragent_t *ta, lwpid_t lwp)
-{
-	return _map_thread((pt_thragent_t *)ta, (psaddr_t)lwp, PT_LWP);
-}
-
 static void
-pt_unmap_lwp(const pt_thragent_t *ta, lwpid_t lwp)
+pt_unmap_lwp(const td_thragent_t *ta, lwpid_t lwp)
 {
 	int i;
 
@@ -962,33 +788,38 @@
 static int
 pt_validate(const td_thrhandle_t *th)
 {
-	pt_thragent_t *ta = (pt_thragent_t *)th->th_ta_p;
 
-	if (th->th_unique < 0 || th->th_unique >= ta->map_len ||
-	    ta->map[th->th_unique].type == PT_NONE)
+	if (th->th_tid < 0 || th->th_tid >= th->th_ta->map_len ||
+	    th->th_ta->map[th->th_tid].type == PT_NONE)
 		return (TD_NOTHR);
 	return (TD_OK);
 }
 
-struct ta_ops pthread_ops = {
+struct ta_ops libpthread_db_ops = {
 	.to_init		= pt_init,
-	.to_ta_new		= pt_ta_new,
+	.to_ta_clear_event	= pt_ta_clear_event,
 	.to_ta_delete		= pt_ta_delete,
+	.to_ta_event_addr	= pt_ta_event_addr,
+	.to_ta_event_getmsg	= pt_ta_event_getmsg,
 	.to_ta_map_id2thr	= pt_ta_map_id2thr,
 	.to_ta_map_lwp2thr	= pt_ta_map_lwp2thr,
+	.to_ta_new		= pt_ta_new,
+	.to_ta_set_event	= pt_ta_set_event,
 	.to_ta_thr_iter		= pt_ta_thr_iter,
-	.to_ta_event_addr	= pt_ta_event_addr,
-	.to_ta_set_event	= pt_ta_set_event,
-	.to_ta_clear_event	= pt_ta_clear_event,
-	.to_ta_event_getmsg	= pt_ta_event_getmsg,
-	.to_thr_validate	= pt_thr_validate,
+	.to_ta_tsd_iter		= pt_ta_tsd_iter,
+	.to_thr_clear_event	= pt_thr_clear_event,
+	.to_thr_dbresume	= pt_thr_dbresume,
+	.to_thr_dbsuspend	= pt_thr_dbsuspend,
+	.to_thr_event_enable	= pt_thr_event_enable,
+	.to_thr_event_getmsg	= pt_thr_event_getmsg,
 	.to_thr_get_info	= pt_thr_get_info,
 	.to_thr_getfpregs	= pt_thr_getfpregs,
 	.to_thr_getgregs	= pt_thr_getgregs,
+	.to_thr_set_event	= pt_thr_set_event,
 	.to_thr_setfpregs	= pt_thr_setfpregs,
 	.to_thr_setgregs	= pt_thr_setgregs,
-	.to_thr_event_enable	= pt_thr_event_enable,
-	.to_thr_set_event	= pt_thr_set_event,
-	.to_thr_clear_event	= pt_thr_clear_event,
-	.to_thr_event_getmsg	= pt_thr_event_getmsg,
+	.to_thr_validate	= pt_thr_validate,
+
+	/* FreeBSD specific extensions. */
+	.to_thr_sstep		= pt_thr_sstep,
 };

==== //depot/projects/gdb/lib/libthread_db/libthr_db.c#4 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libthread_db/libthr_db.c,v 1.1 2004/07/18 04:17:13 marcel Exp $");
 
 #include <proc_service.h>
 #include <stdlib.h>
@@ -85,7 +85,31 @@
 libthr_db_ta_map_lwp2thr(const td_thragent_t *ta, lwpid_t lwpid,
     td_thrhandle_t *th)
 {
-	return (TD_ERR);
+	psaddr_t addr;
+	thread_t tid;
+	ps_err_e err;
+
+	th->th_ta = ta;
+
+	err = ps_pread(ta->ta_ph, ta->ta_thread_list, &th->th_thread,
+	    sizeof(th->th_thread));
+	if (err != PS_OK)
+		return (TD_ERR);
+	while (th->th_thread != NULL) {
+		addr = (psaddr_t)((uintptr_t)th->th_thread +
+		    ta->ta_ofs_thr_id);
+		err = ps_pread(ta->ta_ph, addr, &tid, sizeof(thread_t));
+		if (err != PS_OK)
+			return (TD_ERR);
+		if (tid == lwpid)
+			return (TD_OK);
+		addr = (psaddr_t)((uintptr_t)th->th_thread + ta->ta_ofs_next);
+		err = ps_pread(ta->ta_ph, addr, &th->th_thread,
+		    sizeof(th->th_thread));
+		if (err != PS_OK)
+			return (TD_ERR);
+	}
+	return (TD_NOLWP);
 }
 
 static td_err_e
@@ -195,7 +219,7 @@
 	ps_err_e err;
 
 	ta = th->th_ta;
-	ti->ti_ta = ta;
+	ti->ti_ta_p = ta;
 	addr = (psaddr_t)((uintptr_t)th->th_thread + ta->ta_ofs_thr_id);
 	err = ps_pread(ta->ta_ph, addr, &tid, sizeof(thread_t));
 	ti->ti_lid = tid;
@@ -221,7 +245,7 @@
 }
 
 static td_err_e
-libthr_db_thr_getgregs(const td_thrhandle_t *th, prgregset_t *r)
+libthr_db_thr_getgregs(const td_thrhandle_t *th, prgregset_t r)
 {
 	const td_thragent_t *ta;
 	psaddr_t addr;
@@ -250,7 +274,7 @@
 }
 
 static td_err_e
-libthr_db_thr_setgregs(const td_thrhandle_t *th, const prgregset_t *r)
+libthr_db_thr_setgregs(const td_thrhandle_t *th, const prgregset_t r)
 {
 	return (TD_ERR);
 }

==== //depot/projects/gdb/lib/libthread_db/thread_db.c#3 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libthread_db/thread_db.c,v 1.1 2004/07/18 04:17:13 marcel Exp $");
 
 #include <proc_service.h>
 #include <stddef.h>
@@ -34,20 +34,23 @@
 
 #include "thread_db_int.h"
 
+struct td_thragent 
+{
+	TD_THRAGENT_FIELDS;
+};
+
 static TAILQ_HEAD(, td_thragent) proclist = TAILQ_HEAD_INITIALIZER(proclist);
 
 extern struct ta_ops libc_r_db_ops;
+extern struct ta_ops libpthread_db_ops;
 extern struct ta_ops libthr_db_ops;
 
 static struct ta_ops *ops[] = {
+	&libpthread_db_ops,
 	&libthr_db_ops,
 	&libc_r_db_ops
 };
 
-struct td_thragent {
-	TD_THRAGENT_FIELDS;
-};
-
 td_err_e
 td_init(void)
 {
@@ -133,6 +136,13 @@
 }
 
 td_err_e
+td_ta_tsd_iter(const td_thragent_t *ta, td_key_iter_f *callback,
+    void *cbdata_p)
+{
+	return (ta->ta_ops->to_ta_tsd_iter(ta, callback, cbdata_p));
+}
+
+td_err_e
 td_thr_clear_event(const td_thrhandle_t *th, td_thr_events_t *events)
 {
 	const td_thragent_t *ta = th->th_ta;
@@ -140,6 +150,20 @@
 }
 
 td_err_e
+td_thr_dbresume(const td_thrhandle_t *th)
+{
+	const td_thragent_t *ta = th->th_ta;
+	return (ta->ta_ops->to_thr_dbresume(th));
+}
+
+td_err_e
+td_thr_dbsuspend(const td_thrhandle_t *th)
+{
+	const td_thragent_t *ta = th->th_ta;
+	return (ta->ta_ops->to_thr_dbsuspend(th));
+}
+
+td_err_e
 td_thr_event_enable(const td_thrhandle_t *th, int en)
 {
 	const td_thragent_t *ta = th->th_ta;
@@ -168,7 +192,7 @@

>>> TRUNCATED FOR MAIL (1000 lines) <<<



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