Date: Wed, 26 Jul 2006 01:36:18 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 102424 for review Message-ID: <200607260136.k6Q1aI6u038762@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=102424 Change 102424 by jhb@jhb_mutex on 2006/07/26 01:35:17 Add a 'kldstat' ddb command complete with a '/v' option that mimics 'kldstat -v'. Affected files ... .. //depot/projects/smpng/sys/kern/kern_linker.c#80 edit .. //depot/projects/smpng/sys/kern/kern_module.c#22 edit .. //depot/projects/smpng/sys/sys/module.h#8 edit Differences ... ==== //depot/projects/smpng/sys/kern/kern_linker.c#80 (text+ko) ==== @@ -54,6 +54,10 @@ #include "linker_if.h" +#ifdef DDB +#include <ddb/ddb.h> +#endif + #ifdef HWPMC_HOOKS #include <sys/pmckern.h> #endif @@ -2012,3 +2016,28 @@ SYSCTL_PROC(_kern, OID_AUTO, function_list, CTLFLAG_RD, NULL, 0, sysctl_kern_function_list, "", "kernel function list"); + +#ifdef DDB +DB_COMMAND(kldstat, db_kldstat) +{ + linker_file_t lf; + int verbose; + + verbose = index(modif, 'v') != NULL; +#ifdef __LP64__ + db_printf("Id Refs Address Size Name\n"); +#else + db_printf("Id Refs Address Size Name\n"); +#endif + TAILQ_FOREACH(lf, &linker_files, link) { + if (db_pager_quit) + return; + db_printf("%2d %4d %p %-8zx %s\n", lf->id, lf->refs, + lf->address, lf->size, lf->filename); + if (!verbose) + continue; + db_printf(" Contains modules:\n"); + db_show_modules(lf, " "); + } +} +#endif ==== //depot/projects/smpng/sys/kern/kern_module.c#22 (text+ko) ==== @@ -25,6 +25,7 @@ */ #include "opt_compat.h" +#include "opt_ddb.h" #include <sys/cdefs.h> __FBSDID("$FreeBSD: src/sys/kern/kern_module.c,v 1.51 2006/06/26 18:34:45 jhb Exp $"); @@ -44,6 +45,10 @@ #include <sys/module.h> #include <sys/linker.h> +#ifdef DDB +#include <ddb/ddb.h> +#endif + static MALLOC_DEFINE(M_MODULE, "module", "module data structures"); typedef TAILQ_HEAD(, module) modulelist_t; @@ -504,3 +509,18 @@ return (error); } #endif + +#ifdef DDB +void +db_show_modules(linker_file_t lf, const char *prefix) +{ + module_t mod; + + db_printf("%sId Name\n", prefix); + TAILQ_FOREACH(mod, &lf->modules, flink) { + if (db_pager_quit) + return; + db_printf("%s%-4d %s\n", prefix, mod->id, mod->name); + } +} +#endif ==== //depot/projects/smpng/sys/sys/module.h#8 (text+ko) ==== @@ -148,6 +148,9 @@ module_t module_getfnext(module_t); void module_setspecific(module_t, modspecific_t *); struct linker_file *module_file(module_t); +#ifdef DDB +void db_show_modules(struct linker_file *, const char *); +#endif #ifdef MOD_DEBUG extern int mod_debug;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607260136.k6Q1aI6u038762>