summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorKlemens Nanni <kn@cvs.openbsd.org>2023-11-09 15:43:29 +0000
committerKlemens Nanni <kn@cvs.openbsd.org>2023-11-09 15:43:29 +0000
commit1b3c1df8fefb73bc704a94823903f47ba66cb377 (patch)
tree4ded8cca52638c09d7512c5f7a34aa2829aef475 /usr.bin
parente5b789217a3adbf0b4579505cf8888adbd989549 (diff)
Add [-P progam] to filter dumps by basename
[-p pid] requires knowing the PIDs beforehand, sieving through big dumps by argv[0] strings is more ergonomic. OK deraadt
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/kdump/kdump.19
-rw-r--r--usr.bin/kdump/kdump.c15
2 files changed, 18 insertions, 6 deletions
diff --git a/usr.bin/kdump/kdump.1 b/usr.bin/kdump/kdump.1
index 1c745572321..8b45710d15f 100644
--- a/usr.bin/kdump/kdump.1
+++ b/usr.bin/kdump/kdump.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: kdump.1,v 1.38 2023/09/30 13:03:40 naddy Exp $
+.\" $OpenBSD: kdump.1,v 1.39 2023/11/09 15:43:28 kn Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" from: @(#)kdump.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd $Mdocdate: September 30 2023 $
+.Dd $Mdocdate: November 9 2023 $
.Dt KDUMP 1
.Os
.Sh NAME
@@ -40,6 +40,7 @@
.Op Fl dHlnRTXx
.Op Fl f Ar file
.Op Fl m Ar maxdata
+.Op Fl P Ar program
.Op Fl p Ar pid
.Op Fl t Ar trstr
.Op Fl u Ar label
@@ -88,6 +89,10 @@ values are replaced with the
string.
Suppressing this feature yields a more consistent output format and is
easily amenable to further processing.
+.It Fl P Ar program
+Show output only for processes with
+.Ar program
+as their command name.
.It Fl p Ar pid
Show output only for the
.Ar pid
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index 09683d9e9a0..3411f7a33b2 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kdump.c,v 1.158 2023/08/21 01:37:56 visa Exp $ */
+/* $OpenBSD: kdump.c,v 1.159 2023/11/09 15:43:28 kn Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -88,6 +88,7 @@ int needtid, tail, basecol;
char *tracefile = DEF_TRACEFILE;
struct ktr_header ktr_header;
pid_t pid_opt = -1;
+const char *program;
char* utracefilter;
#define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
@@ -169,7 +170,7 @@ main(int argc, char *argv[])
screenwidth = 80;
}
- while ((ch = getopt(argc, argv, "f:dHlm:np:RTt:u:xX")) != -1)
+ while ((ch = getopt(argc, argv, "f:dHlm:nP:p:RTt:u:xX")) != -1)
switch (ch) {
case 'f':
tracefile = optarg;
@@ -191,6 +192,9 @@ main(int argc, char *argv[])
case 'n':
fancy = 0;
break;
+ case 'P':
+ program = optarg;
+ break;
case 'p':
pid_opt = strtonum(optarg, 1, INT_MAX, &errstr);
if (errstr)
@@ -252,6 +256,9 @@ main(int argc, char *argv[])
silent = 0;
if (pid_opt != -1 && pid_opt != ktr_header.ktr_pid)
silent = 1;
+ if (program != NULL &&
+ strcmp(ktr_header.ktr_comm, program) != 0)
+ silent = 1;
if (utracefilter == NULL && silent == 0 &&
trpoints & (1<<ktr_header.ktr_type))
dumpheader(&ktr_header);
@@ -1490,8 +1497,8 @@ usage(void)
extern char *__progname;
fprintf(stderr, "usage: %s "
- "[-dHlnRTXx] [-f file] [-m maxdata] [-p pid] [-t trstr] "
- "[-u label]\n", __progname);
+ "[-dHlnRTXx] [-f file] [-m maxdata] [-P program] [-p pid] "
+ "[-t trstr]\n\t[-u label]\n", __progname);
exit(1);
}