RFC: Optionally verbose SYSINIT

Scott Long scottl at samsco.org
Thu May 11 07:53:00 UTC 2006


This would be awesome, please do it.

Scott


Benno Rice wrote:

> 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?
> 
> 
> ------------------------------------------------------------------------
> 
> 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;
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"



More information about the freebsd-hackers mailing list