Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ddb Add:
details: https://anonhg.NetBSD.org/src/rev/ee782c8329f5
branches: trunk
changeset: 764038:ee782c8329f5
user: christos <christos%NetBSD.org@localhost>
date: Sun Apr 10 20:59:22 2011 +0000
description:
Add:
usage: show proc [/a] [/p] address|pid
/a == argument is an address of any lwp
/p == argument is a pid [default]
From: Vladimir Kirillov proger at wilab dot org dot ua
diffstat:
sys/ddb/db_command.c | 8 ++-
sys/ddb/db_interface.h | 3 +-
sys/ddb/db_proc.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 94 insertions(+), 8 deletions(-)
diffs (165 lines):
diff -r 29331052b353 -r ee782c8329f5 sys/ddb/db_command.c
--- a/sys/ddb/db_command.c Sun Apr 10 20:39:42 2011 +0000
+++ b/sys/ddb/db_command.c Sun Apr 10 20:59:22 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_command.c,v 1.134 2010/09/13 08:42:04 drochner Exp $ */
+/* $NetBSD: db_command.c,v 1.135 2011/04/10 20:59:22 christos Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.134 2010/09/13 08:42:04 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.135 2011/04/10 20:59:22 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_aio.h"
@@ -219,10 +219,12 @@
#endif
{ DDB_ADD_CMD("pages", db_show_all_pages,
0 ,"List all used memory pages.",NULL,NULL) },
+ { DDB_ADD_CMD("proc", db_show_proc,
+ 0 ,"Print process information.",NULL,NULL) },
{ DDB_ADD_CMD("procs", db_show_all_procs,
0 ,"List all processes.",NULL,NULL) },
{ DDB_ADD_CMD("pools", db_show_all_pools,
- 0 ,"Show all poolS",NULL,NULL) },
+ 0 ,"Show all pools",NULL,NULL) },
#ifdef AIO
/*added from all sub cmds*/
{ DDB_ADD_CMD("aio_jobs", db_show_aio_jobs, 0,
diff -r 29331052b353 -r ee782c8329f5 sys/ddb/db_interface.h
--- a/sys/ddb/db_interface.h Sun Apr 10 20:39:42 2011 +0000
+++ b/sys/ddb/db_interface.h Sun Apr 10 20:59:22 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_interface.h,v 1.25 2009/02/18 13:31:59 yamt Exp $ */
+/* $NetBSD: db_interface.h,v 1.26 2011/04/10 20:59:22 christos Exp $ */
/*-
* Copyright (c) 1995 The NetBSD Foundation, Inc.
@@ -46,6 +46,7 @@
/* kern/kern_proc.c */
void db_kill_proc(db_expr_t, bool, db_expr_t, const char *);
+void db_show_proc(db_expr_t, bool, db_expr_t, const char *);
void db_show_all_procs(db_expr_t, bool, db_expr_t, const char *);
void db_show_all_pools(db_expr_t, bool, db_expr_t, const char *);
void db_show_sched_qs(db_expr_t, bool, db_expr_t, const char *);
diff -r 29331052b353 -r ee782c8329f5 sys/ddb/db_proc.c
--- a/sys/ddb/db_proc.c Sun Apr 10 20:39:42 2011 +0000
+++ b/sys/ddb/db_proc.c Sun Apr 10 20:59:22 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_proc.c,v 1.3 2009/03/09 06:07:05 mrg Exp $ */
+/* $NetBSD: db_proc.c,v 1.4 2011/04/10 20:59:22 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_proc.c,v 1.3 2009/03/09 06:07:05 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_proc.c,v 1.4 2011/04/10 20:59:22 christos Exp $");
#ifndef _KERNEL
#include <stdbool.h>
@@ -129,8 +129,8 @@
if (mode == NULL || *mode == 'm') {
db_printf("usage: show all procs [/a] [/l] [/n] [/w]\n");
db_printf("\t/a == show process address info\n");
- db_printf("\t/l == show LWP info\n");
- db_printf("\t/n == show normal process info [default]\n");
+ db_printf("\t/l == show LWP info [default]\n");
+ db_printf("\t/n == show normal process info\n");
db_printf("\t/w == show process wait/emul info\n");
return;
}
@@ -257,3 +257,86 @@
}
}
+void
+db_show_proc(db_expr_t addr, bool haddr, db_expr_t count, const char *modif)
+{
+ static proc_t p;
+ static lwp_t l;
+ const char *mode;
+ proc_t *pp;
+ lwp_t *lp;
+ char db_nbuf[MAXCOMLEN + 1], wbuf[MAXCOMLEN + 1];
+ bool run;
+ int cpuno;
+
+ if (modif[0] == 0)
+ mode = "p"; /* default == by pid */
+ else
+ mode = strchr("ap", modif[0]);
+
+ if (mode == NULL || !haddr) {
+ db_printf("usage: show proc [/a] [/p] address|pid\n");
+ db_printf("\t/a == argument is an address of any lwp\n");
+ db_printf("\t/p == argument is a pid [default]\n");
+ return;
+ }
+
+ switch (*mode) {
+ case 'a':
+ lp = (lwp_t *)addr;
+ db_printf("lwp_t %lx\n", (long)lp);
+ db_read_bytes((db_addr_t)lp, sizeof(l), (char *)&l);
+ pp = l.l_proc;
+ break;
+ default:
+ case 'p':
+ pp = db_proc_find((pid_t)addr);
+ lp = NULL;
+ break;
+ }
+
+ if (pp == NULL) {
+ db_printf("bad address\n");
+ return;
+ }
+
+ db_read_bytes((db_addr_t)pp, sizeof(p), (char *)&p);
+ if (lp == NULL)
+ lp = p.p_lwps.lh_first;
+
+ db_printf("%s: pid %d proc %lx vmspace/map %lx flags %x\n",
+ p.p_comm, p.p_pid, (long)pp, (long)p.p_vmspace, p.p_flag);
+
+ while (lp != NULL) {
+ db_read_bytes((db_addr_t)lp, sizeof(l), (char *)&l);
+
+ run = (l.l_stat == LSONPROC ||
+ (l.l_pflag & LP_RUNNING) != 0);
+
+ db_printf("%slwp %d", (run ? "> " : " "), l.l_lid);
+ if (l.l_name != NULL) {
+ db_read_bytes((db_addr_t)l.l_name,
+ MAXCOMLEN, db_nbuf);
+ db_printf(" [%s]", db_nbuf);
+ }
+ db_printf(" %lx pcb %lx\n", (long)lp, (long)l.l_addr);
+
+ if (l.l_cpu != NULL) {
+ db_read_bytes((db_addr_t)
+ &l.l_cpu->ci_data.cpu_index,
+ sizeof(cpuno), (char *)&cpuno);
+ } else
+ cpuno = -1;
+ db_printf(" stat %d flags %x cpu %d pri %d \n",
+ l.l_stat, l.l_flag, cpuno, l.l_priority);
+
+ if (l.l_wchan && l.l_wmesg) {
+ db_read_bytes((db_addr_t)l.l_wmesg,
+ sizeof(wbuf), (char *)wbuf);
+ db_printf(" wmesg %s wchan %lx\n",
+ wbuf, (long)l.l_wchan);
+ }
+
+ lp = LIST_NEXT(&l, l_sibling);
+ }
+}
Home |
Main Index |
Thread Index |
Old Index