From bc86b22810eed37052800ae9d83fe8b80010e0dd Mon Sep 17 00:00:00 2001 From: gad Date: Sun, 20 Jun 2004 23:40:54 +0000 Subject: Add the `-O emul' format option, which prints the name of the system-call emulation environment the process is in. "emul" as a keyword is picked up from OpenBSD. PR: bin/65803 Submitted by: Cyrille Lefevre --- bin/ps/extern.h | 1 + bin/ps/keyword.c | 3 +++ bin/ps/print.c | 9 +++++++++ 3 files changed, 13 insertions(+) (limited to 'bin/ps') diff --git a/bin/ps/extern.h b/bin/ps/extern.h index ca12a79..3642fc9 100644 --- a/bin/ps/extern.h +++ b/bin/ps/extern.h @@ -48,6 +48,7 @@ void command(KINFO *, VARENT *); void cputime(KINFO *, VARENT *); int donlist(void); void elapsed(KINFO *, VARENT *); +void emulname(KINFO *, VARENT *); VARENT *find_varentry(VAR *); const char *fmt_argv(char **, char *, size_t); double getpcpu(const KINFO *); diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c index f5aa959..6764b90 100644 --- a/bin/ps/keyword.c +++ b/bin/ps/keyword.c @@ -57,6 +57,7 @@ static int vcmp(const void *, const void *); #define KOFF(x) offsetof(struct kinfo_proc, x) #define ROFF(x) offsetof(struct rusage, x) +#define EMULLEN 13 /* enough for "FreeBSD ELF32" */ #define LWPFMT "d" #define LWPLEN 6 #define NLWPFMT "d" @@ -85,6 +86,8 @@ static VAR var[] = { {"cpu", "CPU", NULL, 0, kvar, NULL, 3, KOFF(ki_estcpu), UINT, "d", 0}, {"cputime", "", "time", 0, NULL, NULL, 0, 0, CHAR, NULL, 0}, + {"emul", "EMUL", NULL, LJUST, emulname, NULL, EMULLEN, 0, CHAR, + NULL, 0}, {"etime", "ELAPSED", NULL, USER, elapsed, NULL, 12, 0, CHAR, NULL, 0}, {"f", "F", NULL, 0, kvar, NULL, 7, KOFF(ki_flag), INT, "x", 0}, {"flags", "", "f", 0, NULL, NULL, 0, 0, CHAR, NULL, 0}, diff --git a/bin/ps/print.c b/bin/ps/print.c index 76e29ab..01e7e1c 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -750,6 +750,15 @@ rvar(KINFO *k, VARENT *ve) } void +emulname(KINFO *k, VARENT *ve) +{ + VAR *v; + + v = ve->var; + printf("%-*s", v->width, *k->ki_p->ki_emul ? k->ki_p->ki_emul : "-"); +} + +void label(KINFO *k, VARENT *ve) { char *string; -- cgit v1.1