summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2013-06-01 09:51:31 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2013-06-01 09:51:31 +0000
commitef21a2cb5b0d81e925c90a50449ba06a311298e0 (patch)
treeb706bc221bbd3d98138080ff2e0c0e3d95443072
parent786bbfc14be1f59f643c0d189e0a2fa7b271381c (diff)
Userland bits for utrace record handling; from otto@
-rw-r--r--usr.bin/kdump/kdump.18
-rw-r--r--usr.bin/kdump/kdump.c53
-rw-r--r--usr.bin/ktrace/ktrace.115
-rw-r--r--usr.bin/ktrace/ktrace.h5
-rw-r--r--usr.bin/ktrace/subr.c5
5 files changed, 58 insertions, 28 deletions
diff --git a/usr.bin/kdump/kdump.1 b/usr.bin/kdump/kdump.1
index fad59ab85bf..b66e0544c3d 100644
--- a/usr.bin/kdump/kdump.1
+++ b/usr.bin/kdump/kdump.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: kdump.1,v 1.22 2012/04/10 20:39:37 mikeb Exp $
+.\" $OpenBSD: kdump.1,v 1.23 2013/06/01 09:51:30 miod 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: April 10 2012 $
+.Dd $Mdocdate: June 1 2013 $
.Dt KDUMP 1
.Os
.Sh NAME
@@ -43,7 +43,7 @@
.Op Fl f Ar file
.Op Fl m Ar maxdata
.Op Fl p Ar pid
-.Op Fl t Op ceinsw
+.Op Fl t Op ceinstuw
.Ek
.Sh DESCRIPTION
.Nm
@@ -106,7 +106,7 @@ CALL records or structure members in STRU records
display symbolically instead of numerically.
.It Fl T
Display absolute timestamps for each entry (seconds since the Epoch).
-.It Fl t Op ceinstw
+.It Fl t Op ceinstuw
Selects which tracepoints to display.
See the
.Fl t
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index 863b0c9696d..76dcfeb256d 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kdump.c,v 1.80 2013/04/23 20:03:05 deraadt Exp $ */
+/* $OpenBSD: kdump.c,v 1.81 2013/06/01 09:51:30 miod Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -157,6 +157,7 @@ static void ktrsyscall(struct ktr_syscall *);
static const char *kresolvsysctl(int, int *, int);
static void ktrsysret(struct ktr_sysret *);
static void ktrstruct(char *, size_t);
+static void ktruser(struct ktr_user *, size_t);
static void setemul(const char *);
static void usage(void);
static void atfd(int);
@@ -286,6 +287,9 @@ main(int argc, char *argv[])
case KTR_STRUCT:
ktrstruct(m, ktrlen);
break;
+ case KTR_USER:
+ ktruser(m, ktrlen);
+ break;
}
if (tail)
(void)fflush(stdout);
@@ -369,6 +373,9 @@ dumpheader(struct ktr_header *kth)
case KTR_STRUCT:
type = "STRU";
break;
+ case KTR_USER:
+ type = "USER";
+ break;
default:
(void)snprintf(unknown, sizeof unknown, "UNKNOWN(%d)",
kth->ktr_type);
@@ -1094,12 +1101,10 @@ ktremul(char *cp, size_t len)
}
static void
-ktrgenio(struct ktr_genio *ktr, size_t len)
+showbuf(unsigned char *dp, size_t datalen)
{
- unsigned char *dp = (unsigned char *)ktr + sizeof(struct ktr_genio);
int i, j;
- size_t datalen = len - sizeof(struct ktr_genio);
- static int screenwidth = 0;
+ static int screenwidth;
int col = 0, width, bpl;
unsigned char visbuf[5], *cp, c;
@@ -1112,14 +1117,6 @@ ktrgenio(struct ktr_genio *ktr, size_t len)
else
screenwidth = 80;
}
- printf("fd %d %s %zu bytes\n", ktr->ktr_fd,
- ktr->ktr_rw == UIO_READ ? "read" : "wrote", datalen);
- if (maxdata == 0)
- return;
- if (datalen > maxdata)
- datalen = maxdata;
- if (iohex && !datalen)
- return;
if (iohex == 1) {
putchar('\t');
col = 8;
@@ -1202,6 +1199,23 @@ ktrgenio(struct ktr_genio *ktr, size_t len)
}
static void
+ktrgenio(struct ktr_genio *ktr, size_t len)
+{
+ unsigned char *dp = (unsigned char *)ktr + sizeof(struct ktr_genio);
+ size_t datalen = len - sizeof(struct ktr_genio);
+
+ printf("fd %d %s %zu bytes\n", ktr->ktr_fd,
+ ktr->ktr_rw == UIO_READ ? "read" : "wrote", datalen);
+ if (maxdata == 0)
+ return;
+ if (datalen > maxdata)
+ datalen = maxdata;
+ if (iohex && !datalen)
+ return;
+ showbuf(dp, datalen);
+}
+
+static void
ktrpsig(struct ktr_psig *psig)
{
(void)printf("SIG%s ", sys_signame[psig->signo]);
@@ -1263,8 +1277,6 @@ ktrcsw(struct ktr_csw *cs)
cs->user ? "user" : "kernel");
}
-
-
static void
ktrsockaddr(struct sockaddr *sa)
{
@@ -1589,13 +1601,22 @@ invalid:
}
static void
+ktruser(struct ktr_user *usr, size_t 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);
+}
+
+static void
usage(void)
{
extern char *__progname;
fprintf(stderr, "usage: %s "
"[-dHlnRrTXx] [-e emulation] [-f file] [-m maxdata] [-p pid]\n"
- "%*s[-t [ceinsw]]\n",
+ "%*s[-t [ceinstuw]]\n",
__progname, (int)(sizeof("usage: ") + strlen(__progname)), "");
exit(1);
}
diff --git a/usr.bin/ktrace/ktrace.1 b/usr.bin/ktrace/ktrace.1
index 4d2224031ec..3468674cd38 100644
--- a/usr.bin/ktrace/ktrace.1
+++ b/usr.bin/ktrace/ktrace.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ktrace.1,v 1.23 2012/07/12 16:45:15 guenther Exp $
+.\" $OpenBSD: ktrace.1,v 1.24 2013/06/01 09:51:28 miod Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" from: @(#)ktrace.1 8.1 (Berkeley) 6/6/93
.\"
-.Dd $Mdocdate: July 12 2012 $
+.Dd $Mdocdate: June 1 2013 $
.Dt KTRACE 1
.Os
.Sh NAME
@@ -73,7 +73,7 @@ The trace file is not human-readable; use
to decode it.
.Pp
The options are as follows:
-.Bl -tag -width "-t trstr"
+.Bl -tag -width 9n
.It Fl a
Append to the trace file instead of recreating it.
.It Fl B
@@ -117,8 +117,9 @@ The default flags are
.Cm i ,
.Cm n ,
.Cm s ,
+.Cm t ,
and
-.Cm t .
+.Cm u .
The following table equates the letters with the tracepoints:
.Pp
.Bl -tag -width flag -offset indent -compact
@@ -134,6 +135,9 @@ trace namei translations
trace signal processing
.It Cm t
trace various structures
+.It Cm u
+trace user data coming from
+.Xr utrace 2
.It Cm w
trace context switch points
.It Cm +
@@ -185,7 +189,8 @@ Disable tracing of all processes owned by the user:
.Dl $ ktrace -C
.Sh SEE ALSO
.Xr kdump 1 ,
-.Xr ktrace 2
+.Xr ktrace 2 ,
+.Xr utrace 2
.Sh HISTORY
The
.Nm ktrace
diff --git a/usr.bin/ktrace/ktrace.h b/usr.bin/ktrace/ktrace.h
index f0ce8b9394b..01d18a20adf 100644
--- a/usr.bin/ktrace/ktrace.h
+++ b/usr.bin/ktrace/ktrace.h
@@ -1,4 +1,4 @@
-/* * $OpenBSD: ktrace.h,v 1.4 2011/07/08 19:29:44 otto Exp $*/
+/* * $OpenBSD: ktrace.h,v 1.5 2013/06/01 09:51:28 miod Exp $*/
/*-
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,7 +31,8 @@
*/
#define DEF_POINTS (KTRFAC_SYSCALL | KTRFAC_SYSRET | KTRFAC_NAMEI | \
- KTRFAC_GENIO | KTRFAC_PSIG | KTRFAC_EMUL | KTRFAC_STRUCT)
+ KTRFAC_GENIO | KTRFAC_PSIG | KTRFAC_EMUL | KTRFAC_STRUCT | \
+ KTRFAC_USER)
#define ALL_POINTS (DEF_POINTS | KTRFAC_CSW)
diff --git a/usr.bin/ktrace/subr.c b/usr.bin/ktrace/subr.c
index 0b44bb02498..251a5db5096 100644
--- a/usr.bin/ktrace/subr.c
+++ b/usr.bin/ktrace/subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr.c,v 1.7 2011/07/08 19:29:44 otto Exp $ */
+/* $OpenBSD: subr.c,v 1.8 2013/06/01 09:51:28 miod Exp $ */
/* $NetBSD: subr.c,v 1.6 1995/08/31 23:01:45 jtc Exp $ */
/*-
@@ -71,6 +71,9 @@ getpoints(s)
case 't':
facs |= KTRFAC_STRUCT;
break;
+ case 'u':
+ facs |= KTRFAC_USER;
+ break;
case '+':
facs |= DEF_POINTS;
break;