diff options
author | rwatson <rwatson@FreeBSD.org> | 2007-02-15 10:50:48 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2007-02-15 10:50:48 +0000 |
commit | 8ae276c86f35fec6aafa3cbb38d716f46f8b6054 (patch) | |
tree | d019b4c0ca144d692e1264a9e7ab139e23b21477 | |
parent | 62ceb5ba2195709964f9b11f82b7fe5e253d4412 (diff) | |
download | FreeBSD-src-8ae276c86f35fec6aafa3cbb38d716f46f8b6054.zip FreeBSD-src-8ae276c86f35fec6aafa3cbb38d716f46f8b6054.tar.gz |
Break file descriptor printing logic out of db_show_files() into
db_print_file(), and add a new "show file <ptr>" DDB command, which can
be used to print out file descriptors referenced in stack traces.
-rw-r--r-- | sys/kern/kern_descrip.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index b4e4560..f762039 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -2577,20 +2577,43 @@ file_to_first_proc(struct file *fp) return (NULL); } +static void +db_print_file(struct file *fp, int header) +{ + struct proc *p; + + if (header) + db_printf("%8s %4s %8s %8s %4s %5s %6s %8s %5s %12s\n", + "File", "Type", "Data", "Flag", "GCFl", "Count", + "MCount", "Vnode", "FPID", "FCmd"); + p = file_to_first_proc(fp); + db_printf("%8p %4s %8p %08x %04x %5d %6d %8p %5d %12s\n", fp, + file_type_to_name(fp->f_type), fp->f_data, fp->f_flag, + fp->f_gcflag, fp->f_count, fp->f_msgcount, fp->f_vnode, + p != NULL ? p->p_pid : -1, p != NULL ? p->p_comm : "-"); +} + +DB_SHOW_COMMAND(file, db_show_file) +{ + struct file *fp; + + if (!have_addr) { + db_printf("usage: show file <addr>\n"); + return; + } + fp = (struct file *)addr; + db_print_file(fp, 1); +} + DB_SHOW_COMMAND(files, db_show_files) { struct file *fp; - struct proc *p; + int header; - db_printf("%8s %4s %8s %8s %4s %5s %6s %8s %5s %12s\n", "File", - "Type", "Data", "Flag", "GCFl", "Count", "MCount", "Vnode", - "FPID", "FCmd"); + header = 1; LIST_FOREACH(fp, &filehead, f_list) { - p = file_to_first_proc(fp); - db_printf("%8p %4s %8p %08x %04x %5d %6d %8p %5d %12s\n", fp, - file_type_to_name(fp->f_type), fp->f_data, fp->f_flag, - fp->f_gcflag, fp->f_count, fp->f_msgcount, fp->f_vnode, - p != NULL ? p->p_pid : -1, p != NULL ? p->p_comm : "-"); + db_print_file(fp, header); + header = 0; } } #endif |