Add some basic DDB stuff for modules.
This commit is contained in:
parent
173ac732fd
commit
31afc5b6d8
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_command.c,v 1.122 2008/11/16 19:34:29 pooka Exp $ */
|
||||
/* $NetBSD: db_command.c,v 1.123 2008/11/25 15:14:07 ad Exp $ */
|
||||
/*
|
||||
* Mach Operating System
|
||||
* Copyright (c) 1991,1990 Carnegie Mellon University
|
||||
|
@ -58,7 +58,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.122 2008/11/16 19:34:29 pooka Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.123 2008/11/25 15:14:07 ad Exp $");
|
||||
|
||||
#include "opt_aio.h"
|
||||
#include "opt_ddb.h"
|
||||
|
@ -83,6 +83,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.122 2008/11/16 19:34:29 pooka Exp $
|
|||
#include <sys/sleepq.h>
|
||||
#include <sys/cpu.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/module.h>
|
||||
|
||||
/*include queue macros*/
|
||||
#include <sys/queue.h>
|
||||
|
@ -248,6 +249,8 @@ static const struct db_command db_show_cmds[] = {
|
|||
{ DDB_ADD_CMD("malloc", db_malloc_print_cmd,0,NULL,NULL,NULL) },
|
||||
{ DDB_ADD_CMD("map", db_map_print_cmd, 0,
|
||||
"Print the vm_map at address.", "[/f] address",NULL) },
|
||||
{ DDB_ADD_CMD("module", db_show_module_cmd, 0,
|
||||
"Print kernel modules", NULL, NULL) },
|
||||
{ DDB_ADD_CMD("mount", db_mount_print_cmd, 0,
|
||||
"Print the mount structure at address.", "[/f] address",NULL) },
|
||||
{ DDB_ADD_CMD("mqueue", db_show_mqueue_cmd, 0,
|
||||
|
@ -1401,4 +1404,5 @@ db_whatis_cmd(db_expr_t address, bool have_addr,
|
|||
pool_whatis(addr, db_printf);
|
||||
vmem_whatis(addr, db_printf);
|
||||
uvm_whatis(addr, db_printf);
|
||||
module_whatis(addr, db_printf);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_interface.h,v 1.23 2008/07/10 12:42:24 blymn Exp $ */
|
||||
/* $NetBSD: db_interface.h,v 1.24 2008/11/25 15:14:07 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995 The NetBSD Foundation, Inc.
|
||||
|
@ -65,6 +65,9 @@ void db_show_aio_jobs(db_expr_t, bool, db_expr_t, const char *);
|
|||
/* kern/sys_mqueue.c */
|
||||
void db_show_mqueue_cmd(db_expr_t, bool, db_expr_t, const char *);
|
||||
|
||||
/* kern/kern_module.c */
|
||||
void db_show_module_cmd(db_expr_t, bool, db_expr_t, const char *);
|
||||
|
||||
/*
|
||||
* This is used in several places to determine which printf format
|
||||
* string is appropriate for displaying a variable of type db_expr_t.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_xxx.c,v 1.53 2008/11/14 23:37:50 ad Exp $ */
|
||||
/* $NetBSD: db_xxx.c,v 1.54 2008/11/25 15:14:07 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.53 2008/11/14 23:37:50 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.54 2008/11/25 15:14:07 ad Exp $");
|
||||
|
||||
#include "opt_kgdb.h"
|
||||
#include "opt_aio.h"
|
||||
|
@ -58,6 +58,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.53 2008/11/14 23:37:50 ad Exp $");
|
|||
#include <sys/kauth.h>
|
||||
#include <sys/mqueue.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/module.h>
|
||||
|
||||
#include <machine/db_machdep.h>
|
||||
|
||||
|
@ -177,6 +178,13 @@ db_show_mqueue_cmd(db_expr_t addr, bool haddr,
|
|||
mqueue_print_list(db_printf);
|
||||
}
|
||||
|
||||
void
|
||||
db_show_module_cmd(db_expr_t addr, bool haddr,
|
||||
db_expr_t count, const char *modif)
|
||||
{
|
||||
module_print_list(db_printf);
|
||||
}
|
||||
|
||||
void
|
||||
db_show_all_procs(db_expr_t addr, bool haddr,
|
||||
db_expr_t count, const char *modif)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: kern_module.c,v 1.29 2008/11/19 13:07:42 ad Exp $ */
|
||||
/* $NetBSD: kern_module.c,v 1.30 2008/11/25 15:14:07 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -34,7 +34,11 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.29 2008/11/19 13:07:42 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.30 2008/11/25 15:14:07 ad Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_ddb.h"
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -901,3 +905,64 @@ module_thread_kick(void)
|
|||
cv_broadcast(&module_thread_cv);
|
||||
mutex_exit(&module_thread_lock);
|
||||
}
|
||||
|
||||
#ifdef DDB
|
||||
/*
|
||||
* module_whatis:
|
||||
*
|
||||
* Helper routine for DDB.
|
||||
*/
|
||||
void
|
||||
module_whatis(uintptr_t addr, void (*pr)(const char *, ...))
|
||||
{
|
||||
module_t *mod;
|
||||
size_t msize;
|
||||
vaddr_t maddr;
|
||||
|
||||
TAILQ_FOREACH(mod, &module_list, mod_chain) {
|
||||
kobj_stat(mod->mod_kobj, &maddr, &msize);
|
||||
if (addr < maddr || addr >= maddr + msize) {
|
||||
continue;
|
||||
}
|
||||
(*pr)("%p is %p+%zu, in kernel module `%s'\n",
|
||||
(void *)addr, (void *)maddr,
|
||||
(size_t)(addr - maddr), mod->mod_info->mi_name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* module_print_list:
|
||||
*
|
||||
* Helper routine for DDB.
|
||||
*/
|
||||
void
|
||||
module_print_list(void (*pr)(const char *, ...))
|
||||
{
|
||||
const char *src;
|
||||
module_t *mod;
|
||||
size_t msize;
|
||||
vaddr_t maddr;
|
||||
|
||||
(*pr)("%16s %16s %8s %8s\n", "NAME", "TEXT/DATA", "SIZE", "SOURCE");
|
||||
|
||||
TAILQ_FOREACH(mod, &module_list, mod_chain) {
|
||||
switch (mod->mod_source) {
|
||||
case MODULE_SOURCE_KERNEL:
|
||||
src = "builtin";
|
||||
break;
|
||||
case MODULE_SOURCE_FILESYS:
|
||||
src = "filesys";
|
||||
break;
|
||||
case MODULE_SOURCE_BOOT:
|
||||
src = "boot";
|
||||
break;
|
||||
default:
|
||||
src = "unknown";
|
||||
break;
|
||||
}
|
||||
kobj_stat(mod->mod_kobj, &maddr, &msize);
|
||||
(*pr)("%16s %16lx %8lx %8s\n", mod->mod_info->mi_name,
|
||||
(long)maddr, (long)msize, src);
|
||||
}
|
||||
}
|
||||
#endif /* DDB */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: module.h,v 1.13 2008/11/19 11:08:06 ad Exp $ */
|
||||
/* $NetBSD: module.h,v 1.14 2008/11/25 15:14:07 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -128,6 +128,8 @@ void module_rele(const char *);
|
|||
int module_find_section(const char *, void **, size_t *);
|
||||
void module_thread_kick(void);
|
||||
|
||||
void module_whatis(uintptr_t, void (*)(const char *, ...));
|
||||
void module_print_list(void (*)(const char *, ...));
|
||||
#else /* _KERNEL */
|
||||
|
||||
#include <stdint.h>
|
||||
|
|
Loading…
Reference in New Issue