-.\" $OpenBSD: kdump.1,v 1.35 2022/07/30 07:19:30 jsg Exp $
+.\" $OpenBSD: kdump.1,v 1.36 2023/04/16 19:42:40 otto Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" from: @(#)kdump.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd $Mdocdate: July 30 2022 $
+.Dd $Mdocdate: April 16 2023 $
.Dt KDUMP 1
.Os
.Sh NAME
.Op Fl m Ar maxdata
.Op Fl p Ar pid
.Op Fl t Ar trstr
+.Op Fl u Ar label
.Sh DESCRIPTION
.Nm
displays the kernel trace files produced with
option of
.Xr ktrace 1
for the meaning of the letters.
+.It Fl u Ar label
+Display
+.Xr utrace 2
+tracepoints having
+.XR utrace 2
+label
+.Ar label
+as strings with
+.Xr vis 3
+escaping, without
+.Xr ktrace 2
+header information.
.It Fl X
Display I/O data with hexadecimal data and printable ASCII characters
side by side.
.It Fl x
Display I/O data in hexadecimal.
.El
+.Pp
+The
+.Fl t
+and
+.Fl u
+options are mutually exclusive,
+the last one specified overrides any previous ones.
.Sh FILES
.Bl -tag -width ktrace.out -compact
.It Pa ktrace.out
-/* $OpenBSD: kdump.c,v 1.156 2023/02/17 18:01:26 deraadt Exp $ */
+/* $OpenBSD: kdump.c,v 1.157 2023/04/16 19:42:40 otto Exp $ */
/*-
* Copyright (c) 1988, 1993
char *tracefile = DEF_TRACEFILE;
struct ktr_header ktr_header;
pid_t pid_opt = -1;
+char* utracefilter;
#define eqs(s1, s2) (strcmp((s1), (s2)) == 0)
screenwidth = 80;
}
- while ((ch = getopt(argc, argv, "f:dHlm:np:RTt:xX")) != -1)
+ while ((ch = getopt(argc, argv, "f:dHlm:np:RTt:u:xX")) != -1)
switch (ch) {
case 'f':
tracefile = optarg;
trpoints = getpoints(optarg, DEF_POINTS);
if (trpoints < 0)
errx(1, "unknown trace point in %s", optarg);
+ utracefilter = NULL;
+ break;
+ case 'u':
+ utracefilter = optarg;
+ trpoints = KTRFAC_USER;
break;
case 'x':
iohex = 1;
silent = 0;
if (pid_opt != -1 && pid_opt != ktr_header.ktr_pid)
silent = 1;
- if (silent == 0 && trpoints & (1<<ktr_header.ktr_type))
+ if (utracefilter == NULL && silent == 0 &&
+ trpoints & (1<<ktr_header.ktr_type))
dumpheader(&ktr_header);
ktrlen = ktr_header.ktr_len;
if (ktrlen > size) {
static void
showbuf(unsigned char *dp, size_t datalen)
{
- int i, j;
+ size_t i, j;
int col = 0, bpl;
unsigned char c;
+ char visbuf[4 * KTR_USER_MAXLEN + 1];
+ if (utracefilter != NULL) {
+ strvisx(visbuf, dp, datalen, VIS_SAFE | VIS_OCTAL);
+ printf("%s", visbuf);
+ return;
+ }
if (iohex == 1) {
putchar('\t');
col = 8;
if (bpl <= 0)
bpl = 1;
for (i = 0; i < datalen; i += bpl) {
- printf(" %04x: ", i);
+ printf(" %04zx: ", i);
for (j = 0; j < bpl; j++) {
if (i+j >= datalen)
printf(" ");
if (len < sizeof(struct ktr_user))
errx(1, "invalid ktr user length %zu", len);
len -= sizeof(struct ktr_user);
- printf("%.*s:", KTR_USER_MAXIDLEN, usr->ktr_id);
- printf(" %zu bytes\n", len);
- showbuf((unsigned char *)(usr + 1), len);
+ if (utracefilter == NULL) {
+ printf("%.*s:", KTR_USER_MAXIDLEN, usr->ktr_id);
+ printf(" %zu bytes\n", len);
+ showbuf((unsigned char *)(usr + 1), len);
+ } else if (strncmp(usr->ktr_id, utracefilter, KTR_USER_MAXIDLEN) == 0)
+ showbuf((unsigned char *)(usr + 1), len);
}
static void
extern char *__progname;
fprintf(stderr, "usage: %s "
- "[-dHlnRTXx] [-f file] [-m maxdata] [-p pid] [-t trstr]\n",
- __progname);
+ "[-dHlnRTXx] [-f file] [-m maxdata] [-p pid] [-t trstr] "
+ "[-u label]\n", __progname);
exit(1);
}