Add a new kernel config option, VERBOSE_SYSINIT.

When porting FreeBSD to a new platform, one of the more useful things to do is
get mi_startup() to let you know which SYSINIT it's up to.  Most people tend to
whack a printf in the SYSINIT loop to print the address of the function it's
about to call.  Going one better, jhb made a version that uses DDB to look up
the name of the function and print that instead.  This version is essentially
his with the addition of some ifdeffery to make it optional and to allow it to
work (although using only the function address, not the symbol) if you forgot
to enable DDB.

All the cool bits by:	jhb
Approved by:		scottl, rink, cognet, imp
This commit is contained in:
Benno Rice 2006-05-12 02:01:38 +00:00
parent 6dfb15fc17
commit 26ab616fdc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=158463
2 changed files with 46 additions and 0 deletions

View File

@ -158,6 +158,7 @@ SW_WATCHDOG opt_watchdog.h
TURNSTILE_PROFILING
TTYHOG opt_tty.h
VFS_AIO
VERBOSE_SYSINIT opt_global.h
WLCACHE opt_wavelan.h
WLDEBUG opt_wavelan.h

View File

@ -84,6 +84,9 @@ __FBSDID("$FreeBSD$");
#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 @@ mi_startup(void)
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 @@ mi_startup(void)
}
}
#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 @@ mi_startup(void)
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;