Add a show files command that prints the vnodes associated with a
given struct proc and, if LOCKDEBUG is built in, the lock status of the uvmobject.
This commit is contained in:
parent
8070795214
commit
8a19e9911c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_command.c,v 1.116 2008/07/10 12:38:28 blymn Exp $ */
|
||||
/* $NetBSD: db_command.c,v 1.117 2008/07/10 12:42:24 blymn 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.116 2008/07/10 12:38:28 blymn Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.117 2008/07/10 12:42:24 blymn Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_kgdb.h"
|
||||
|
@ -233,6 +233,9 @@ static const struct db_command db_show_cmds[] = {
|
|||
"Print the struct buf at address.", "[/f] address",NULL) },
|
||||
{ DDB_ADD_CMD("event", db_event_print_cmd, 0,
|
||||
"Print all the non-zero evcnt(9) event counters.", "[/f]",NULL) },
|
||||
{ DDB_ADD_CMD("files", db_show_files_cmd, 0,
|
||||
"Print the files open by process at address",
|
||||
"[/f] address", NULL) },
|
||||
{ DDB_ADD_CMD("lock", db_lock_print_cmd, 0,NULL,NULL,NULL) },
|
||||
{ DDB_ADD_CMD("malloc", db_malloc_print_cmd,0,NULL,NULL,NULL) },
|
||||
{ DDB_ADD_CMD("map", db_map_print_cmd, 0,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_interface.h,v 1.22 2008/04/28 20:23:46 martin Exp $ */
|
||||
/* $NetBSD: db_interface.h,v 1.23 2008/07/10 12:42:24 blymn Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1995 The NetBSD Foundation, Inc.
|
||||
|
@ -42,6 +42,7 @@ void db_stack_trace_print(db_expr_t, bool, db_expr_t, const char *,
|
|||
|
||||
/* ddb/db_xxx.c */
|
||||
void db_kgdb_cmd(db_expr_t, bool, db_expr_t, const char *);
|
||||
void db_show_files_cmd(db_expr_t, bool, db_expr_t, const char *);
|
||||
|
||||
/* kern/kern_proc.c */
|
||||
void db_kill_proc(db_expr_t, bool, db_expr_t, const char *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_xxx.c,v 1.48 2007/12/02 19:35:33 ad Exp $ */
|
||||
/* $NetBSD: db_xxx.c,v 1.49 2008/07/10 12:42:24 blymn 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.48 2007/12/02 19:35:33 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.49 2008/07/10 12:42:24 blymn Exp $");
|
||||
|
||||
#include "opt_kgdb.h"
|
||||
|
||||
|
@ -48,11 +48,15 @@ __KERNEL_RCSID(0, "$NetBSD: db_xxx.c,v 1.48 2007/12/02 19:35:33 ad Exp $");
|
|||
#include <sys/msgbuf.h>
|
||||
|
||||
#include <sys/callout.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/filedesc.h>
|
||||
#include <sys/lockdebug.h>
|
||||
#include <sys/signalvar.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/pool.h>
|
||||
#include <sys/kauth.h>
|
||||
#include <sys/mqueue.h>
|
||||
#include <sys/vnode.h>
|
||||
|
||||
#include <machine/db_machdep.h>
|
||||
|
||||
|
@ -115,6 +119,44 @@ db_kgdb_cmd(db_expr_t addr, bool haddr,
|
|||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
db_show_files_cmd(db_expr_t addr, bool haddr,
|
||||
db_expr_t count, const char *modif)
|
||||
{
|
||||
struct proc *p;
|
||||
int i;
|
||||
filedesc_t *fdp;
|
||||
fdfile_t *ff;
|
||||
file_t *fp;
|
||||
struct vnode *vn;
|
||||
bool full = false;
|
||||
|
||||
if (modif[0] == 'f')
|
||||
full = true;
|
||||
|
||||
p = (struct proc *) (intptr_t) addr;
|
||||
|
||||
fdp = p->p_fd;
|
||||
for (i = 0; i < fdp->fd_nfiles; i++) {
|
||||
if ((ff = fdp->fd_ofiles[i]) == NULL)
|
||||
continue;
|
||||
|
||||
fp = ff->ff_file;
|
||||
|
||||
/* Only look at vnodes... */
|
||||
if (fp->f_type == DTYPE_VNODE) {
|
||||
vn = (struct vnode *) fp->f_data;
|
||||
vfs_vnode_print(vn, full, db_printf);
|
||||
|
||||
#ifdef LOCKDEBUG
|
||||
lockdebug_lock_print(&(vn->v_uobj.vmobjlock),
|
||||
db_printf);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
db_show_aio_jobs(db_expr_t addr, bool haddr,
|
||||
db_expr_t count, const char *modif)
|
||||
|
@ -137,7 +179,7 @@ db_show_all_procs(db_expr_t addr, bool haddr,
|
|||
struct proc *p, *pp, *cp;
|
||||
struct lwp *l, *cl;
|
||||
const struct proclist_desc *pd;
|
||||
char nbuf[MAXCOMLEN + 1];
|
||||
char db_nbuf[MAXCOMLEN + 1];
|
||||
|
||||
if (modif[0] == 0)
|
||||
mode = "n"; /* default == normal mode */
|
||||
|
@ -197,14 +239,17 @@ db_show_all_procs(db_expr_t addr, bool haddr,
|
|||
case 'l':
|
||||
while (l != NULL) {
|
||||
if (l->l_name != NULL) {
|
||||
snprintf(nbuf, sizeof(nbuf),
|
||||
snprintf(db_nbuf,
|
||||
sizeof(db_nbuf),
|
||||
"%s", l->l_name);
|
||||
} else
|
||||
snprintf(nbuf, sizeof(nbuf),
|
||||
snprintf(db_nbuf,
|
||||
sizeof(db_nbuf),
|
||||
"%s", p->p_comm);
|
||||
db_printf("%c%4d %d %9x %18lx %18s %-8s\n",
|
||||
(cl == l ? '>' : ' '), l->l_lid,
|
||||
l->l_stat, l->l_flag, (long)l, nbuf,
|
||||
l->l_stat, l->l_flag, (long)l,
|
||||
db_nbuf,
|
||||
(l->l_wchan && l->l_wmesg) ?
|
||||
l->l_wmesg : "");
|
||||
|
||||
|
|
Loading…
Reference in New Issue