From: kn Date: Thu, 9 Nov 2023 15:43:28 +0000 (+0000) Subject: Add [-P progam] to filter dumps by basename X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=cf347463208cf1c551f60c2b6e3d7e3d0855bd2c;p=openbsd 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 --- 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<