PERFORCE change 102424 for review

John Baldwin jhb at FreeBSD.org
Wed Jul 26 01:36:20 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=102424

Change 102424 by jhb at 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;


More information about the p4-projects mailing list