Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Jul 2004 05:36:40 GMT
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 56404 for review
Message-ID:  <200407040536.i645aeh7013914@repoman.freebsd.org>

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

Change 56404 by marcel@marcel_nfs on 2004/07/04 05:35:46

	Finish rudimentary debugging of libc_r on i386.

Affected files ...

.. //depot/projects/gdb/lib/libthread_db/Makefile#4 edit
.. //depot/projects/gdb/lib/libthread_db/arch/i386/libc_r_md.c#1 add
.. //depot/projects/gdb/lib/libthread_db/libc_r_db.c#2 edit

Differences ...

==== //depot/projects/gdb/lib/libthread_db/Makefile#4 (text+ko) ====

@@ -1,8 +1,12 @@
 # $FreeBSD$
 
+.PATH:	${.CURDIR}/arch/${MACHINE_ARCH}
+
 LIB=	thread_db
 SHLIB_MAJOR= 1
-SRCS=	libc_r_db.c libthr_db.c thread_db.c
+SRCS=	thread_db.c
+SRCS+=	libc_r_db.c libc_r_md.c
+SRCS+=	libthr_db.c
 INCS=	thread_db.h
 WARNS?= 2
 

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

@@ -27,6 +27,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include <machine/setjmp.h>
 #include <proc_service.h>
 #include <stdlib.h>
 #include <string.h>
@@ -34,11 +35,15 @@
 
 #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 *);
+
 struct td_thragent {
 	TD_THRAGENT_FIELDS;
 	struct ps_prochandle	*ta_ph;
 	psaddr_t ta_thread_list;
 	psaddr_t ta_thread_run;
+	int	ta_ofs_ctx;
 	int	ta_ofs_next;
 	int	ta_ofs_uniqueid;
 };
@@ -113,6 +118,12 @@
 	err = ps_pglobal_lookup(ph, NULL, "_thread_run", &ta->ta_thread_run);
 	if (err != PS_OK)
 		goto fail;
+	err = ps_pglobal_lookup(ph, NULL, "_thread_ctx_offset", &addr);
+	if (err != PS_OK)
+		goto fail;
+	err = ps_pread(ph, addr, &ta->ta_ofs_ctx, sizeof(int));
+	if (err != PS_OK)
+		goto fail;
 	err = ps_pglobal_lookup(ph, NULL, "_thread_next_offset", &addr);
 	if (err != PS_OK)
 		goto fail;
@@ -209,41 +220,50 @@
 static td_err_e
 libc_r_db_thr_getfpregs(const td_thrhandle_t *th, prfpregset_t *r)
 {
+	jmp_buf jb;
 	const td_thragent_t *ta;
-	psaddr_t current;
+	psaddr_t addr;
 	ps_err_e err;
 
 	ta = th->th_ta;
-	err = ps_pread(ta->ta_ph, ta->ta_thread_run, &current,
-	    sizeof(psaddr_t));
+	err = ps_lgetfpregs(ta->ta_ph, -1, r);
+	if (err != PS_OK)
+		return (TD_ERR);
+	err = ps_pread(ta->ta_ph, ta->ta_thread_run, &addr, sizeof(psaddr_t));
+	if (err != PS_OK)
+		return (TD_ERR);
+	if (th->th_thread == addr)
+		return (TD_OK);
+	addr = (psaddr_t)((uintptr_t)th->th_thread + ta->ta_ofs_ctx);
+	err = ps_pread(ta->ta_ph, addr, jb, sizeof(jb));
 	if (err != PS_OK)
 		return (TD_ERR);
-	if (th->th_thread == current) {
-		err = ps_lgetfpregs(ta->ta_ph, -1, r);
-		return ((err != PS_OK) ? TD_ERR : TD_OK);
-	}
-	memset(r, 0, sizeof(*r));
+	libc_r_md_getfpregs(jb, r);
 	return (TD_OK);
 }
 
 static td_err_e
 libc_r_db_thr_getgregs(const td_thrhandle_t *th, prgregset_t *r)
 {
+	jmp_buf jb;
 	const td_thragent_t *ta;
-	psaddr_t current;
+	psaddr_t addr;
 	ps_err_e err;
 
 	ta = th->th_ta;
-	err = ps_pread(ta->ta_ph, ta->ta_thread_run, &current,
-	    sizeof(psaddr_t));
+	err = ps_lgetregs(ta->ta_ph, -1, r);
+	if (err != PS_OK)
+		return (TD_ERR);
+	err = ps_pread(ta->ta_ph, ta->ta_thread_run, &addr, sizeof(psaddr_t));
+	if (err != PS_OK)
+		return (TD_ERR);
+	if (th->th_thread == addr)
+		return (TD_OK);
+	addr = (psaddr_t)((uintptr_t)th->th_thread + ta->ta_ofs_ctx);
+	err = ps_pread(ta->ta_ph, addr, jb, sizeof(jb));
 	if (err != PS_OK)
 		return (TD_ERR);
-	if (th->th_thread == current) {
-		err = ps_lgetregs(ta->ta_ph, -1, r);
-		return ((err != PS_OK) ? TD_ERR : TD_OK);
-	}
-	memset(r, 0, sizeof(*r));
-	
+	libc_r_md_getgregs(jb, r);
 	return (TD_OK);
 }
 



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