From owner-freebsd-hackers@FreeBSD.ORG Thu May 11 05:48:19 2006 Return-Path: X-Original-To: hackers@FreeBSD.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0B61116A410 for ; Thu, 11 May 2006 05:48:19 +0000 (UTC) (envelope-from benno@FreeBSD.org) Received: from mail.jeamland.net (rafe.jeamland.net [202.45.126.103]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8B23543D45 for ; Thu, 11 May 2006 05:48:16 +0000 (GMT) (envelope-from benno@FreeBSD.org) Received: from mail.jeamland.net (localhost [127.0.0.1]) by mail.jeamland.net (Postfix) with ESMTP id 10C271CCFC for ; Thu, 11 May 2006 15:48:15 +1000 (EST) Received: from [10.2.3.17] (ppp67-100.lns1.mel4.internode.on.net [59.167.67.100]) by mail.jeamland.net (Postfix) with ESMTP id 47DD51CC63 for ; Thu, 11 May 2006 15:48:14 +1000 (EST) Message-ID: <4462D01D.1000500@FreeBSD.org> Date: Thu, 11 May 2006 15:48:13 +1000 From: Benno Rice User-Agent: Thunderbird 1.5.0.2 (Macintosh/20060308) MIME-Version: 1.0 To: hackers@FreeBSD.org Content-Type: multipart/mixed; boundary="------------010009070002000005040300" X-Virus-Scanned: ClamAV using ClamSMTP at rafe.jeamland.net Cc: Subject: RFC: Optionally verbose SYSINIT X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 May 2006 05:48:19 -0000 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 #include +#include +#include + 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--