Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 May 2006 15:48:13 +1000
From:      Benno Rice <benno@FreeBSD.org>
To:        hackers@FreeBSD.org
Subject:   RFC: Optionally verbose SYSINIT
Message-ID:  <4462D01D.1000500@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------010009070002000005040300
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

One of the things that I found useful both in starting the PowerPC port 
and in doing the XScale stuff I'm working on is making the SYSINIT stuff 
done by mi_startup() verbose.  This generally requires hacking your own 
code into mi_startup() to print out which SYSINIT you're up to and the 
like.  jhb recently pointed me at this version he wrote which uses DDB 
to look up the symbol corresponding to the SYSINIT in question which 
makes it even more useful.

I would like to commit this version, which I've made optional based on a 
VERBOSE_SYSINIT option, so as to make it available to anyone else 
further down the line who's porting to a new architecture.

Comments?  Questions?

-- 
Benno Rice
benno@FreeBSD.org

--------------010009070002000005040300
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
	name="verbose-sysinit.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="verbose-sysinit.diff"

Index: conf/options
===================================================================
RCS file: /home/ncvs/src/sys/conf/options,v
retrieving revision 1.540
diff -u -r1.540 options
--- conf/options	7 May 2006 18:12:17 -0000	1.540
+++ conf/options	11 May 2006 05:34:26 -0000
@@ -158,6 +158,7 @@
 TURNSTILE_PROFILING
 TTYHOG		opt_tty.h
 VFS_AIO
+VERBOSE_SYSINIT	opt_global.h
 WLCACHE		opt_wavelan.h
 WLDEBUG		opt_wavelan.h
 
Index: kern/init_main.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/init_main.c,v
retrieving revision 1.262
diff -u -r1.262 init_main.c
--- kern/init_main.c	7 Feb 2006 21:22:01 -0000	1.262
+++ kern/init_main.c	11 May 2006 05:35:21 -0000
@@ -84,6 +84,9 @@
 #include <vm/vm_map.h>
 #include <sys/copyright.h>
 
+#include <ddb/ddb.h>
+#include <ddb/db_sym.h>
+
 void mi_startup(void);				/* Should be elsewhere */
 
 /* Components of the first process -- never freed. */
@@ -169,6 +172,11 @@
 	register struct sysinit **xipp;		/* interior loop of sort*/
 	register struct sysinit *save;		/* bubble*/
 
+#if defined(VERBOSE_SYSINIT)
+	int last;
+	int verbose;
+#endif
+
 	if (sysinit == NULL) {
 		sysinit = SET_BEGIN(sysinit_set);
 		sysinit_end = SET_LIMIT(sysinit_set);
@@ -191,6 +199,14 @@
 		}
 	}
 
+#if defined(VERBOSE_SYSINIT)
+	last = SI_SUB_COPYRIGHT;
+	verbose = 0;
+#if !defined(DDB)
+	printf("VERBOSE_SYSINIT: DDB not enabled, symbol lookups disabled.\n");
+#endif
+#endif
+
 	/*
 	 * Traverse the (now) ordered list of system initialization tasks.
 	 * Perform each task, and continue on to the next task.
@@ -206,9 +222,38 @@
 		if ((*sipp)->subsystem == SI_SUB_DONE)
 			continue;
 
+#if defined(VERBOSE_SYSINIT)
+		if ((*sipp)->subsystem > last) {
+			verbose = 1;
+			last = (*sipp)->subsystem;
+			printf("subsystem %x\n", last);
+		}
+		if (verbose) {
+#if defined(DDB)
+			const char *name;
+			c_db_sym_t sym;
+			db_expr_t  offset;
+
+			sym = db_search_symbol((vm_offset_t)(*sipp)->func,
+			    DB_STGY_PROC, &offset);
+			db_symbol_values(sym, &name, NULL);
+			if (name != NULL)
+				printf("   %s(%p)... ", name, (*sipp)->udata);
+			else
+#endif
+				printf("   %p(%p)... ", (*sipp)->func,
+				    (*sipp)->udata);
+		}
+#endif
+
 		/* Call function */
 		(*((*sipp)->func))((*sipp)->udata);
 
+#if defined(VERBOSE_SYSINIT)
+		if (verbose)
+			printf("done.\n");
+#endif
+
 		/* Check off the one we're just done */
 		(*sipp)->subsystem = SI_SUB_DONE;
 

--------------010009070002000005040300--



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