From: guenther Date: Mon, 18 Jul 2016 09:36:50 +0000 (+0000) Subject: Add 'p' trace point for KTRFAC_PLEDGE, as noted by X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=adacb5b9c7bfadd718eb842c33f0200ab15ad9dc;p=openbsd Add 'p' trace point for KTRFAC_PLEDGE, as noted by Michal Mazurek While here, fix handling of -t+ in ltrace. --- diff --git a/usr.bin/kdump/kdump.1 b/usr.bin/kdump/kdump.1 index b777a186def..4369b3f865d 100644 --- a/usr.bin/kdump/kdump.1 +++ b/usr.bin/kdump/kdump.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: kdump.1,v 1.31 2016/06/02 22:47:13 tedu Exp $ +.\" $OpenBSD: kdump.1,v 1.32 2016/07/18 09:36:50 guenther 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: June 2 2016 $ +.Dd $Mdocdate: July 18 2016 $ .Dt KDUMP 1 .Os .Sh NAME @@ -41,7 +41,7 @@ .Op Fl f Ar file .Op Fl m Ar maxdata .Op Fl p Ar pid -.Op Fl t Op Cm cinstuxX+ +.Op Fl t Op Cm cinpstuxX+ .Sh DESCRIPTION .Nm displays the kernel trace files produced with @@ -94,7 +94,7 @@ Display relative timestamps (time since previous entry). Display absolute timestamps for each entry (seconds since the Epoch). .It Fl TR If both options are specified, display timestamps relative to trace start. -.It Fl t Op Cm cinstuxX+ +.It Fl t Op Cm cinpstuxX+ Selects which tracepoints to display. See the .Fl t diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c index ca2a4790dbb..da5c51ce0db 100644 --- a/usr.bin/kdump/kdump.c +++ b/usr.bin/kdump/kdump.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kdump.c,v 1.128 2016/06/02 22:47:13 tedu Exp $ */ +/* $OpenBSD: kdump.c,v 1.129 2016/07/18 09:36:50 guenther Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -192,7 +192,7 @@ main(int argc, char *argv[]) timestamp = timestamp == 2 ? 3 : 1; break; case 't': - trpoints = getpoints(optarg); + trpoints = getpoints(optarg, DEF_POINTS); if (trpoints < 0) errx(1, "unknown trace point in %s", optarg); break; @@ -1384,7 +1384,7 @@ usage(void) extern char *__progname; fprintf(stderr, "usage: %s " "[-dHlnRTXx] [-f file] [-m maxdata] [-p pid]\n" - "%*s[-t [cinstuxX+]]\n", + "%*s[-t [cinpstuxX+]]\n", __progname, (int)(sizeof("usage: ") + strlen(__progname)), ""); exit(1); } diff --git a/usr.bin/ktrace/extern.h b/usr.bin/ktrace/extern.h index 2a8a42150da..aca47f7b9c4 100644 --- a/usr.bin/ktrace/extern.h +++ b/usr.bin/ktrace/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.2 2002/02/16 21:27:47 millert Exp $ */ +/* $OpenBSD: extern.h,v 1.3 2016/07/18 09:36:50 guenther Exp $ */ /* * Copyright (c) 2001 Marc Espie. @@ -25,5 +25,5 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -extern int getpoints(const char *); -extern const char *ioctlname(unsigned long); +int getpoints(const char *, int); +const char *ioctlname(unsigned long); diff --git a/usr.bin/ktrace/ktrace.1 b/usr.bin/ktrace/ktrace.1 index aec875e6152..7ecbb113394 100644 --- a/usr.bin/ktrace/ktrace.1 +++ b/usr.bin/ktrace/ktrace.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ktrace.1,v 1.28 2016/03/06 20:25:27 guenther Exp $ +.\" $OpenBSD: ktrace.1,v 1.29 2016/07/18 09:36:50 guenther 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: March 6 2016 $ +.Dd $Mdocdate: July 18 2016 $ .Dt KTRACE 1 .Os .Sh NAME @@ -111,16 +111,10 @@ Enable (disable) tracing on the indicated process ID (only one flag is permitted). .It Fl t Ar trstr The string argument represents the kernel trace points, one per letter. -The default flags are -.Cm c , -.Cm i , -.Cm n , -.Cm s , -.Cm t , -.Cm u , -and -.Cm x . -The following table equates the letters with the tracepoints: +By default all trace points except for +.Cm X +are enabled. +The following table equates the letters with the trace points: .Pp .Bl -tag -width flag -offset indent -compact .It Cm c @@ -129,6 +123,10 @@ trace system calls trace I/O .It Cm n trace namei translations +.It Cm p +trace violation of +.Xr pledge 2 +restrictions .It Cm s trace signal processing .It Cm t diff --git a/usr.bin/ktrace/ktrace.c b/usr.bin/ktrace/ktrace.c index 94180ca769a..7864bc5bfea 100644 --- a/usr.bin/ktrace/ktrace.c +++ b/usr.bin/ktrace/ktrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ktrace.c,v 1.32 2015/04/18 18:28:37 deraadt Exp $ */ +/* $OpenBSD: ktrace.c,v 1.33 2016/07/18 09:36:50 guenther Exp $ */ /* $NetBSD: ktrace.c,v 1.4 1995/08/31 23:01:44 jtc Exp $ */ /*- @@ -87,7 +87,7 @@ main(int argc, char *argv[]) inherit = 1; break; case 't': - trpoints = getpoints(optarg); + trpoints = getpoints(optarg, KTRFAC_USER); if (trpoints < 0) { warnx("unknown facility in %s", optarg); usage(); @@ -133,7 +133,7 @@ main(int argc, char *argv[]) pidset = 1; break; case 't': - trpoints = getpoints(optarg); + trpoints = getpoints(optarg, DEF_POINTS); if (trpoints < 0) { warnx("unknown facility in %s", optarg); usage(); diff --git a/usr.bin/ktrace/ltrace.1 b/usr.bin/ktrace/ltrace.1 index 64f015e79f8..55717db6f65 100644 --- a/usr.bin/ktrace/ltrace.1 +++ b/usr.bin/ktrace/ltrace.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ltrace.1,v 1.9 2016/03/06 20:25:27 guenther Exp $ +.\" $OpenBSD: ltrace.1,v 1.10 2016/07/18 09:36:50 guenther Exp $ .\" .\" Copyright (c) 2013 Miodrag Vallat. .\" @@ -43,7 +43,7 @@ .\" .\" from: @(#)ktrace.1 8.1 (Berkeley) 6/6/93 .\" -.Dd $Mdocdate: March 6 2016 $ +.Dd $Mdocdate: July 18 2016 $ .Dt LTRACE 1 .Os .Sh NAME @@ -102,16 +102,9 @@ Inherit; pass the trace flags to all future children of the designated processes. .It Fl t Ar trstr The string argument represents the kernel trace points, one per letter. -The default flags are -.Cm c , -.Cm i , -.Cm n , -.Cm s , -.Cm t , -.Cm u , -and -.Cm x . -The following table equates the letters with the tracepoints: +The default is just +.Cm u . +The following table equates the letters with the trace points: .Pp .Bl -tag -width flag -offset indent -compact .It Cm c @@ -120,6 +113,10 @@ trace system calls trace I/O .It Cm n trace namei translations +.It Cm p +trace violation of +.Xr pledge 2 +restrictions .It Cm s trace signal processing .It Cm t diff --git a/usr.bin/ktrace/subr.c b/usr.bin/ktrace/subr.c index 5dd90123b17..43a5717ced7 100644 --- a/usr.bin/ktrace/subr.c +++ b/usr.bin/ktrace/subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr.c,v 1.12 2016/03/06 20:25:27 guenther Exp $ */ +/* $OpenBSD: subr.c,v 1.13 2016/07/18 09:36:50 guenther Exp $ */ /* $NetBSD: subr.c,v 1.6 1995/08/31 23:01:45 jtc Exp $ */ /*- @@ -42,9 +42,13 @@ #include "ktrace.h" #include "extern.h" +/* + * If you change the trace point letters, then update to match: + * ktrace/ktrace.1, ktrace/ltrace.1, kdump/kdump.1, and + * usage() in kdump/kdump.c + */ int -getpoints(s) - const char *s; +getpoints(const char *s, int defpoints) { int facs = 0; @@ -53,11 +57,14 @@ getpoints(s) case 'c': facs |= KTRFAC_SYSCALL | KTRFAC_SYSRET; break; + case 'i': + facs |= KTRFAC_GENIO; + break; case 'n': facs |= KTRFAC_NAMEI; break; - case 'i': - facs |= KTRFAC_GENIO; + case 'p': + facs |= KTRFAC_PLEDGE; break; case 's': facs |= KTRFAC_PSIG; @@ -75,7 +82,7 @@ getpoints(s) facs |= KTRFAC_EXECENV; break; case '+': - facs |= DEF_POINTS; + facs |= defpoints; break; default: return (-1);