From f191aecbd1d55f1216537ff2a5336a49b3deabbe Mon Sep 17 00:00:00 2001 From: claudio Date: Tue, 19 Sep 2023 11:35:30 +0000 Subject: [PATCH] Improve the output of ddb "show proc" command Include missing fields -- like the sleep channel and message -- and show both the PID and TID of the proc. Also add '/t' as an argument that can be used to specify a proc by TID instead of by address. OK mpi@ --- sys/ddb/db_command.c | 9 ++++++++- sys/kern/kern_proc.c | 18 +++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index fd2070b91e9..ca4226c512a 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_command.c,v 1.99 2023/07/02 19:02:27 cheloha Exp $ */ +/* $OpenBSD: db_command.c,v 1.100 2023/09/19 11:35:30 claudio Exp $ */ /* $NetBSD: db_command.c,v 1.20 1996/03/30 22:30:05 christos Exp $ */ /* @@ -541,6 +541,13 @@ db_proc_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { if (!have_addr) addr = (db_expr_t)curproc; + if (modif[0] == 't') { + addr = (db_expr_t)tfind((pid_t)addr); + if (addr == 0) { + db_printf("not found\n"); + return; + } + } proc_printit((struct proc *)addr, modif, db_printf); } diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 0eb2df6583a..3c19519629b 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_proc.c,v 1.94 2023/01/02 23:09:48 guenther Exp $ */ +/* $OpenBSD: kern_proc.c,v 1.95 2023/09/19 11:35:30 claudio Exp $ */ /* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */ /* @@ -489,18 +489,22 @@ proc_printit(struct proc *p, const char *modif, else pst = pstat[(int)p->p_stat - 1]; - (*pr)("PROC (%s) pid=%d stat=%s\n", p->p_p->ps_comm, p->p_tid, pst); + (*pr)("PROC (%s) tid=%d pid=%d tcnt=%d stat=%s\n", p->p_p->ps_comm, + p->p_tid, p->p_p->ps_pid, p->p_p->ps_threadcnt, pst); (*pr)(" flags process=%b proc=%b\n", p->p_p->ps_flags, PS_BITS, p->p_flag, P_BITS); - (*pr)(" pri=%u, usrpri=%u, nice=%d\n", - p->p_runpri, p->p_usrpri, p->p_p->ps_nice); + (*pr)(" runpri=%u, usrpri=%u, slppri=%u, nice=%d\n", + p->p_runpri, p->p_usrpri, p->p_slppri, p->p_p->ps_nice); + (*pr)(" wchan=%p, wmesg=%s, ps_single=%p\n", + p->p_wchan, (p->p_wchan && p->p_wmesg) ? p->p_wmesg : "", + p->p_p->ps_single); (*pr)(" forw=%p, list=%p,%p\n", TAILQ_NEXT(p, p_runq), p->p_list.le_next, p->p_list.le_prev); (*pr)(" process=%p user=%p, vmspace=%p\n", p->p_p, p->p_addr, p->p_vmspace); - (*pr)(" estcpu=%u, cpticks=%d, pctcpu=%u.%u\n", - p->p_estcpu, p->p_cpticks, p->p_pctcpu / 100, p->p_pctcpu % 100); - (*pr)(" user=%u, sys=%u, intr=%u\n", + (*pr)(" estcpu=%u, cpticks=%d, pctcpu=%u.%u, " + "user=%u, sys=%u, intr=%u\n", + p->p_estcpu, p->p_cpticks, p->p_pctcpu / 100, p->p_pctcpu % 100, p->p_uticks, p->p_sticks, p->p_iticks); } #include -- 2.20.1