Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Feb 2009 03:36:11 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org
Subject:   svn commit: r189058 - stable/6/lib/libthread_db
Message-ID:  <200902260336.n1Q3aBYM015469@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Thu Feb 26 03:36:10 2009
New Revision: 189058
URL: http://svn.freebsd.org/changeset/base/189058

Log:
  MFC r177490 - diff reduction w/ head.
  
    Use linker set to collection all target operations.

Modified:
  stable/6/lib/libthread_db/   (props changed)
  stable/6/lib/libthread_db/libc_r_db.c
  stable/6/lib/libthread_db/libpthread_db.c
  stable/6/lib/libthread_db/libthr_db.c
  stable/6/lib/libthread_db/thread_db.c

Modified: stable/6/lib/libthread_db/libc_r_db.c
==============================================================================
--- stable/6/lib/libthread_db/libc_r_db.c	Wed Feb 25 22:24:56 2009	(r189057)
+++ stable/6/lib/libthread_db/libc_r_db.c	Thu Feb 26 03:36:10 2009	(r189058)
@@ -28,6 +28,7 @@
 __FBSDID("$FreeBSD$");
 
 #include <machine/setjmp.h>
+#include <sys/linker_set.h>
 #include <proc_service.h>
 #include <stdlib.h>
 #include <string.h>
@@ -346,3 +347,5 @@ struct ta_ops libc_r_db_ops = {
 	.to_thr_setxmmregs	= libc_r_db_thr_setxmmregs,
 #endif
 };
+
+DATA_SET(__ta_ops, libc_r_db_ops);

Modified: stable/6/lib/libthread_db/libpthread_db.c
==============================================================================
--- stable/6/lib/libthread_db/libpthread_db.c	Wed Feb 25 22:24:56 2009	(r189057)
+++ stable/6/lib/libthread_db/libpthread_db.c	Thu Feb 26 03:36:10 2009	(r189058)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
 #include <unistd.h>
 #include <pthread.h>
 #include <sys/types.h>
+#include <sys/linker_set.h>
 #include <sys/kse.h>
 #include <sys/ptrace.h>
 #include <proc_service.h>
@@ -1147,3 +1148,5 @@ struct ta_ops libpthread_db_ops = {
 	.to_thr_setxmmregs	= pt_thr_setxmmregs,
 #endif
 };
+
+DATA_SET(__ta_ops, libpthread_db_ops);

Modified: stable/6/lib/libthread_db/libthr_db.c
==============================================================================
--- stable/6/lib/libthread_db/libthr_db.c	Wed Feb 25 22:24:56 2009	(r189057)
+++ stable/6/lib/libthread_db/libthr_db.c	Thu Feb 26 03:36:10 2009	(r189058)
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
+#include <sys/linker_set.h>
 #include <sys/ptrace.h>
 #include <thread_db.h>
 #include <unistd.h>
@@ -791,3 +792,5 @@ struct ta_ops libthr_db_ops = {
 	.to_thr_setxmmregs	= pt_thr_setxmmregs,
 #endif
 };
+
+DATA_SET(__ta_ops, libthr_db_ops);

Modified: stable/6/lib/libthread_db/thread_db.c
==============================================================================
--- stable/6/lib/libthread_db/thread_db.c	Wed Feb 25 22:24:56 2009	(r189057)
+++ stable/6/lib/libthread_db/thread_db.c	Thu Feb 26 03:36:10 2009	(r189058)
@@ -31,6 +31,8 @@ __FBSDID("$FreeBSD$");
 #include <stddef.h>
 #include <thread_db.h>
 #include <unistd.h>
+#include <sys/cdefs.h>
+#include <sys/linker_set.h>
 
 #include "thread_db_int.h"
 
@@ -41,26 +43,20 @@ struct td_thragent 
 
 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
-};
+SET_DECLARE(__ta_ops, struct ta_ops);
 
 td_err_e
 td_init(void)
 {
 	td_err_e ret, tmp;
+	struct ta_ops *ops_p, **ops_pp;
 	size_t i;
 
 	ret = 0;
-	for (i = 0; i < sizeof(ops)/sizeof(ops[0]); i++) {
-		if (ops[i]->to_init != NULL) {
-			tmp = ops[i]->to_init();
+	SET_FOREACH(ops_pp, __ta_ops) {
+		ops_p = *ops_pp;
+		if (ops_p->to_init != NULL) {
+			tmp = ops_p->to_init();
 			if (tmp != TD_OK)
 				ret = tmp;
 		}
@@ -109,11 +105,13 @@ td_err_e
 td_ta_new(struct ps_prochandle *ph, td_thragent_t **pta)
 {
 	size_t i;
+	struct ta_ops *ops_p, **ops_pp;
 
-	for (i = 0; i < sizeof(ops)/sizeof(ops[0]); ++i) {
-		if (ops[i]->to_ta_new(ph, pta) == TD_OK) {
+	SET_FOREACH(ops_pp, __ta_ops) {
+		ops_p = *ops_pp;
+		if (ops_p->to_ta_new(ph, pta) == TD_OK) {
 			TAILQ_INSERT_HEAD(&proclist, *pta, ta_next);
-			(*pta)->ta_ops = ops[i];
+			(*pta)->ta_ops = ops_p;
 			return (TD_OK);
 		}
 	}



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