summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2003-05-12 19:56:05 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2003-05-12 19:56:05 +0000
commit1305009a7d2fa7fb5184f76339e28061673bfcaf (patch)
tree3bf61ba3ae870c47ce2d623291ead43b20c86bbb /sys
parente32eb83ef7db72d9e8e35710c2049b1d43f130b1 (diff)
sho proc [addr] to print some proc's field; art@ ok
Diffstat (limited to 'sys')
-rw-r--r--sys/ddb/db_command.c17
-rw-r--r--sys/ddb/db_command.h3
-rw-r--r--sys/kern/kern_proc.c31
-rw-r--r--sys/sys/proc.h10
4 files changed, 57 insertions, 4 deletions
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c
index 2edf162fa4b..f3e61da919f 100644
--- a/sys/ddb/db_command.c
+++ b/sys/ddb/db_command.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_command.c,v 1.30 2003/02/12 14:41:07 jason Exp $ */
+/* $OpenBSD: db_command.c,v 1.31 2003/05/12 19:56:03 mickey Exp $ */
/* $NetBSD: db_command.c,v 1.20 1996/03/30 22:30:05 christos Exp $ */
/*
@@ -376,6 +376,20 @@ db_pool_print_cmd(addr, have_addr, count, modif)
/*ARGSUSED*/
void
+db_proc_print_cmd(addr, have_addr, count, modif)
+ db_expr_t addr;
+ int have_addr;
+ db_expr_t count;
+ char * modif;
+{
+ if (!have_addr)
+ addr = (db_expr_t)curproc;
+
+ proc_printit((struct proc *)addr, modif, db_printf);
+}
+
+/*ARGSUSED*/
+void
db_uvmexp_print_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
@@ -404,6 +418,7 @@ struct db_command db_show_cmds[] = {
{ "object", db_object_print_cmd, 0, NULL },
{ "page", db_page_print_cmd, 0, NULL },
{ "pool", db_pool_print_cmd, 0, NULL },
+ { "proc", db_proc_print_cmd, 0, NULL },
{ "registers", db_show_regs, 0, NULL },
{ "uvmexp", db_uvmexp_print_cmd, 0, NULL },
{ "watches", db_listwatch_cmd, 0, NULL },
diff --git a/sys/ddb/db_command.h b/sys/ddb/db_command.h
index d76dac736c3..2fc48550b86 100644
--- a/sys/ddb/db_command.h
+++ b/sys/ddb/db_command.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_command.h,v 1.16 2003/02/12 14:41:07 jason Exp $ */
+/* $OpenBSD: db_command.h,v 1.17 2003/05/12 19:56:04 mickey Exp $ */
/* $NetBSD: db_command.h,v 1.8 1996/02/05 01:56:55 christos Exp $ */
/*
@@ -44,6 +44,7 @@ void db_object_print_cmd(db_expr_t, int, db_expr_t, char *);
void db_page_print_cmd(db_expr_t, int, db_expr_t, char *);
void db_extent_print_cmd(db_expr_t, int, db_expr_t, char *);
void db_pool_print_cmd(db_expr_t, int, db_expr_t, char *);
+void db_proc_print_cmd(db_expr_t, int, db_expr_t, char *);
void db_uvmexp_print_cmd(db_expr_t, int, db_expr_t, char *);
void db_machine_commands_install(struct db_command *);
void db_help_cmd(db_expr_t, int, db_expr_t, char *);
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index bbf8b93889b..b1ed6499de5 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_proc.c,v 1.13 2002/03/14 01:27:04 millert Exp $ */
+/* $OpenBSD: kern_proc.c,v 1.14 2003/05/12 19:56:03 mickey Exp $ */
/* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */
/*
@@ -387,6 +387,35 @@ orphanpg(pg)
}
}
+void
+proc_printit(struct proc *p, const char *modif, int (*pr)(const char *, ...))
+{
+ const static char *pstat[] = {
+ "idle", "run", "sleep", "stop", "zombie", "dead"
+ };
+ char pstbuf[5];
+ const char *pst = pstbuf;
+
+ if (p->p_stat > sizeof(pstat)/sizeof(*pstat))
+ sprintf(pstbuf, "%d", p->p_stat);
+ else
+ pst = pstat[(int)p->p_stat];
+
+ (*pr)("PROC (%s) pid=%d stat=%s flags=%b\n",
+ p->p_comm, p->p_pid, pst, p->p_flag, P_BITS);
+ (*pr)(" pri=%u, usrpri=%u, nice=%d\n",
+ p->p_priority, p->p_usrpri, p->p_nice);
+ (*pr)(" forw=%p, back=%p, list=%p,%p\n",
+ p->p_forw, p->p_back, p->p_list.le_next, p->p_list.le_prev);
+ (*pr)(" user=%p, vmspace=%p, md_regs=%p\n",
+ p->p_addr, p->p_vmspace, p->p_md.md_regs);
+ (*pr)(" estcpu=%u, cpticks=%d, pctcpu=%d.%d%, swtime=%u\n",
+ p->p_estcpu, p->p_cpticks, p->p_pctcpu / 100, p->p_pctcpu % 100,
+ p->p_swtime);
+ (*pr)(" user=%llu, sys=%llu, intr=%llu\n",
+ p->p_uticks, p->p_sticks, p->p_iticks);
+}
+
#ifdef DEBUG
void
pgrpdump()
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index ed3d79b4104..033eaee542f 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.h,v 1.62 2002/07/20 19:24:57 art Exp $ */
+/* $OpenBSD: proc.h,v 1.63 2003/05/12 19:56:03 mickey Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
@@ -255,6 +255,12 @@ struct proc {
#define P_INEXEC 0x200000 /* Process is doing an exec right now */
#define P_SYSTRACE 0x400000 /* Process system call tracing active*/
+#define P_BITS \
+ ("\20\01ADVLOCK\02CTTY\03INMEM\04NOCLDSTOP\05PPWAIT\06PROFIL\07SELECT" \
+ "\010SINTR\011SUGID\012SYSTEM\013TIMEOUT\014TRACED\015WAITED\016WEXIT" \
+ "\017EXEC\020PWEUPC\021FSTRACE\022SSTEP\023SUGIDEXEC\024NOCLDWAIT" \
+ "\025NOZOMBIE\026INEXEC\027SYSTRACE")
+
/* Macro to compute the exit signal to be delivered. */
#define P_EXITSIG(p) \
(((p)->p_flag & (P_TRACED | P_FSTRACE)) ? SIGCHLD : (p)->p_exitsig)
@@ -363,6 +369,8 @@ struct simplelock;
struct proc *pfind(pid_t); /* Find process by id. */
struct pgrp *pgfind(pid_t); /* Find process group by id. */
+void proc_printit(struct proc *p, const char *modif,
+ int (*pr)(const char *, ...));
int chgproccnt(uid_t uid, int diff);
int enterpgrp(struct proc *p, pid_t pgid, int mksess);