diff options
Diffstat (limited to 'cddl')
455 files changed, 7231 insertions, 1729 deletions
diff --git a/cddl/Makefile b/cddl/Makefile index 284a370c0167..ab0d9896d2ec 100644 --- a/cddl/Makefile +++ b/cddl/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .include <src.opts.mk> SUBDIR= lib .WAIT \ diff --git a/cddl/Makefile.inc b/cddl/Makefile.inc index 687068d599e8..dc942ed2812d 100644 --- a/cddl/Makefile.inc +++ b/cddl/Makefile.inc @@ -1,13 +1,7 @@ -# $FreeBSD$ - OPENSOLARIS_USR_DISTDIR= ${.CURDIR}/../../../cddl/contrib/opensolaris OPENSOLARIS_SYS_DISTDIR= ${.CURDIR}/../../../sys/cddl/contrib/opensolaris IGNORE_PRAGMA= YES CFLAGS+= -DNEED_SOLARIS_BOOLEAN - -# Do not lint the CDDL stuff. It is all externally maintained and -# lint output is wasteful noise here. - -NO_LINT= +CFLAGS+= -DHAVE_STRLCAT -DHAVE_STRLCPY diff --git a/cddl/compat/opensolaris/include/alloca.h b/cddl/compat/opensolaris/include/alloca.h index b8433c100dc2..723115ea2af1 100644 --- a/cddl/compat/opensolaris/include/alloca.h +++ b/cddl/compat/opensolaris/include/alloca.h @@ -23,8 +23,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * */ #ifndef _COMPAT_OPENSOLARIS_ALLOCA_H_ diff --git a/cddl/compat/opensolaris/include/assert.h b/cddl/compat/opensolaris/include/assert.h index 0887093d5d64..5afaae7166bf 100644 --- a/cddl/compat/opensolaris/include/assert.h +++ b/cddl/compat/opensolaris/include/assert.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #undef assert diff --git a/cddl/compat/opensolaris/include/devid.h b/cddl/compat/opensolaris/include/devid.h index 205e461f8956..6718ce2b9fbc 100644 --- a/cddl/compat/opensolaris/include/devid.h +++ b/cddl/compat/opensolaris/include/devid.h @@ -18,8 +18,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD$ */ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. diff --git a/cddl/compat/opensolaris/include/dtrace.h b/cddl/compat/opensolaris/include/dtrace.h index 9630f9e74f58..7696d74a1414 100644 --- a/cddl/compat/opensolaris/include/dtrace.h +++ b/cddl/compat/opensolaris/include/dtrace.h @@ -23,8 +23,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * */ #ifndef _COMPAT_OPENSOLARIS_DTRACE_H_ diff --git a/cddl/compat/opensolaris/include/fcntl.h b/cddl/compat/opensolaris/include/fcntl.h index b962bb4855ee..dd1a66cbbcae 100644 --- a/cddl/compat/opensolaris/include/fcntl.h +++ b/cddl/compat/opensolaris/include/fcntl.h @@ -23,8 +23,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * */ #ifndef _COMPAT_OPENSOLARIS_FCNTL_H_ diff --git a/cddl/compat/opensolaris/include/fsshare.h b/cddl/compat/opensolaris/include/fsshare.h index 11a8dbf0b04d..0492006892f1 100644 --- a/cddl/compat/opensolaris/include/fsshare.h +++ b/cddl/compat/opensolaris/include/fsshare.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _OPENSOLARIS_FSSHARE_H_ diff --git a/cddl/compat/opensolaris/include/libintl.h b/cddl/compat/opensolaris/include/libintl.h index da13f4749081..5dbc06a75b2f 100644 --- a/cddl/compat/opensolaris/include/libintl.h +++ b/cddl/compat/opensolaris/include/libintl.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _LIBINTL_H_ #define _LIBINTL_H_ diff --git a/cddl/compat/opensolaris/include/libproc.h b/cddl/compat/opensolaris/include/libproc.h index 428fa6cf53fe..9c153cd817e9 100644 --- a/cddl/compat/opensolaris/include/libproc.h +++ b/cddl/compat/opensolaris/include/libproc.h @@ -23,8 +23,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * */ #ifndef _COMPAT_OPENSOLARIS_LIBPROC_H_ @@ -35,9 +33,6 @@ #define ps_prochandle proc_handle #define Lmid_t int -#define PR_RLC 0x0001 -#define PR_KLC 0x0002 - #include_next <libproc.h> #endif diff --git a/cddl/compat/opensolaris/include/libshare.h b/cddl/compat/opensolaris/include/libshare.h index 82aacadd93a9..eb93933ed901 100644 --- a/cddl/compat/opensolaris/include/libshare.h +++ b/cddl/compat/opensolaris/include/libshare.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _OPENSOLARIS_LIBSHARE_H_ diff --git a/cddl/compat/opensolaris/include/priv.h b/cddl/compat/opensolaris/include/priv.h index 2fee5b0d40c8..182921a02b3f 100644 --- a/cddl/compat/opensolaris/include/priv.h +++ b/cddl/compat/opensolaris/include/priv.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _OPENSOLARIS_PRIV_H_ #define _OPENSOLARIS_PRIV_H_ diff --git a/cddl/compat/opensolaris/include/sha2.h b/cddl/compat/opensolaris/include/sha2.h index 488f2dbd8b47..1add5365da21 100644 --- a/cddl/compat/opensolaris/include/sha2.h +++ b/cddl/compat/opensolaris/include/sha2.h @@ -22,8 +22,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _OPENSOLARIS_SHA2_H_ diff --git a/cddl/compat/opensolaris/include/solaris.h b/cddl/compat/opensolaris/include/solaris.h index 9bead018bcec..b4fb71be92a6 100644 --- a/cddl/compat/opensolaris/include/solaris.h +++ b/cddl/compat/opensolaris/include/solaris.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _SOLARIS_H_ #define _SOLARIS_H_ diff --git a/cddl/compat/opensolaris/include/stdio.h b/cddl/compat/opensolaris/include/stdio.h index eba348744475..3c4f323c355f 100644 --- a/cddl/compat/opensolaris/include/stdio.h +++ b/cddl/compat/opensolaris/include/stdio.h @@ -23,8 +23,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * */ #ifndef _COMPAT_OPENSOLARIS_STDIO_H_ diff --git a/cddl/compat/opensolaris/include/strings.h b/cddl/compat/opensolaris/include/strings.h index a62bbc845e15..913f0214febc 100644 --- a/cddl/compat/opensolaris/include/strings.h +++ b/cddl/compat/opensolaris/include/strings.h @@ -23,8 +23,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * */ #ifndef _COMPAT_OPENSOLARIS_STRINGS_H_ diff --git a/cddl/compat/opensolaris/include/thread_pool.h b/cddl/compat/opensolaris/include/thread_pool.h index 3bd23a6dd2aa..3f4f74212d78 100644 --- a/cddl/compat/opensolaris/include/thread_pool.h +++ b/cddl/compat/opensolaris/include/thread_pool.h @@ -25,7 +25,6 @@ */ /* - * $FreeBSD$ */ #ifndef _THREAD_POOL_H_ diff --git a/cddl/compat/opensolaris/include/unistd.h b/cddl/compat/opensolaris/include/unistd.h index e1a1bc81e60f..48c284cfb45c 100644 --- a/cddl/compat/opensolaris/include/unistd.h +++ b/cddl/compat/opensolaris/include/unistd.h @@ -23,8 +23,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * */ #ifndef _COMPAT_OPENSOLARIS_UNISTD_H_ diff --git a/cddl/compat/opensolaris/include/zone.h b/cddl/compat/opensolaris/include/zone.h index 8c377cf6574d..66a041772963 100644 --- a/cddl/compat/opensolaris/include/zone.h +++ b/cddl/compat/opensolaris/include/zone.h @@ -1,4 +1,3 @@ -/* $FreeBSD$ */ #ifndef _ZONE_H_ #define _ZONE_H_ diff --git a/cddl/compat/opensolaris/lib/libumem/umem.c b/cddl/compat/opensolaris/lib/libumem/umem.c index 9dc101f2e65f..e9662ce3c1e8 100644 --- a/cddl/compat/opensolaris/lib/libumem/umem.c +++ b/cddl/compat/opensolaris/lib/libumem/umem.c @@ -17,8 +17,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD$ */ /* * Copyright 2006 Ricardo Correia. All rights reserved. diff --git a/cddl/compat/opensolaris/lib/libumem/umem.h b/cddl/compat/opensolaris/lib/libumem/umem.h index da4b32fa551e..971cde36e1b2 100644 --- a/cddl/compat/opensolaris/lib/libumem/umem.h +++ b/cddl/compat/opensolaris/lib/libumem/umem.h @@ -18,8 +18,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD$ */ /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 index 8724b27f4cbb..1836707d72df 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 +++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 @@ -20,7 +20,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 7, 2021 +.Dd June 14, 2025 .Dt DTRACE 1 .Os .Sh NAME @@ -29,7 +29,8 @@ .Sh SYNOPSIS .Nm .Op Fl 32 | Fl 64 -.Op Fl aACeFGhHlqSvVwZ +.Op Fl aACdeFGhHlOqSvVwZ +.Op Fl -libxo .Op Fl b Ar bufsz .Op Fl c Ar cmd .Op Fl D Ar name Op Ns = Ns value @@ -195,6 +196,12 @@ option. For a description of the set of tokens defined by the D compiler when invoking the C preprocessor, see .Fl X . +.It Fl d +Dump the D script to standard output, after syntactic transformations have been +applied. +For example, if-statements in D are implemented using such transformations: a +conditional clause in a probe body is replaced at compile-time by a separate +probe predicated on the original condition. .It Fl D Ar name Op Ns = Ns value Define .Ar name @@ -351,6 +358,11 @@ writing D programs. The specified .Ar path is added after the default library search path. +.It Fl -libxo +Generate output via +.Xr libxo 3 . +This option is the same as specifying +.Sy oformat . .It Fl m Oo Ar provider : Oc Ar module Oo Oo Ar predicate Oc Ar action Oc Specify module name to trace or list .Fl ( l @@ -394,6 +406,14 @@ argument can be suffixed with an optional D probe clause. More than one .Fl n option can be specified on the command line at a time. +.It Fl O +This option causes +.Nm +to print all the aggregations upon exiting if +.Sy oformat +or +.Fl -libxo +are specified. .It Fl o Ar output Specify the .Ar output @@ -646,6 +666,32 @@ Number of whitespace characters to use when indenting and .Fn ustack output. +.It Sy oformat Ns = Ns Ar format +Specify the format to use for output. +Setting +.Sy oformat +to +.Ql text +makes +.Nm +use regular human-readable output which is its default behavior. +The options passed to +.Sy oformat +are directly forwarded to +.Xr libxo 3 . +Some of the supported formatters include +.Ql json , +.Ql xml +and +.Ql html . +Note that this option will cause +.Nm +to not produce any output unless printing functions are explicitly called, +or the +.Fl O +flag is specified. +For more information see +.Sx STRUCTURED OUTPUT . .It Sy statusrate Ns = Ns Ar time Rate of status checking. .It Sy switchrate Ns = Ns Ar time @@ -772,6 +818,376 @@ or .Fl i options) contain descriptions that do not match any known probes. .El +.Sh STRUCTURED OUTPUT +.Nm +supports structured output using +.Xr libxo 3 . +The output will always have a top-level object called +.Dq dtrace , +followed by a list of objects +.Dq probes . +Each of the probe objects will to have a timestamp which is generated at +output time rather than probe firing time, an identifier for the CPU on +which the probe was executed, and the probe's full specification: +.Bd -literal +{ + "dtrace": { + "probes": [ + { + "timestamp": ..., + "cpu": ..., + "id": ..., + "provider": ..., + "module": ..., + "function": ..., + "name": ..., + "output": [ + ... (script-specific output) + ] + } + ] + } +} + +<?xml version="1.0"?> +<dtrace> + <probes> + <timestamp>...</timestamp> + <cpu>...</cpu> + <id>...</id> + <provider>...</provider> + <module>...</module> + <function>...</function> + <name>...</name> + <output> + ... (script-specific output) + </output> + </probes> +</dtrace> +.Ed +.Pp +It is also possible for XML output to take the following form if some +of the fields are empty (in this example, module and function values +are absent): +.Bd -literal +<?xml version="1.0"?> +<dtrace> + <probes> + ... + <module/> + <function/> + ... + <output> + ... (script-specific output) + </output> + </probes> +</dtrace> +.Ed +.Pp +Similarly, +.Sy oformat +can be used to generate HTML: +.Bd -literal +<div class="line"> +<div class="data" data-tag="timestamp">...</div> +<div class="text"></div> +<div class="data" data-tag="cpu">...</div> +<div class="text"></div> +<div class="data" data-tag="id">...</div> +<div class="text"></div> +<div class="data" data-tag="provider">...</div> +<div class="text"></div> +<div class="data" data-tag="module">...</div> +<div class="text"></div> +<div class="data" data-tag="function">...</div> +<div class="text"></div> +<div class="data" data-tag="name">...</div> +<div class="data" data-tag="... (script-specific output)">...</div> +</div> +.Ed +.Pp +Unlike JSON and XML, the +.Dq output +array is not present. +Instead, data is simply formatted into a div of class +.Dq data +and a data-tag is associated with each of the keys. +.Pp +The +.Dq output +array's contents depend on the probes' actions and is explained below. +The examples here are presented in JSON form as opposed to XML or HTML, +however the conversion explained above applies for all output formats. +.Pp +Any scalar output, such as output produced by the +.Fn trace +action is of form: +.Bd -literal +{ + "value": ... +} +.Ed +.Pp +The +.Fn printf +action begins with an object containing the formatted output of the +.Fn printf +action. +Subsequent objects contains the value of each of the arguments to +.Fn printf +in its raw form as if the +.Fn trace +action was used instead. +A +.Fn printf +statement which contains no arguments other than the message will only have +one object following the message object and its value will always be 0. +This is an artefact of the implementation and can safely be ignored. +.Bd -literal +# dtrace --libxo json,pretty -n 'BEGIN { printf("... %Y, ..", walltimestamp); }' + +{ + "message": "... 2023 Sep 7 16:49:02, .." +}, +{ + "value": 1694105342633402400 +}, +{ + ... +} +.Ed +.Pp +Scalar aggregations are aggregations which produce a single value for a given +key. +These aggregations include +.Fn count , +.Fn min , +.Fn max , +.Fn stddev +and +.Fn sum . +Each one of them is represented by the key containing their name. +For example, the output of a +.Fn stddev +aggregation will contain a key +.Dq stddev +inside an +.Dq aggregation-data +object: +.Bd -literal +{ + "aggregation-data": [ + { + "keys": [ + ... + ], + "stddev": ... + } + ], + "aggregation-name": ... +} +.Ed +.Pp +The +.Dq keys +field remains consistent across all aggregations, however +.Fn quantize , +.Fn lquantize +and +.Fn llquantize +need to be treated differently. +.Sy oformat +will create a new array of objects called +.Dq buckets . +Each of the objects contains a +.Dq value +and a +.Dq count +field which are +the left-hand side and the right-hand side of human-readable +.Nm +output respectively. +The full object has the following format: +.Bd -literal +{ + "aggregation-data": [ + ... + { + "keys": [ + ... + ], + "buckets": [ + { + "value": 32, + "count": 0 + }, + { + "value": 64, + "count": 17 + }, + ... + ], + }, + ... + ] + "aggregation-name": ... +} +.Ed +.Pp +Similar to scalar aggregations, named scalar actions such as +.Fn mod , +.Fn umod , +.Fn usym , +.Fn tracemem +and +.Fn printm +will output an object with the key being equal to the +name of the action. +For example, +.Fn printm +output would produce the following object: +.Bd -literal +{ + "printm": "0x4054171100" +} +.Ed +.Pp +.Fn sym +is slightly different. +While it will create a +.Dq sym +field which contains its value, in some cases it will also create additional +fields +.Dq object , +.Dq name +and +.Dq offset : +.Bd -literal +# dtrace -x oformat=json,pretty -On 'BEGIN { sym((uintptr_t)&`prison0); }' + +{ + "sym": "kernel`prison0", + "object": "kernel", + "name": "prison0" +} + +# dtrace --libxo json,pretty -On 'BEGIN { sym((uintptr_t)curthread); }' + +{ + "sym": "0xfffffe00c18d2000", + "offset": "0xfffffe00c18d2000" +} +.Ed +.Pp +.Fn stack +and +.Fn ustack +actions unroll each of the stack frames into its own object in an array. +The only real difference between them is that the +.Fn stack +action will produce a list called +.Dq stack-frames +while +.Fn ustack +will produce one called +.Dq ustack-frames . +The following is an example of their +.Sy oformat +output: +.Bd -literal +{ + "stack-frames": [ + { + "symbol": "dtrace.ko`dtrace_dof_create+0x35", + "module": "dtrace.ko", + "name": "dtrace_dof_create", + "offset": "0x35" + }, + { + "symbol": "dtrace.ko`dtrace_ioctl+0x81c", + "module": "dtrace.ko", + "name": "dtrace_ioctl", + "offset": "0x81c" + }, + ... + ] +} + +{ + "ustack-frames": [ + { + "symbol": "libc.so.7`ioctl+0xa", + "module": "libc.so.7", + "name": "ioctl", + "offset": "0xa" + }, + { + "symbol": "libdtrace.so.2`dtrace_go+0xf3", + "module": "libdtrace.so.2", + "name": "dtrace_go", + "offset": "0xf3" + }, + ... + ] +} +.Ed +.Pp +The +.Fn print +action produces a +.Dq type +list in the following form: +.Bd -literal +{ + "type": [ + { + "object-name": "kernel", + "name": "struct thread", + "ctfid": 2372 + }, + { + "member-name": "td_lock", + "name": "struct mtx *volatile", + "ctfid": 2035, + "value": "0xffffffff82158440" + }, + ... +} +.Ed +.Pp +If the type is invalid, a +.Dq warning +object will be produced containing the diagnostic message as well as two +possible optional fields: +.Dq type-identifier +which contains the CTF identifier of the type and +.Dq size containing the size of an integer, enum or float. +The fields generated will depend on the kind of error that was encountered +while processing the trace data. +.Pp +Finally, +.Sy oformat +provides a special pseudo-probe to represent drops. +As +.Nm +polls for various kinds of drops +.Sy oformat +will produce output similar to the following in order to represent drops: +.Bd -literal +{ + "cpu": -1, + "id": -1, + "provider": "dtrace", + "module": "INTERNAL", + "function": "INTERNAL", + "name": "DROP", + "timestamp": ..., + "count": ..., + "total": ..., + "kind": 2, + "msg": "... dynamic variable drops\n" +} +.Ed .Sh OPERANDS You can specify zero or more additional arguments on the .Nm @@ -803,15 +1219,26 @@ failed or that the specified request could not be satisfied. .It 2 Invalid command line options or arguments were specified. .El -.Sh HISTORY -The -.Nm -utility first appeared in -.Fx 7.1 . .Sh SEE ALSO .Xr cpp 1 , +.Xr dtrace_audit 4 , +.Xr dtrace_io 4 , +.Xr dtrace_ip 4 , +.Xr dtrace_kinst 4 , +.Xr dtrace_lockstat 4 , +.Xr dtrace_proc 4 , +.Xr dtrace_sched 4 , +.Xr dtrace_sctp 4 , +.Xr dtrace_tcp 4 , +.Xr dtrace_udp 4 , +.Xr dtrace_udplite 4 , .Xr elf 5 , .Xr SDT 9 .Rs .%T Solaris Dynamic Tracing Guide .Re +.Sh HISTORY +The +.Nm +utility first appeared in +.Fx 7.1 . diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c index 06eff2055c17..162224478ec0 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c +++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c @@ -26,6 +26,7 @@ /* * Copyright (c) 2012 by Delphix. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. + * Copyright (c) 2023, Domagoj Stolfa. All rights reserved. */ #include <sys/types.h> @@ -55,6 +56,9 @@ #include <spawn.h> #endif +#undef NORETURN /* needed because libxo redefines it */ +#include <libxo/xo.h> + typedef struct dtrace_cmd { void (*dc_func)(struct dtrace_cmd *); /* function to compile arg */ dtrace_probespec_t dc_spec; /* probe specifier context */ @@ -77,7 +81,7 @@ typedef struct dtrace_cmd { #define E_USAGE 2 static const char DTRACE_OPTSTR[] = - "3:6:aAb:Bc:CD:ef:FGhHi:I:lL:m:n:o:p:P:qs:SU:vVwx:X:Z"; + "3:6:aAb:Bc:CdD:ef:FGhHi:I:lL:m:n:o:Op:P:qs:SU:vVwx:X:Z"; static char **g_argv; static int g_argc; @@ -130,7 +134,7 @@ usage(FILE *fp) { static const char predact[] = "[[ predicate ] action ]"; - (void) fprintf(fp, "Usage: %s [-32|-64] [-aACeFGhHlqSvVwZ] " + (void) fprintf(fp, "Usage: %s [-32|-64] [-aACdeFGhHlqSvVwZ] " "[-b bufsz] [-c cmd] [-D name[=def]]\n\t[-I path] [-L path] " "[-o output] [-p pid] [-s script] [-U name]\n\t" "[-x opt[=val]] [-X a|c|s|t]\n\n" @@ -152,6 +156,7 @@ usage(FILE *fp) "\t-b set trace buffer size\n" "\t-c run specified command and exit upon its completion\n" "\t-C run cpp(1) preprocessor on script files\n" + "\t-d dump script after syntactic transformations\n" "\t-D define symbol when invoking preprocessor\n" "\t-e exit after compiling request but prior to enabling probes\n" "\t-f enable or list probes matching the specified function name\n" @@ -166,6 +171,7 @@ usage(FILE *fp) "\t-m enable or list probes matching the specified module name\n" "\t-n enable or list probes matching the specified probe name\n" "\t-o set output file\n" + "\t-O print output upon exiting (specific to oformat)\n" "\t-p grab specified process-ID and cache its symbol tables\n" "\t-P enable or list probes matching the specified provider name\n" "\t-q set quiet mode (only output explicitly traced data)\n" @@ -906,7 +912,10 @@ errhandler(const dtrace_errdata_t *data, void *arg) static int drophandler(const dtrace_dropdata_t *data, void *arg) { - error(data->dtdda_msg); + if (!dtrace_oformat(g_dtp)) { + error(data->dtdda_msg); + } + return (DTRACE_HANDLE_OK); } @@ -1125,7 +1134,9 @@ chew(const dtrace_probedata_t *data, void *arg) } if (!g_flowindent) { - if (!g_quiet) { + if (dtrace_oformat(g_dtp)) { + dtrace_oformat_probe(g_dtp, data, cpu, pd); + } else if (!g_quiet) { char name[DTRACE_FUNCNAMELEN + DTRACE_NAMELEN + 2]; (void) snprintf(name, sizeof (name), "%s:%s", @@ -1312,7 +1323,8 @@ main(int argc, char *argv[]) g_ofp = stdout; int done = 0, mode = 0; - int err, i, c; + int err, i, c, new_argc, libxo_specified; + int print_upon_exit = 0; char *p, **v; struct ps_prochandle *P; pid_t pid; @@ -1335,6 +1347,15 @@ main(int argc, char *argv[]) (g_psv = malloc(sizeof (struct ps_prochandle *) * argc)) == NULL) fatal("failed to allocate memory for arguments"); + new_argc = xo_parse_args(argc, argv); + if (new_argc < 0) + return (usage(stderr)); + + if (new_argc != argc) + libxo_specified = 1; + + argc = new_argc; + g_argv[g_argc++] = argv[0]; /* propagate argv[0] to D as $0/$$0 */ argv[0] = g_pname; /* rewrite argv[0] for getopt errors */ @@ -1357,7 +1378,7 @@ main(int argc, char *argv[]) argv[0], optarg); return (usage(stderr)); } - g_oflags &= ~DTRACE_O_LP64; + g_oflags &= ~DTRACE_O_MODEL_MASK; g_oflags |= DTRACE_O_ILP32; break; @@ -1368,7 +1389,7 @@ main(int argc, char *argv[]) argv[0], optarg); return (usage(stderr)); } - g_oflags &= ~DTRACE_O_ILP32; + g_oflags &= ~DTRACE_O_MODEL_MASK; g_oflags |= DTRACE_O_LP64; break; @@ -1439,8 +1460,7 @@ main(int argc, char *argv[]) * files. We ignore certain errors since we'll catch them later when * we actually process the object files. */ - if (g_mode == DMODE_LINK && - (g_oflags & (DTRACE_O_ILP32 | DTRACE_O_LP64)) == 0 && + if (g_mode == DMODE_LINK && (g_oflags & DTRACE_O_MODEL_MASK) == 0 && elf_version(EV_CURRENT) != EV_NONE) { int fd; Elf *elf; @@ -1531,6 +1551,10 @@ main(int argc, char *argv[]) } else if (g_mode == DMODE_ANON) (void) dtrace_setopt(g_dtp, "linkmode", "primary"); + + if (libxo_specified) + dtrace_oformat_configure(g_dtp); + /* * Now that we have libdtrace open, make a second pass through argv[] * to perform any dtrace_setopt() calls and change any compiler flags. @@ -1559,6 +1583,10 @@ main(int argc, char *argv[]) g_cflags |= DTRACE_C_CPP; break; + case 'd': + g_cflags |= DTRACE_C_SUGAR; + break; + case 'D': if (dtrace_setopt(g_dtp, "define", optarg) != 0) dfatal("failed to set -D %s", optarg); @@ -1619,6 +1647,10 @@ main(int argc, char *argv[]) dcp->dc_arg = optarg; break; + case 'O': + print_upon_exit = 1; + break; + case 'q': if (dtrace_setopt(g_dtp, "quiet", 0) != 0) dfatal("failed to set -q"); @@ -1760,6 +1792,11 @@ main(int argc, char *argv[]) (void) dtrace_getopt(g_dtp, "quiet", &opt); g_quiet = opt != DTRACEOPT_UNSET; + if (dtrace_oformat(g_dtp)) { + if (dtrace_setopt(g_dtp, "quiet", 0) != 0) + dfatal("failed to set quiet (caused by oformat)"); + } + /* * Now make a fifth and final pass over the options that have been * turned into programs and saved in g_cmdv[], performing any mode- @@ -1772,6 +1809,9 @@ main(int argc, char *argv[]) if (g_ofile != NULL && (g_ofp = fopen(g_ofile, "a")) == NULL) fatal("failed to open output file '%s'", g_ofile); + if (dtrace_oformat(g_dtp)) + dtrace_set_outfp(g_ofp); + for (i = 0; i < g_cmdc; i++) exec_prog(&g_cmdv[i]); @@ -1806,6 +1846,9 @@ main(int argc, char *argv[]) if ((g_ofp = fopen(g_ofile, "a")) == NULL) fatal("failed to open output file '%s'", g_ofile); + if (dtrace_oformat(g_dtp)) + dtrace_set_outfp(g_ofp); + for (i = 0; i < g_cmdc; i++) { anon_prog(&g_cmdv[i], dtrace_dof_create(g_dtp, g_cmdv[i].dc_prog, 0), i); @@ -1966,12 +2009,21 @@ main(int argc, char *argv[]) g_pslive = g_psc; /* count for prochandler() */ + dtrace_oformat_setup(g_dtp); do { if (!g_intr && !done) dtrace_sleep(g_dtp); #ifdef __FreeBSD__ - if (g_siginfo) { + /* + * XXX: Supporting SIGINFO with oformat makes little sense, as + * it can't really produce sensible DTrace output. + * + * If needed, we could support it by having an imaginary + * "SIGINFO" probe that we can construct in the output but leave + * it out for now. + */ + if (g_siginfo && !dtrace_oformat(g_dtp)) { (void)dtrace_aggregate_print(g_dtp, g_ofp, NULL); g_siginfo = 0; } @@ -2008,14 +2060,24 @@ main(int argc, char *argv[]) clearerr(g_ofp); } while (!done); - oprintf("\n"); + if (!dtrace_oformat(g_dtp)) + oprintf("\n"); - if (!g_impatient) { + /* + * Since there is no way to format a probe here and machine-readable + * output makes little sense without explicitly asking for it, we print + * nothing upon Ctrl-C if oformat is specified. If the user wishes to + * get output upon exit, they must write an explicit dtrace:::END probe + * to do so. + */ + if ((!g_impatient && !dtrace_oformat(g_dtp)) || + (!g_impatient && print_upon_exit)) { if (dtrace_aggregate_print(g_dtp, g_ofp, NULL) == -1 && dtrace_errno(g_dtp) != EINTR) dfatal("failed to print aggregations"); } + dtrace_oformat_teardown(g_dtp); dtrace_close(g_dtp); return (g_status); } diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.argtest.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.argtest.ksh new file mode 100644 index 000000000000..dc3641b01101 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.argtest.ksh @@ -0,0 +1,34 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. +# +# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# When distributing Covered Code, include this CDDL HEADER in each +# file and include the License file at usr/src/OPENSOLARIS.LICENSE. +# If applicable, add the following below this CDDL HEADER, with the +# fields enclosed by brackets "[]" replaced with your own identifying +# information: Portions Copyright [yyyy] [name of copyright owner] +# +# CDDL HEADER END +# + +# +# Copyright (c) 2024 Mark Johnston <markj@FreeBSD.org> +# + +dtrace=$1 + +$dtrace -q -s /dev/stdin -c "sysctl debug.dtracetest.fbttest=1" <<__EOF__ +fbt:dtrace_test:fbttest:entry +{ + printf("%d %d %d %d %d %d %d %d %d %d\n", args[0], args[1], args[2], + args[3], args[4], args[5], args[6], args[7], args[8], args[9]); +} +__EOF__ diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.argtest.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.argtest.ksh.out new file mode 100644 index 000000000000..301e154b3339 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/fbtprovider/tst.argtest.ksh.out @@ -0,0 +1,3 @@ +debug.dtracetest.fbttest: 0 -> 0 +1 2 3 4 5 6 7 8 9 10 + diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out index 2e94ff35de88..7f7368f13900 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv6localicmp.ksh.out @@ -1,6 +1,6 @@ -PING6(56=40+8+8 bytes) ::1 --> ::1 +PING(56=40+8+8 bytes) ::1 --> ::1 1 packets transmitted, 1 packets received, 0.0% packet loss 2 ip:::send (args[2]: 6 16, args[5]: 6 0 16) 2 ip:::send (args[2]: 6 16, args[5]: 6 0 16) diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/kinst/tst.basic.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/kinst/tst.basic.ksh new file mode 100644 index 000000000000..3005da74c895 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/kinst/tst.basic.ksh @@ -0,0 +1,48 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2022 Mark Johnston <markj@FreeBSD.org> +# + +script() +{ + $dtrace -q -s /dev/stdin <<__EOF__ +kinst::vm_fault: {} +kinst::amd64_syscall: {} +kinst::exit1: {} +kinst::spinlock_enter: {} +kinst::memcpy: {} + +tick-10s {exit(0);} +__EOF__ +} + +spin() +{ + while true; do + ls -la / >/dev/null 2>&1 + done +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +spin & +child=$! + +script +exit $? diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/mib/tst.icmp.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/mib/tst.icmp.ksh index b1cac20fc8db..6def4da1062b 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/mib/tst.icmp.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/mib/tst.icmp.ksh @@ -59,7 +59,7 @@ pinger() { while true; do ping -A inet localhost - /usr/bin/sleep 1 + sleep 1 done } diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/mib/tst.udp.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/mib/tst.udp.ksh index a492124c9c17..10a83cbd06fd 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/mib/tst.udp.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/mib/tst.udp.ksh @@ -54,7 +54,7 @@ rupper() { while true; do rup localhost - /usr/bin/sleep 1 + sleep 1 done } diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.avg.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.avg.ksh new file mode 100644 index 000000000000..daf5c7f4e9bb --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.avg.ksh @@ -0,0 +1,66 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + @[probefunc] = avg(tid); +} + +tick-5s +{ + exit(0); +} + +END +{ + printa(@); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.count.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.count.ksh new file mode 100644 index 000000000000..ab7c5fa28471 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.count.ksh @@ -0,0 +1,66 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + @[execname] = count(); +} + +tick-5s +{ + exit(0); +} + +END +{ + printa(@); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.llquantize.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.llquantize.ksh new file mode 100644 index 000000000000..380335de000a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.llquantize.ksh @@ -0,0 +1,73 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + self->ts = timestamp; +} + +syscall:::return +/self->ts/ +{ + @[probefunc] = llquantize(timestamp - self->ts, 2, 1, 32, 32); + self->ts = 0; +} + +tick-5s +{ + exit(0); +} + +END +{ + printa(@); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.lquantize.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.lquantize.ksh new file mode 100644 index 000000000000..5ec6c725a7f0 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.lquantize.ksh @@ -0,0 +1,73 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + self->ts = timestamp; +} + +syscall:::return +/self->ts/ +{ + @[probefunc] = lquantize(timestamp - self->ts, 0, 1000000, 100); + self->ts = 0; +} + +tick-5s +{ + exit(0); +} + +END +{ + printa(@); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.max.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.max.ksh new file mode 100644 index 000000000000..45f790aae030 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.max.ksh @@ -0,0 +1,66 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + @[probefunc] = max(tid); +} + +tick-5s +{ + exit(0); +} + +END +{ + printa(@); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.min.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.min.ksh new file mode 100644 index 000000000000..6f40acdfff40 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.min.ksh @@ -0,0 +1,66 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + @[probefunc] = min(tid); +} + +tick-5s +{ + exit(0); +} + +END +{ + printa(@); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.quantize.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.quantize.ksh new file mode 100644 index 000000000000..c0ba0f4a6c0f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.quantize.ksh @@ -0,0 +1,73 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + self->ts = timestamp; +} + +syscall:::return +/self->ts/ +{ + @[probefunc] = quantize(timestamp - self->ts); + self->ts = 0; +} + +tick-5s +{ + exit(0); +} + +END +{ + printa(@); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.stddev.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.stddev.ksh new file mode 100644 index 000000000000..7b06a67b9a8a --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.stddev.ksh @@ -0,0 +1,66 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + @[probefunc] = stddev(tid); +} + +tick-5s +{ + exit(0); +} + +END +{ + printa(@); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.sum.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.sum.ksh new file mode 100644 index 000000000000..f7c323c6baac --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.agg.sum.ksh @@ -0,0 +1,66 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + @[probefunc] = sum(1); +} + +tick-5s +{ + exit(0); +} + +END +{ + printa(@); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggmod.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggmod.ksh new file mode 100644 index 000000000000..335819cbcfc9 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggmod.ksh @@ -0,0 +1,66 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + @[mod((uintptr_t)rand())] = count(); +} + +tick-5s +{ + exit(0); +} + +END +{ + printa(@); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggstack.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggstack.ksh new file mode 100644 index 000000000000..30af498c2498 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggstack.ksh @@ -0,0 +1,66 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +fbt:::entry +{ + @[stack()] = count(); +} + +tick-5s +{ + exit(0); +} + +END +{ + printa(@); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggsym.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggsym.ksh new file mode 100644 index 000000000000..d0da3e5086ed --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggsym.ksh @@ -0,0 +1,66 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + @[sym((uintptr_t)rand())] = count(); +} + +tick-5s +{ + exit(0); +} + +END +{ + printa(@); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggustack.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggustack.ksh new file mode 100644 index 000000000000..98cf2a0562a4 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggustack.ksh @@ -0,0 +1,66 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + @[ustack()] = count(); +} + +tick-5s +{ + exit(0); +} + +END +{ + printa(@); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggusym.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggusym.ksh new file mode 100644 index 000000000000..7945b83250c3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.aggusym.ksh @@ -0,0 +1,66 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + @[usym((uintptr_t)rand())] = count(); +} + +tick-5s +{ + exit(0); +} + +END +{ + printa(@); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.drop.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.drop.ksh new file mode 100644 index 000000000000..7f17c321ff74 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.drop.ksh @@ -0,0 +1,61 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +fbt:::entry +{ + x[timestamp] = 1; +} + +tick-5s +{ + exit(0); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.mod.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.mod.ksh new file mode 100644 index 000000000000..b0e6ce3cc380 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.mod.ksh @@ -0,0 +1,57 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +BEGIN +{ + mod(0); + exit(0); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.print.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.print.ksh new file mode 100644 index 000000000000..68d675f20329 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.print.ksh @@ -0,0 +1,60 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +BEGIN +{ + print(*curthread); + print(*curthread->td_proc); + print(*curthread->td_ucred); + print(*curthread->td_ucred->cr_prison); + exit(0); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.printf.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.printf.ksh new file mode 100644 index 000000000000..a25352c4a1ca --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.printf.ksh @@ -0,0 +1,57 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +BEGIN +{ + printf("Hello World!"); + exit(0); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.printm.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.printm.ksh new file mode 100644 index 000000000000..634606fa574e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.printm.ksh @@ -0,0 +1,57 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +BEGIN +{ + printm(100, memref(curthread, 10)); + exit(0); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.stack.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.stack.ksh new file mode 100644 index 000000000000..33d1ee6dc1d7 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.stack.ksh @@ -0,0 +1,61 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + stack(); +} + +tick-1s +{ + exit(0); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.sym.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.sym.ksh new file mode 100644 index 000000000000..5e9bb3fea58e --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.sym.ksh @@ -0,0 +1,57 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +BEGIN +{ + sym(0); + exit(0); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.trace.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.trace.ksh new file mode 100644 index 000000000000..42f714a1a500 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.trace.ksh @@ -0,0 +1,66 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +BEGIN +{ + trace(0); + trace(1); + trace(2); + trace(3); + trace(4); + trace(5); + trace(6); + trace(7); + trace(8); + trace(9); + exit(0); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.tracemem.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.tracemem.ksh new file mode 100644 index 000000000000..dd9dbff3c191 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.tracemem.ksh @@ -0,0 +1,57 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +BEGIN +{ + tracemem(curthread, 10); + exit(0); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.umod.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.umod.ksh new file mode 100644 index 000000000000..0d50e34dfff1 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.umod.ksh @@ -0,0 +1,57 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +BEGIN +{ + umod(0); + exit(0); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.ustack.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.ustack.ksh new file mode 100644 index 000000000000..1b1cc0a247d3 --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.ustack.ksh @@ -0,0 +1,61 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +syscall:::entry +{ + ustack(); +} + +tick-1s +{ + exit(0); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.usym.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.usym.ksh new file mode 100644 index 000000000000..36372d05aa2f --- /dev/null +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/oformat/tst.usym.ksh @@ -0,0 +1,57 @@ +#!/usr/bin/ksh +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2023 Domagoj Stolfa +# + +bname=`basename $0` +dtraceout=/tmp/dtrace.$bname + +script() +{ + $dtrace -o $dtraceout.$1 -x oformat=$1 -s /dev/stdin <<__EOF__ +BEGIN +{ + usym(0); + exit(0); +} +__EOF__ +} + +if [ $# != 1 ]; then + echo expected one argument: '<'dtrace-path'>' + exit 2 +fi + +dtrace=$1 + +script json +jq . $dtraceout.json + +if [ $? != 0 ]; then + echo $bname: failed to produce valid JSON. see $dtraceout.json + exit 1 +fi + +script xml +xmllint $dtraceout.xml + +if [ $? != 0 ]; then + echo $bname: failed to produce valid XML. see $dtraceout.xml + exit 1 +fi + +rm $dtraceout.json +rm $dtraceout.xml + +exit 0 diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.exe b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.exe index e360d25b465b..4985133fb2a6 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.exe +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PDESC_ZERO.badlib.exe @@ -1,4 +1,4 @@ -#!/usr/bin/env ksh +#!/usr/local/bin/ksh -p # # CDDL HEADER START # diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.exe b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.exe index e360d25b465b..4985133fb2a6 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.exe +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_FUNC.badfunc.exe @@ -1,4 +1,4 @@ -#!/usr/bin/env ksh +#!/usr/local/bin/ksh -p # # CDDL HEADER START # diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.exe b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.exe index e360d25b465b..4985133fb2a6 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.exe +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_LIB.libdash.exe @@ -1,4 +1,4 @@ -#!/usr/bin/env ksh +#!/usr/local/bin/ksh -p # # CDDL HEADER START # diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.exe b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.exe index e360d25b465b..4985133fb2a6 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.exe +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.alldash.exe @@ -1,4 +1,4 @@ -#!/usr/bin/env ksh +#!/usr/local/bin/ksh -p # # CDDL HEADER START # diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.exe b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.exe index e360d25b465b..4985133fb2a6 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.exe +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.badname.exe @@ -1,4 +1,4 @@ -#!/usr/bin/env ksh +#!/usr/local/bin/ksh -p # # CDDL HEADER START # diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.exe b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.exe index e360d25b465b..4985133fb2a6 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.exe +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_NAME.globdash.exe @@ -1,4 +1,4 @@ -#!/usr/bin/env ksh +#!/usr/local/bin/ksh -p # # CDDL HEADER START # diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.exe b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.exe index e360d25b465b..4985133fb2a6 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.exe +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/err.D_PROC_OFF.toobig.exe @@ -1,4 +1,4 @@ -#!/usr/bin/env ksh +#!/usr/local/bin/ksh -p # # CDDL HEADER START # diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.coverage.exe b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.coverage.exe index ddd0f60f63ce..b9365eaafe3d 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.coverage.exe +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.coverage.exe @@ -1,4 +1,4 @@ -#!/usr/bin/env ksh +#!/usr/local/bin/ksh -p # # CDDL HEADER START # diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.emptystack.exe b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.emptystack.exe index 6369bc561412..9b9e2659786d 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.emptystack.exe +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.emptystack.exe @@ -1,4 +1,4 @@ -#!/usr/bin/env ksh +#!/usr/local/bin/ksh -p # # CDDL HEADER START # diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/proc/tst.exitcore.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/proc/tst.exitcore.ksh index 59094e3da37f..1c23b2a0b9e0 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/proc/tst.exitcore.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/proc/tst.exitcore.ksh @@ -61,7 +61,7 @@ EOF sleeper() { while true; do - $longsleep & + limits -c unlimited $longsleep & /bin/sleep 1 kill -SEGV $! done diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/proc/tst.startexit.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/proc/tst.startexit.ksh index 429173806f35..76996bfcb413 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/proc/tst.startexit.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/proc/tst.startexit.ksh @@ -68,7 +68,7 @@ EOF sleeper() { while true; do - /usr/bin/sleep 1 + sleep 1 done } diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.d index e965b05f2405..d3f7bfad5db1 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.d +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.d @@ -27,7 +27,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" /* - * ASSERTION: Verify that argN (1..7) variables are properly remapped. + * ASSERTION: Verify that argN (1..6) variables are properly remapped. */ BEGIN @@ -44,13 +44,12 @@ ERROR } test:::sdttest -/arg0 != 1 || arg1 != 2 || arg2 != 3 || arg3 != 4 || arg4 != 5 || arg5 != 6 || - arg6 != 7/ +/arg0 != 1 || arg1 != 2 || arg2 != 3 || arg3 != 4 || arg4 != 5 || arg5 != 6/ { printf("sdt arg mismatch\n\n"); - printf("args are : %d, %d, %d, %d, %d, %d, %d\n", arg0, arg1, arg2, - arg3, arg4, arg5, arg6); - printf("should be : 1, 2, 3, 4, 5, 6, 7\n"); + printf("args are : %d, %d, %d, %d, %d, %d\n", arg0, arg1, arg2, + arg3, arg4, arg5); + printf("should be : 1, 2, 3, 4, 5, 6\n"); exit(1); } diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/speculation/tst.NoSpecBuffer.exe b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/speculation/tst.NoSpecBuffer.exe index 5acce76efc6c..d15d0668cfc1 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/speculation/tst.NoSpecBuffer.exe +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/speculation/tst.NoSpecBuffer.exe @@ -1,4 +1,4 @@ -#!/usr/bin/env ksh +#!/usr/local/bin/ksh -p # # CDDL HEADER START # diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.OutputAliasTrans.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.OutputAliasTrans.d index cd4715319913..c6bfff2181e6 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.OutputAliasTrans.d +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/translators/tst.OutputAliasTrans.d @@ -37,23 +37,23 @@ #pragma D option quiet -struct input_struct { +struct dtrace_input_struct { int ii; char ic; }; -struct output_struct { +struct dtrace_output_struct { int oi; char oc; }; -typedef struct output_struct output_t; +typedef struct dtrace_output_struct dtrace_output_t; -translator output_t < struct input_struct *ivar > +translator dtrace_output_t < struct dtrace_input_struct *ivar > { - oi = ((struct input_struct *) ivar)->ii; - oc = ((struct input_struct *) ivar)->ic; + oi = ((struct dtrace_input_struct *) ivar)->ii; + oc = ((struct dtrace_input_struct *) ivar)->ic; }; BEGIN diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.multiprov.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.multiprov.ksh index 9620b97cb019..c8f0d1e5f8c0 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.multiprov.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.multiprov.ksh @@ -40,8 +40,8 @@ echo '#pragma D option aggsortkey' >> test.d cat > test.c <<EOF #include <unistd.h> -void -main() +int +main(void) { EOF @@ -52,7 +52,7 @@ for oogle in doogle bagnoogle; do #include <sys/sdt.h> void -$oogle() +$oogle(void) { DTRACE_PROBE($oogle, knows); } @@ -79,6 +79,7 @@ EOF fi objs="$objs $oogle.o $oogle.d.o" + echo "extern void $oogle(void);" >> test.c echo $oogle'();' >> test.c echo $oogle'$target:::{@[probefunc] = count()}' >> test.d done diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh index 2e404f4b8df6..4dd54f3fb633 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/usdt/tst.sameprovmulti.ksh @@ -35,8 +35,8 @@ cd $DIR cat > test.c <<EOF #include <unistd.h> -void -main() +int +main(void) { EOF @@ -74,6 +74,7 @@ EOF fi objs="$objs $oogle.o $oogle.d.o" + echo "extern void $oogle(void);" >> test.c echo $oogle'();' >> test.c done diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedargs.ksh b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedargs.ksh index 5b14fc989138..c74a278c1347 100755 --- a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedargs.ksh +++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedargs.ksh @@ -45,7 +45,7 @@ outf=/tmp/sched.args.$$ script() { - $dtrace -c '/usr/bin/sleep 10' -o $outf -qs /dev/stdin <<EOF + $dtrace -c 'sleep 10' -o $outf -qs /dev/stdin <<EOF xdt:sched::off-cpu, xdt:sched::on-cpu, xdt:sched::block, diff --git a/cddl/contrib/opensolaris/cmd/lockstat/lockstat.1 b/cddl/contrib/opensolaris/cmd/lockstat/lockstat.1 index c649e21bb67e..6c9657fa5406 100644 --- a/cddl/contrib/opensolaris/cmd/lockstat/lockstat.1 +++ b/cddl/contrib/opensolaris/cmd/lockstat/lockstat.1 @@ -19,8 +19,6 @@ .\" CDDL HEADER END .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved. .\" -.\" $FreeBSD$ -.\" .Dd February 25, 2020 .Dt LOCKSTAT 1 .Os diff --git a/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c b/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c index 2fd29843b8ce..2cbad3442efb 100644 --- a/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c +++ b/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c @@ -632,7 +632,7 @@ predicate_destroy(char **pred) } static void -filter_add(char **filt, char *what, uintptr_t base, uintptr_t size) +filter_add(char **filt, char *what, uintptr_t base, size_t size) { char buf[256], *c = buf, *new; int len, newlen; diff --git a/cddl/contrib/opensolaris/cmd/lockstat/sym.c b/cddl/contrib/opensolaris/cmd/lockstat/sym.c index b5366c566857..7516e7d435f4 100644 --- a/cddl/contrib/opensolaris/cmd/lockstat/sym.c +++ b/cddl/contrib/opensolaris/cmd/lockstat/sym.c @@ -42,6 +42,7 @@ #include <libelf.h> #include <link.h> #include <elf.h> +#include <gelf.h> #ifdef illumos #include <sys/machelf.h> @@ -54,7 +55,6 @@ #endif #include <sys/cpuvar.h> - typedef struct syment { uintptr_t addr; char *name; @@ -73,11 +73,6 @@ static char maxsymname[64]; #endif #endif -#define __sElfN(x) typedef __CONCAT(__CONCAT(__CONCAT(Elf,__ELF_WORD_SIZE),_),x) x -__sElfN(Sym); -__sElfN(Shdr); -#define elf_getshdr __elfN(getshdr) - static void add_symbol(char *name, uintptr_t addr, size_t size) { @@ -174,7 +169,7 @@ symtab_init(void) { Elf *elf; Elf_Scn *scn = NULL; - Sym *symtab, *symp, *lastsym; + GElf_Sym *symtab, *symp, *lastsym; char *strtab; uint_t cnt; int fd; @@ -198,13 +193,13 @@ symtab_init(void) (void) elf_version(EV_CURRENT); elf = elf_begin(fd, ELF_C_READ, NULL); - for (cnt = 1; (scn = elf_nextscn(elf, scn)) != NULL; cnt++) { - Shdr *shdr = elf_getshdr(scn); - if (shdr->sh_type == SHT_SYMTAB) { - symtab = (Sym *)elf_getdata(scn, NULL)->d_buf; - nsyms = shdr->sh_size / shdr->sh_entsize; - strindex = shdr->sh_link; + GElf_Shdr shdr; + (void) gelf_getshdr(scn, &shdr); + if (shdr.sh_type == SHT_SYMTAB) { + symtab = (GElf_Sym *)elf_getdata(scn, NULL)->d_buf; + nsyms = shdr.sh_size / shdr.sh_entsize; + strindex = shdr.sh_link; } } diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c index 5ea55a05faf0..e5d10ad5ac0a 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c @@ -35,6 +35,7 @@ #include <unistd.h> #include <dt_impl.h> #include <assert.h> +#include <dt_oformat.h> #ifdef illumos #include <alloca.h> #else @@ -471,8 +472,17 @@ dt_aggregate_snap_cpu(dtrace_hdl_t *dtp, processorid_t cpu) } if (buf->dtbd_drops != 0) { - if (dt_handle_cpudrop(dtp, cpu, - DTRACEDROP_AGGREGATION, buf->dtbd_drops) == -1) + int error; + + if (dtp->dt_oformat) { + xo_open_instance("probes"); + dt_oformat_drop(dtp, cpu); + } + error = dt_handle_cpudrop(dtp, cpu, DTRACEDROP_AGGREGATION, + buf->dtbd_drops); + if (dtp->dt_oformat) + xo_close_instance("probes"); + if (error != 0) return (-1); } @@ -1086,8 +1096,10 @@ dt_aggregate_go(dtrace_hdl_t *dtp) assert(agp->dtat_ncpu == 0); assert(agp->dtat_cpus == NULL); - agp->dtat_maxcpu = dt_sysconf(dtp, _SC_CPUID_MAX) + 1; - agp->dtat_ncpu = dt_sysconf(dtp, _SC_NPROCESSORS_MAX); + agp->dtat_maxcpu = dt_cpu_maxid(dtp) + 1; + if (agp->dtat_maxcpu <= 0) + return (-1); + agp->dtat_ncpu = dt_sysconf(dtp, _SC_NPROCESSORS_CONF); agp->dtat_cpus = malloc(agp->dtat_ncpu * sizeof (processorid_t)); if (agp->dtat_cpus == NULL) @@ -2127,8 +2139,13 @@ dtrace_aggregate_print(dtrace_hdl_t *dtp, FILE *fp, if (func == NULL) func = dtrace_aggregate_walk_sorted; - if ((*func)(dtp, dt_print_agg, &pd) == -1) - return (dt_set_errno(dtp, dtp->dt_errno)); + if (dtp->dt_oformat) { + if ((*func)(dtp, dt_format_agg, &pd) == -1) + return (dt_set_errno(dtp, dtp->dt_errno)); + } else { + if ((*func)(dtp, dt_print_agg, &pd) == -1) + return (dt_set_errno(dtp, dtp->dt_errno)); + } return (0); } diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c index e63771c91e08..f3fda4af834e 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c @@ -2478,10 +2478,7 @@ dt_compile(dtrace_hdl_t *dtp, int context, dtrace_probespec_t pspec, void *arg, "not referenced)\n", yypcb->pcb_sargv[argc - 1], argc - 1); } - /* - * Perform sugar transformations (for "if" / "else") and replace the - * existing clause chain with the new one. - */ + /* Perform sugar transformations. */ if (context == DT_CTX_DPROG) { dt_node_t *dnp, *next_dnp; dt_node_t *new_list = NULL; @@ -2492,8 +2489,17 @@ dt_compile(dtrace_hdl_t *dtp, int context, dtrace_probespec_t pspec, void *arg, next_dnp = dnp->dn_list; dnp->dn_list = NULL; - if (dnp->dn_kind == DT_NODE_CLAUSE) + if (dnp->dn_kind == DT_NODE_CLAUSE) { dnp = dt_compile_sugar(dtp, dnp); + if (cflags & DTRACE_C_SUGAR) { + dt_node_t *p; + + dt_printd(dnp, stdout, 0); + for (p = dnp->dn_list; p != NULL; + p = p->dn_list) + dt_printd(p, stdout, 0); + } + } /* append node to the new list */ new_list = dt_node_link(new_list, dnp); } diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c index 862d4b9222d7..385c9d78bdfc 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c @@ -24,6 +24,7 @@ */ /* + * Copyright (c) 2023, Domagoj Stolfa. All rights reserved. * Copyright (c) 2017, Joyent, Inc. All rights reserved. * Copyright (c) 2012 by Delphix. All rights reserved. */ @@ -40,12 +41,50 @@ #endif #include <dt_impl.h> #include <dt_pq.h> +#include <dt_oformat.h> #ifndef illumos #include <libproc_compat.h> #endif #define DT_MASK_LO 0x00000000FFFFFFFFULL +#define dt_format_sym(dtp, addr) dt_print_sym((dtp), NULL, NULL, addr) + +typedef struct dt_prepare_args { + int first_bin; + int last_bin; + union { + struct lquantize_args { +#define lquantize_step u.lquantize.step +#define lquantize_levels u.lquantize.levels +#define lquantize_base u.lquantize.base + int base; + uint16_t step; + uint16_t levels; + } lquantize; + struct llquantize_args { +#define llquantize_next u.llquantize.next +#define llquantize_step u.llquantize.step +#define llquantize_value u.llquantize.value +#define llquantize_levels u.llquantize.levels +#define llquantize_order u.llquantize.order +#define llquantize_factor u.llquantize.factor +#define llquantize_low u.llquantize.low +#define llquantize_high u.llquantize.high +#define llquantize_nsteps u.llquantize.nsteps + int64_t next; + int64_t step; + int64_t value; + int levels; + int order; + uint16_t factor; + uint16_t low; + uint16_t high; + uint16_t nsteps; + } llquantize; + } u; +} dt_prepare_args_t; + /* * We declare this here because (1) we need it and (2) we want to avoid a * dependency on libm in libdtrace. @@ -761,17 +800,17 @@ dt_print_packed(dtrace_hdl_t *dtp, FILE *fp, return (dt_printf(dtp, fp, "%c", ascii[(uint_t)(val + 0.5)])); } -int -dt_print_quantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr, - size_t size, uint64_t normal) +static const int64_t * +dt_format_quantize_prepare(dtrace_hdl_t *dtp, const void *addr, size_t size, + dt_prepare_args_t *args) { const int64_t *data = addr; - int i, first_bin = 0, last_bin = DTRACE_QUANTIZE_NBUCKETS - 1; - long double total = 0; - char positives = 0, negatives = 0; + int first_bin = 0, last_bin = DTRACE_QUANTIZE_NBUCKETS - 1; - if (size != DTRACE_QUANTIZE_NBUCKETS * sizeof (uint64_t)) - return (dt_set_errno(dtp, EDT_DMISMATCH)); + if (size != DTRACE_QUANTIZE_NBUCKETS * sizeof (uint64_t)) { + (void) dt_set_errno(dtp, EDT_DMISMATCH); + return (NULL); + } while (first_bin < DTRACE_QUANTIZE_NBUCKETS - 1 && data[first_bin] == 0) first_bin++; @@ -795,6 +834,58 @@ dt_print_quantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr, last_bin++; } + args->first_bin = first_bin; + args->last_bin = last_bin; + return (data); +} + +int +dt_format_quantize(dtrace_hdl_t *dtp, const void *addr, size_t size, + uint64_t normal) +{ + const int64_t *data; + dt_prepare_args_t args = { 0 }; + int i, first_bin = 0, last_bin = DTRACE_QUANTIZE_NBUCKETS - 1; + + data = dt_format_quantize_prepare(dtp, addr, size, &args); + /* dt_errno is set for us */ + if (data == NULL) + return (-1); + + first_bin = args.first_bin; + last_bin = args.last_bin; + + xo_open_list("buckets"); + for (i = first_bin; i <= last_bin; i++) { + long long value = (long long)DTRACE_QUANTIZE_BUCKETVAL(i); + xo_open_instance("buckets"); + xo_emit("{:value/%lld} {:count/%lld}", value, + (long long)data[i] / normal); + xo_close_instance("buckets"); + } + xo_close_list("buckets"); + + return (0); +} + +int +dt_print_quantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr, + size_t size, uint64_t normal) +{ + const int64_t *data; + dt_prepare_args_t args = { 0 }; + int i, first_bin = 0, last_bin = DTRACE_QUANTIZE_NBUCKETS - 1; + long double total = 0; + char positives = 0, negatives = 0; + + data = dt_format_quantize_prepare(dtp, addr, size, &args); + /* dt_errno is set for us */ + if (data == NULL) + return (-1); + + first_bin = args.first_bin; + last_bin = args.last_bin; + for (i = first_bin; i <= last_bin; i++) { positives |= (data[i] > 0); negatives |= (data[i] < 0); @@ -859,19 +950,19 @@ dt_print_quantize_packed(dtrace_hdl_t *dtp, FILE *fp, const void *addr, return (0); } -int -dt_print_lquantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr, - size_t size, uint64_t normal) +static const int64_t * +dt_format_lquantize_prepare(dtrace_hdl_t *dtp, const void *addr, size_t size, + dt_prepare_args_t *args) { const int64_t *data = addr; - int i, first_bin, last_bin, base; + int first_bin = 0, last_bin = DTRACE_QUANTIZE_NBUCKETS - 1, base; uint64_t arg; - long double total = 0; uint16_t step, levels; - char positives = 0, negatives = 0; - if (size < sizeof (uint64_t)) - return (dt_set_errno(dtp, EDT_DMISMATCH)); + if (size < sizeof (uint64_t)) { + (void) dt_set_errno(dtp, EDT_DMISMATCH); + return (NULL); + } arg = *data++; size -= sizeof (uint64_t); @@ -883,8 +974,10 @@ dt_print_lquantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr, first_bin = 0; last_bin = levels + 1; - if (size != sizeof (uint64_t) * (levels + 2)) - return (dt_set_errno(dtp, EDT_DMISMATCH)); + if (size != sizeof (uint64_t) * (levels + 2)) { + (void) dt_set_errno(dtp, EDT_DMISMATCH); + return (NULL); + } while (first_bin <= levels + 1 && data[first_bin] == 0) first_bin++; @@ -903,6 +996,80 @@ dt_print_lquantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr, last_bin++; } + args->first_bin = first_bin; + args->last_bin = last_bin; + args->lquantize_base = base; + args->lquantize_step = step; + args->lquantize_levels = levels; + return (data); +} + +int +dt_format_lquantize(dtrace_hdl_t *dtp, const void *addr, size_t size, + uint64_t normal) +{ + const int64_t *data; + dt_prepare_args_t args = { 0 }; + int i, first_bin, last_bin, base; + uint16_t step, levels; + + data = dt_format_lquantize_prepare(dtp, addr, size, &args); + /* dt_errno is set for us */ + if (data == NULL) + return (-1); + + first_bin = args.first_bin; + last_bin = args.last_bin; + step = args.lquantize_step; + levels = args.lquantize_levels; + base = args.lquantize_base; + + xo_open_list("buckets"); + for (i = first_bin; i <= last_bin; i++) { + char c[32]; + int err; + + xo_open_instance("buckets"); + if (i == 0) { + xo_emit("{:value/%d} {:operator/%s}", base, "<"); + } else if (i == levels + 1) { + xo_emit("{:value/%d} {:operator/%s}", + base + (levels * step), ">="); + } else { + xo_emit("{:value/%d}", base + (i - 1) * step); + } + + xo_emit("{:count/%lld}", (long long)data[i] / normal); + xo_close_instance("buckets"); + } + xo_close_list("buckets"); + + return (0); +} + +int +dt_print_lquantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr, + size_t size, uint64_t normal) +{ + const int64_t *data; + dt_prepare_args_t args = { 0 }; + int i, first_bin, last_bin, base; + uint64_t arg; + long double total = 0; + uint16_t step, levels; + char positives = 0, negatives = 0; + + data = dt_format_lquantize_prepare(dtp, addr, size, &args); + /* dt_errno is set for us */ + if (data == NULL) + return (-1); + + first_bin = args.first_bin; + last_bin = args.last_bin; + step = args.lquantize_step; + levels = args.lquantize_levels; + base = args.lquantize_base; + for (i = first_bin; i <= last_bin; i++) { positives |= (data[i] > 0); negatives |= (data[i] < 0); @@ -990,21 +1157,20 @@ dt_print_lquantize_packed(dtrace_hdl_t *dtp, FILE *fp, const void *addr, return (dt_printf(dtp, fp, ": %-8s | %lld\n", c, (long long)count)); } -int -dt_print_llquantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr, - size_t size, uint64_t normal) +static const int64_t * +dt_format_llquantize_prepare(dtrace_hdl_t *dtp, const void *addr, size_t size, + dt_prepare_args_t *args) { int i, first_bin, last_bin, bin = 1, order, levels; uint16_t factor, low, high, nsteps; const int64_t *data = addr; int64_t value = 1, next, step; - char positives = 0, negatives = 0; - long double total = 0; uint64_t arg; - char c[32]; - if (size < sizeof (uint64_t)) - return (dt_set_errno(dtp, EDT_DMISMATCH)); + if (size < sizeof(uint64_t)) { + (void) dt_set_errno(dtp, EDT_DMISMATCH); + return (NULL); + } arg = *data++; size -= sizeof (uint64_t); @@ -1019,8 +1185,10 @@ dt_print_llquantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr, * but sanity check them (to a degree) nonetheless. */ if (size > INT32_MAX || factor < 2 || low >= high || - nsteps == 0 || factor > nsteps) - return (dt_set_errno(dtp, EDT_DMISMATCH)); + nsteps == 0 || factor > nsteps) { + (void) dt_set_errno(dtp, EDT_DMISMATCH); + return (NULL); + } levels = (int)size / sizeof (uint64_t); @@ -1044,6 +1212,133 @@ dt_print_llquantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr, last_bin++; } + for (order = 0; order < low; order++) + value *= factor; + + next = value * factor; + step = next > nsteps ? next / nsteps : 1; + + args->first_bin = first_bin; + args->last_bin = last_bin; + args->llquantize_factor = factor; + args->llquantize_low = low; + args->llquantize_high = high; + args->llquantize_nsteps = nsteps; + args->llquantize_levels = levels; + args->llquantize_order = order; + args->llquantize_next = next; + args->llquantize_step = step; + args->llquantize_value = value; + + return (data); +} + +int +dt_format_llquantize(dtrace_hdl_t *dtp, const void *addr, size_t size, + uint64_t normal) +{ + int first_bin, last_bin, bin = 1, order, levels; + uint16_t factor, low, high, nsteps; + const int64_t *data; + dt_prepare_args_t args = { 0 }; + int64_t value = 1, next, step; + uint64_t arg; + char c[32]; + + data = dt_format_llquantize_prepare(dtp, addr, size, &args); + /* dt_errno is set for us */ + if (data == NULL) + return (-1); + + first_bin = args.first_bin; + last_bin = args.last_bin; + factor = args.llquantize_factor; + low = args.llquantize_low; + high = args.llquantize_high; + nsteps = args.llquantize_nsteps; + levels = args.llquantize_levels; + order = args.llquantize_order; + next = args.llquantize_next; + step = args.llquantize_step; + value = args.llquantize_value; + + xo_open_list("buckets"); + if (first_bin == 0) { + /* + * We have to represent < value somehow in JSON, so we bundle an + * optional "operator" in llquantize buckets. + */ + xo_open_instance("buckets"); + xo_emit("{:value/%lld} {:count/%lld} {:operator/%s}", + (long long)value, (long long)data[0] / normal, "<"); + xo_close_instance("buckets"); + } + + while (order <= high) { + if (bin >= first_bin && bin <= last_bin) { + xo_open_instance("buckets"); + xo_emit("{:value/%lld} {:count/%lld}", (long long)value, + (long long)data[bin] / normal); + xo_close_instance("buckets"); + } + + assert(value < next); + bin++; + + if ((value += step) != next) + continue; + + next = value * factor; + step = next > nsteps ? next / nsteps : 1; + order++; + } + + if (last_bin < bin) { + xo_close_list("buckets"); + return (0); + } + + assert(last_bin == bin); + xo_open_instance("buckets"); + xo_emit("{:value/%lld} {:count/%lld} {:operator/%s}", (long long)value, + (long long)data[bin] / normal, ">="); + xo_close_instance("buckets"); + + xo_close_list("buckets"); + return (0); +} + +int +dt_print_llquantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr, + size_t size, uint64_t normal) +{ + int i, first_bin, last_bin, bin = 1, order, levels; + uint16_t factor, low, high, nsteps; + const int64_t *data; + dt_prepare_args_t args = { 0 }; + int64_t value = 1, next, step; + char positives = 0, negatives = 0; + long double total = 0; + uint64_t arg; + char c[32]; + + data = dt_format_llquantize_prepare(dtp, addr, size, &args); + /* dt_errno is set for us */ + if (data == NULL) + return (-1); + + first_bin = args.first_bin; + last_bin = args.last_bin; + factor = args.llquantize_factor; + low = args.llquantize_low; + high = args.llquantize_high; + nsteps = args.llquantize_nsteps; + levels = args.llquantize_levels; + order = args.llquantize_order; + next = args.llquantize_next; + step = args.llquantize_step; + value = args.llquantize_value; + for (i = first_bin; i <= last_bin; i++) { positives |= (data[i] > 0); negatives |= (data[i] < 0); @@ -1054,12 +1349,6 @@ dt_print_llquantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr, "------------- Distribution -------------", "count") < 0) return (-1); - for (order = 0; order < low; order++) - value *= factor; - - next = value * factor; - step = next > nsteps ? next / nsteps : 1; - if (first_bin == 0) { (void) snprintf(c, sizeof (c), "< %lld", (long long)value); @@ -1105,6 +1394,16 @@ dt_print_llquantize(dtrace_hdl_t *dtp, FILE *fp, const void *addr, total, positives, negatives)); } +static int +dt_format_average(dtrace_hdl_t *dtp, caddr_t addr, size_t size, uint64_t normal) +{ + int64_t *data = (int64_t *)addr; + + xo_emit("{:average/%lld}", + data[0] ? (long long)(data[1] / (int64_t)normal / data[0]) : 0); + return (0); +} + /*ARGSUSED*/ static int dt_print_average(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, @@ -1117,6 +1416,16 @@ dt_print_average(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, (long long)(data[1] / (int64_t)normal / data[0]) : 0)); } +static int +dt_format_stddev(dtrace_hdl_t *dtp, caddr_t addr, size_t size, uint64_t normal) +{ + uint64_t *data = (uint64_t *)addr; + + xo_emit("{:stddev/%llu}", + data[0] ? (unsigned long long)dt_stddev(data, normal) : 0); + return (0); +} + /*ARGSUSED*/ static int dt_print_stddev(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, @@ -1249,6 +1558,185 @@ raw: } int +dt_format_stack(dtrace_hdl_t *dtp, caddr_t addr, int depth, int size) +{ + dtrace_syminfo_t dts; + GElf_Sym sym; + int i; + uint64_t pc; + + xo_open_list("stack-frames"); + for (i = 0; i < depth; i++) { + switch (size) { + case sizeof (uint32_t): + pc = *((uint32_t *)addr); + break; + + case sizeof (uint64_t): + pc = *((uint64_t *)addr); + break; + + default: + return (dt_set_errno(dtp, EDT_BADSTACKPC)); + } + + if (pc == 0) + break; + + addr += size; + + xo_open_instance("stack-frames"); + if (dtrace_lookup_by_addr(dtp, pc, &sym, &dts) == 0) { + if (pc > sym.st_value) { + xo_emit("{:symbol/%s`%s+0x%llx} {:module/%s} " + "{:name/%s} {:offset/0x%llx}", + dts.dts_object, dts.dts_name, + (u_longlong_t)(pc - sym.st_value), + dts.dts_object, dts.dts_name, + (u_longlong_t)(pc - sym.st_value)); + } else { + xo_emit("{:symbol/%s`%s} {:module/%s} " + "{:name/%s}", + dts.dts_object, dts.dts_name, + dts.dts_object, dts.dts_name); + } + } else { + /* + * We'll repeat the lookup, but this time we'll specify + * a NULL GElf_Sym -- indicating that we're only + * interested in the containing module. + */ + if (dtrace_lookup_by_addr(dtp, pc, NULL, &dts) == 0) { + xo_emit("{:symbol/%s`0x%llx} {:module/%s} " + "{:offset/0x%llx}", + dts.dts_object, (u_longlong_t)pc, + dts.dts_object, (u_longlong_t)pc); + } else { + xo_emit("{:symbol/0x%llx} {:offset/0x%llx}", + (u_longlong_t)pc, (u_longlong_t)pc); + } + } + xo_close_instance("stack-frames"); + } + xo_close_list("stack-frames"); + + return (0); +} + +int +dt_format_ustack(dtrace_hdl_t *dtp, caddr_t addr, uint64_t arg) +{ + uint64_t *pc = (uint64_t *)addr; + uint32_t depth = DTRACE_USTACK_NFRAMES(arg); + uint32_t strsize = DTRACE_USTACK_STRSIZE(arg); + const char *strbase = addr + (depth + 1) * sizeof (uint64_t); + const char *str = strsize ? strbase : NULL; + int err = 0; + + char name[PATH_MAX], objname[PATH_MAX], c[PATH_MAX * 2]; + struct ps_prochandle *P; + GElf_Sym sym; + int i, indent; + pid_t pid; + + if (depth == 0) + return (0); + + pid = (pid_t)*pc++; + + /* + * Ultimately, we need to add an entry point in the library vector for + * determining <symbol, offset> from <pid, address>. For now, if + * this is a vector open, we just print the raw address or string. + */ + if (dtp->dt_vector == NULL) + P = dt_proc_grab(dtp, pid, PGRAB_RDONLY | PGRAB_FORCE, 0); + else + P = NULL; + + if (P != NULL) + dt_proc_lock(dtp, P); /* lock handle while we perform lookups */ + + xo_open_list("ustack-frames"); + for (i = 0; i < depth && pc[i] != 0; i++) { + const prmap_t *map; + + xo_open_instance("ustack-frames"); + if (P != NULL && Plookup_by_addr(P, pc[i], + name, sizeof (name), &sym) == 0) { + (void) Pobjname(P, pc[i], objname, sizeof (objname)); + + if (pc[i] > sym.st_value) { + xo_emit("{:symbol/%s`%s+0x%llx} {:module/%s} " + "{:name/%s} {:offset/0x%llx}", + dt_basename(objname), name, + (u_longlong_t)(pc[i] - sym.st_value), + dt_basename(objname), name, + (u_longlong_t)(pc[i] - sym.st_value)); + } else { + xo_emit("{:symbol/%s`%s} {:module/%s} " + "{:name/%s}", + dt_basename(objname), name, + dt_basename(objname), name); + } + } else if (str != NULL && str[0] != '\0' && str[0] != '@' && + (P != NULL && ((map = Paddr_to_map(P, pc[i])) == NULL || + (map->pr_mflags & MA_WRITE)))) { + /* + * If the current string pointer in the string table + * does not point to an empty string _and_ the program + * counter falls in a writable region, we'll use the + * string from the string table instead of the raw + * address. This last condition is necessary because + * some (broken) ustack helpers will return a string + * even for a program counter that they can't + * identify. If we have a string for a program + * counter that falls in a segment that isn't + * writable, we assume that we have fallen into this + * case and we refuse to use the string. + */ + xo_emit("{:symbol/%s}", str); + } else { + if (P != NULL && Pobjname(P, pc[i], objname, + sizeof (objname)) != 0) { + xo_emit("{:symbol/%s`0x%llx} {:module/%s} " + "{:offset/0x%llx}", + dt_basename(objname), (u_longlong_t)pc[i], + dt_basename(objname), (u_longlong_t)pc[i]); + } else { + xo_emit("{:symbol/0x%llx} {:offset/0x%llx}", + (u_longlong_t)pc[i], (u_longlong_t)pc[i]); + } + } + + if (str != NULL && str[0] == '@') { + /* + * If the first character of the string is an "at" sign, + * then the string is inferred to be an annotation -- + * and it is printed out beneath the frame and offset + * with brackets. + */ + xo_emit("{:annotation/%s}", &str[1]); + } + + if (str != NULL) { + str += strlen(str) + 1; + if (str - strbase >= strsize) + str = NULL; + } + xo_close_instance("ustack-frames"); + } + xo_close_list("ustack-frames"); + + if (P != NULL) { + dt_proc_unlock(dtp, P); + dt_proc_release(dtp, P); + } + + return (err); +} + +int dt_print_stack(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr, int depth, int size) { @@ -1461,6 +1949,41 @@ dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format, } static int +dt_format_usym(dtrace_hdl_t *dtp, caddr_t addr, dtrace_actkind_t act) +{ + uint64_t pid = ((uint64_t *)addr)[0]; + uint64_t pc = ((uint64_t *)addr)[1]; + char *s; + int n, len = 256; + + if (act == DTRACEACT_USYM && dtp->dt_vector == NULL) { + struct ps_prochandle *P; + + if ((P = dt_proc_grab(dtp, pid, + PGRAB_RDONLY | PGRAB_FORCE, 0)) != NULL) { + GElf_Sym sym; + + dt_proc_lock(dtp, P); + + if (Plookup_by_addr(P, pc, NULL, 0, &sym) == 0) + pc = sym.st_value; + + dt_proc_unlock(dtp, P); + dt_proc_release(dtp, P); + } + } + + do { + n = len; + s = alloca(n); + } while ((len = dtrace_uaddr2str(dtp, pid, pc, s, n)) > n); + + xo_emit("{:usym/%s}", s); + return (0); +} + + +static int dt_print_usym(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, dtrace_actkind_t act) { /* LINTED - alignment */ @@ -1497,6 +2020,42 @@ dt_print_usym(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, dtrace_actkind_t act) } int +dt_format_umod(dtrace_hdl_t *dtp, caddr_t addr) +{ + uint64_t pid = ((uint64_t *)addr)[0]; + uint64_t pc = ((uint64_t *)addr)[1]; + int err = 0; + + char objname[PATH_MAX]; + struct ps_prochandle *P; + + /* + * See the comment in dt_print_ustack() for the rationale for + * printing raw addresses in the vectored case. + */ + if (dtp->dt_vector == NULL) + P = dt_proc_grab(dtp, pid, PGRAB_RDONLY | PGRAB_FORCE, 0); + else + P = NULL; + + if (P != NULL) + dt_proc_lock(dtp, P); /* lock handle while we perform lookups */ + + if (P != NULL && Pobjname(P, pc, objname, sizeof (objname)) != 0) { + xo_emit("{:umod/%s}", dt_basename(objname)); + } else { + xo_emit("{:umod/0x%llx}", (u_longlong_t)pc); + } + + if (P != NULL) { + dt_proc_unlock(dtp, P); + dt_proc_release(dtp, P); + } + + return (0); +} + +int dt_print_umod(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr) { /* LINTED - alignment */ @@ -1552,8 +2111,13 @@ dt_print_sym(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr) format = " %-50s"; if (dtrace_lookup_by_addr(dtp, pc, &sym, &dts) == 0) { - (void) snprintf(c, sizeof (c), "%s`%s", - dts.dts_object, dts.dts_name); + if (dtp->dt_oformat) + xo_emit("{:sym/%s`%s} {:object/%s} {:name/%s}", + dts.dts_object, dts.dts_name, dts.dts_object, + dts.dts_name); + else + (void) snprintf(c, sizeof (c), "%s`%s", + dts.dts_object, dts.dts_name); } else { /* * We'll repeat the lookup, but this time we'll specify a @@ -1561,21 +2125,47 @@ dt_print_sym(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr) * the containing module. */ if (dtrace_lookup_by_addr(dtp, pc, NULL, &dts) == 0) { - (void) snprintf(c, sizeof (c), "%s`0x%llx", - dts.dts_object, (u_longlong_t)pc); + if (dtp->dt_oformat) + xo_emit("{:sym/%s`0x%llx} {:object/%s} " + "{:offset/0x%llx}", + dts.dts_object, (u_longlong_t)pc, + dts.dts_object, (u_longlong_t)pc); + else + (void) snprintf(c, sizeof (c), "%s`0x%llx", + dts.dts_object, (u_longlong_t)pc); } else { - (void) snprintf(c, sizeof (c), "0x%llx", - (u_longlong_t)pc); + if (dtp->dt_oformat) + xo_emit("{:sym/0x%llx} {:offset/0x%llx}", + (u_longlong_t)pc, (u_longlong_t)pc); + else + (void) snprintf(c, sizeof (c), "0x%llx", + (u_longlong_t)pc); } } - if (dt_printf(dtp, fp, format, c) < 0) + if (dtp->dt_oformat != 0 && dt_printf(dtp, fp, format, c) < 0) return (-1); return (0); } int +dt_format_mod(dtrace_hdl_t *dtp, caddr_t addr) +{ + /* LINTED - alignment */ + uint64_t pc = *((uint64_t *)addr); + dtrace_syminfo_t dts; + + if (dtrace_lookup_by_addr(dtp, pc, NULL, &dts) == 0) { + xo_emit("{:mod/%s}", dts.dts_object); + } else { + xo_emit("{:mod/0x%llx}", (u_longlong_t)pc); + } + + return (0); +} + +int dt_print_mod(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr) { /* LINTED - alignment */ @@ -1598,6 +2188,74 @@ dt_print_mod(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr) return (0); } +static char * +dt_format_bytes_get(dtrace_hdl_t *dtp, caddr_t addr, size_t nbytes) +{ + char *s = dt_alloc(dtp, nbytes * 2 + 2 + 1); /* 2 bytes per byte + 0x + '\0' */ + char t[6]; + char *c = (char *)addr; + size_t i, j; + + if (s == NULL) + return (NULL); + + /* + * XXX: Some duplication with dt_print_bytes(). + */ + for (i = 0; i < nbytes; i++) { + if (isprint(c[i]) || isspace(c[i]) || c[i] == '\b' || c[i] == '\a') + continue; + + if (c[i] == '\0' && i > 0) { + for (j = i + 1; j < nbytes; j++) { + if (c[j] != '\0') + break; + } + + if (j != nbytes) + break; + + memcpy(s, c, nbytes); + return (s); + } + + break; + } + + if (i == nbytes) { + memcpy(s, c, nbytes); + s[nbytes] = '\0'; + return (s); + } + + s[0] = '0'; + s[1] = 'x'; + for (i = 0; i < nbytes; i++) { + snprintf(t, sizeof(t), "%02x", (uchar_t)c[i]); + memcpy(s + (i * 2) + 2, t, 2); + } + + s[nbytes * 2 + 2] = 0; + return (s); +} + +static int +dt_format_memory(dtrace_hdl_t *dtp, caddr_t addr) +{ + + size_t nbytes = *((uintptr_t *) addr); + char *s; + + s = dt_format_bytes_get(dtp, addr + sizeof(uintptr_t), nbytes); + if (s == NULL) + return (-1); + + xo_emit("{:printm/%s}", s); + dt_free(dtp, s); + + return (0); +} + static int dt_print_memory(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr) { @@ -1803,6 +2461,90 @@ dt_trunc(dtrace_hdl_t *dtp, caddr_t base, dtrace_recdesc_t *rec) } static int +dt_format_datum(dtrace_hdl_t *dtp, dtrace_recdesc_t *rec, caddr_t addr, + size_t size, const dtrace_aggdata_t *aggdata, uint64_t normal, + dt_print_aggdata_t *pd) +{ + dtrace_actkind_t act = rec->dtrd_action; + boolean_t packed = pd->dtpa_agghist || pd->dtpa_aggpack; + dtrace_aggdesc_t *agg = aggdata->dtada_desc; + char fmt[512]; + char *s; + + if (packed && pd->dtpa_agghisthdr != agg->dtagd_varid) + pd->dtpa_agghisthdr = agg->dtagd_varid; + + switch (act) { + case DTRACEACT_STACK: + return (dt_format_stack(dtp, addr, rec->dtrd_arg, + rec->dtrd_size / rec->dtrd_arg)); + + case DTRACEACT_USTACK: + case DTRACEACT_JSTACK: + return (dt_format_ustack(dtp, addr, rec->dtrd_arg)); + + case DTRACEACT_USYM: + case DTRACEACT_UADDR: + return (dt_format_usym(dtp, addr, act)); + + case DTRACEACT_UMOD: + return (dt_format_umod(dtp, addr)); + + case DTRACEACT_SYM: + return (dt_format_sym(dtp, addr)); + case DTRACEACT_MOD: + return (dt_format_mod(dtp, addr)); + + case DTRACEAGG_QUANTIZE: + return (dt_format_quantize(dtp, addr, size, normal)); + + case DTRACEAGG_LQUANTIZE: + return (dt_format_lquantize(dtp, addr, size, normal)); + + case DTRACEAGG_LLQUANTIZE: + return (dt_format_llquantize(dtp, addr, size, normal)); + + case DTRACEAGG_AVG: + return (dt_format_average(dtp, addr, size, normal)); + + case DTRACEAGG_STDDEV: + return (dt_format_stddev(dtp, addr, size, normal)); + + default: + break; + } + + switch (size) { + case sizeof (uint64_t): + snprintf(fmt, sizeof(fmt), "{:%s/%%lld}", pd->dtpa_keyname); + xo_emit(fmt, (long long)*((uint64_t *)addr) / normal); + break; + case sizeof (uint32_t): + snprintf(fmt, sizeof(fmt), "{:%s/%%d}", pd->dtpa_keyname); + xo_emit(fmt, *((uint32_t *)addr) / (uint32_t)normal); + break; + case sizeof (uint16_t): + snprintf(fmt, sizeof(fmt), "{:%s/%%d}", pd->dtpa_keyname); + xo_emit(fmt, *((uint16_t *)addr) / (uint32_t)normal); + break; + case sizeof (uint8_t): + snprintf(fmt, sizeof(fmt), "{:%s/%%d}", pd->dtpa_keyname); + xo_emit(fmt, *((uint8_t *)addr) / (uint32_t)normal); + break; + default: + s = dt_format_bytes_get(dtp, addr, size); + if (s == NULL) + return (-1); + + xo_emit("{:value/%s}", s); + dt_free(dtp, s); + break; + } + + return (0); +} + +static int dt_print_datum(dtrace_hdl_t *dtp, FILE *fp, dtrace_recdesc_t *rec, caddr_t addr, size_t size, const dtrace_aggdata_t *aggdata, uint64_t normal, dt_print_aggdata_t *pd) @@ -1957,6 +2699,119 @@ dt_print_datum(dtrace_hdl_t *dtp, FILE *fp, dtrace_recdesc_t *rec, } int +dt_format_aggs(const dtrace_aggdata_t **aggsdata, int naggvars, void *arg) +{ + int i, aggact = 0; + dt_print_aggdata_t *pd = arg; + const dtrace_aggdata_t *aggdata = aggsdata[0]; + dtrace_aggdesc_t *agg = aggdata->dtada_desc; + dtrace_hdl_t *dtp = pd->dtpa_dtp; + dtrace_recdesc_t *rec; + dtrace_actkind_t act; + caddr_t addr; + size_t size; + + if (pd->dtpa_aggname == NULL) + pd->dtpa_aggname = agg->dtagd_name; + + xo_open_instance("aggregation-data"); + strcpy(pd->dtpa_keyname, "value"); + xo_open_list("keys"); + + /* + * Iterate over each record description in the key, printing the traced + * data, skipping the first datum (the tuple member created by the + * compiler). + */ + for (i = 1; i < agg->dtagd_nrecs; i++) { + rec = &agg->dtagd_rec[i]; + act = rec->dtrd_action; + addr = aggdata->dtada_data + rec->dtrd_offset; + size = rec->dtrd_size; + + if (DTRACEACT_ISAGG(act)) { + aggact = i; + break; + } + + xo_open_instance("keys"); + if (dt_format_datum(dtp, rec, addr, + size, aggdata, 1, pd) < 0) { + xo_close_instance("keys"); + xo_close_instance("aggregation-data"); + return (-1); + } + xo_close_instance("keys"); + + if (dt_buffered_flush(dtp, NULL, rec, aggdata, + DTRACE_BUFDATA_AGGKEY) < 0) { + xo_close_instance("aggregation-data"); + return (-1); + } + } + xo_close_list("keys"); + + assert(aggact != 0); + + for (i = (naggvars == 1 ? 0 : 1); i < naggvars; i++) { + uint64_t normal; + + aggdata = aggsdata[i]; + agg = aggdata->dtada_desc; + rec = &agg->dtagd_rec[aggact]; + act = rec->dtrd_action; + addr = aggdata->dtada_data + rec->dtrd_offset; + size = rec->dtrd_size; + + assert(DTRACEACT_ISAGG(act)); + + switch (act) { + case DTRACEAGG_MIN: + strcpy(pd->dtpa_keyname, "min"); + break; + case DTRACEAGG_MAX: + strcpy(pd->dtpa_keyname, "max"); + break; + case DTRACEAGG_COUNT: + strcpy(pd->dtpa_keyname, "count"); + break; + case DTRACEAGG_SUM: + strcpy(pd->dtpa_keyname, "sum"); + break; + default: + strcpy(pd->dtpa_keyname, "UNKNOWN"); + break; + } + + normal = aggdata->dtada_normal; + + if (dt_format_datum(dtp, rec, addr, size, + aggdata, normal, pd) < 0) { + xo_close_instance("aggregation-data"); + return (-1); + } + + if (dt_buffered_flush(dtp, NULL, rec, aggdata, + DTRACE_BUFDATA_AGGVAL) < 0) { + xo_close_instance("aggregation-data"); + return (-1); + } + + if (!pd->dtpa_allunprint) + agg->dtagd_flags |= DTRACE_AGD_PRINTED; + } + + if (dt_buffered_flush(dtp, NULL, NULL, aggdata, + DTRACE_BUFDATA_AGGFORMAT | DTRACE_BUFDATA_AGGLAST) < 0) { + xo_close_instance("aggregation-data"); + return (-1); + } + + xo_close_instance("aggregation-data"); + return (0); +} + +int dt_print_aggs(const dtrace_aggdata_t **aggsdata, int naggvars, void *arg) { int i, aggact = 0; @@ -2038,6 +2893,33 @@ dt_print_aggs(const dtrace_aggdata_t **aggsdata, int naggvars, void *arg) } int +dt_format_agg(const dtrace_aggdata_t *aggdata, void *arg) +{ + dt_print_aggdata_t *pd = arg; + dtrace_aggdesc_t *agg = aggdata->dtada_desc; + dtrace_aggvarid_t aggvarid = pd->dtpa_id; + + if (pd->dtpa_allunprint) { + if (agg->dtagd_flags & DTRACE_AGD_PRINTED) + return (0); + } else { + /* + * If we're not printing all unprinted aggregations, then the + * aggregation variable ID denotes a specific aggregation + * variable that we should print -- skip any other aggregations + * that we encounter. + */ + if (agg->dtagd_nrecs == 0) + return (0); + + if (aggvarid != agg->dtagd_varid) + return (0); + } + + return (dt_format_aggs(&aggdata, 1, arg)); +} + +int dt_print_agg(const dtrace_aggdata_t *aggdata, void *arg) { dt_print_aggdata_t *pd = arg; @@ -2101,6 +2983,33 @@ dt_setopt(dtrace_hdl_t *dtp, const dtrace_probedata_t *data, return (rval); } +/* + * Helper functions to help maintain style(9) in dt_consume_cpu(). + */ +static int +dt_oformat_agg_sorted(dtrace_hdl_t *dtp, dtrace_aggregate_f *func, + dt_print_aggdata_t *pd) +{ + int r; + + r = dtrace_aggregate_walk_sorted(dtp, dt_format_agg, pd); + if (r < 0) { + xo_close_list("aggregation-data"); + xo_emit("{:aggregation-name/%s}", pd->dtpa_aggname); + xo_close_instance("output"); + } + + return (r); +} + +static void +dt_oformat_agg_name(dt_print_aggdata_t *pd) +{ + + xo_close_list("aggregation-data"); + xo_emit("{:aggregation-name/%s}", pd->dtpa_aggname); +} + static int dt_consume_cpu(dtrace_hdl_t *dtp, FILE *fp, int cpu, dtrace_bufdesc_t *buf, boolean_t just_one, @@ -2114,6 +3023,7 @@ dt_consume_cpu(dtrace_hdl_t *dtp, FILE *fp, int cpu, uint64_t tracememsize = 0; dtrace_probedata_t data; uint64_t drops; + size_t skip_format; bzero(&data, sizeof (data)); data.dtpda_handle = dtp; @@ -2145,6 +3055,8 @@ dt_consume_cpu(dtrace_hdl_t *dtp, FILE *fp, int cpu, epd = data.dtpda_edesc; data.dtpda_data = buf->dtbd_data + offs; + data.dtpda_timestamp = DTRACE_RECORD_LOAD_TIMESTAMP( + (struct dtrace_rechdr *)data.dtpda_data); if (data.dtpda_edesc->dtepd_uarg != DT_ECB_DEFAULT) { rval = dt_handle(dtp, &data); @@ -2160,6 +3072,8 @@ dt_consume_cpu(dtrace_hdl_t *dtp, FILE *fp, int cpu, (void) dt_flowindent(dtp, &data, dtp->dt_last_epid, buf, offs); + if (dtp->dt_oformat) + xo_open_instance("probes"); rval = (*efunc)(&data, arg); if (flow) { @@ -2176,11 +3090,17 @@ dt_consume_cpu(dtrace_hdl_t *dtp, FILE *fp, int cpu, if (rval != DTRACE_CONSUME_THIS) return (dt_set_errno(dtp, EDT_BADRVAL)); + skip_format = 0; + if (dtp->dt_oformat) + xo_open_list("output"); for (i = 0; i < epd->dtepd_nrecs; i++) { caddr_t addr; dtrace_recdesc_t *rec = &epd->dtepd_rec[i]; dtrace_actkind_t act = rec->dtrd_action; + if (skip_format > 0) + skip_format--; + data.dtpda_data = buf->dtbd_data + offs + rec->dtrd_offset; addr = data.dtpda_data; @@ -2301,54 +3221,109 @@ dt_consume_cpu(dtrace_hdl_t *dtp, FILE *fp, int cpu, if (rval != DTRACE_CONSUME_THIS) return (dt_set_errno(dtp, EDT_BADRVAL)); + if (dtp->dt_oformat && rec->dtrd_size > 0) + xo_open_instance("output"); if (act == DTRACEACT_STACK) { int depth = rec->dtrd_arg; - if (dt_print_stack(dtp, fp, NULL, addr, depth, - rec->dtrd_size / depth) < 0) + if (dtp->dt_oformat) { + if (dt_format_stack(dtp, addr, depth, + rec->dtrd_size / depth) < 0) { + xo_close_instance("output"); + return (-1); + } + } else { + if (dt_print_stack(dtp, + fp, NULL, addr, depth, + rec->dtrd_size / depth) < 0) return (-1); + } goto nextrec; } if (act == DTRACEACT_USTACK || act == DTRACEACT_JSTACK) { - if (dt_print_ustack(dtp, fp, NULL, - addr, rec->dtrd_arg) < 0) - return (-1); + if (dtp->dt_oformat) { + if (dt_format_ustack(dtp, addr, + rec->dtrd_arg) < 0) { + xo_close_instance("output"); + return (-1); + } + } else { + if (dt_print_ustack(dtp, fp, NULL, + addr, rec->dtrd_arg) < 0) + return (-1); + } goto nextrec; } if (act == DTRACEACT_SYM) { - if (dt_print_sym(dtp, fp, NULL, addr) < 0) - return (-1); + if (dtp->dt_oformat) { + if (dt_format_sym(dtp, addr) < 0) { + xo_close_instance("output"); + return (-1); + } + } else { + if (dt_print_sym(dtp, fp, NULL, addr) < 0) + return (-1); + } goto nextrec; } if (act == DTRACEACT_MOD) { - if (dt_print_mod(dtp, fp, NULL, addr) < 0) - return (-1); + if (dtp->dt_oformat) { + if (dt_format_mod(dtp, addr) < 0) { + xo_close_instance("output"); + return (-1); + } + } else { + if (dt_print_mod(dtp, fp, NULL, addr) < 0) + return (-1); + } goto nextrec; } if (act == DTRACEACT_USYM || act == DTRACEACT_UADDR) { - if (dt_print_usym(dtp, fp, addr, act) < 0) - return (-1); + if (dtp->dt_oformat) { + if (dt_format_usym(dtp, addr, act) < 0) { + xo_close_instance("output"); + return (-1); + } + } else { + if (dt_print_usym(dtp, fp, addr, act) < 0) + return (-1); + } goto nextrec; } if (act == DTRACEACT_UMOD) { - if (dt_print_umod(dtp, fp, NULL, addr) < 0) - return (-1); + if (dtp->dt_oformat) { + if (dt_format_umod(dtp, addr) < 0) { + xo_close_instance("output"); + return (-1); + } + } else { + if (dt_print_umod(dtp, fp, NULL, addr) < 0) + return (-1); + } goto nextrec; } if (act == DTRACEACT_PRINTM) { - if (dt_print_memory(dtp, fp, addr) < 0) - return (-1); + if (dtp->dt_oformat) { + if (dt_format_memory(dtp, addr) < 0) { + xo_close_instance("output"); + return (-1); + } + } else { + if (dt_print_memory(dtp, fp, addr) < 0) + return (-1); + } goto nextrec; } - if (DTRACEACT_ISPRINTFLIKE(act)) { + if (dtp->dt_oformat == DTRACE_OFORMAT_TEXT && + DTRACEACT_ISPRINTFLIKE(act)) { void *fmtdata; int (*func)(dtrace_hdl_t *, FILE *, void *, const dtrace_probedata_t *, @@ -2388,6 +3363,54 @@ dt_consume_cpu(dtrace_hdl_t *dtp, FILE *fp, int cpu, } /* + * We don't care about a formatted printa, system or + * freopen for oformat. + */ + if (dtp->dt_oformat && act == DTRACEACT_PRINTF && + skip_format == 0) { + void *fmtdata; + if ((fmtdata = dt_format_lookup(dtp, + rec->dtrd_format)) == NULL) + goto nofmt; + + n = dtrace_sprintf(dtp, fp, fmtdata, rec, + epd->dtepd_nrecs - i, + (uchar_t *)buf->dtbd_data + offs, + buf->dtbd_size - offs); + + if (n < 0) { + xo_close_instance("output"); + return (-1); /* errno is set for us */ + } + + xo_emit("{:message/%s}", dtp->dt_sprintf_buf); + skip_format += n; + + /* + * We want the "message" object to be its own + * thing, but we still want to process the + * current DIFEXPR in case there is a value + * attached to it. If there is, we need to + * re-open a new output instance, as otherwise + * the message ends up bundled with the first + * value. + * + * XXX: There is an edge case where a + * printf("hello"); will produce a DIFO that + * returns 0 attached to it and we have no good + * way to determine if this 0 value is because + * there's no real data attached to the printf + * as an argument, or it's because the argument + * actually returns 0. + */ + if (skip_format == 0) + goto nextrec; + + xo_close_instance("output"); + xo_open_instance("output"); + } + + /* * If this is a DIF expression, and the record has a * format set, this indicates we have a CTF type name * associated with the data and we should try to print @@ -2397,8 +3420,14 @@ dt_consume_cpu(dtrace_hdl_t *dtp, FILE *fp, int cpu, const char *strdata = dt_strdata_lookup(dtp, rec->dtrd_format); if (strdata != NULL) { - n = dtrace_print(dtp, fp, strdata, - addr, rec->dtrd_size); + if (dtp->dt_oformat) + n = dtrace_format_print(dtp, fp, + strdata, addr, + rec->dtrd_size); + else + n = dtrace_print(dtp, fp, + strdata, addr, + rec->dtrd_size); /* * dtrace_print() will return -1 on @@ -2408,8 +3437,12 @@ dt_consume_cpu(dtrace_hdl_t *dtp, FILE *fp, int cpu, * should fall through to the normal * trace method. */ - if (n < 0) + if (n < 0) { + if (dtp->dt_oformat) + xo_close_instance( + "output"); return (-1); + } if (n > 0) goto nextrec; @@ -2424,8 +3457,11 @@ nofmt: size_t size = ((epd->dtepd_nrecs - i) * sizeof (dtrace_aggvarid_t)); - if ((aggvars = dt_alloc(dtp, size)) == NULL) + if ((aggvars = dt_alloc(dtp, size)) == NULL) { + if (dtp->dt_oformat) + xo_close_instance("output"); return (-1); + } /* * This might be a printa() with multiple @@ -2443,6 +3479,9 @@ nofmt: break; if (nrec->dtrd_action != act) { + if (dtp->dt_oformat) + xo_close_instance( + "output"); return (dt_set_errno(dtp, EDT_BADAGG)); } @@ -2462,24 +3501,50 @@ nofmt: assert(naggvars >= 1); + if (dtp->dt_oformat) + xo_open_list("aggregation-data"); if (naggvars == 1) { pd.dtpa_id = aggvars[0]; dt_free(dtp, aggvars); - if (dt_printf(dtp, fp, "\n") < 0 || - dtrace_aggregate_walk_sorted(dtp, - dt_print_agg, &pd) < 0) - return (-1); + if (dtp->dt_oformat) { + n = dt_oformat_agg_sorted(dtp, + dt_format_agg, &pd); + if (n < 0) + return (-1); + } else { + if (dt_printf(dtp, fp, "\n") < 0 || + dtrace_aggregate_walk_sorted(dtp, + dt_print_agg, &pd) < 0) + return (-1); + } + + if (dtp->dt_oformat) + dt_oformat_agg_name(&pd); goto nextrec; } - if (dt_printf(dtp, fp, "\n") < 0 || - dtrace_aggregate_walk_joined(dtp, aggvars, - naggvars, dt_print_aggs, &pd) < 0) { - dt_free(dtp, aggvars); - return (-1); + if (dtp->dt_oformat) { + if (dtrace_aggregate_walk_joined(dtp, + aggvars, naggvars, + dt_format_aggs, &pd) < 0) { + dt_oformat_agg_name(&pd); + xo_close_instance("output"); + dt_free(dtp, aggvars); + return (-1); + } + } else { + if (dt_printf(dtp, fp, "\n") < 0 || + dtrace_aggregate_walk_joined(dtp, + aggvars, naggvars, + dt_print_aggs, &pd) < 0) { + dt_free(dtp, aggvars); + return (-1); + } } + if (dtp->dt_oformat) + dt_oformat_agg_name(&pd); dt_free(dtp, aggvars); goto nextrec; } @@ -2490,8 +3555,17 @@ nofmt: tracememsize = rec->dtrd_size; } - n = dt_print_bytes(dtp, fp, addr, - tracememsize, -33, quiet, 1); + if (dtp->dt_oformat) { + char *s; + + s = dt_format_bytes_get(dtp, addr, + tracememsize); + n = xo_emit("{:tracemem/%s}", s); + dt_free(dtp, s); + } else { + n = dt_print_bytes(dtp, fp, addr, + tracememsize, -33, quiet, 1); + } tracememsize = 0; @@ -2503,31 +3577,67 @@ nofmt: switch (rec->dtrd_size) { case sizeof (uint64_t): - n = dt_printf(dtp, fp, - quiet ? "%lld" : " %16lld", - /* LINTED - alignment */ - *((unsigned long long *)addr)); + if (dtp->dt_oformat) { + xo_emit("{:value/%lld}", + *((unsigned long long *)addr)); + n = 0; + } else + n = dt_printf(dtp, fp, + quiet ? "%lld" : " %16lld", + /* LINTED - alignment */ + *((unsigned long long *)addr)); break; case sizeof (uint32_t): - n = dt_printf(dtp, fp, quiet ? "%d" : " %8d", - /* LINTED - alignment */ - *((uint32_t *)addr)); + if (dtp->dt_oformat) { + xo_emit("{:value/%d}", + *((uint32_t *)addr)); + n = 0; + } else + n = dt_printf(dtp, fp, + quiet ? "%d" : " %8d", + /* LINTED - alignment */ + *((uint32_t *)addr)); break; case sizeof (uint16_t): - n = dt_printf(dtp, fp, quiet ? "%d" : " %5d", - /* LINTED - alignment */ - *((uint16_t *)addr)); + if (dtp->dt_oformat) { + xo_emit("{:value/%d}", + *((uint16_t *)addr)); + n = 0; + } else + n = dt_printf(dtp, fp, + quiet ? "%d" : " %5d", + /* LINTED - alignment */ + *((uint16_t *)addr)); break; case sizeof (uint8_t): - n = dt_printf(dtp, fp, quiet ? "%d" : " %3d", - *((uint8_t *)addr)); + if (dtp->dt_oformat) { + xo_emit("{:value/%d}", + *((uint8_t *)addr)); + n = 0; + } else + n = dt_printf(dtp, fp, + quiet ? "%d" : " %3d", + *((uint8_t *)addr)); break; default: - n = dt_print_bytes(dtp, fp, addr, - rec->dtrd_size, -33, quiet, 0); + if (dtp->dt_oformat && rec->dtrd_size > 0) { + char *s; + + s = dt_format_bytes_get(dtp, addr, + rec->dtrd_size); + xo_emit("{:value/%s}", s); + dt_free(dtp, s); + n = 0; + } else { + n = dt_print_bytes(dtp, fp, addr, + rec->dtrd_size, -33, quiet, 0); + } break; } + if (dtp->dt_oformat && rec->dtrd_size > 0) + xo_close_instance("output"); + if (n < 0) return (-1); /* errno is set for us */ @@ -2544,6 +3654,12 @@ nextrec: nextepid: offs += epd->dtepd_size; dtp->dt_last_epid = id; + + if (dtp->dt_oformat) { + xo_close_list("output"); + xo_close_instance("probes"); + xo_flush(); + } if (just_one) { buf->dtbd_oldest = offs; break; @@ -2562,7 +3678,15 @@ nextepid: */ buf->dtbd_drops = 0; - return (dt_handle_cpudrop(dtp, cpu, DTRACEDROP_PRINCIPAL, drops)); + if (dtp->dt_oformat) { + xo_open_instance("probes"); + dt_oformat_drop(dtp, cpu); + } + rval = dt_handle_cpudrop(dtp, cpu, DTRACEDROP_PRINCIPAL, drops); + if (dtp->dt_oformat) + xo_close_instance("probes"); + + return (rval); } /* @@ -2828,8 +3952,8 @@ dt_consume_begin(dtrace_hdl_t *dtp, FILE *fp, return (rval); } - if (max_ncpus == 0) - max_ncpus = dt_sysconf(dtp, _SC_CPUID_MAX) + 1; + if (max_ncpus == 0 && (max_ncpus = dt_cpu_maxid(dtp) + 1) <= 0) + return (-1); for (i = 0; i < max_ncpus; i++) { dtrace_bufdesc_t *nbuf; @@ -2919,8 +4043,8 @@ dtrace_consume(dtrace_hdl_t *dtp, FILE *fp, if (!dtp->dt_active) return (dt_set_errno(dtp, EINVAL)); - if (max_ncpus == 0) - max_ncpus = dt_sysconf(dtp, _SC_CPUID_MAX) + 1; + if (max_ncpus == 0 && (max_ncpus = dt_cpu_maxid(dtp) + 1) <= 0) + return (-1); if (pf == NULL) pf = (dtrace_consume_probe_f *)dt_nullprobe; @@ -3065,8 +4189,16 @@ dtrace_consume(dtrace_hdl_t *dtp, FILE *fp, /* Consume drops. */ for (i = 0; i < max_ncpus; i++) { if (drops[i] != 0) { - int error = dt_handle_cpudrop(dtp, i, + int error; + + if (dtp->dt_oformat) { + xo_open_instance("probes"); + dt_oformat_drop(dtp, i); + } + error = dt_handle_cpudrop(dtp, i, DTRACEDROP_PRINCIPAL, drops[i]); + if (dtp->dt_oformat) + xo_close_instance("probes"); if (error != 0) return (error); } @@ -3082,3 +4214,22 @@ dtrace_consume(dtrace_hdl_t *dtp, FILE *fp, return (0); } + +void +dtrace_oformat_probe(dtrace_hdl_t *dtp __unused, const dtrace_probedata_t *data, + processorid_t cpu, dtrace_probedesc_t *pd) +{ + + xo_emit("{:timestamp/%llu} {:cpu/%d} {:id/%d} {:provider/%s} " + "{:module/%s} {:function/%s} {:name/%s}", + (unsigned long long)data->dtpda_timestamp, cpu, pd->dtpd_id, + pd->dtpd_provider, pd->dtpd_mod, pd->dtpd_func, pd->dtpd_name); +} + +void +dt_oformat_drop(dtrace_hdl_t *dtp, processorid_t cpu) +{ + xo_emit("{:cpu/%d} {:id/%d} {:provider/%s} " + "{:module/%s} {:function/%s} {:name/%s}", + cpu, -1, "dtrace", "INTERNAL", "INTERNAL", "DROP"); +} diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dis.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dis.c index d1335180ec97..41765efb7717 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dis.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dis.c @@ -348,86 +348,86 @@ dt_dis(const dtrace_difo_t *dp, FILE *fp) void (*op_func)(const dtrace_difo_t *, const char *, dif_instr_t, FILE *); } optab[] = { - { "(illegal opcode)", dt_dis_str }, - { "or", dt_dis_log }, /* DIF_OP_OR */ - { "xor", dt_dis_log }, /* DIF_OP_XOR */ - { "and", dt_dis_log }, /* DIF_OP_AND */ - { "sll", dt_dis_log }, /* DIF_OP_SLL */ - { "srl", dt_dis_log }, /* DIF_OP_SRL */ - { "sub", dt_dis_log }, /* DIF_OP_SUB */ - { "add", dt_dis_log }, /* DIF_OP_ADD */ - { "mul", dt_dis_log }, /* DIF_OP_MUL */ - { "sdiv", dt_dis_log }, /* DIF_OP_SDIV */ - { "udiv", dt_dis_log }, /* DIF_OP_UDIV */ - { "srem", dt_dis_log }, /* DIF_OP_SREM */ - { "urem", dt_dis_log }, /* DIF_OP_UREM */ - { "not", dt_dis_r1rd }, /* DIF_OP_NOT */ - { "mov", dt_dis_r1rd }, /* DIF_OP_MOV */ - { "cmp", dt_dis_cmp }, /* DIF_OP_CMP */ - { "tst", dt_dis_tst }, /* DIF_OP_TST */ - { "ba", dt_dis_branch }, /* DIF_OP_BA */ - { "be", dt_dis_branch }, /* DIF_OP_BE */ - { "bne", dt_dis_branch }, /* DIF_OP_BNE */ - { "bg", dt_dis_branch }, /* DIF_OP_BG */ - { "bgu", dt_dis_branch }, /* DIF_OP_BGU */ - { "bge", dt_dis_branch }, /* DIF_OP_BGE */ - { "bgeu", dt_dis_branch }, /* DIF_OP_BGEU */ - { "bl", dt_dis_branch }, /* DIF_OP_BL */ - { "blu", dt_dis_branch }, /* DIF_OP_BLU */ - { "ble", dt_dis_branch }, /* DIF_OP_BLE */ - { "bleu", dt_dis_branch }, /* DIF_OP_BLEU */ - { "ldsb", dt_dis_load }, /* DIF_OP_LDSB */ - { "ldsh", dt_dis_load }, /* DIF_OP_LDSH */ - { "ldsw", dt_dis_load }, /* DIF_OP_LDSW */ - { "ldub", dt_dis_load }, /* DIF_OP_LDUB */ - { "lduh", dt_dis_load }, /* DIF_OP_LDUH */ - { "lduw", dt_dis_load }, /* DIF_OP_LDUW */ - { "ldx", dt_dis_load }, /* DIF_OP_LDX */ - { "ret", dt_dis_ret }, /* DIF_OP_RET */ - { "nop", dt_dis_str }, /* DIF_OP_NOP */ - { "setx", dt_dis_setx }, /* DIF_OP_SETX */ - { "sets", dt_dis_sets }, /* DIF_OP_SETS */ - { "scmp", dt_dis_cmp }, /* DIF_OP_SCMP */ - { "ldga", dt_dis_lda }, /* DIF_OP_LDGA */ - { "ldgs", dt_dis_ldv }, /* DIF_OP_LDGS */ - { "stgs", dt_dis_stv }, /* DIF_OP_STGS */ - { "ldta", dt_dis_lda }, /* DIF_OP_LDTA */ - { "ldts", dt_dis_ldv }, /* DIF_OP_LDTS */ - { "stts", dt_dis_stv }, /* DIF_OP_STTS */ - { "sra", dt_dis_log }, /* DIF_OP_SRA */ - { "call", dt_dis_call }, /* DIF_OP_CALL */ - { "pushtr", dt_dis_pushts }, /* DIF_OP_PUSHTR */ - { "pushtv", dt_dis_pushts }, /* DIF_OP_PUSHTV */ - { "popts", dt_dis_str }, /* DIF_OP_POPTS */ - { "flushts", dt_dis_str }, /* DIF_OP_FLUSHTS */ - { "ldgaa", dt_dis_ldv }, /* DIF_OP_LDGAA */ - { "ldtaa", dt_dis_ldv }, /* DIF_OP_LDTAA */ - { "stgaa", dt_dis_stv }, /* DIF_OP_STGAA */ - { "sttaa", dt_dis_stv }, /* DIF_OP_STTAA */ - { "ldls", dt_dis_ldv }, /* DIF_OP_LDLS */ - { "stls", dt_dis_stv }, /* DIF_OP_STLS */ - { "allocs", dt_dis_r1rd }, /* DIF_OP_ALLOCS */ - { "copys", dt_dis_log }, /* DIF_OP_COPYS */ - { "stb", dt_dis_store }, /* DIF_OP_STB */ - { "sth", dt_dis_store }, /* DIF_OP_STH */ - { "stw", dt_dis_store }, /* DIF_OP_STW */ - { "stx", dt_dis_store }, /* DIF_OP_STX */ - { "uldsb", dt_dis_load }, /* DIF_OP_ULDSB */ - { "uldsh", dt_dis_load }, /* DIF_OP_ULDSH */ - { "uldsw", dt_dis_load }, /* DIF_OP_ULDSW */ - { "uldub", dt_dis_load }, /* DIF_OP_ULDUB */ - { "ulduh", dt_dis_load }, /* DIF_OP_ULDUH */ - { "ulduw", dt_dis_load }, /* DIF_OP_ULDUW */ - { "uldx", dt_dis_load }, /* DIF_OP_ULDX */ - { "rldsb", dt_dis_load }, /* DIF_OP_RLDSB */ - { "rldsh", dt_dis_load }, /* DIF_OP_RLDSH */ - { "rldsw", dt_dis_load }, /* DIF_OP_RLDSW */ - { "rldub", dt_dis_load }, /* DIF_OP_RLDUB */ - { "rlduh", dt_dis_load }, /* DIF_OP_RLDUH */ - { "rlduw", dt_dis_load }, /* DIF_OP_RLDUW */ - { "rldx", dt_dis_load }, /* DIF_OP_RLDX */ - { "xlate", dt_dis_xlate }, /* DIF_OP_XLATE */ - { "xlarg", dt_dis_xlate }, /* DIF_OP_XLARG */ + [0] = { "(illegal opcode)", dt_dis_str }, + [DIF_OP_OR] = { "or", dt_dis_log }, + [DIF_OP_XOR] = { "xor", dt_dis_log }, + [DIF_OP_AND] = { "and", dt_dis_log }, + [DIF_OP_SLL] = { "sll", dt_dis_log }, + [DIF_OP_SRL] = { "srl", dt_dis_log }, + [DIF_OP_SUB] = { "sub", dt_dis_log }, + [DIF_OP_ADD] = { "add", dt_dis_log }, + [DIF_OP_MUL] = { "mul", dt_dis_log }, + [DIF_OP_SDIV] = { "sdiv", dt_dis_log }, + [DIF_OP_UDIV] = { "udiv", dt_dis_log }, + [DIF_OP_SREM] = { "srem", dt_dis_log }, + [DIF_OP_UREM] = { "urem", dt_dis_log }, + [DIF_OP_NOT] = { "not", dt_dis_r1rd }, + [DIF_OP_MOV] = { "mov", dt_dis_r1rd }, + [DIF_OP_CMP] = { "cmp", dt_dis_cmp }, + [DIF_OP_TST] = { "tst", dt_dis_tst }, + [DIF_OP_BA] = { "ba", dt_dis_branch }, + [DIF_OP_BE] = { "be", dt_dis_branch }, + [DIF_OP_BNE] = { "bne", dt_dis_branch }, + [DIF_OP_BG] = { "bg", dt_dis_branch }, + [DIF_OP_BGU] = { "bgu", dt_dis_branch }, + [DIF_OP_BGE] = { "bge", dt_dis_branch }, + [DIF_OP_BGEU] = { "bgeu", dt_dis_branch }, + [DIF_OP_BL] = { "bl", dt_dis_branch }, + [DIF_OP_BLU] = { "blu", dt_dis_branch }, + [DIF_OP_BLE] = { "ble", dt_dis_branch }, + [DIF_OP_BLEU] = { "bleu", dt_dis_branch }, + [DIF_OP_LDSB] = { "ldsb", dt_dis_load }, + [DIF_OP_LDSH] = { "ldsh", dt_dis_load }, + [DIF_OP_LDSW] = { "ldsw", dt_dis_load }, + [DIF_OP_LDUB] = { "ldub", dt_dis_load }, + [DIF_OP_LDUH] = { "lduh", dt_dis_load }, + [DIF_OP_LDUW] = { "lduw", dt_dis_load }, + [DIF_OP_LDX] = { "ldx", dt_dis_load }, + [DIF_OP_RET] = { "ret", dt_dis_ret }, + [DIF_OP_NOP] = { "nop", dt_dis_str }, + [DIF_OP_SETX] = { "setx", dt_dis_setx }, + [DIF_OP_SETS] = { "sets", dt_dis_sets }, + [DIF_OP_SCMP] = { "scmp", dt_dis_cmp }, + [DIF_OP_LDGA] = { "ldga", dt_dis_lda }, + [DIF_OP_LDGS] = { "ldgs", dt_dis_ldv }, + [DIF_OP_STGS] = { "stgs", dt_dis_stv }, + [DIF_OP_LDTA] = { "ldta", dt_dis_lda }, + [DIF_OP_LDTS] = { "ldts", dt_dis_ldv }, + [DIF_OP_STTS] = { "stts", dt_dis_stv }, + [DIF_OP_SRA] = { "sra", dt_dis_log }, + [DIF_OP_CALL] = { "call", dt_dis_call }, + [DIF_OP_PUSHTR] = { "pushtr", dt_dis_pushts }, + [DIF_OP_PUSHTV] = { "pushtv", dt_dis_pushts }, + [DIF_OP_POPTS] = { "popts", dt_dis_str }, + [DIF_OP_FLUSHTS] = { "flushts", dt_dis_str }, + [DIF_OP_LDGAA] = { "ldgaa", dt_dis_ldv }, + [DIF_OP_LDTAA] = { "ldtaa", dt_dis_ldv }, + [DIF_OP_STGAA] = { "stgaa", dt_dis_stv }, + [DIF_OP_STTAA] = { "sttaa", dt_dis_stv }, + [DIF_OP_LDLS] = { "ldls", dt_dis_ldv }, + [DIF_OP_STLS] = { "stls", dt_dis_stv }, + [DIF_OP_ALLOCS] = { "allocs", dt_dis_r1rd }, + [DIF_OP_COPYS] = { "copys", dt_dis_log }, + [DIF_OP_STB] = { "stb", dt_dis_store }, + [DIF_OP_STH] = { "sth", dt_dis_store }, + [DIF_OP_STW] = { "stw", dt_dis_store }, + [DIF_OP_STX] = { "stx", dt_dis_store }, + [DIF_OP_ULDSB] = { "uldsb", dt_dis_load }, + [DIF_OP_ULDSH] = { "uldsh", dt_dis_load }, + [DIF_OP_ULDSW] = { "uldsw", dt_dis_load }, + [DIF_OP_ULDUB] = { "uldub", dt_dis_load }, + [DIF_OP_ULDUH] = { "ulduh", dt_dis_load }, + [DIF_OP_ULDUW] = { "ulduw", dt_dis_load }, + [DIF_OP_ULDX] = { "uldx", dt_dis_load }, + [DIF_OP_RLDSB] = { "rldsb", dt_dis_load }, + [DIF_OP_RLDSH] = { "rldsh", dt_dis_load }, + [DIF_OP_RLDSW] = { "rldsw", dt_dis_load }, + [DIF_OP_RLDUB] = { "rldub", dt_dis_load }, + [DIF_OP_RLDUH] = { "rlduh", dt_dis_load }, + [DIF_OP_RLDUW] = { "rlduw", dt_dis_load }, + [DIF_OP_RLDX] = { "rldx", dt_dis_load }, + [DIF_OP_XLATE] = { "xlate", dt_dis_xlate }, + [DIF_OP_XLARG] = { "xlarg", dt_dis_xlate }, }; const struct opent *op; diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c index f26126bba517..91a4871f56b5 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c @@ -36,6 +36,7 @@ #endif #include <dt_impl.h> +#include <dt_oformat.h> #include <dt_program.h> static const char _dt_errprog[] = @@ -315,6 +316,7 @@ dt_handle_cpudrop(dtrace_hdl_t *dtp, processorid_t cpu, dtrace_dropdata_t drop; char str[80], *s; int size; + struct timeval tv; assert(what == DTRACEDROP_PRINCIPAL || what == DTRACEDROP_AGGREGATION); @@ -339,6 +341,15 @@ dt_handle_cpudrop(dtrace_hdl_t *dtp, processorid_t cpu, what == DTRACEDROP_PRINCIPAL ? "" : "aggregation ", howmany > 1 ? "s" : "", cpu); + if (dtp->dt_oformat) { + (void) gettimeofday(&tv, NULL); + xo_emit("{:timestamp/%ld.%06ld} {:count/%ju} " + "{:total/%ju} {:kind/%d} {:msg/%s}", + tv.tv_sec, tv.tv_usec, (uintmax_t)drop.dtdda_drops, + (uintmax_t)drop.dtdda_total, drop.dtdda_kind, + drop.dtdda_msg); + } + if (dtp->dt_drophdlr == NULL) return (dt_set_errno(dtp, EDT_DROPABORT)); @@ -396,6 +407,7 @@ dt_handle_status(dtrace_hdl_t *dtp, dtrace_status_t *old, dtrace_status_t *new) char str[80], *s; uintptr_t base = (uintptr_t)new, obase = (uintptr_t)old; int i, size; + struct timeval tv; bzero(&drop, sizeof (drop)); drop.dtdda_handle = dtp; @@ -408,6 +420,8 @@ dt_handle_status(dtrace_hdl_t *dtp, dtrace_status_t *old, dtrace_status_t *new) if (new->dtst_killed && !old->dtst_killed) return (dt_set_errno(dtp, EDT_BRICKED)); + (void) gettimeofday(&tv, NULL); + for (i = 0; _dt_droptab[i].dtdrt_str != NULL; i++) { uintptr_t naddr = base + _dt_droptab[i].dtdrt_offset; uintptr_t oaddr = obase + _dt_droptab[i].dtdrt_offset; @@ -438,12 +452,31 @@ dt_handle_status(dtrace_hdl_t *dtp, dtrace_status_t *old, dtrace_status_t *new) drop.dtdda_total = nval; drop.dtdda_drops = nval - oval; - if (dtp->dt_drophdlr == NULL) + if (dtp->dt_oformat) { + xo_open_instance("probes"); + dt_oformat_drop(dtp, DTRACE_CPUALL); + xo_emit("{:timestamp/%ld.%06ld} {:count/%ju} " + "{:total/%ju} {:kind/%d} {:msg/%s}", + tv.tv_sec, tv.tv_usec, (uintmax_t)drop.dtdda_drops, + (uintmax_t)drop.dtdda_total, drop.dtdda_kind, + drop.dtdda_msg); + } + + if (dtp->dt_drophdlr == NULL) { + if (dtp->dt_oformat) + xo_close_instance("probes"); return (dt_set_errno(dtp, EDT_DROPABORT)); + } if ((*dtp->dt_drophdlr)(&drop, - dtp->dt_droparg) == DTRACE_HANDLE_ABORT) + dtp->dt_droparg) == DTRACE_HANDLE_ABORT) { + if (dtp->dt_oformat) + xo_close_instance("probes"); return (dt_set_errno(dtp, EDT_DROPABORT)); + } + + if (dtp->dt_oformat) + xo_close_instance("probes"); } return (0); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_ident.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_ident.c index 5ff772be041d..d03347d0e7c1 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_ident.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_ident.c @@ -577,51 +577,51 @@ dt_idsize_none(dt_ident_t *idp) } const dt_idops_t dt_idops_assc = { - dt_idcook_assc, - dt_iddtor_sign, - dt_idsize_none, + .di_cook = dt_idcook_assc, + .di_dtor = dt_iddtor_sign, + .di_size = dt_idsize_none, }; const dt_idops_t dt_idops_func = { - dt_idcook_func, - dt_iddtor_sign, - dt_idsize_none, + .di_cook = dt_idcook_func, + .di_dtor = dt_iddtor_sign, + .di_size = dt_idsize_none, }; const dt_idops_t dt_idops_args = { - dt_idcook_args, - dt_iddtor_none, - dt_idsize_none, + .di_cook = dt_idcook_args, + .di_dtor = dt_iddtor_none, + .di_size = dt_idsize_none, }; const dt_idops_t dt_idops_regs = { - dt_idcook_regs, - dt_iddtor_free, - dt_idsize_none, + .di_cook = dt_idcook_regs, + .di_dtor = dt_iddtor_free, + .di_size = dt_idsize_none, }; const dt_idops_t dt_idops_type = { - dt_idcook_type, - dt_iddtor_free, - dt_idsize_type, + .di_cook = dt_idcook_type, + .di_dtor = dt_iddtor_free, + .di_size = dt_idsize_type, }; const dt_idops_t dt_idops_thaw = { - dt_idcook_thaw, - dt_iddtor_free, - dt_idsize_type, + .di_cook = dt_idcook_thaw, + .di_dtor = dt_iddtor_free, + .di_size = dt_idsize_type, }; const dt_idops_t dt_idops_inline = { - dt_idcook_inline, - dt_iddtor_inline, - dt_idsize_type, + .di_cook = dt_idcook_inline, + .di_dtor = dt_iddtor_inline, + .di_size = dt_idsize_type, }; const dt_idops_t dt_idops_probe = { - dt_idcook_thaw, - dt_iddtor_probe, - dt_idsize_none, + .di_cook = dt_idcook_thaw, + .di_dtor = dt_iddtor_probe, + .di_size = dt_idsize_none, }; static void diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h index b3f69bb6329d..b73ecc3e57f4 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h @@ -211,6 +211,8 @@ typedef struct dt_print_aggdata { int dtpa_agghist; /* print aggregation as histogram */ int dtpa_agghisthdr; /* aggregation histogram hdr printed */ int dtpa_aggpack; /* pack quantized aggregations */ + char dtpa_keyname[256]; /* key name for oformat */ + char *dtpa_aggname; /* aggregate name for oformat */ } dt_print_aggdata_t; typedef struct dt_dirpath { @@ -323,6 +325,7 @@ struct dtrace_hdl { #endif int dt_fd; /* file descriptor for dtrace pseudo-device */ int dt_ftfd; /* file descriptor for fasttrap pseudo-device */ + int dt_kinstfd; /* file descriptor for kinst pseudo-device */ int dt_fterr; /* saved errno from failed open of dt_ftfd */ int dt_cdefs_fd; /* file descriptor for C CTF debugging cache */ int dt_ddefs_fd; /* file descriptor for D CTF debugging cache */ @@ -363,6 +366,7 @@ struct dtrace_hdl { dtrace_epid_t dt_last_epid; /* most recently consumed EPID */ uint64_t dt_last_timestamp; /* most recently consumed timestamp */ boolean_t dt_has_sugar; /* syntactic sugar used? */ + int dt_oformat; /* output format (none, json, xml, html) */ }; /* @@ -616,6 +620,7 @@ extern int dt_version_defined(dt_version_t); */ extern char *dt_cpp_add_arg(dtrace_hdl_t *, const char *); extern char *dt_cpp_pop_arg(dtrace_hdl_t *); +extern int dt_cpu_maxid(dtrace_hdl_t *); #ifdef illumos extern int dt_set_errno(dtrace_hdl_t *, int); @@ -701,6 +706,8 @@ extern int dt_print_llquantize(dtrace_hdl_t *, FILE *, const void *, size_t, uint64_t); extern int dt_print_agg(const dtrace_aggdata_t *, void *); +extern int dt_format_agg(const dtrace_aggdata_t *, void *); + extern int dt_handle(dtrace_hdl_t *, dtrace_probedata_t *); extern int dt_handle_liberr(dtrace_hdl_t *, const dtrace_probedata_t *, const char *); @@ -710,6 +717,8 @@ extern int dt_handle_status(dtrace_hdl_t *, dtrace_status_t *, dtrace_status_t *); extern int dt_handle_setopt(dtrace_hdl_t *, dtrace_setoptdata_t *); +extern void dt_oformat_drop(dtrace_hdl_t *, processorid_t); + extern int dt_lib_depend_add(dtrace_hdl_t *, dt_list_t *, const char *); extern dt_lib_depend_t *dt_lib_depend_lookup(dt_list_t *, const char *); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l index 7dcf21652586..756a48b9c45f 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l @@ -97,6 +97,8 @@ static void unput(int); */ %} +%option yylineno + %e 1500 /* maximum nodes */ %p 4900 /* maximum positions */ %n 600 /* maximum states */ @@ -405,7 +407,7 @@ if (yypcb->pcb_token != 0) { <S0>{RGX_FP} yyerror("floating-point constants are not permitted\n"); -<S0>\"{RGX_STR}$ | +<S0>\"{RGX_STR}$ xyerror(D_STR_NL, "newline encountered in string literal"); <S3>\"{RGX_STR}$ xyerror(D_STR_NL, "newline encountered in string literal"); <S0>\"{RGX_STR}\" | diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c index 0b3dac0224f9..442c6f940733 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c @@ -215,10 +215,6 @@ prepare_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf32_t *dep) dofr[j].dofr_offset; rel->r_info = ELF32_R_INFO(count + dep->de_global, R_386_PC32); -#elif defined(__mips__) -/* XXX */ - printf("%s:%s(%d): MIPS not implemented\n", - __FUNCTION__, __FILE__, __LINE__); #elif defined(__powerpc__) /* * Add 4 bytes to hit the low half of this 64-bit @@ -229,9 +225,9 @@ prepare_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf32_t *dep) rel->r_info = ELF32_R_INFO(count + dep->de_global, R_PPC_REL32); #elif defined(__riscv) -/* XXX */ - printf("%s:%s(%d): RISC-V not implemented\n", - __FUNCTION__, __FILE__, __LINE__); + rel->r_offset = s->dofs_offset + dofr[j].dofr_offset; + rel->r_info = ELF32_R_INFO(count + dep->de_global, + R_RISCV_32_PCREL); #else #error unknown ISA #endif @@ -401,15 +397,15 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep) R_AARCH64_PREL64); #elif defined(__arm__) /* XXX */ -#elif defined(__mips__) -/* XXX */ #elif defined(__powerpc__) rel->r_offset = s->dofs_offset + dofr[j].dofr_offset; rel->r_info = ELF64_R_INFO(count + dep->de_global, R_PPC64_REL64); #elif defined(__riscv) -/* XXX */ + rel->r_offset = s->dofs_offset + dofr[j].dofr_offset; + rel->r_info = ELF64_R_INFO(count + dep->de_global, + R_RISCV_32_PCREL); #elif defined(__i386) || defined(__amd64) rel->r_offset = s->dofs_offset + dofr[j].dofr_offset; @@ -504,14 +500,28 @@ dump_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd) elf_file.ehdr.e_type = ET_REL; #if defined(__arm__) elf_file.ehdr.e_machine = EM_ARM; -#elif defined(__mips__) - elf_file.ehdr.e_machine = EM_MIPS; #elif defined(__powerpc__) elf_file.ehdr.e_machine = EM_PPC; #elif defined(__i386) || defined(__amd64) elf_file.ehdr.e_machine = EM_386; #elif defined(__aarch64__) elf_file.ehdr.e_machine = EM_AARCH64; +#elif defined(__riscv) + elf_file.ehdr.e_machine = EM_RISCV; + + /* Set the ELF flags according to our current ABI */ +#if defined(__riscv_compressed) + elf_file.ehdr.e_flags |= EF_RISCV_RVC; +#endif +#if defined(__riscv_float_abi_soft) + elf_file.ehdr.e_flags |= EF_RISCV_FLOAT_ABI_SOFT; +#endif +#if defined(__riscv_float_abi_single) + elf_file.ehdr.e_flags |= EF_RISCV_FLOAT_ABI_SINGLE; +#endif +#if defined(__riscv_float_abi_double) + elf_file.ehdr.e_flags |= EF_RISCV_FLOAT_ABI_DOUBLE; +#endif #endif elf_file.ehdr.e_version = EV_CURRENT; elf_file.ehdr.e_shoff = sizeof (Elf32_Ehdr); @@ -572,7 +582,7 @@ dump_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd) } else { shp = &elf_file.shdr[ESHDR_REL]; shp->sh_name = 37; /* DTRACE_SHSTRTAB32[37] = ".rel.SUNW_dof" */ - shp->sh_flags = SHF_ALLOC; + shp->sh_flags = 0; shp->sh_type = SHT_REL; shp->sh_entsize = sizeof (de.de_rel[0]); shp->sh_link = ESHDR_SYMTAB; @@ -644,8 +654,6 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd) elf_file.ehdr.e_type = ET_REL; #if defined(__arm__) elf_file.ehdr.e_machine = EM_ARM; -#elif defined(__mips__) - elf_file.ehdr.e_machine = EM_MIPS; #elif defined(__powerpc64__) #if defined(_CALL_ELF) && _CALL_ELF == 2 elf_file.ehdr.e_flags = 2; @@ -655,6 +663,22 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd) elf_file.ehdr.e_machine = EM_AMD64; #elif defined(__aarch64__) elf_file.ehdr.e_machine = EM_AARCH64; +#elif defined(__riscv) + elf_file.ehdr.e_machine = EM_RISCV; + + /* Set the ELF flags according to our current ABI */ +#if defined(__riscv_compressed) + elf_file.ehdr.e_flags |= EF_RISCV_RVC; +#endif +#if defined(__riscv_float_abi_soft) + elf_file.ehdr.e_flags |= EF_RISCV_FLOAT_ABI_SOFT; +#endif +#if defined(__riscv_float_abi_single) + elf_file.ehdr.e_flags |= EF_RISCV_FLOAT_ABI_SINGLE; +#endif +#if defined(__riscv_float_abi_double) + elf_file.ehdr.e_flags |= EF_RISCV_FLOAT_ABI_DOUBLE; +#endif #endif elf_file.ehdr.e_version = EV_CURRENT; elf_file.ehdr.e_shoff = sizeof (Elf64_Ehdr); @@ -715,7 +739,7 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd) } else { shp = &elf_file.shdr[ESHDR_REL]; shp->sh_name = 37; /* DTRACE_SHSTRTAB64[37] = ".rel.SUNW_dof" */ - shp->sh_flags = SHF_ALLOC; + shp->sh_flags = 0; shp->sh_type = SHT_RELA; shp->sh_entsize = sizeof (de.de_rel[0]); shp->sh_link = ESHDR_SYMTAB; @@ -843,17 +867,6 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, __LINE__); return (-1); } -#elif defined(__mips__) -#define DT_REL_NONE R_MIPS_NONE - -static int -dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, - uint32_t *off) -{ - printf("%s:%s(%d): MIPS not implemented\n", __FUNCTION__, __FILE__, - __LINE__); - return (-1); -} #elif defined(__powerpc__) /* The sentinel is 'xor r3,r3,r3'. */ #define DT_OP_XOR_R3 0x7c631a78 @@ -938,14 +951,74 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, return (0); } #elif defined(__riscv) +#define DT_OP_NOP 0x00000013 /* addi x0, x0, 0 */ +#define DT_OP_RET 0x00008067 /* jalr x0, x1, 0 */ +#define DT_OP_IS_AUIPC(op) (((op) & 0x7f) == 0x17) +#define DT_OP_IS_JALR(op) (((op) & 0x707f) == 0x67) +#define DT_OP_JALR_CALL 0x000080e7 /* jalr x1, x1, 0 */ +#define DT_OP_JALR_TAIL 0x00030067 /* jalr x0, x6, 0 */ #define DT_REL_NONE R_RISCV_NONE + static int dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, uint32_t *off) { - printf("%s:%s(%d): RISC-V implementation required\n", __FUNCTION__, - __FILE__, __LINE__); - return (-1); + uint32_t *ip; + + /* + * XXX: this implementation is untested, but should serve as a decent + * starting point. + */ + + /* + * Ensure that the offset is aligned on a compressed-instruction + * boundary. + */ + if ((rela->r_offset & (sizeof (uint16_t) - 1)) != 0) + return (-1); + + /* + * We only know about some specific relocation types. + * We also recognize relocation type NONE, since that gets used for + * relocations of USDT probes, and we might be re-processing a file. + */ + if (GELF_R_TYPE(rela->r_info) != R_RISCV_CALL && + GELF_R_TYPE(rela->r_info) != R_RISCV_CALL_PLT && + GELF_R_TYPE(rela->r_info) != R_RISCV_NONE) + return (-1); + + ip = (uint32_t *)(p + rela->r_offset); + + /* + * We may have already processed this object file in an earlier linker + * invocation. Check to see if the present instruction sequence matches + * the one we would install below. + */ + if (ip[0] == DT_OP_NOP && (ip[1] == DT_OP_NOP || ip[1] == DT_OP_RET)) + return (0); + + /* + * We expect a auipc+jalr pair, either from a call or a tail. + * - call: auipc x1 0; jalr x1, x1, 0 + * - tail: auipc x6 0; jalr x0, x6, 0 + */ + if (!DT_OP_IS_AUIPC(ip[0]) || !DT_OP_IS_JALR(ip[1])) + return (-1); + + /* + * On riscv, we do not have to differentiate between regular probes and + * is-enabled probes. Calls are to be converted into a no-op whereas + * tail calls should become a return. + */ + if (ip[1] == DT_OP_JALR_CALL) { + ip[0] = DT_OP_NOP; + ip[1] = DT_OP_NOP; + } else { + ip[0] = DT_OP_NOP; + ip[1] = DT_OP_RET; + } + + return (0); } #elif defined(__i386) || defined(__amd64) @@ -1167,9 +1240,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp) if (dtp->dt_oflags & DTRACE_O_LP64) { eclass = ELFCLASS64; -#if defined(__mips__) - emachine1 = emachine2 = EM_MIPS; -#elif defined(__powerpc__) +#if defined(__powerpc__) emachine1 = emachine2 = EM_PPC64; #if !defined(_CALL_ELF) || _CALL_ELF == 1 uses_funcdesc = 1; @@ -1178,14 +1249,14 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp) emachine1 = emachine2 = EM_AMD64; #elif defined(__aarch64__) emachine1 = emachine2 = EM_AARCH64; +#elif defined(__riscv) + emachine1 = emachine2 = EM_RISCV; #endif symsize = sizeof (Elf64_Sym); } else { eclass = ELFCLASS32; #if defined(__arm__) emachine1 = emachine2 = EM_ARM; -#elif defined(__mips__) - emachine1 = emachine2 = EM_MIPS; #elif defined(__powerpc__) emachine1 = emachine2 = EM_PPC; #elif defined(__i386) || defined(__amd64) @@ -1612,6 +1683,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp) * invocation. */ if (rsym.st_shndx != SHN_ABS) { + rsym.st_info = GELF_ST_INFO(STB_WEAK, STT_FUNC); rsym.st_shndx = SHN_ABS; (void) gelf_update_sym(data_sym, ndx, &rsym); } diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c index b9408944f8c5..f6a328bb9b39 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c @@ -109,8 +109,7 @@ dt_module_syminit32(dt_module_t *dmp) if (sym->st_name == 0 || sym->st_name >= ss_size) continue; /* skip null or invalid names */ - if (sym->st_value != 0 && - (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) { + if (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size) { asrsv++; /* reserve space in the address map */ #if defined(__FreeBSD__) @@ -159,8 +158,7 @@ dt_module_syminit64(dt_module_t *dmp) if (sym->st_name == 0 || sym->st_name >= ss_size) continue; /* skip null or invalid names */ - if (sym->st_value != 0 && - (ELF64_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) { + if (ELF64_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size) { asrsv++; /* reserve space in the address map */ #if defined(__FreeBSD__) sym->st_value += (Elf_Addr) dmp->dm_reloc_offset; @@ -245,8 +243,7 @@ dt_module_symsort32(dt_module_t *dmp) for (i = 1; i < n; i++, dsp++) { Elf32_Sym *sym = symtab + dsp->ds_symid; - if (sym->st_value != 0 && - (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) + if (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size) *sympp++ = sym; } @@ -269,8 +266,7 @@ dt_module_symsort64(dt_module_t *dmp) for (i = 1; i < n; i++, dsp++) { Elf64_Sym *sym = symtab + dsp->ds_symid; - if (sym->st_value != 0 && - (ELF64_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) + if (ELF64_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size) *sympp++ = sym; } @@ -452,17 +448,17 @@ dt_module_symaddr64(dt_module_t *dmp, GElf_Addr addr, } static const dt_modops_t dt_modops_32 = { - dt_module_syminit32, - dt_module_symsort32, - dt_module_symname32, - dt_module_symaddr32 + .do_syminit = dt_module_syminit32, + .do_symsort = dt_module_symsort32, + .do_symname = dt_module_symname32, + .do_symaddr = dt_module_symaddr32 }; static const dt_modops_t dt_modops_64 = { - dt_module_syminit64, - dt_module_symsort64, - dt_module_symname64, - dt_module_symaddr64 + .do_syminit = dt_module_syminit64, + .do_symsort = dt_module_symsort64, + .do_symname = dt_module_symname64, + .do_symaddr = dt_module_symaddr64 }; dt_module_t * @@ -1129,33 +1125,21 @@ dt_module_getctflib(dtrace_hdl_t *dtp, dt_module_t *dmp, const char *name) * including the path. */ static void -#ifdef illumos -dt_module_update(dtrace_hdl_t *dtp, const char *name) -#else dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) -#endif { char fname[MAXPATHLEN]; struct stat64 st; int fd, err, bits; -#ifdef __FreeBSD__ struct module_stat ms; dt_kmodule_t *dkmp; uint_t h; int modid; -#endif - dt_module_t *dmp; const char *s; size_t shstrs; GElf_Shdr sh; Elf_Data *dp; Elf_Scn *sp; - -#ifdef illumos - (void) snprintf(fname, sizeof (fname), - "%s/%s/object", OBJFS_ROOT, name); -#else GElf_Ehdr ehdr; GElf_Phdr ph; char name[MAXPATHLEN]; @@ -1165,7 +1149,6 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) (void) strlcpy(name, k_stat->name, sizeof(name)); (void) strlcpy(fname, k_stat->pathname, sizeof(fname)); -#endif if ((fd = open(fname, O_RDONLY)) == -1 || fstat64(fd, &st) == -1 || (dmp = dt_module_create(dtp, name)) == NULL) { @@ -1174,6 +1157,9 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) return; } + (void) strlcpy(dmp->dm_file, fname, sizeof(dmp->dm_file)); + dmp->dm_modid = k_stat->id; + /* * Since the module can unload out from under us (and /system/object * will return ENOENT), tell libelf to cook the entire file now and @@ -1206,7 +1192,6 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) dt_module_destroy(dtp, dmp); return; } -#if defined(__FreeBSD__) mapbase = (uintptr_t)k_stat->address; gelf_getehdr(dmp->dm_elf, &ehdr); is_elf_obj = (ehdr.e_type == ET_REL); @@ -1219,7 +1204,6 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) return; } } -#endif /* * Iterate over the section headers locating various sections of * interest and use their attributes to flesh out the dt_module_t. @@ -1228,10 +1212,9 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) if (gelf_getshdr(sp, &sh) == NULL || sh.sh_type == SHT_NULL || (s = elf_strptr(dmp->dm_elf, shstrs, sh.sh_name)) == NULL) continue; /* skip any malformed sections */ -#if defined(__FreeBSD__) if (sh.sh_size == 0) continue; - if (sh.sh_type == SHT_PROGBITS || sh.sh_type == SHT_NOBITS) { + if (sh.sh_flags & SHF_ALLOC) { alignmask = sh.sh_addralign - 1; mapbase += alignmask; mapbase &= ~alignmask; @@ -1240,7 +1223,6 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) dmp->dm_sec_offsets[elf_ndxscn(sp)] = sh.sh_addr; mapbase += sh.sh_size; } -#endif if (strcmp(s, ".text") == 0) { dmp->dm_text_size = sh.sh_size; dmp->dm_text_va = sh.sh_addr; @@ -1254,17 +1236,10 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) (dp = elf_getdata(sp, NULL)) != NULL) { bcopy(dp->d_buf, &dmp->dm_info, MIN(sh.sh_size, sizeof (dmp->dm_info))); - } else if (strcmp(s, ".filename") == 0 && - (dp = elf_getdata(sp, NULL)) != NULL) { - (void) strlcpy(dmp->dm_file, - dp->d_buf, sizeof (dmp->dm_file)); } } dmp->dm_flags |= DT_DM_KERNEL; -#ifdef illumos - dmp->dm_modid = (int)OBJFS_MODID(st.st_ino); -#else /* * Include .rodata and special sections into .text. * This depends on default section layout produced by GNU ld @@ -1272,25 +1247,25 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) * [Text][R/O data][R/W data][Dynamic][BSS][Non loadable] */ dmp->dm_text_size = dmp->dm_data_va - dmp->dm_text_va; -#if defined(__i386__) - /* - * Find the first load section and figure out the relocation - * offset for the symbols. The kernel module will not need - * relocation, but the kernel linker modules will. - */ - for (i = 0; gelf_getphdr(dmp->dm_elf, i, &ph) != NULL; i++) { - if (ph.p_type == PT_LOAD) { - dmp->dm_reloc_offset = k_stat->address - ph.p_vaddr; - break; + + if (!is_elf_obj) { + /* + * Find the first load section and figure out the relocation + * offset for the symbols. The kernel module will not need + * relocation, but the kernel linker modules will. + */ + for (i = 0; gelf_getphdr(dmp->dm_elf, i, &ph) != NULL; i++) { + if (ph.p_type == PT_LOAD) { + dmp->dm_reloc_offset = + k_stat->address - ph.p_vaddr; + break; + } } } -#endif -#endif /* illumos */ if (dmp->dm_info.objfs_info_primary) dmp->dm_flags |= DT_DM_PRIMARY; -#ifdef __FreeBSD__ ms.version = sizeof(ms); for (modid = kldfirstmod(k_stat->id); modid > 0; modid = modnext(modid)) { @@ -1315,7 +1290,6 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) dkmp->dkm_module = dmp; dtp->dt_kmods[h] = dkmp; } -#endif dt_dprintf("opened %d-bit module %s (%s) [%d]\n", bits, dmp->dm_name, dmp->dm_file, dmp->dm_modid); diff --git a/cddl/compat/opensolaris/include/stdlib.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_oformat.h index 9ba32322c03b..bea7dbd19b4d 100644 --- a/cddl/compat/opensolaris/include/stdlib.h +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_oformat.h @@ -1,7 +1,8 @@ -/* - * Copyright (C) 2007 John Birrell <jb@freebsd.org> - * All rights reserved. - * +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 Domagoj Stolfa + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -10,11 +11,11 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) @@ -22,16 +23,12 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ - * */ -#include_next <stdlib.h> - -#ifndef _COMPAT_OPENSOLARIS_STDLIB_H_ -#define _COMPAT_OPENSOLARIS_STDLIB_H_ +#ifndef _DT_OFORMAT_H_ +#define _DT_OFORMAT_H_ -#define getexecname getprogname +#undef NORETURN /* needed because libxo redefines it */ +#include <libxo/xo.h> -#endif +#endif /* _DT_OFORMAT_H_ */ diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c index f55d488f4d91..40200771fd4d 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c @@ -59,6 +59,7 @@ #include <dt_printf.h> #include <dt_string.h> #include <dt_provider.h> +#include <dt_oformat.h> #ifndef illumos #include <sys/sysctl.h> #include <string.h> @@ -416,6 +417,8 @@ static const dt_ident_t _dtrace_globals[] = { &dt_idops_func, "void(int)" }, { "rand", DT_IDENT_FUNC, 0, DIF_SUBR_RAND, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_func, "int()" }, +{ "regs", DT_IDENT_ARRAY, 0, DIF_VAR_REGS, DT_ATTR_STABCMN, DT_VERS_1_13, + &dt_idops_regs, NULL }, { "rindex", DT_IDENT_FUNC, 0, DIF_SUBR_RINDEX, DT_ATTR_STABCMN, DT_VERS_1_1, &dt_idops_func, "int(const char *, const char *, [int])" }, #ifdef illumos @@ -1070,8 +1073,14 @@ dt_vopen(int version, int flags, int *errp, if (flags & ~DTRACE_O_MASK) return (set_open_errno(dtp, errp, EINVAL)); - if ((flags & DTRACE_O_LP64) && (flags & DTRACE_O_ILP32)) + switch (flags & DTRACE_O_MODEL_MASK) { + case 0: /* native model */ + case DTRACE_O_ILP32: + case DTRACE_O_LP64: + break; + default: return (set_open_errno(dtp, errp, EINVAL)); + } if (vector == NULL && arg != NULL) return (set_open_errno(dtp, errp, EINVAL)); @@ -1113,6 +1122,15 @@ dt_vopen(int version, int flags, int *errp, */ if (err == ENOENT && modfind("dtraceall") < 0) { kldload("dtraceall"); /* ignore the error */ +#if __SIZEOF_LONG__ == 8 + if (modfind("linux64elf") >= 0) + kldload("systrace_linux"); + if (modfind("linuxelf") >= 0) + kldload("systrace_linux32"); +#else + if (modfind("linuxelf") >= 0) + kldload("systrace_linux"); +#endif dtfd = open("/dev/dtrace/dtrace", O_RDWR | O_CLOEXEC); err = errno; } @@ -1171,6 +1189,7 @@ alloc: dtp->dt_version = version; dtp->dt_fd = dtfd; dtp->dt_ftfd = ftfd; + dtp->dt_kinstfd = -1; dtp->dt_fterr = fterr; dtp->dt_cdefs_fd = -1; dtp->dt_ddefs_fd = -1; @@ -1679,6 +1698,8 @@ dtrace_close(dtrace_hdl_t *dtp) (void) close(dtp->dt_fd); if (dtp->dt_ftfd != -1) (void) close(dtp->dt_ftfd); + if (dtp->dt_kinstfd != -1) + (void) close(dtp->dt_kinstfd); if (dtp->dt_cdefs_fd != -1) (void) close(dtp->dt_cdefs_fd); if (dtp->dt_ddefs_fd != -1) @@ -1722,6 +1743,8 @@ dtrace_close(dtrace_hdl_t *dtp) free(dtp->dt_kmods); #endif free(dtp->dt_provs); + + xo_finish(); free(dtp); } diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c index ce13659f1685..1e7a8115c960 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c @@ -43,6 +43,7 @@ #include <dt_impl.h> #include <dt_string.h> +#include <dt_oformat.h> static int dt_opt_agg(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) @@ -724,6 +725,18 @@ dt_opt_size(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) } static int +dt_opt_oformat(dtrace_hdl_t *dtp, const char *arg, uintptr_t option __unused) +{ + if (arg == NULL) + return (dt_set_errno(dtp, EDT_BADOPTVAL)); + + if (xo_set_options(NULL, arg) < 0) + return (dt_set_errno(dtp, EDT_BADOPTVAL)); + + return (dtrace_oformat_configure(dtp)); +} + +static int dt_opt_rate(dtrace_hdl_t *dtp, const char *arg, uintptr_t option) { char *end; @@ -1046,6 +1059,7 @@ static const dt_option_t _dtrace_rtoptions[] = { { "jstackframes", dt_opt_runtime, DTRACEOPT_JSTACKFRAMES }, { "jstackstrsize", dt_opt_size, DTRACEOPT_JSTACKSTRSIZE }, { "nspec", dt_opt_runtime, DTRACEOPT_NSPEC }, + { "oformat", dt_opt_oformat, 0 }, { "specsize", dt_opt_size, DTRACEOPT_SPECSIZE }, { "stackframes", dt_opt_runtime, DTRACEOPT_STACKFRAMES }, { "statusrate", dt_opt_rate, DTRACEOPT_STATUSRATE }, diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c index f028f99ccf64..d1ebaa8791da 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c @@ -1131,6 +1131,29 @@ dt_node_is_ptrcompat(const dt_node_t *lp, const dt_node_t *rp, rp_is_void = ctf_type_encoding(rfp, rref, &e) == 0 && IS_VOID(e); /* + * Let a pointer to a forward declaration be compatible with a pointer + * to a struct or union of the same name. + */ + if (lkind == CTF_K_POINTER && rkind == CTF_K_POINTER) { + int lrkind, rrkind; + + lrkind = ctf_type_kind(lfp, lref); + rrkind = ctf_type_kind(rfp, rref); + if (lrkind == CTF_K_FORWARD || rrkind == CTF_K_FORWARD) { + const char *lname, *rname; + char ln[DT_TYPE_NAMELEN], rn[DT_TYPE_NAMELEN]; + + lname = ctf_type_name(lfp, lref, ln, sizeof (ln)); + rname = ctf_type_name(rfp, rref, rn, sizeof (rn)); + if (lname != NULL && rname != NULL && + strcmp(lname, rname) == 0) { + lp_is_void = lrkind == CTF_K_FORWARD; + rp_is_void = rrkind == CTF_K_FORWARD; + } + } + } + + /* * The types are compatible if both are pointers to the same type, or * if either pointer is a void pointer. If they are compatible, set * tp to point to the more specific pointer type and return it. @@ -4767,8 +4790,8 @@ dt_printd(dt_node_t *dnp, FILE *fp, int depth) dt_printd(dnp->dn_pred, fp, 0); (void) fprintf(fp, "/\n"); } - (void) fprintf(fp, "{\n"); + (void) fprintf(fp, "{\n"); for (arg = dnp->dn_acts; arg != NULL; arg = arg->dn_list) dt_printd(arg, fp, depth + 1); (void) fprintf(fp, "}\n"); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pq.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pq.c index 0cd556abd8f5..ffbac8b6ea1e 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pq.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pq.c @@ -37,7 +37,7 @@ dt_pq_init(dtrace_hdl_t *dtp, uint_t size, dt_pq_value_f value_cb, void *cb_arg) if ((p = dt_zalloc(dtp, sizeof (dt_pq_t))) == NULL) return (NULL); - p->dtpq_items = dt_zalloc(dtp, size * sizeof (p->dtpq_items[0])); + p->dtpq_items = dt_zalloc(dtp, (size + 1) * sizeof (p->dtpq_items[0])); if (p->dtpq_items == NULL) { dt_free(dtp, p); return (NULL); @@ -73,9 +73,9 @@ dt_pq_insert(dt_pq_t *p, void *item) { uint_t i; - assert(p->dtpq_last < p->dtpq_size); - i = p->dtpq_last++; + assert(i <= p->dtpq_size); + p->dtpq_items[i] = item; while (i > 1 && dt_pq_getvalue(p, i) < dt_pq_getvalue(p, i / 2)) { diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c index 97da0c3a5ac2..9bbd12e5544f 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_print.c @@ -27,6 +27,7 @@ */ /* * Copyright (c) 2013, Joyent, Inc. All rights reserved. + * Copyright (c) 2023, Domagoj Stolfa. All rights reserved. */ /* @@ -82,6 +83,7 @@ #include <dt_printf.h> #include <dt_string.h> #include <dt_impl.h> +#include <dt_oformat.h> /* determines whether the given integer CTF encoding is a character */ #define CTF_IS_CHAR(e) \ @@ -101,8 +103,10 @@ typedef struct dt_printarg { int pa_depth; /* member depth */ int pa_nest; /* nested array depth */ FILE *pa_file; /* output file */ + const char *pa_object; /* object name */ } dt_printarg_t; +static int dt_format_member(const char *, ctf_id_t, ulong_t, int, void *); static int dt_print_member(const char *, ctf_id_t, ulong_t, int, void *); /* @@ -189,7 +193,10 @@ print_bitfield(dt_printarg_t *pap, ulong_t off, ctf_encoding_t *ep) value >>= shift; value &= mask; - (void) fprintf(fp, "%#llx", (u_longlong_t)value); + xo_emit("{:value/%#llx}", (u_longlong_t)value); + + /* Flush in order to ensure output is aligned properly */ + xo_flush(); } /* @@ -200,24 +207,25 @@ dt_print_hex(FILE *fp, caddr_t addr, size_t size) { switch (size) { case sizeof (uint8_t): - (void) fprintf(fp, "%#x", *(uint8_t *)addr); + xo_emit("{:value/%#x}", *(uint8_t *)addr); break; case sizeof (uint16_t): - /* LINTED - alignment */ - (void) fprintf(fp, "%#x", *(uint16_t *)addr); + xo_emit("{:value/%#x}", *(uint16_t *)addr); break; case sizeof (uint32_t): - /* LINTED - alignment */ - (void) fprintf(fp, "%#x", *(uint32_t *)addr); + xo_emit("{:value/%#x}", *(uint32_t *)addr); break; case sizeof (uint64_t): - (void) fprintf(fp, "%#llx", - /* LINTED - alignment */ + xo_emit("{:value/%#llx}", (unsigned long long)*(uint64_t *)addr); break; default: - (void) fprintf(fp, "<invalid size %u>", (uint_t)size); + xo_emit("<{:warning} {:size/%u}>", "invalid size", + (uint_t)size); } + + /* Flush in order to ensure output is aligned properly */ + xo_flush(); } /* @@ -229,12 +237,16 @@ dt_print_int(ctf_id_t base, ulong_t off, dt_printarg_t *pap) { FILE *fp = pap->pa_file; ctf_file_t *ctfp = pap->pa_ctfp; + dtrace_hdl_t *dtp = pap->pa_dtp; ctf_encoding_t e; size_t size; caddr_t addr = pap->pa_addr + off / NBBY; if (ctf_type_encoding(ctfp, base, &e) == CTF_ERR) { - (void) fprintf(fp, "<unknown encoding>"); + xo_emit("<{:warning}>", "unknown encoding"); + + /* Flush in order to ensure output is aligned properly */ + xo_flush(); return; } @@ -243,7 +255,8 @@ dt_print_int(ctf_id_t base, ulong_t off, dt_printarg_t *pap) * would be found. */ if (e.cte_format & CTF_INT_VARARGS) { - (void) fprintf(fp, "..."); + if (!dtp->dt_oformat) + (void)fprintf(fp, "..."); return; } @@ -263,11 +276,14 @@ dt_print_int(ctf_id_t base, ulong_t off, dt_printarg_t *pap) if (CTF_IS_CHAR(e)) { char c = *(char *)addr; if (isprint(c)) - (void) fprintf(fp, "'%c'", c); + xo_emit("'{:value/%c}'", c); else if (c == 0) - (void) fprintf(fp, "'\\0'"); + xo_emit("'\\{:value/0}'"); else - (void) fprintf(fp, "'\\%03o'", c); + xo_emit("'\\{:value/%03o}'", c); + + /* Flush in order to ensure output is aligned properly */ + xo_flush(); return; } @@ -285,22 +301,20 @@ dt_print_float(ctf_id_t base, ulong_t off, dt_printarg_t *pap) ctf_file_t *ctfp = pap->pa_ctfp; ctf_encoding_t e; caddr_t addr = pap->pa_addr + off / NBBY; + dtrace_hdl_t *dtp = pap->pa_dtp; if (ctf_type_encoding(ctfp, base, &e) == 0) { if (e.cte_format == CTF_FP_SINGLE && e.cte_bits == sizeof (float) * NBBY) { - /* LINTED - alignment */ - (void) fprintf(fp, "%+.7e", *((float *)addr)); + xo_emit("{:value/%+.7e}", *((float *)addr)); } else if (e.cte_format == CTF_FP_DOUBLE && e.cte_bits == sizeof (double) * NBBY) { - /* LINTED - alignment */ - (void) fprintf(fp, "%+.7e", *((double *)addr)); + xo_emit("{:value/%+.7e}", *((double *)addr)); } else if (e.cte_format == CTF_FP_LDOUBLE && e.cte_bits == sizeof (long double) * NBBY) { - /* LINTED - alignment */ - (void) fprintf(fp, "%+.16LE", *((long double *)addr)); + xo_emit("{:value/%+.16LE}", *((long double *)addr)); } else { - (void) fprintf(fp, "<unknown encoding>"); + xo_emit("<{:warning}>", "unknown encoding"); } } } @@ -329,8 +343,7 @@ dt_print_ptr(ctf_id_t base, ulong_t off, dt_printarg_t *pap) if (dtrace_lookup_by_addr(pap->pa_dtp, pc, &sym, &dts) != 0) { dt_print_hex(fp, addr, size); } else { - (void) fprintf(fp, "%s`%s", dts.dts_object, - dts.dts_name); + xo_emit("{:value/%s`%s}", dts.dts_object, dts.dts_name); } } } @@ -367,6 +380,7 @@ dt_print_array(ctf_id_t base, ulong_t off, dt_printarg_t *pap) FILE *fp = pap->pa_file; ctf_file_t *ctfp = pap->pa_ctfp; caddr_t addr = pap->pa_addr + off / NBBY; + char *str; ctf_arinfo_t car; ssize_t eltsize; ctf_encoding_t e; @@ -374,16 +388,18 @@ dt_print_array(ctf_id_t base, ulong_t off, dt_printarg_t *pap) boolean_t isstring; int kind; ctf_id_t rtype; + dtrace_hdl_t *dtp = pap->pa_dtp; if (ctf_array_info(ctfp, base, &car) == CTF_ERR) { - (void) fprintf(fp, "%p", (void *)addr); + xo_emit("{:value/%p}", (void *)addr); return; } if ((eltsize = ctf_type_size(ctfp, car.ctr_contents)) < 0 || (rtype = ctf_type_resolve(ctfp, car.ctr_contents)) == CTF_ERR || (kind = ctf_type_kind(ctfp, rtype)) == CTF_ERR) { - (void) fprintf(fp, "<invalid type %lu>", car.ctr_contents); + xo_emit("<{:warning} {:type-identifier/%lu}>", "invalid type", + car.ctr_contents); return; } @@ -411,18 +427,44 @@ dt_print_array(ctf_id_t base, ulong_t off, dt_printarg_t *pap) * * As D will internally represent this as a char[256] array. */ - if (!isstring || pap->pa_depth != 0) - (void) fprintf(fp, "[ "); + if (dtp->dt_oformat) { + if (!isstring) + xo_open_list("value"); + else { + str = malloc(car.ctr_nelems); + if (str == NULL) + return; + *str = 0; + } + } else { + if (!isstring || pap->pa_depth != 0) + (void)fprintf(fp, "[ "); - if (isstring) - (void) fprintf(fp, "\""); + if (isstring) + (void)fprintf(fp, "\""); + } for (i = 0; i < car.ctr_nelems; i++) { if (isstring) { char c = *((char *)addr + eltsize * i); - if (c == '\0') + if (c == '\0') { + if (dtp->dt_oformat) + str[i] = 0; break; - (void) fprintf(fp, "%c", c); + } + + if (dtp->dt_oformat) + str[i] = c; + else + (void)fprintf(fp, "%c", c); + } else if (dtp->dt_oformat) { + dt_printarg_t pa = *pap; + pa.pa_nest += pap->pa_depth + 1; + pa.pa_depth = 0; + pa.pa_addr = addr + eltsize * i; + + (void) ctf_type_visit(ctfp, car.ctr_contents, + dt_format_member, &pa); } else { /* * Recursively invoke ctf_type_visit() on each member. @@ -444,15 +486,24 @@ dt_print_array(ctf_id_t base, ulong_t off, dt_printarg_t *pap) } } - if (isstring) - (void) fprintf(fp, "\""); - - if (!isstring || pap->pa_depth != 0) { - if (CTF_IS_STRUCTLIKE(kind)) - dt_print_indent(pap); - else - (void) fprintf(fp, " "); - (void) fprintf(fp, "]"); + if (dtp->dt_oformat) { + if (!isstring) + xo_close_list("value"); + else { + xo_emit("{:value/%s}", str); + free(str); + } + } else { + if (isstring) + (void)fprintf(fp, "\""); + + if (!isstring || pap->pa_depth != 0) { + if (CTF_IS_STRUCTLIKE(kind)) + dt_print_indent(pap); + else + (void)fprintf(fp, " "); + (void)fprintf(fp, "]"); + } } } @@ -463,7 +514,8 @@ dt_print_array(ctf_id_t base, ulong_t off, dt_printarg_t *pap) static void dt_print_structlike(ctf_id_t id, ulong_t off, dt_printarg_t *pap) { - (void) fprintf(pap->pa_file, "{"); + if (pap->pa_dtp->dt_oformat == DTRACE_OFORMAT_TEXT) + (void)fprintf(pap->pa_file, "{"); } /* @@ -480,6 +532,7 @@ dt_print_enum(ctf_id_t base, ulong_t off, dt_printarg_t *pap) ssize_t size; caddr_t addr = pap->pa_addr + off / NBBY; int value = 0; + dtrace_hdl_t *dtp = pap->pa_dtp; /* * The C standard says that an enum will be at most the sizeof (int). @@ -498,14 +551,19 @@ dt_print_enum(ctf_id_t base, ulong_t off, dt_printarg_t *pap) value = *(int32_t *)addr; break; default: - (void) fprintf(fp, "<invalid enum size %u>", (uint_t)size); + xo_emit("<{:warning} {:size/%u}>", "invalid enum size", + (uint_t)size); return; } - if ((ename = ctf_enum_name(ctfp, base, value)) != NULL) - (void) fprintf(fp, "%s", ename); - else - (void) fprintf(fp, "%d", value); + if ((ename = ctf_enum_name(ctfp, base, value)) != NULL) { + xo_emit("{:value/%s}", ename); + } else { + xo_emit("{:value/%d}", value); + } + + /* Flush in order to ensure output is aligned properly */ + xo_flush(); } /* @@ -516,7 +574,8 @@ dt_print_enum(ctf_id_t base, ulong_t off, dt_printarg_t *pap) static void dt_print_tag(ctf_id_t base, ulong_t off, dt_printarg_t *pap) { - (void) fprintf(pap->pa_file, "<forward decl>"); + if (pap->pa_dtp->dt_oformat == DTRACE_OFORMAT_TEXT) + (void)fprintf(pap->pa_file, "<forward decl>"); } typedef void dt_printarg_f(ctf_id_t, ulong_t, dt_printarg_t *); @@ -533,6 +592,46 @@ static dt_printarg_f *const dt_printfuncs[] = { dt_print_tag /* CTF_K_FORWARD */ }; +static int +dt_format_member(const char *name, ctf_id_t id, ulong_t off, int depth, + void *data) +{ + char type[DT_TYPE_NAMELEN]; + int kind; + dt_printarg_t *pap = data; + FILE *fp = pap->pa_file; + ctf_file_t *ctfp = pap->pa_ctfp; + boolean_t arraymember; + boolean_t brief; + ctf_encoding_t e; + ctf_id_t rtype; + + if ((rtype = ctf_type_resolve(ctfp, id)) == CTF_ERR || + (kind = ctf_type_kind(ctfp, rtype)) == CTF_ERR || + kind < CTF_K_INTEGER || kind > CTF_K_FORWARD) { + xo_emit("{:name/%s} <{:warning} {:type-identifier/%lu}>" + " {:value/0x%llx}", + name, "invalid type", id, pap->pa_addr); + return (0); + } + + dt_print_type_name(ctfp, id, type, sizeof (type)); + xo_open_instance("type"); + if (pap->pa_object) { + xo_emit("{:object-name/%s}", pap->pa_object); + /* Clear the object to avoid duplication */ + pap->pa_object = NULL; + } + + if (*name != 0) + xo_emit("{:member-name/%s}", name); + xo_emit("{:name/%s} {:ctfid/%ld}", type, id); + dt_printfuncs[kind - 1](rtype, off, pap); + + xo_close_instance("type"); + return (0); +} + /* * Print one member of a structure. This callback is invoked from * ctf_type_visit() recursively. @@ -634,16 +733,12 @@ dt_print_member(const char *name, ctf_id_t id, ulong_t off, int depth, return (0); } -/* - * Main print function invoked by dt_consume_cpu(). - */ -int -dtrace_print(dtrace_hdl_t *dtp, FILE *fp, const char *typename, - caddr_t addr, size_t len) +static ctf_id_t +dt_print_prepare(dtrace_hdl_t *dtp, const char *typename, caddr_t addr, + size_t len, dt_printarg_t *pa) { const char *s; char *object; - dt_printarg_t pa; ctf_id_t id; dt_module_t *dmp; ctf_file_t *ctfp; @@ -661,20 +756,20 @@ dtrace_print(dtrace_hdl_t *dtp, FILE *fp, const char *typename, ; if (*s != '`') - return (0); + return (CTF_ERR); object = alloca(s - typename + 1); bcopy(typename, object, s - typename); object[s - typename] = '\0'; dmp = dt_module_lookup_by_name(dtp, object); if (dmp == NULL) - return (0); + return (CTF_ERR); if (dmp->dm_pid != 0) { libid = atoi(s + 1); s = strchr(s + 1, '`'); if (s == NULL || libid > dmp->dm_nctflibs) - return (0); + return (CTF_ERR); ctfp = dmp->dm_libctfp[libid]; } else { ctfp = dt_module_getctf(dtp, dmp); @@ -688,18 +783,63 @@ dtrace_print(dtrace_hdl_t *dtp, FILE *fp, const char *typename, * work. */ if (ctfp == NULL || ctf_type_kind(ctfp, id) == CTF_ERR) + return (CTF_ERR); + + pa->pa_dtp = dtp; + pa->pa_addr = addr; + pa->pa_ctfp = ctfp; + pa->pa_nest = 0; + pa->pa_depth = 0; + pa->pa_object = strdup(object); + return (id); +} + +/* + * Main print function invoked by dt_consume_cpu(). + */ +int +dtrace_print(dtrace_hdl_t *dtp, FILE *fp, const char *typename, + caddr_t addr, size_t len) +{ + dt_printarg_t pa; + ctf_id_t id; + + id = dt_print_prepare(dtp, typename, addr, len, &pa); + if (id == CTF_ERR) return (0); - /* setup the print structure and kick off the main print routine */ - pa.pa_dtp = dtp; - pa.pa_addr = addr; - pa.pa_ctfp = ctfp; - pa.pa_nest = 0; - pa.pa_depth = 0; pa.pa_file = fp; (void) ctf_type_visit(pa.pa_ctfp, id, dt_print_member, &pa); dt_print_trailing_braces(&pa, 0); + dt_free(dtp, (void *)pa.pa_object); + + return (len); +} + +/* + * Main format function invoked by dt_consume_cpu(). + */ +int +dtrace_format_print(dtrace_hdl_t *dtp, FILE *fp, const char *typename, + caddr_t addr, size_t len) +{ + dt_printarg_t pa; + ctf_id_t id; + char toplevel[1024]; + + id = dt_print_prepare(dtp, typename, addr, len, &pa); + if (id == CTF_ERR) + return (0); + + if (ctf_type_name(pa.pa_ctfp, id, toplevel, sizeof(toplevel)) < 0) + return (0); + + xo_open_list("type"); + (void) ctf_type_visit(pa.pa_ctfp, id, dt_format_member, &pa); + xo_close_list("type"); + dt_free(dtp, (void *)pa.pa_object); return (len); } + diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c index 57a7db4ad0fd..c33ae955ba61 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c @@ -317,8 +317,7 @@ pfprint_fp(dtrace_hdl_t *dtp, FILE *fp, const char *format, case sizeof (double): return (dt_printf(dtp, fp, format, *((double *)addr) / n)); -#if !defined(__arm__) && !defined(__powerpc__) && \ - !defined(__mips__) && !defined(__riscv) +#if !defined(__arm__) && !defined(__powerpc__) && !defined(__riscv) case sizeof (long double): return (dt_printf(dtp, fp, format, *((long double *)addr) / ldn)); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.h index b3b5b8b94bf6..58e345b204ac 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.h +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.h @@ -21,6 +21,7 @@ */ /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2023 Domagoj Stolfa. All rights reserved. * Use is subject to license terms. */ @@ -128,6 +129,11 @@ extern int dt_print_ustack(dtrace_hdl_t *, FILE *, extern int dt_print_mod(dtrace_hdl_t *, FILE *, const char *, caddr_t); extern int dt_print_umod(dtrace_hdl_t *, FILE *, const char *, caddr_t); +extern int dt_format_stack(dtrace_hdl_t *, caddr_t, int, int); +extern int dt_format_ustack(dtrace_hdl_t *, caddr_t, uint64_t); +extern int dt_format_mod(dtrace_hdl_t *, caddr_t); +extern int dt_format_umod(dtrace_hdl_t *, caddr_t); + #ifdef __cplusplus } #endif diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c index 34bcc15b9ac7..b32dcea1f8ba 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c @@ -80,10 +80,8 @@ * up using this condition and will then call the client handler as necessary. */ +#include <sys/syscall.h> #include <sys/wait.h> -#ifdef illumos -#include <sys/lwp.h> -#endif #include <strings.h> #include <signal.h> #include <assert.h> @@ -93,14 +91,10 @@ #include <dt_pid.h> #include <dt_impl.h> -#ifndef illumos -#include <sys/syscall.h> #include <libproc_compat.h> -#define SYS_forksys SYS_fork -#endif #define IS_SYS_EXEC(w) (w == SYS_execve) -#define IS_SYS_FORK(w) (w == SYS_vfork || w == SYS_forksys) +#define IS_SYS_FORK(w) (w == SYS_vfork || w == SYS_fork) static dt_bkpt_t * dt_proc_bpcreate(dt_proc_t *dpr, uintptr_t addr, dt_bkpt_f *func, void *data) @@ -147,38 +141,23 @@ dt_proc_bpdestroy(dt_proc_t *dpr, int delbkpts) static void dt_proc_bpmatch(dtrace_hdl_t *dtp, dt_proc_t *dpr) { -#ifdef illumos - const lwpstatus_t *psp = &Pstatus(dpr->dpr_proc)->pr_lwp; -#else unsigned long pc; -#endif dt_bkpt_t *dbp; assert(DT_MUTEX_HELD(&dpr->dpr_lock)); -#ifndef illumos proc_regget(dpr->dpr_proc, REG_PC, &pc); proc_bkptregadj(&pc); -#endif for (dbp = dt_list_next(&dpr->dpr_bps); dbp != NULL; dbp = dt_list_next(dbp)) { -#ifdef illumos - if (psp->pr_reg[R_PC] == dbp->dbp_addr) - break; -#else if (pc == dbp->dbp_addr) break; -#endif } if (dbp == NULL) { dt_dprintf("pid %d: spurious breakpoint wakeup for %lx\n", -#ifdef illumos - (int)dpr->dpr_pid, (ulong_t)psp->pr_reg[R_PC]); -#else (int)dpr->dpr_pid, pc); -#endif return; } @@ -346,12 +325,8 @@ dt_proc_rdwatch(dt_proc_t *dpr, rd_event_e event, const char *evname) } (void) dt_proc_bpcreate(dpr, rdn.u.bptaddr, -#ifdef illumos - (dt_bkpt_f *)dt_proc_rdevent, (void *)evname); -#else /* XXX ugly */ (dt_bkpt_f *)dt_proc_rdevent, __DECONST(void *, evname)); -#endif } /* @@ -361,34 +336,18 @@ dt_proc_rdwatch(dt_proc_t *dpr, rd_event_e event, const char *evname) static void dt_proc_attach(dt_proc_t *dpr, int exec) { -#ifdef illumos - const pstatus_t *psp = Pstatus(dpr->dpr_proc); -#endif rd_err_e err; GElf_Sym sym; assert(DT_MUTEX_HELD(&dpr->dpr_lock)); if (exec) { -#ifdef illumos - if (psp->pr_lwp.pr_errno != 0) - return; /* exec failed: nothing needs to be done */ -#endif dt_proc_bpdestroy(dpr, B_FALSE); -#ifdef illumos - Preset_maps(dpr->dpr_proc); -#endif } if ((dpr->dpr_rtld = Prd_agent(dpr->dpr_proc)) != NULL && (err = rd_event_enable(dpr->dpr_rtld, B_TRUE)) == RD_OK) { -#ifdef illumos - dt_proc_rdwatch(dpr, RD_PREINIT, "RD_PREINIT"); -#endif dt_proc_rdwatch(dpr, RD_POSTINIT, "RD_POSTINIT"); -#ifdef illumos - dt_proc_rdwatch(dpr, RD_DLACTIVITY, "RD_DLACTIVITY"); -#endif } else { dt_dprintf("pid %d: failed to enable rtld events: %s\n", (int)dpr->dpr_pid, dpr->dpr_rtld ? rd_errstr(err) : @@ -407,84 +366,6 @@ dt_proc_attach(dt_proc_t *dpr, int exec) } } -/* - * Wait for a stopped process to be set running again by some other debugger. - * This is typically not required by /proc-based debuggers, since the usual - * model is that one debugger controls one victim. But DTrace, as usual, has - * its own needs: the stop() action assumes that prun(1) or some other tool - * will be applied to resume the victim process. This could be solved by - * adding a PCWRUN directive to /proc, but that seems like overkill unless - * other debuggers end up needing this functionality, so we implement a cheap - * equivalent to PCWRUN using the set of existing kernel mechanisms. - * - * Our intent is really not just to wait for the victim to run, but rather to - * wait for it to run and then stop again for a reason other than the current - * PR_REQUESTED stop. Since PCWSTOP/Pstopstatus() can be applied repeatedly - * to a stopped process and will return the same result without affecting the - * victim, we can just perform these operations repeatedly until Pstate() - * changes, the representative LWP ID changes, or the stop timestamp advances. - * dt_proc_control() will then rediscover the new state and continue as usual. - * When the process is still stopped in the same exact state, we sleep for a - * brief interval before waiting again so as not to spin consuming CPU cycles. - */ -static void -dt_proc_waitrun(dt_proc_t *dpr) -{ - printf("%s:%s(%d): not implemented\n", __FUNCTION__, __FILE__, - __LINE__); -#ifdef DOODAD - struct ps_prochandle *P = dpr->dpr_proc; - const lwpstatus_t *psp = &Pstatus(P)->pr_lwp; - - int krflag = psp->pr_flags & (PR_KLC | PR_RLC); - timestruc_t tstamp = psp->pr_tstamp; - lwpid_t lwpid = psp->pr_lwpid; - - const long wstop = PCWSTOP; - int pfd = Pctlfd(P); - - assert(DT_MUTEX_HELD(&dpr->dpr_lock)); - assert(psp->pr_flags & PR_STOPPED); - assert(Pstate(P) == PS_STOP); - - /* - * While we are waiting for the victim to run, clear PR_KLC and PR_RLC - * so that if the libdtrace client is killed, the victim stays stopped. - * dt_proc_destroy() will also observe this and perform PRELEASE_HANG. - */ - (void) Punsetflags(P, krflag); - Psync(P); - - (void) pthread_mutex_unlock(&dpr->dpr_lock); - - while (!dpr->dpr_quit) { - if (write(pfd, &wstop, sizeof (wstop)) == -1 && errno == EINTR) - continue; /* check dpr_quit and continue waiting */ - - (void) pthread_mutex_lock(&dpr->dpr_lock); - (void) Pstopstatus(P, PCNULL, 0); - psp = &Pstatus(P)->pr_lwp; - - /* - * If we've reached a new state, found a new representative, or - * the stop timestamp has changed, restore PR_KLC/PR_RLC to its - * original setting and then return with dpr_lock held. - */ - if (Pstate(P) != PS_STOP || psp->pr_lwpid != lwpid || - bcmp(&psp->pr_tstamp, &tstamp, sizeof (tstamp)) != 0) { - (void) Psetflags(P, krflag); - Psync(P); - return; - } - - (void) pthread_mutex_unlock(&dpr->dpr_lock); - (void) poll(NULL, 0, MILLISEC / 2); - } - - (void) pthread_mutex_lock(&dpr->dpr_lock); -#endif -} - typedef struct dt_proc_control_data { dtrace_hdl_t *dpcd_hdl; /* DTrace handle */ dt_proc_t *dpcd_proc; /* proccess to control */ @@ -511,12 +392,6 @@ dt_proc_control(void *arg) dt_proc_hash_t *dph = dtp->dt_procs; struct ps_prochandle *P = dpr->dpr_proc; int pid = dpr->dpr_pid; - -#ifdef illumos - int pfd = Pctlfd(P); - - const long wstop = PCWSTOP; -#endif int notify = B_FALSE; /* @@ -534,44 +409,14 @@ dt_proc_control(void *arg) */ (void) pthread_mutex_lock(&dpr->dpr_lock); -#ifdef illumos - (void) Punsetflags(P, PR_ASYNC); /* require synchronous mode */ - (void) Psetflags(P, PR_BPTADJ); /* always adjust eip on x86 */ - (void) Punsetflags(P, PR_FORK); /* do not inherit on fork */ - - (void) Pfault(P, FLTBPT, B_TRUE); /* always trace breakpoints */ - (void) Pfault(P, FLTTRACE, B_TRUE); /* always trace single-step */ - - /* - * We must trace exit from exec() system calls so that if the exec is - * successful, we can reset our breakpoints and re-initialize libproc. - */ - (void) Psysexit(P, SYS_execve, B_TRUE); - - /* - * We must trace entry and exit for fork() system calls in order to - * disable our breakpoints temporarily during the fork. We do not set - * the PR_FORK flag, so if fork succeeds the child begins executing and - * does not inherit any other tracing behaviors or a control thread. - */ - (void) Psysentry(P, SYS_vfork, B_TRUE); - (void) Psysexit(P, SYS_vfork, B_TRUE); - (void) Psysentry(P, SYS_forksys, B_TRUE); - (void) Psysexit(P, SYS_forksys, B_TRUE); - - Psync(P); /* enable all /proc changes */ -#endif dt_proc_attach(dpr, B_FALSE); /* enable rtld breakpoints */ /* - * If PR_KLC is set, we created the process; otherwise we grabbed it. - * Check for an appropriate stop request and wait for dt_proc_continue. + * If DT_CLOSE_KILL is set, we created the process; otherwise we + * grabbed it. Check for an appropriate stop request and wait for + * dt_proc_continue. */ -#ifdef illumos - if (Pstatus(P)->pr_flags & PR_KLC) -#else - if (proc_getflags(P) & PR_KLC) -#endif + if (dpr->dpr_close == DT_CLOSE_KILL) dt_proc_stop(dpr, DT_PROC_STOP_CREATE); else dt_proc_stop(dpr, DT_PROC_STOP_GRAB); @@ -595,55 +440,21 @@ dt_proc_control(void *arg) while (!dpr->dpr_quit) { const lwpstatus_t *psp; -#ifdef illumos - if (write(pfd, &wstop, sizeof (wstop)) == -1 && errno == EINTR) - continue; /* check dpr_quit and continue waiting */ -#else /* Wait for the process to report status. */ proc_wstatus(P); if (errno == EINTR) continue; /* check dpr_quit and continue waiting */ -#endif (void) pthread_mutex_lock(&dpr->dpr_lock); -#ifdef illumos -pwait_locked: - if (Pstopstatus(P, PCNULL, 0) == -1 && errno == EINTR) { - (void) pthread_mutex_unlock(&dpr->dpr_lock); - continue; /* check dpr_quit and continue waiting */ - } -#endif - switch (Pstate(P)) { case PS_STOP: -#ifdef illumos - psp = &Pstatus(P)->pr_lwp; -#else psp = proc_getlwpstatus(P); -#endif dt_dprintf("pid %d: proc stopped showing %d/%d\n", pid, psp->pr_why, psp->pr_what); /* - * If the process stops showing PR_REQUESTED, then the - * DTrace stop() action was applied to it or another - * debugging utility (e.g. pstop(1)) asked it to stop. - * In either case, the user's intention is for the - * process to remain stopped until another external - * mechanism (e.g. prun(1)) is applied. So instead of - * setting the process running ourself, we wait for - * someone else to do so. Once that happens, we return - * to our normal loop waiting for an event of interest. - */ - if (psp->pr_why == PR_REQUESTED) { - dt_proc_waitrun(dpr); - (void) pthread_mutex_unlock(&dpr->dpr_lock); - continue; - } - - /* * If the process stops showing one of the events that * we are tracing, perform the appropriate response. * Note that we ignore PR_SUSPENDED, PR_CHECKPOINT, and @@ -666,11 +477,6 @@ pwait_locked: break; case PS_LOST: -#ifdef illumos - if (Preopen(P) == 0) - goto pwait_locked; -#endif - dt_dprintf("pid %d: proc lost: %s\n", pid, strerror(errno)); @@ -685,9 +491,19 @@ pwait_locked: break; } - if (Pstate(P) != PS_UNDEAD && Psetrun(P, 0, 0) == -1) { - dt_dprintf("pid %d: failed to set running: %s\n", - (int)dpr->dpr_pid, strerror(errno)); + if (Pstate(P) != PS_UNDEAD) { + if (dpr->dpr_quit && dpr->dpr_close == DT_CLOSE_KILL) { + /* + * We're about to kill the child, so don't + * bother resuming it. In some cases, such as + * an initialization error, we shouldn't have + * started it in the first place, so letting it + * run could be harmful. + */ + } else if (Psetrun(P, 0, 0) == -1) { + dt_dprintf("pid %d: failed to set running: " + "%s\n", (int)dpr->dpr_pid, strerror(errno)); + } } (void) pthread_mutex_unlock(&dpr->dpr_lock); @@ -739,11 +555,7 @@ dt_proc_t * dt_proc_lookup(dtrace_hdl_t *dtp, struct ps_prochandle *P, int remove) { dt_proc_hash_t *dph = dtp->dt_procs; -#ifdef illumos - pid_t pid = Pstatus(P)->pr_pid; -#else pid_t pid = proc_getpid(P); -#endif dt_proc_t *dpr, **dpp = &dph->dph_hash[pid & (dph->dph_hashlen - 1)]; for (dpr = *dpp; dpr != NULL; dpr = dpr->dpr_hash) { @@ -772,28 +584,15 @@ dt_proc_destroy(dtrace_hdl_t *dtp, struct ps_prochandle *P) assert(dpr != NULL); - /* - * If neither PR_KLC nor PR_RLC is set, then the process is stopped by - * an external debugger and we were waiting in dt_proc_waitrun(). - * Leave the process in this condition using PRELEASE_HANG. - */ -#ifdef illumos - if (!(Pstatus(dpr->dpr_proc)->pr_flags & (PR_KLC | PR_RLC))) { -#else - if (!(proc_getflags(dpr->dpr_proc) & (PR_KLC | PR_RLC))) { -#endif - dt_dprintf("abandoning pid %d\n", (int)dpr->dpr_pid); - rflag = PRELEASE_HANG; -#ifdef illumos - } else if (Pstatus(dpr->dpr_proc)->pr_flags & PR_KLC) { -#else - } else if (proc_getflags(dpr->dpr_proc) & PR_KLC) { -#endif + switch (dpr->dpr_close) { + case DT_CLOSE_KILL: dt_dprintf("killing pid %d\n", (int)dpr->dpr_pid); - rflag = PRELEASE_KILL; /* apply kill-on-last-close */ - } else { + rflag = PRELEASE_KILL; + break; + case DT_CLOSE_RUN: dt_dprintf("releasing pid %d\n", (int)dpr->dpr_pid); - rflag = 0; /* apply run-on-last-close */ + rflag = 0; + break; } if (dpr->dpr_tid) { @@ -813,11 +612,7 @@ dt_proc_destroy(dtrace_hdl_t *dtp, struct ps_prochandle *P) */ (void) pthread_mutex_lock(&dpr->dpr_lock); dpr->dpr_quit = B_TRUE; -#ifdef illumos - (void) _lwp_kill(dpr->dpr_tid, SIGCANCEL); -#else pthread_kill(dpr->dpr_tid, SIGTHR); -#endif /* * If the process is currently idling in dt_proc_stop(), re- @@ -885,11 +680,7 @@ dt_proc_create_thread(dtrace_hdl_t *dtp, dt_proc_t *dpr, uint_t stop) (void) sigfillset(&nset); (void) sigdelset(&nset, SIGABRT); /* unblocked for assert() */ -#ifdef illumos - (void) sigdelset(&nset, SIGCANCEL); /* see dt_proc_destroy() */ -#else (void) sigdelset(&nset, SIGUSR1); /* see dt_proc_destroy() */ -#endif data.dpcd_hdl = dtp; data.dpcd_proc = dpr; @@ -917,14 +708,8 @@ dt_proc_create_thread(dtrace_hdl_t *dtp, dt_proc_t *dpr, uint_t stop) * small amount of useful information to help figure it out. */ if (dpr->dpr_done) { -#ifdef illumos - const psinfo_t *prp = Ppsinfo(dpr->dpr_proc); - int stat = prp ? prp->pr_wstat : 0; - int pid = dpr->dpr_pid; -#else int stat = proc_getwstat(dpr->dpr_proc); int pid = proc_getpid(dpr->dpr_proc); -#endif if (proc_state(dpr->dpr_proc) == PS_LOST) { (void) dt_proc_error(dpr->dpr_hdl, dpr, "failed to control pid %d: process exec'd " @@ -968,29 +753,15 @@ dt_proc_create(dtrace_hdl_t *dtp, const char *file, char *const *argv, (void) pthread_mutex_init(&dpr->dpr_lock, NULL); (void) pthread_cond_init(&dpr->dpr_cv, NULL); -#ifdef illumos - dpr->dpr_proc = Pxcreate(file, argv, dtp->dt_proc_env, &err, NULL, 0); - if (dpr->dpr_proc == NULL) { - return (dt_proc_error(dtp, dpr, - "failed to execute %s: %s\n", file, Pcreate_error(err))); - } -#else if ((err = proc_create(file, argv, dtp->dt_proc_env, pcf, child_arg, &dpr->dpr_proc)) != 0) { return (dt_proc_error(dtp, dpr, "failed to execute %s: %s\n", file, Pcreate_error(err))); } -#endif dpr->dpr_hdl = dtp; -#ifdef illumos - dpr->dpr_pid = Pstatus(dpr->dpr_proc)->pr_pid; -#else dpr->dpr_pid = proc_getpid(dpr->dpr_proc); -#endif - - (void) Punsetflags(dpr->dpr_proc, PR_RLC); - (void) Psetflags(dpr->dpr_proc, PR_KLC); + dpr->dpr_close = DT_CLOSE_KILL; if (dt_proc_create_thread(dtp, dpr, dtp->dt_prcmode) != 0) return (NULL); /* dt_proc_error() has been called for us */ @@ -1048,20 +819,14 @@ dt_proc_grab(dtrace_hdl_t *dtp, pid_t pid, int flags, int nomonitor) (void) pthread_mutex_init(&dpr->dpr_lock, NULL); (void) pthread_cond_init(&dpr->dpr_cv, NULL); -#ifdef illumos - if ((dpr->dpr_proc = Pgrab(pid, flags, &err)) == NULL) { -#else if ((err = proc_attach(pid, flags, &dpr->dpr_proc)) != 0) { -#endif return (dt_proc_error(dtp, dpr, "failed to grab pid %d: %s\n", (int)pid, Pgrab_error(err))); } dpr->dpr_hdl = dtp; dpr->dpr_pid = pid; - - (void) Punsetflags(dpr->dpr_proc, PR_KLC); - (void) Psetflags(dpr->dpr_proc, PR_RLC); + dpr->dpr_close = DT_CLOSE_RUN; /* * If we are attempting to grab the process without a monitor @@ -1227,11 +992,7 @@ dtrace_proc_create(dtrace_hdl_t *dtp, const char *file, char *const *argv, struct ps_prochandle *P = dt_proc_create(dtp, file, argv, pcf, child_arg); if (P != NULL && idp != NULL && idp->di_id == 0) { -#ifdef illumos - idp->di_id = Pstatus(P)->pr_pid; /* $target = created pid */ -#else idp->di_id = proc_getpid(P); /* $target = created pid */ -#endif } return (P); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.h index beae6f6d5cda..458e9902881f 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.h +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.h @@ -40,6 +40,11 @@ extern "C" { #endif +enum dt_close_action { + DT_CLOSE_RUN, + DT_CLOSE_KILL, +}; + typedef struct dt_proc { dt_list_t dpr_list; /* prev/next pointers for lru chain */ struct dt_proc *dpr_hash; /* next pointer for pid hash chain */ @@ -60,6 +65,7 @@ typedef struct dt_proc { uint8_t dpr_rdonly; /* proc flag: opened read-only */ pthread_t dpr_tid; /* control thread (or zero if none) */ dt_list_t dpr_bps; /* list of dt_bkpt_t structures */ + enum dt_close_action dpr_close; /* do this to child when exiting */ } dt_proc_t; typedef struct dt_proc_notify { diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c index 7cf352d4d505..2391690afc0b 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c @@ -48,6 +48,7 @@ #include <dt_list.h> #include <dt_pid.h> #include <dtrace.h> +#include <kinst.h> static dt_provider_t * dt_provider_insert(dtrace_hdl_t *dtp, dt_provider_t *pvp, uint_t h) @@ -699,6 +700,34 @@ dt_probe_info(dtrace_hdl_t *dtp, prp = idp->di_data; else if (pdp->dtpd_id != DTRACE_IDNONE) prp = dt_probe_discover(pvp, pdp); + + if (strcmp(pvp->pv_desc.dtvd_name, "kinst") == 0) { + dtrace_kinst_probedesc_t pd; + + if (dtp->dt_kinstfd == -1) { + int fd; + + fd = open("/dev/dtrace/kinst", O_WRONLY); + if (fd < 0) { + (void) dt_set_errno(dtp, errno); + return (NULL); + } + dtp->dt_kinstfd = fd; + } + memset(&pd, 0, sizeof(pd)); + strlcpy(pd.kpd_func, pdp->dtpd_func, + sizeof (pd.kpd_func)); + + if (n_is_glob) + pd.kpd_off = -1; + else + pd.kpd_off = strtol(pdp->dtpd_name, NULL, 10); + if (ioctl(dtp->dt_kinstfd, KINSTIOC_MAKEPROBE, &pd) != + 0) { + (void) dt_set_errno(dtp, errno); + return (NULL); + } + } } /* diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c index 1729eaf2e7be..5dc8e1648fd3 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c @@ -50,6 +50,7 @@ #include <stdint.h> #include <dt_impl.h> +#include <dt_oformat.h> static const struct { size_t dtps_offset; @@ -462,6 +463,20 @@ dt_cpp_pop_arg(dtrace_hdl_t *dtp) return (arg); } +int +dt_cpu_maxid(dtrace_hdl_t *dtp) +{ + size_t len; + u_int count; + int error; + + len = sizeof(count); + error = sysctlbyname("kern.smp.maxid", &count, &len, NULL, 0); + if (error != 0) + return (dt_set_errno(dtp, errno)); + return (count); +} + /*PRINTFLIKE1*/ void dt_dprintf(const char *format, ...) @@ -992,3 +1007,44 @@ dtrace_uaddr2str(dtrace_hdl_t *dtp, pid_t pid, return (dt_string2str(c, str, nbytes)); } + +int +dtrace_oformat_configure(dtrace_hdl_t *dtp) +{ + + dtp->dt_oformat = xo_get_style(NULL) == XO_STYLE_TEXT ? + DTRACE_OFORMAT_TEXT : + DTRACE_OFORMAT_STRUCTURED; + xo_set_flags(NULL, XOF_DTRT); + return (0); +} + +int +dtrace_oformat(dtrace_hdl_t *dtp) +{ + + return (dtp->dt_oformat != DTRACE_OFORMAT_TEXT); +} + +void +dtrace_set_outfp(const FILE *ofp) +{ + + xo_set_file((FILE *)ofp); +} + +void +dtrace_oformat_setup(dtrace_hdl_t *dtp) +{ + + xo_open_container("dtrace"); + xo_open_list("probes"); +} + +void +dtrace_oformat_teardown(dtrace_hdl_t *dtp) +{ + + xo_close_list("probes"); + xo_close_container("dtrace"); +} diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h index f0bc83a7fc7b..c9496c2df5ba 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h @@ -25,6 +25,7 @@ */ /* + * Copyright (c) 2023 by Domagoj Stolfa. All rights reserved. * Copyright (c) 2014, 2016 by Delphix. All rights reserved. * Copyright (c) 2013, Joyent, Inc. All rights reserved. */ @@ -69,6 +70,7 @@ typedef struct dtrace_aggdata dtrace_aggdata_t; #define DTRACE_O_NOSYS 0x02 /* do not load /system/object modules */ #define DTRACE_O_LP64 0x04 /* force D compiler to be LP64 */ #define DTRACE_O_ILP32 0x08 /* force D compiler to be ILP32 */ +#define DTRACE_O_MODEL_MASK (DTRACE_O_LP64 | DTRACE_O_ILP32) #define DTRACE_O_MASK 0x0f /* mask of valid flags to dtrace_open */ extern dtrace_hdl_t *dtrace_open(int, int, int *); @@ -119,10 +121,11 @@ typedef struct dtrace_proginfo { #define DTRACE_C_PSPEC 0x0080 /* Interpret ambiguous specifiers as probes */ #define DTRACE_C_ETAGS 0x0100 /* Prefix error messages with error tags */ #define DTRACE_C_ARGREF 0x0200 /* Do not require all macro args to be used */ +#define DTRACE_C_SUGAR 0x0400 /* Dump D script post-dt_sugar */ #define DTRACE_C_DEFARG 0x0800 /* Use 0/"" as value for unspecified args */ #define DTRACE_C_NOLIBS 0x1000 /* Do not process D system libraries */ #define DTRACE_C_CTL 0x2000 /* Only process control directives */ -#define DTRACE_C_MASK 0x3bff /* mask of all valid flags to dtrace_*compile */ +#define DTRACE_C_MASK 0x3fff /* mask of all valid flags to dtrace_*compile */ extern dtrace_prog_t *dtrace_program_strcompile(dtrace_hdl_t *, const char *, dtrace_probespec_t, uint_t, int, char *const []); @@ -199,6 +202,7 @@ typedef struct dtrace_probedata { dtrace_flowkind_t dtpda_flow; /* flow kind */ const char *dtpda_prefix; /* recommended flow prefix */ int dtpda_indent; /* recommended flow indent */ + uint64_t dtpda_timestamp; /* hrtime of snapshot */ } dtrace_probedata_t; typedef int dtrace_consume_probe_f(const dtrace_probedata_t *, void *); @@ -232,6 +236,10 @@ extern void *dtrace_printf_create(dtrace_hdl_t *, const char *); extern void *dtrace_printa_create(dtrace_hdl_t *, const char *); extern size_t dtrace_printf_format(dtrace_hdl_t *, void *, char *, size_t); +extern int dtrace_sprintf(dtrace_hdl_t *, FILE *, void *, + const dtrace_recdesc_t *, uint_t, + const void *, size_t); + extern int dtrace_fprintf(dtrace_hdl_t *, FILE *, void *, const dtrace_probedata_t *, const dtrace_recdesc_t *, uint_t, const void *, size_t); @@ -259,6 +267,8 @@ extern int dtrace_freopen(dtrace_hdl_t *, FILE *, void *, */ extern int dtrace_print(dtrace_hdl_t *, FILE *, const char *, caddr_t, size_t); +extern int dtrace_format_print(dtrace_hdl_t *, FILE *, const char *, + caddr_t, size_t); /* * DTrace Work Interface @@ -610,9 +620,18 @@ extern int _dtrace_debug; } #endif -#ifndef illumos -#define _SC_CPUID_MAX _SC_NPROCESSORS_CONF -#define _SC_NPROCESSORS_MAX _SC_NPROCESSORS_CONF -#endif +/* + * Values for the dt_oformat property. + */ +#define DTRACE_OFORMAT_TEXT 0 +#define DTRACE_OFORMAT_STRUCTURED 1 + +extern int dtrace_oformat_configure(dtrace_hdl_t *); +extern int dtrace_oformat(dtrace_hdl_t *); +extern void dtrace_set_outfp(const FILE *); +extern void dtrace_oformat_setup(dtrace_hdl_t *); +extern void dtrace_oformat_teardown(dtrace_hdl_t *); +extern void dtrace_oformat_probe(dtrace_hdl_t *, const dtrace_probedata_t *, + processorid_t, dtrace_probedesc_t *); #endif /* _DTRACE_H */ diff --git a/cddl/contrib/opensolaris/tests/os-tests/tests/oclo/oclo.c b/cddl/contrib/opensolaris/tests/os-tests/tests/oclo/oclo.c new file mode 100644 index 000000000000..8e6f7c726f24 --- /dev/null +++ b/cddl/contrib/opensolaris/tests/os-tests/tests/oclo/oclo.c @@ -0,0 +1,1341 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2025 Oxide Computer Company + */ + +/* + * Verify the behavior of the various O_CLOFORK and O_CLOEXEC variants. In + * particular getting this via: + * + * - open(2): O_CLOFORK/O_CLOEXEC + * - fcntl(2): F_SETFD FD_CLOFORK/FD_CLOEXEC + * - fcntl(2): F_DUPFD_CLOFORK/F_DUPFD_CLOEXEC + * - fcntl(2): F_DUP2FD_CLOFORK/F_DUP2FD_CLOEXEC + * - dup2(3C) + * - dup3(3C): argument translation + * - pipe2(2) + * - socket(2): SOCK_CLOEXEC/SOCK_CLOFORK + * - accept(2): flags on the listen socket aren't inherited on accept + * - socketpair(3SOCKET) + * - accept4(2): SOCK_CLOEXEC/SOCK_CLOFORK + * - recvmsg(2): SCM_RIGHTS MSG_CMSG_CLOFORK/MSG_CMSG_CLOEXEC + * + * The test is designed such that we have an array of functions that are used to + * create file descriptors with different rules. This is found in the + * oclo_create array. Each file descriptor that is created is then registered + * with information about what is expected about it. A given creation function + * can create more than one file descriptor; however, our expectation is that + * every file descriptor is accounted for (ignoring stdin, stdout, and stderr). + * + * We pass a record of each file descriptor that was recorded to a verification + * program that will verify everything is correctly honored after an exec. Note + * that O_CLOFORK is cleared after exec. The original specification in POSIX has + * it being retained; however, this issue was raised after the spec was + * published as folks went to implement it and we have ended up following along + * with the divergence of other implementations. + */ + +#include <sys/param.h> +#include <sys/sysctl.h> +#include <sys/stat.h> +#include <sys/wait.h> + +#include <netinet/in.h> +#include <sys/socket.h> + +#include <err.h> +#include <errno.h> +#include <fcntl.h> +#include <libgen.h> +#include <limits.h> +#include <signal.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +void *recallocarray(void *, size_t, size_t, size_t); + +#define strerrorname_np(e) (sys_errlist[e]) + +/* + * Get pathname to avoid reading /proc/curproc/exe + * + * Taken from procstat_getpathname_sysctl() + */ +static int +getpathname(pid_t pid, char *pathname, size_t maxlen) +{ + int error, name[4]; + size_t len; + + name[0] = CTL_KERN; + name[1] = KERN_PROC; + name[2] = KERN_PROC_PATHNAME; + name[3] = pid; + len = maxlen; + error = sysctl(name, nitems(name), pathname, &len, NULL, 0); + if (error != 0 && errno != ESRCH) + warn("sysctl: kern.proc.pathname: %d", pid); + if (len == 0) + pathname[0] = '\0'; + return (error); +} + +/* + * Verification program name. + */ +#define OCLO_VERIFY "ocloexec_verify" + +/* + * This structure represents a table of ways we expect to create file + * descriptors that should have the resulting flags set when done. The table is + * ordered and subsequent iterations are allowed to assume that the ones that + * have gone ahead of them have run and are therefore allowed to access them. + * The create function is expected to return the created fd. + */ +typedef struct clo_create clo_create_t; +struct clo_create { + const char *clo_desc; + int clo_flags; + void (*clo_func)(const clo_create_t *); +}; + +/* + * This is our run-time data. We expect all file descriptors to be registered by + * our calling functions through oclo_record(). + */ +typedef struct clo_rtdata { + const clo_create_t *crt_data; + size_t crt_idx; + int crt_fd; + int crt_flags; + const char *crt_desc; +} clo_rtdata_t; + +static clo_rtdata_t *oclo_rtdata; +static size_t oclo_rtdata_nents = 0; +static size_t oclo_rtdata_next = 0; +static int oclo_nextfd = STDERR_FILENO + 1; + +static bool +oclo_flags_match(const clo_rtdata_t *rt, bool child) +{ + const char *pass = child ? "post-fork" : "pre-fork"; + bool fail = child && (rt->crt_flags & FD_CLOFORK) != 0; + int flags = fcntl(rt->crt_fd, F_GETFD, NULL); + + if (flags < 0) { + int e = errno; + + if (fail) { + if (e == EBADF) { + (void) printf("TEST PASSED: %s (%s): fd %d: " + "correctly closed\n", + rt->crt_data->clo_desc, pass, rt->crt_fd); + return (true); + } + + warn("TEST FAILED: %s (%s): fd %d: expected fcntl to " + "fail with EBADF, but found %s", + rt->crt_data->clo_desc, pass, rt->crt_fd, + strerrorname_np(e)); + return (false); + } + + warnx("TEST FAILED: %s (%s): fd %d: fcntl(F_GETFD) " + "unexpectedly failed", rt->crt_data->clo_desc, pass, + rt->crt_fd); + return (false); + } + + if (fail) { + warnx("TEST FAILED: %s (%s): fd %d: received flags %d, but " + "expected to fail based on flags %d", + rt->crt_data->clo_desc, pass, rt->crt_fd, flags, + rt->crt_fd); + return (false); + } + + if (flags != rt->crt_flags) { + warnx("TEST FAILED: %s (%s): fd %d: discovered flags 0x%x do " + "not match expected flags 0x%x", rt->crt_data->clo_desc, + pass, rt->crt_fd, flags, rt->crt_fd); + return (false); + } + + (void) printf("TEST PASSED: %s (%s): fd %d discovered flags match " + "(0x%x)\n", rt->crt_data->clo_desc, pass, rt->crt_fd, flags); + return (true); +} + + +static void +oclo_record(const clo_create_t *c, int fd, int exp_flags, const char *desc) +{ + if (oclo_rtdata_next == oclo_rtdata_nents) { + size_t newrt = oclo_rtdata_nents + 8; + clo_rtdata_t *rt; + rt = recallocarray(oclo_rtdata, oclo_rtdata_nents, newrt, + sizeof (clo_rtdata_t)); + if (rt == NULL) { + err(EXIT_FAILURE, "TEST_FAILED: internal error " + "expanding fd records to %zu entries", newrt); + } + + oclo_rtdata_nents = newrt; + oclo_rtdata = rt; + } + + if (fd != oclo_nextfd) { + errx(EXIT_FAILURE, "TEST FAILED: internal test error: expected " + "to record next fd %d, given %d", oclo_nextfd, fd); + } + + oclo_rtdata[oclo_rtdata_next].crt_data = c; + oclo_rtdata[oclo_rtdata_next].crt_fd = fd; + oclo_rtdata[oclo_rtdata_next].crt_flags = exp_flags; + oclo_rtdata[oclo_rtdata_next].crt_desc = desc; + + /* + * Matching errors at this phase are fatal as it means we screwed up the + * program pretty badly. + */ + if (!oclo_flags_match(&oclo_rtdata[oclo_rtdata_next], false)) { + exit(EXIT_FAILURE); + } + + oclo_rtdata_next++; + oclo_nextfd++; +} + +static int +oclo_file(const clo_create_t *c) +{ + int flags = O_RDWR, fd; + + if ((c->clo_flags & FD_CLOEXEC) != 0) + flags |= O_CLOEXEC; + if ((c->clo_flags & FD_CLOFORK) != 0) + flags |= O_CLOFORK; + fd = open("/dev/null", flags); + if (fd < 0) { + err(EXIT_FAILURE, "TEST FAILED: %s: failed to open /dev/null", + c->clo_desc); + } + + return (fd); +} + +static void +oclo_open(const clo_create_t *c) +{ + oclo_record(c, oclo_file(c), c->clo_flags, NULL); +} + +static void +oclo_setfd_common(const clo_create_t *c, int targ_flags) +{ + int fd = oclo_file(c); + if (fcntl(fd, F_SETFD, targ_flags) < 0) { + err(EXIT_FAILURE, "TEST FAILED: %s: F_SETFD failed to set " + "flags to %d", c->clo_desc, targ_flags); + } + + oclo_record(c, fd, targ_flags, NULL); +} + +static void +oclo_setfd_none(const clo_create_t *c) +{ + oclo_setfd_common(c, 0); +} + +static void +oclo_setfd_exec(const clo_create_t *c) +{ + oclo_setfd_common(c, FD_CLOEXEC); +} + +static void +oclo_setfd_fork(const clo_create_t *c) +{ + oclo_setfd_common(c, FD_CLOFORK); +} + +static void +oclo_setfd_both(const clo_create_t *c) +{ + oclo_setfd_common(c, FD_CLOFORK | FD_CLOEXEC); +} + +/* + * Open an fd with flags in a certain form and then use one of the F_DUPFD or + * F_DUP2FD variants and ensure that flags are properly propagated as expected. + */ +static void +oclo_fdup_common(const clo_create_t *c, int targ_flags, int cmd) +{ + int dup, fd; + + fd = oclo_file(c); + oclo_record(c, fd, c->clo_flags, "base"); + switch (cmd) { + case F_DUPFD: + case F_DUPFD_CLOEXEC: + case F_DUPFD_CLOFORK: + dup = fcntl(fd, cmd, fd); + break; + case F_DUP2FD: + case F_DUP2FD_CLOEXEC: +#ifdef F_DUP2FD_CLOFORK + case F_DUP2FD_CLOFORK: +#endif + dup = fcntl(fd, cmd, fd + 1); + break; + case F_DUP3FD: + dup = fcntl(fd, cmd | (targ_flags << F_DUP3FD_SHIFT), fd + 1); + break; + default: + errx(EXIT_FAILURE, "TEST FAILURE: %s: internal error: " + "unexpected fcntl cmd: 0x%x", c->clo_desc, cmd); + } + + if (dup < 0) { + err(EXIT_FAILURE, "TEST FAILURE: %s: failed to dup fd with " + "fcntl command 0x%x", c->clo_desc, cmd); + } + + oclo_record(c, dup, targ_flags, "dup"); +} + +static void +oclo_fdupfd(const clo_create_t *c) +{ + oclo_fdup_common(c, 0, F_DUPFD); +} + +static void +oclo_fdupfd_fork(const clo_create_t *c) +{ + oclo_fdup_common(c, FD_CLOFORK, F_DUPFD_CLOFORK); +} + +static void +oclo_fdupfd_exec(const clo_create_t *c) +{ + oclo_fdup_common(c, FD_CLOEXEC, F_DUPFD_CLOEXEC); +} + +static void +oclo_fdup2fd(const clo_create_t *c) +{ + oclo_fdup_common(c, 0, F_DUP2FD); +} + +#ifdef F_DUP2FD_CLOFORK +static void +oclo_fdup2fd_fork(const clo_create_t *c) +{ + oclo_fdup_common(c, FD_CLOFORK, F_DUP2FD_CLOFORK); +} +#endif + +static void +oclo_fdup2fd_exec(const clo_create_t *c) +{ + oclo_fdup_common(c, FD_CLOEXEC, F_DUP2FD_CLOEXEC); +} + +static void +oclo_fdup3fd_none(const clo_create_t *c) +{ + oclo_fdup_common(c, 0, F_DUP3FD); +} + +static void +oclo_fdup3fd_exec(const clo_create_t *c) +{ + oclo_fdup_common(c, FD_CLOEXEC, F_DUP3FD); +} + +static void +oclo_fdup3fd_fork(const clo_create_t *c) +{ + oclo_fdup_common(c, FD_CLOFORK, F_DUP3FD); +} + +static void +oclo_fdup3fd_both(const clo_create_t *c) +{ + oclo_fdup_common(c, FD_CLOEXEC | FD_CLOFORK, F_DUP3FD); +} + +static void +oclo_dup_common(const clo_create_t *c, int targ_flags, bool v3) +{ + int dup, fd; + fd = oclo_file(c); + oclo_record(c, fd, c->clo_flags, "base"); + if (v3) { + int dflags = 0; + if ((targ_flags & FD_CLOEXEC) != 0) + dflags |= O_CLOEXEC; + if ((targ_flags & FD_CLOFORK) != 0) + dflags |= O_CLOFORK; + dup = dup3(fd, fd + 1, dflags); + } else { + dup = dup2(fd, fd + 1); + } + + oclo_record(c, dup, targ_flags, "dup"); +} + +static void +oclo_dup2(const clo_create_t *c) +{ + oclo_dup_common(c, 0, false); +} + +static void +oclo_dup3_none(const clo_create_t *c) +{ + oclo_dup_common(c, 0, true); +} + +static void +oclo_dup3_exec(const clo_create_t *c) +{ + oclo_dup_common(c, FD_CLOEXEC, true); +} + +static void +oclo_dup3_fork(const clo_create_t *c) +{ + oclo_dup_common(c, FD_CLOFORK, true); +} + +static void +oclo_dup3_both(const clo_create_t *c) +{ + oclo_dup_common(c, FD_CLOEXEC | FD_CLOFORK, true); +} + +static void +oclo_pipe(const clo_create_t *c) +{ + int flags = 0, fds[2]; + + if ((c->clo_flags & FD_CLOEXEC) != 0) + flags |= O_CLOEXEC; + if ((c->clo_flags & FD_CLOFORK) != 0) + flags |= O_CLOFORK; + + if (pipe2(fds, flags) < 0) { + err(EXIT_FAILURE, "TEST FAILED: %s: pipe2() with flags %d " + "failed", c->clo_desc, flags); + } + + oclo_record(c, fds[0], c->clo_flags, "pipe[0]"); + oclo_record(c, fds[1], c->clo_flags, "pipe[1]"); +} + +static void +oclo_socket(const clo_create_t *c) +{ + int type = SOCK_DGRAM, fd; + + if ((c->clo_flags & FD_CLOEXEC) != 0) + type |= SOCK_CLOEXEC; + if ((c->clo_flags & FD_CLOFORK) != 0) + type |= SOCK_CLOFORK; + fd = socket(PF_INET, type, 0); + if (fd < 0) { + err(EXIT_FAILURE, "TEST FAILED: %s: failed to create socket " + "with flags: 0x%x\n", c->clo_desc, c->clo_flags); + } + + oclo_record(c, fd, c->clo_flags, NULL); +} + +static void +oclo_accept_common(const clo_create_t *c, int targ_flags, bool a4) +{ + int lsock, csock, asock; + int ltype = SOCK_STREAM, atype = 0; + struct sockaddr_in in; + socklen_t slen; + + if ((c->clo_flags & FD_CLOEXEC) != 0) + ltype |= SOCK_CLOEXEC; + if ((c->clo_flags & FD_CLOFORK) != 0) + ltype |= SOCK_CLOFORK; + + if ((targ_flags & FD_CLOEXEC) != 0) + atype |= SOCK_CLOEXEC; + if ((targ_flags & FD_CLOFORK) != 0) + atype |= SOCK_CLOFORK; + + lsock = socket(PF_INET, ltype, 0); + if (lsock < 0) { + err(EXIT_FAILURE, "TEST FAILED: %s: failed to create listen " + "socket with flags: 0x%x\n", c->clo_desc, c->clo_flags); + } + + oclo_record(c, lsock, c->clo_flags, "listen"); + (void) memset(&in, 0, sizeof (in)); + in.sin_family = AF_INET; + in.sin_port = 0; + in.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + + if (bind(lsock, (struct sockaddr *)&in, sizeof (in)) != 0) { + err(EXIT_FAILURE, "TEST FAILED: %s: failed to bind socket", + c->clo_desc); + } + + slen = sizeof (struct sockaddr_in); + if (getsockname(lsock, (struct sockaddr *)&in, &slen) != 0) { + err(EXIT_FAILURE, "TEST FAILED: %s: failed to discover bound " + "socket address", c->clo_desc); + } + + if (listen(lsock, 5) < 0) { + err(EXIT_FAILURE, "TEST FAILED: %s: failed to listen on socket", + c->clo_desc); + } + + csock = socket(PF_INET, SOCK_STREAM, 0); + if (csock < 0) { + err(EXIT_FAILURE, "TEST FAILED: %s: failed to create client " + "socket", c->clo_desc); + } + oclo_record(c, csock, 0, "connect"); + + if (connect(csock, (struct sockaddr *)&in, sizeof (in)) != 0) { + err(EXIT_FAILURE, "TEST FAILED: %s: failed to connect to " + "server socket", c->clo_desc); + } + + if (a4) { + asock = accept4(lsock, NULL, NULL, atype); + } else { + asock = accept(lsock, NULL, NULL); + } + if (asock < 0) { + err(EXIT_FAILURE, "TEST FAILED: %s: failed to accept client " + "connection", c->clo_desc); + } + oclo_record(c, asock, targ_flags, "accept"); +} + +static void +oclo_accept(const clo_create_t *c) +{ + oclo_accept_common(c, 0, false); +} + +static void +oclo_accept4_none(const clo_create_t *c) +{ + oclo_accept_common(c, 0, true); +} + +static void +oclo_accept4_fork(const clo_create_t *c) +{ + oclo_accept_common(c, FD_CLOFORK, true); +} + +static void +oclo_accept4_exec(const clo_create_t *c) +{ + oclo_accept_common(c, FD_CLOEXEC, true); +} + +static void +oclo_accept4_both(const clo_create_t *c) +{ + oclo_accept_common(c, FD_CLOEXEC | FD_CLOFORK, true); +} + +/* + * Go through the process of sending ourselves a file descriptor. + */ +static void +oclo_rights_common(const clo_create_t *c, int targ_flags) +{ + int pair[2], type = SOCK_DGRAM, sflags = 0; + int tosend = oclo_file(c), recvfd; + uint32_t data = 0x7777; + struct iovec iov; + struct msghdr msg; + struct cmsghdr *cm; + + if ((c->clo_flags & FD_CLOEXEC) != 0) + type |= SOCK_CLOEXEC; + if ((c->clo_flags & FD_CLOFORK) != 0) + type |= SOCK_CLOFORK; + + if (socketpair(PF_UNIX, type, 0, pair) < 0) { + err(EXIT_FAILURE, "TEST FAILED: %s: failed to create socket " + "pair", c->clo_desc); + } + + oclo_record(c, tosend, c->clo_flags, "send fd"); + oclo_record(c, pair[0], c->clo_flags, "pair[0]"); + oclo_record(c, pair[1], c->clo_flags, "pair[1]"); + + iov.iov_base = (void *)&data; + iov.iov_len = sizeof (data); + + (void) memset(&msg, 0, sizeof (msg)); + msg.msg_iov = &iov; + msg.msg_iovlen = 1; + msg.msg_controllen = CMSG_SPACE(sizeof (int)); + + msg.msg_control = calloc(1, msg.msg_controllen); + if (msg.msg_control == NULL) { + err(EXIT_FAILURE, "TEST FAILED: %s: failed to allocate %u " + "bytes for SCM_RIGHTS control message", c->clo_desc, + msg.msg_controllen); + } + + cm = CMSG_FIRSTHDR(&msg); + cm->cmsg_len = CMSG_LEN(sizeof (int)); + cm->cmsg_level = SOL_SOCKET; + cm->cmsg_type = SCM_RIGHTS; + (void) memcpy(CMSG_DATA(cm), &tosend, sizeof (tosend)); + + if ((targ_flags & FD_CLOEXEC) != 0) + sflags |= MSG_CMSG_CLOEXEC; + if ((targ_flags & FD_CLOFORK) != 0) + sflags |= MSG_CMSG_CLOFORK; + + if (sendmsg(pair[0], &msg, 0) < 0) { + err(EXIT_FAILURE, "TEST FAILED: %s: failed to send fd", + c->clo_desc); + } + + data = 0; + if (recvmsg(pair[1], &msg, sflags) < 0) { + err(EXIT_FAILURE, "TEST FAILED: %s: failed to get fd", + c->clo_desc); + } + + if (data != 0x7777) { + errx(EXIT_FAILURE, "TEST FAILED: %s: did not receive correct " + "data: expected 0x7777, found 0x%x", c->clo_desc, data); + } + + if (msg.msg_controllen < CMSG_SPACE(sizeof (int))) { + errx(EXIT_FAILURE, "TEST FAILED: %s: found insufficient " + "message control length: expected at least 0x%zx, found " + "0x%x", c->clo_desc, CMSG_SPACE(sizeof (int)), + msg.msg_controllen); + } + + cm = CMSG_FIRSTHDR(&msg); + if (cm->cmsg_level != SOL_SOCKET || cm->cmsg_type != SCM_RIGHTS) { + errx(EXIT_FAILURE, "TEST FAILED: %s: found surprising cmsg " + "0x%x/0x%x, expected 0x%x/0x%x", c->clo_desc, + cm->cmsg_level, cm->cmsg_type, SOL_SOCKET, SCM_RIGHTS); + } + + if (cm->cmsg_len != CMSG_LEN(sizeof (int))) { + errx(EXIT_FAILURE, "TEST FAILED: %s: found unexpected " + "SCM_RIGHTS length 0x%x: expected 0x%zx", c->clo_desc, + cm->cmsg_len, CMSG_LEN(sizeof (int))); + } + + (void) memcpy(&recvfd, CMSG_DATA(cm), sizeof (recvfd)); + oclo_record(c, recvfd, targ_flags, "SCM_RIGHTS"); +} + +static void +oclo_rights_none(const clo_create_t *c) +{ + oclo_rights_common(c, 0); +} + +static void +oclo_rights_exec(const clo_create_t *c) +{ + oclo_rights_common(c, FD_CLOEXEC); +} + +static void +oclo_rights_fork(const clo_create_t *c) +{ + oclo_rights_common(c, FD_CLOFORK); +} + +static void +oclo_rights_both(const clo_create_t *c) +{ + oclo_rights_common(c, FD_CLOEXEC | FD_CLOFORK); +} + +static const clo_create_t oclo_create[] = { { + .clo_desc = "open(2), no flags", + .clo_flags = 0, + .clo_func = oclo_open +}, { + .clo_desc = "open(2), O_CLOEXEC", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_open +}, { + .clo_desc = "open(2), O_CLOFORK", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_open +}, { + .clo_desc = "open(2), O_CLOEXEC|O_CLOFORK", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_open +}, { + .clo_desc = "fcntl(F_SETFD) no flags->no flags", + .clo_flags = 0, + .clo_func = oclo_setfd_none +}, { + .clo_desc = "fcntl(F_SETFD) O_CLOFORK|O_CLOEXEC->no flags", + .clo_flags = O_CLOFORK | O_CLOEXEC, + .clo_func = oclo_setfd_none +}, { + .clo_desc = "fcntl(F_SETFD) O_CLOEXEC->no flags", + .clo_flags = O_CLOEXEC, + .clo_func = oclo_setfd_none +}, { + .clo_desc = "fcntl(F_SETFD) O_CLOFORK->no flags", + .clo_flags = O_CLOFORK, + .clo_func = oclo_setfd_none +}, { + .clo_desc = "fcntl(F_SETFD) no flags->O_CLOEXEC", + .clo_flags = 0, + .clo_func = oclo_setfd_exec +}, { + .clo_desc = "fcntl(F_SETFD) O_CLOFORK|O_CLOEXEC->O_CLOEXEC", + .clo_flags = O_CLOFORK | O_CLOEXEC, + .clo_func = oclo_setfd_exec +}, { + .clo_desc = "fcntl(F_SETFD) O_CLOEXEC->O_CLOEXEC", + .clo_flags = O_CLOEXEC, + .clo_func = oclo_setfd_exec +}, { + .clo_desc = "fcntl(F_SETFD) O_CLOFORK->O_CLOEXEC", + .clo_flags = O_CLOFORK, + .clo_func = oclo_setfd_exec +}, { + .clo_desc = "fcntl(F_SETFD) no flags->O_CLOFORK", + .clo_flags = 0, + .clo_func = oclo_setfd_fork +}, { + .clo_desc = "fcntl(F_SETFD) O_CLOFORK|O_CLOEXEC->O_CLOFORK", + .clo_flags = O_CLOFORK | O_CLOEXEC, + .clo_func = oclo_setfd_fork +}, { + .clo_desc = "fcntl(F_SETFD) O_CLOEXEC->O_CLOFORK", + .clo_flags = O_CLOEXEC, + .clo_func = oclo_setfd_fork +}, { + .clo_desc = "fcntl(F_SETFD) O_CLOFORK->O_CLOFORK", + .clo_flags = O_CLOFORK, + .clo_func = oclo_setfd_fork +}, { + .clo_desc = "fcntl(F_SETFD) no flags->O_CLOFORK|O_CLOEXEC", + .clo_flags = 0, + .clo_func = oclo_setfd_both +}, { + .clo_desc = "fcntl(F_SETFD) O_CLOFORK|O_CLOEXEC->O_CLOFORK|O_CLOEXEC", + .clo_flags = O_CLOFORK | O_CLOEXEC, + .clo_func = oclo_setfd_both +}, { + .clo_desc = "fcntl(F_SETFD) O_CLOEXEC->O_CLOFORK|O_CLOEXEC", + .clo_flags = O_CLOEXEC, + .clo_func = oclo_setfd_both +}, { + .clo_desc = "fcntl(F_SETFD) O_CLOFORK->O_CLOFORK|O_CLOEXEC", + .clo_flags = O_CLOFORK, + .clo_func = oclo_setfd_both +}, { + .clo_desc = "fcntl(F_DUPFD) none->none", + .clo_flags = 0, + .clo_func = oclo_fdupfd +}, { + .clo_desc = "fcntl(F_DUPFD) FD_CLOEXEC->none", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_fdupfd +}, { + .clo_desc = "fcntl(F_DUPFD) FD_CLOFORK->none", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_fdupfd +}, { + .clo_desc = "fcntl(F_DUPFD) FD_CLOEXEC|FD_CLOFORK->none", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_fdupfd +}, { + .clo_desc = "fcntl(F_DUPFD_CLOFORK) none", + .clo_flags = 0, + .clo_func = oclo_fdupfd_fork +}, { + .clo_desc = "fcntl(F_DUPFD_CLOFORK) FD_CLOEXEC", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_fdupfd_fork +}, { + .clo_desc = "fcntl(F_DUPFD_CLOFORK) FD_CLOFORK", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_fdupfd_fork +}, { + .clo_desc = "fcntl(F_DUPFD_CLOFORK) FD_CLOEXEC|FD_CLOFORK", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_fdupfd_fork +}, { + .clo_desc = "fcntl(F_DUPFD_CLOEXEC) none", + .clo_flags = 0, + .clo_func = oclo_fdupfd_exec +}, { + .clo_desc = "fcntl(F_DUPFD_CLOEXEC) FD_CLOEXEC", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_fdupfd_exec +}, { + .clo_desc = "fcntl(F_DUPFD_CLOEXEC) FD_CLOFORK", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_fdupfd_exec +}, { + .clo_desc = "fcntl(F_DUPFD_CLOEXEC) FD_CLOEXEC|FD_CLOFORK", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_fdupfd_exec +}, { + .clo_desc = "fcntl(F_DUP2FD) none->none", + .clo_flags = 0, + .clo_func = oclo_fdup2fd +}, { + .clo_desc = "fcntl(F_DUP2FD) FD_CLOEXEC->none", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_fdup2fd +}, { + .clo_desc = "fcntl(F_DUP2FD) FD_CLOFORK->none", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_fdup2fd +}, { + .clo_desc = "fcntl(F_DUP2FD) FD_CLOEXEC|FD_CLOFORK->none", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_fdup2fd +}, { +#ifdef F_DUP2FD_CLOFORK + .clo_desc = "fcntl(F_DUP2FD_CLOFORK) none", + .clo_flags = 0, + .clo_func = oclo_fdup2fd_fork +}, { + .clo_desc = "fcntl(F_DUP2FD_CLOFORK) FD_CLOEXEC", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_fdup2fd_fork +}, { + .clo_desc = "fcntl(F_DUP2FD_CLOFORK) FD_CLOFORK", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_fdup2fd_fork +}, { + .clo_desc = "fcntl(F_DUP2FD_CLOFORK) FD_CLOEXEC|FD_CLOFORK", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_fdup2fd_fork +}, { +#endif + .clo_desc = "fcntl(F_DUP2FD_CLOEXEC) none", + .clo_flags = 0, + .clo_func = oclo_fdup2fd_exec +}, { + .clo_desc = "fcntl(F_DUP2FD_CLOEXEC) FD_CLOEXEC", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_fdup2fd_exec +}, { + .clo_desc = "fcntl(F_DUP2FD_CLOEXEC) FD_CLOFORK", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_fdup2fd_exec +}, { + .clo_desc = "fcntl(F_DUP2FD_CLOEXEC) FD_CLOEXEC|FD_CLOFORK", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_fdup2fd_exec +}, { + .clo_desc = "fcntl(F_DUP3FD) none->none", + .clo_flags = 0, + .clo_func = oclo_fdup3fd_none +}, { + .clo_desc = "fcntl(F_DUP3FD) FD_CLOEXEC->none", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_fdup3fd_none +}, { + .clo_desc = "fcntl(F_DUP3FD) FD_CLOFORK->none", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_fdup3fd_none +}, { + .clo_desc = "fcntl(F_DUP3FD) FD_CLOEXEC|FD_CLOFORK->none", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_fdup3fd_none +}, { + .clo_desc = "fcntl(F_DUP3FD) none->FD_CLOEXEC", + .clo_flags = 0, + .clo_func = oclo_fdup3fd_exec +}, { + .clo_desc = "fcntl(F_DUP3FD) FD_CLOEXEC->FD_CLOEXEC", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_fdup3fd_exec +}, { + .clo_desc = "fcntl(F_DUP3FD) FD_CLOFORK->FD_CLOEXEC", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_fdup3fd_exec +}, { + .clo_desc = "fcntl(F_DUP3FD) FD_CLOEXEC|FD_CLOFORK->FD_CLOEXEC", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_fdup3fd_exec +}, { + .clo_desc = "fcntl(F_DUP3FD) none->FD_CLOFORK|FD_CLOEXEC", + .clo_flags = 0, + .clo_func = oclo_fdup3fd_both +}, { + .clo_desc = "fcntl(F_DUP3FD) FD_CLOEXEC->FD_CLOFORK|FD_CLOEXEC", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_fdup3fd_both +}, { + .clo_desc = "fcntl(F_DUP3FD) FD_CLOFORK->FD_CLOFORK|FD_CLOEXEC", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_fdup3fd_both +}, { + .clo_desc = "fcntl(F_DUP3FD) FD_CLOEXEC|FD_CLOFORK->" + "FD_CLOFORK|FD_CLOEXEC", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_fdup3fd_both +}, { + .clo_desc = "fcntl(F_DUP3FD) none->FD_CLOFORK", + .clo_flags = 0, + .clo_func = oclo_fdup3fd_fork +}, { + .clo_desc = "fcntl(F_DUP3FD) FD_CLOEXEC->FD_CLOFORK", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_fdup3fd_fork +}, { + .clo_desc = "fcntl(F_DUP3FD) FD_CLOFORK->FD_CLOFORK", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_fdup3fd_fork +}, { + .clo_desc = "fcntl(F_DUP3FD) FD_CLOEXEC|FD_CLOFORK->FD_CLOFORK", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_fdup3fd_fork +}, { + .clo_desc = "dup2() none->none", + .clo_flags = 0, + .clo_func = oclo_dup2 +}, { + .clo_desc = "dup2() FD_CLOEXEC->none", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_dup2 +}, { + .clo_desc = "dup2() FD_CLOFORK->none", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_dup2 +}, { + .clo_desc = "dup2() FD_CLOEXEC|FD_CLOFORK->none", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_dup2 +}, { + .clo_desc = "dup3() none->none", + .clo_flags = 0, + .clo_func = oclo_dup3_none +}, { + .clo_desc = "dup3() FD_CLOEXEC->none", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_dup3_none +}, { + .clo_desc = "dup3() FD_CLOFORK->none", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_dup3_none +}, { + .clo_desc = "dup3() FD_CLOEXEC|FD_CLOFORK->none", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_dup3_none +}, { + .clo_desc = "dup3() none->FD_CLOEXEC", + .clo_flags = 0, + .clo_func = oclo_dup3_exec +}, { + .clo_desc = "dup3() FD_CLOEXEC->FD_CLOEXEC", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_dup3_exec +}, { + .clo_desc = "dup3() FD_CLOFORK->FD_CLOEXEC", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_dup3_exec +}, { + .clo_desc = "dup3() FD_CLOEXEC|FD_CLOFORK->FD_CLOEXEC", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_dup3_exec +}, { + .clo_desc = "dup3() none->FD_CLOFORK|FD_CLOEXEC", + .clo_flags = 0, + .clo_func = oclo_dup3_both +}, { + .clo_desc = "dup3() FD_CLOEXEC->FD_CLOFORK|FD_CLOEXEC", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_dup3_both +}, { + .clo_desc = "dup3() FD_CLOFORK->FD_CLOFORK|FD_CLOEXEC", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_dup3_both +}, { + .clo_desc = "dup3() FD_CLOEXEC|FD_CLOFORK->FD_CLOFORK|FD_CLOEXEC", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_dup3_both +}, { + .clo_desc = "dup3() none->FD_CLOFORK", + .clo_flags = 0, + .clo_func = oclo_dup3_fork +}, { + .clo_desc = "dup3() FD_CLOEXEC->FD_CLOFORK", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_dup3_fork +}, { + .clo_desc = "dup3() FD_CLOFORK->FD_CLOFORK", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_dup3_fork +}, { + .clo_desc = "dup3() FD_CLOEXEC|FD_CLOFORK->FD_CLOFORK", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_dup3_fork +}, { + .clo_desc = "pipe(2), no flags", + .clo_flags = 0, + .clo_func = oclo_pipe +}, { + .clo_desc = "pipe(2), O_CLOEXEC", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_pipe +}, { + .clo_desc = "pipe(2), O_CLOFORK", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_pipe +}, { + .clo_desc = "pipe(2), O_CLOEXEC|O_CLOFORK", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_pipe +}, { + .clo_desc = "socket(2), no flags", + .clo_flags = 0, + .clo_func = oclo_socket +}, { + .clo_desc = "socket(2), O_CLOEXEC", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_socket +}, { + .clo_desc = "socket(2), O_CLOFORK", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_socket +}, { + .clo_desc = "socket(2), O_CLOEXEC|O_CLOFORK", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_socket +}, { + .clo_desc = "socket(2), no flags->accept() none", + .clo_flags = 0, + .clo_func = oclo_accept +}, { + .clo_desc = "socket(2), O_CLOEXEC->accept() none", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_accept +}, { + .clo_desc = "socket(2), O_CLOFORK->accept() none", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_accept +}, { + .clo_desc = "socket(2), O_CLOEXEC|O_CLOFORK->accept() none", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_accept +}, { + .clo_desc = "socket(2), no flags->accept4() none", + .clo_flags = 0, + .clo_func = oclo_accept4_none +}, { + .clo_desc = "socket(2), O_CLOEXEC->accept4() none", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_accept4_none +}, { + .clo_desc = "socket(2), O_CLOFORK->accept4() none", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_accept4_none +}, { + .clo_desc = "socket(2), O_CLOEXEC|O_CLOFORK->accept4() none", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_accept4_none +}, { + .clo_desc = "socket(2), no flags->accept4() SOCK_CLOFORK|SOCK_CLOEXEC", + .clo_flags = 0, + .clo_func = oclo_accept4_both +}, { + .clo_desc = "socket(2), O_CLOEXEC->accept4() SOCK_CLOFORK|SOCK_CLOEXEC", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_accept4_both +}, { + .clo_desc = "socket(2), O_CLOFORK->accept4() SOCK_CLOFORK|SOCK_CLOEXEC", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_accept4_both +}, { + .clo_desc = "socket(2), O_CLOEXEC|O_CLOFORK->accept4() " + "SOCK_CLOFORK|SOCK_CLOEXEC", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_accept4_both +}, { + .clo_desc = "socket(2), no flags->accept4() SOCK_CLOFORK", + .clo_flags = 0, + .clo_func = oclo_accept4_fork +}, { + .clo_desc = "socket(2), O_CLOEXEC->accept4() SOCK_CLOFORK", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_accept4_fork +}, { + .clo_desc = "socket(2), O_CLOFORK->accept4() SOCK_CLOFORK", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_accept4_fork +}, { + .clo_desc = "socket(2), O_CLOEXEC|O_CLOFORK->accept4() SOCK_CLOFORK", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_accept4_fork +}, { + .clo_desc = "socket(2), no flags->accept4() SOCK_CLOEXEC", + .clo_flags = 0, + .clo_func = oclo_accept4_exec +}, { + .clo_desc = "socket(2), O_CLOEXEC->accept4() SOCK_CLOEXEC", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_accept4_exec +}, { + .clo_desc = "socket(2), O_CLOFORK->accept4() SOCK_CLOEXEC", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_accept4_exec +}, { + .clo_desc = "socket(2), O_CLOEXEC|O_CLOFORK->accept4() SOCK_CLOEXEC", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_accept4_exec +}, { + .clo_desc = "SCM_RIGHTS none->none", + .clo_flags = 0, + .clo_func = oclo_rights_none +}, { + .clo_desc = "SCM_RIGHTS FD_CLOFORK->none", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_rights_none +}, { + .clo_desc = "SCM_RIGHTS FD_CLOEXEC->none", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_rights_none +}, { + .clo_desc = "SCM_RIGHTS FD_CLOEXEC|FD_CLOFORK->none", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_rights_none +}, { + .clo_desc = "SCM_RIGHTS none->MSG_CMSG_CLOEXEC", + .clo_flags = 0, + .clo_func = oclo_rights_exec +}, { + .clo_desc = "SCM_RIGHTS FD_CLOFORK->MSG_CMSG_CLOEXEC", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_rights_exec +}, { + .clo_desc = "SCM_RIGHTS FD_CLOEXEC->MSG_CMSG_CLOEXEC", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_rights_exec +}, { + .clo_desc = "SCM_RIGHTS FD_CLOEXEC|FD_CLOFORK->MSG_CMSG_CLOEXEC", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_rights_exec +}, { + .clo_desc = "SCM_RIGHTS MSG_CMSG_CLOFORK->nMSG_CMSG_CLOFORK", + .clo_flags = 0, + .clo_func = oclo_rights_fork +}, { + .clo_desc = "SCM_RIGHTS FD_CLOFORK->MSG_CMSG_CLOFORK", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_rights_fork +}, { + .clo_desc = "SCM_RIGHTS FD_CLOEXEC->MSG_CMSG_CLOFORK", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_rights_fork +}, { + .clo_desc = "SCM_RIGHTS FD_CLOEXEC|FD_CLOFORK->MSG_CMSG_CLOFORK", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_rights_fork +}, { + .clo_desc = "SCM_RIGHTS none->MSG_CMSG_CLOEXEC|MSG_CMSG_CLOFORK", + .clo_flags = 0, + .clo_func = oclo_rights_both +}, { + .clo_desc = "SCM_RIGHTS FD_CLOFORK->MSG_CMSG_CLOEXEC|MSG_CMSG_CLOFORK", + .clo_flags = FD_CLOFORK, + .clo_func = oclo_rights_both +}, { + .clo_desc = "SCM_RIGHTS FD_CLOEXEC->MSG_CMSG_CLOEXEC|MSG_CMSG_CLOFORK", + .clo_flags = FD_CLOEXEC, + .clo_func = oclo_rights_both +}, { + .clo_desc = "SCM_RIGHTS FD_CLOEXEC|FD_CLOFORK->" + "MSG_CMSG_CLOEXEC|MSG_CMSG_CLOFORK", + .clo_flags = FD_CLOEXEC | FD_CLOFORK, + .clo_func = oclo_rights_both +} }; + +static bool +oclo_verify_fork(void) +{ + bool ret = true; + + for (size_t i = 0; i < oclo_rtdata_next; i++) { + if (!oclo_flags_match(&oclo_rtdata[i], true)) { + ret = false; + } + } + + return (ret); +} + +/* + * Here we proceed to re-open any fd that was closed due to O_CLOFORK again to + * make sure that the file descriptor makes it to our child verifier. + * Importantly, with the changes that cause O_CLOFORK to be cleared on exec, we + * should not see any file descriptors with the flag in the child. This allows + * us to confirm that this is what we expect. + * + * In addition, this serves as a test to make sure that our opening of the + * lowest fd is correct. While this doesn't actually use the same method as was + * done previously, this should get us most of the way there. + */ +static void +oclo_child_reopen(void) +{ + for (size_t i = 0; i < oclo_rtdata_next; i++) { + int fd; + int flags = O_RDWR | O_CLOFORK; + + if ((oclo_rtdata[i].crt_flags & FD_CLOFORK) == 0) + continue; + + if ((oclo_rtdata[i].crt_flags & FD_CLOEXEC) != 0) + flags |= O_CLOEXEC; + + fd = open("/dev/zero", flags); + if (fd < 0) { + err(EXIT_FAILURE, "TEST FAILED: failed to re-open fd " + "%d with flags %d", oclo_rtdata[i].crt_fd, flags); + } + + if (fd != oclo_rtdata[i].crt_fd) { + errx(EXIT_FAILURE, "TEST FAILED: re-opening fd %d " + "returned fd %d: test design issue or lowest fd " + "algorithm is broken", oclo_rtdata[i].crt_fd, fd); + } + } + + (void) printf("TEST PASSED: successfully reopened fds post-fork"); +} + +/* + * Look for the verification program in the same directory that this program is + * found in. Note, that isn't the same thing as the current working directory. + */ +static void +oclo_exec(void) +{ + ssize_t ret; + char dir[PATH_MAX], file[PATH_MAX]; + char **argv; + + ret = getpathname(getpid(), dir, sizeof(dir)); + if (ret < 0) + err(EXIT_FAILURE, "TEST FAILED: failed to read executable path"); + + if (snprintf(file, sizeof (file), "%s/%s", dirname(dir), OCLO_VERIFY) >= + (int)sizeof (file)) { + errx(EXIT_FAILURE, "TEST FAILED: cannot assemble exec path " + "name: internal buffer overflow"); + } + + /* We need an extra for both the NULL terminator and the program name */ + argv = calloc(oclo_rtdata_next + 2, sizeof (char *)); + if (argv == NULL) { + err(EXIT_FAILURE, "TEST FAILED: failed to allocate exec " + "argument array"); + } + + argv[0] = file; + for (size_t i = 0; i < oclo_rtdata_next; i++) { + if (asprintf(&argv[i + 1], "0x%x", oclo_rtdata[i].crt_flags) == + -1) { + err(EXIT_FAILURE, "TEST FAILED: failed to assemble " + "exec argument %zu", i + 1); + } + } + + (void) execv(file, argv); + warn("TEST FAILED: failed to exec verifier %s", file); +} + +int +main(void) +{ + int ret = EXIT_SUCCESS; + siginfo_t cret; + + /* + * Before we do anything else close all FDs that aren't standard. We + * don't want anything the test suite environment may have left behind. + */ + (void) closefrom(STDERR_FILENO + 1); + + /* + * Treat failure during this set up phase as a hard failure. There's no + * reason to continue if we can't successfully create the FDs we expect. + */ + for (size_t i = 0; i < nitems(oclo_create); i++) { + oclo_create[i].clo_func(&oclo_create[i]); + } + + pid_t child = fork(); + if (child == 0) { + if (!oclo_verify_fork()) { + ret = EXIT_FAILURE; + } + + oclo_child_reopen(); + + oclo_exec(); + ret = EXIT_FAILURE; + _exit(ret); + } + + if (waitid(P_PID, child, &cret, WEXITED) < 0) { + err(EXIT_FAILURE, "TEST FAILED: internal test failure waiting " + "for forked child to report"); + } + + if (cret.si_code != CLD_EXITED) { + warnx("TEST FAILED: child process did not successfully exit: " + "found si_code: %d", cret.si_code); + ret = EXIT_FAILURE; + } else if (cret.si_status != 0) { + warnx("TEST FAILED: child process did not exit with code 0: " + "found %d", cret.si_status); + ret = EXIT_FAILURE; + } + + if (ret == EXIT_SUCCESS) { + (void) printf("All tests passed successfully\n"); + } + + return (ret); +} diff --git a/cddl/contrib/opensolaris/tests/os-tests/tests/oclo/oclo_errors.c b/cddl/contrib/opensolaris/tests/os-tests/tests/oclo/oclo_errors.c new file mode 100644 index 000000000000..05b0c1a0839b --- /dev/null +++ b/cddl/contrib/opensolaris/tests/os-tests/tests/oclo/oclo_errors.c @@ -0,0 +1,202 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2024 Oxide Computer Company + */ + +/* + * Verify that unsupported flags will properly generate errors across the + * functions that we know perform strict error checking. This includes: + * + * o fcntl(..., F_DUP3FD, ...) + * o dup3() + * o pipe2() + * o socket() + * o accept4() + */ + +#include <netinet/in.h> +#include <sys/socket.h> + +#include <err.h> +#include <errno.h> +#include <fcntl.h> +#include <limits.h> +#include <stdbool.h> +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#define strerrorname_np(e) (sys_errlist[e]) + +static bool +oclo_check(const char *desc, const char *act, int ret, int e) +{ + if (ret >= 0) { + warnx("TEST FAILED: %s: fd was %s!", desc, act); + return (false); + } else if (errno != EINVAL) { + e = errno; + warnx("TEST FAILED: %s: failed with %s, expected " + "EINVAL", desc, strerrorname_np(e)); + return (false); + } + + (void) printf("TEST PASSED: %s: correctly failed with EINVAL\n", + desc); + return (true); +} + +static bool +oclo_dup3(const char *desc, int flags) +{ + int fd = dup3(STDERR_FILENO, 23, flags); + return (oclo_check(desc, "duplicated", fd, errno)); +} + +static bool +oclo_dup3fd(const char *desc, int flags) +{ + int fd = fcntl(STDERR_FILENO, F_DUP3FD | (flags << F_DUP3FD_SHIFT), 23); + return (oclo_check(desc, "duplicated", fd, errno)); +} + + +static bool +oclo_pipe2(const char *desc, int flags) +{ + int fds[2], ret; + + ret = pipe2(fds, flags); + return (oclo_check(desc, "piped", ret, errno)); +} + +#if 0 +static bool +oclo_socket(const char *desc, int type) +{ + int fd = socket(PF_UNIX, SOCK_STREAM | type, 0); + return (oclo_check(desc, "created", fd, errno)); +} +#endif + +static bool +oclo_accept(const char *desc, int flags) +{ + int sock, fd, e; + struct sockaddr_in in; + + sock = socket(PF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0); + if (sock < 0) { + warn("TEST FAILED: %s: failed to create listen socket", desc); + return (false); + } + + (void) memset(&in, 0, sizeof (in)); + in.sin_family = AF_INET; + in.sin_port = 0; + in.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + + if (bind(sock, (struct sockaddr *)&in, sizeof (in)) != 0) { + warn("TEST FAILED: %s: failed to bind socket", desc); + (void) close(sock); + return (false); + } + + if (listen(sock, 5) < 0) { + warn("TEST FAILED: %s: failed to listen on socket", desc); + (void) close(sock); + return (false); + } + + + fd = accept4(sock, NULL, NULL, flags); + e = errno; + (void) close(sock); + return (oclo_check(desc, "accepted", fd, e)); +} + +int +main(void) +{ + int ret = EXIT_SUCCESS; + + closefrom(STDERR_FILENO + 1); + + if (!oclo_dup3("dup3(): O_RDWR", O_RDWR)) { + ret = EXIT_FAILURE; + } + + if (!oclo_dup3("dup3(): O_NONBLOCK|O_CLOXEC", O_NONBLOCK | O_CLOEXEC)) { + ret = EXIT_FAILURE; + } + + if (!oclo_dup3("dup3(): O_CLOFORK|O_WRONLY", O_CLOFORK | O_WRONLY)) { + ret = EXIT_FAILURE; + } + + if (!oclo_dup3fd("fcntl(FDUP3FD): 0x7777", 0x7777)) { + ret = EXIT_FAILURE; + } + + if (!oclo_dup3fd("fcntl(FDUP3FD): FD_CLOEXEC|FD_CLOFORK + 1", + (FD_CLOEXEC | FD_CLOFORK) + 1)) { + ret = EXIT_FAILURE; + } + + if (!oclo_dup3fd("fcntl(FDUP3FD): INT_MAX", INT_MAX)) { + ret = EXIT_FAILURE; + } + + + if (!oclo_pipe2("pipe2(): O_RDWR", O_RDWR)) { + ret = EXIT_FAILURE; + } + + if (!oclo_pipe2("pipe2(): O_SYNC|O_CLOXEC", O_SYNC | O_CLOEXEC)) { + ret = EXIT_FAILURE; + } + + if (!oclo_pipe2("pipe2(): O_CLOFORK|O_WRONLY", O_CLOFORK | O_WRONLY)) { + ret = EXIT_FAILURE; + } + + if (!oclo_pipe2("pipe2(): INT32_MAX", INT32_MAX)) { + ret = EXIT_FAILURE; + } + +#if 0 /* These tests are known to fail on FreeBSD */ + if (!oclo_socket("socket(): INT32_MAX", INT32_MAX)) { + ret = EXIT_FAILURE; + } + + if (!oclo_socket("socket(): 3 << 25", 3 << 25)) { + ret = EXIT_FAILURE; + } +#endif + + if (!oclo_accept("accept4(): INT32_MAX", INT32_MAX)) { + ret = EXIT_FAILURE; + } + + if (!oclo_accept("accept4(): 3 << 25", 3 << 25)) { + ret = EXIT_FAILURE; + } + + if (ret == EXIT_SUCCESS) { + (void) printf("All tests completed successfully\n"); + } + + return (ret); +} diff --git a/cddl/contrib/opensolaris/tests/os-tests/tests/oclo/ocloexec_verify.c b/cddl/contrib/opensolaris/tests/os-tests/tests/oclo/ocloexec_verify.c new file mode 100644 index 000000000000..e33c61f03d54 --- /dev/null +++ b/cddl/contrib/opensolaris/tests/os-tests/tests/oclo/ocloexec_verify.c @@ -0,0 +1,154 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2025 Oxide Computer Company + */ + +/* + * Verify that our file descriptors starting after stderr are correct based upon + * the series of passed in arguments from the 'oclo' program. Arguments are + * passed as a string that represents the flags that were originally verified + * pre-fork/exec via fcntl(F_GETFD). In addition, anything that was originally + * closed because it had FD_CLOFORK set was reopened with the same flags. This + * allows us to verify that the combinations worked and that FD_CLOFORK was + * properly cleared. + */ + +#include <sys/types.h> +#include <sys/user.h> +#include <err.h> +#include <errno.h> +#include <fcntl.h> +#include <libutil.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#define strerrorname_np(e) (sys_errlist[e]) + +static int +getmaxfd(void) +{ + struct kinfo_file *files; + int i, cnt, max; + + if ((files = kinfo_getfile(getpid(), &cnt)) == NULL) + err(1, "kinfo_getfile"); + + max = -1; + for (i = 0; i < cnt; i++) + if (files[i].kf_fd > max) + max = files[i].kf_fd; + + free(files); + return (max); +} + +/* + * Our flags may have FD_CLOFORK set in them (anything with FD_CLOEXEC Should + * not exist by definition). FD_CLOFORK is supposed to be cleared on exec. We + * still indicate which file descriptors FD_CLOFORK so we can check where it + * wasn't cleared. + */ +static bool +verify_flags(int fd, int exp_flags) +{ + bool fail = (exp_flags & FD_CLOEXEC) != 0; + int flags = fcntl(fd, F_GETFD, NULL); + bool clofork = (exp_flags & FD_CLOFORK) != 0; + exp_flags &= ~FD_CLOFORK; + + if (flags < 0) { + int e = errno; + + if (fail) { + if (e == EBADF) { + (void) printf("TEST PASSED: post-exec fd %d: " + "flags 0x%x: correctly closed\n", fd, + exp_flags); + return (true); + } + + + warn("TEST FAILED: post-fork fd %d: expected fcntl to " + "fail with EBADF, but found %s", fd, + strerrorname_np(e)); + return (false); + } + + warnx("TEST FAILED: post-fork fd %d: fcntl(F_GETFD) " + "unexpectedly failed with %s, expected flags %d", fd, + strerrorname_np(e), exp_flags); + return (false); + } + + if (fail) { + warnx("TEST FAILED: post-fork fd %d: received flags %d, but " + "expected to fail based on flags %d", fd, flags, exp_flags); + return (false); + } + + if (clofork && (flags & FD_CLOFORK) != 0) { + warnx("TEST FAILED: post-fork fd %d (flags %d) retained " + "FD_CLOFORK, but it should have been cleared", fd, flags); + return (false); + } + + if (flags != exp_flags) { + warnx("TEST FAILED: post-exec fd %d: discovered flags 0x%x do " + "not match expected flags 0x%x", fd, flags, exp_flags); + return (false); + } + + (void) printf("TEST PASSED: post-exec fd %d: flags 0x%x: successfully " + "matched\n", fd, exp_flags); + return (true); +} + +int +main(int argc, char *argv[]) +{ + int maxfd; + int ret = EXIT_SUCCESS; + + /* + * We should have one argument for each fd we found, ignoring stdin, + * stdout, and stderr. argc will also have an additional entry for our + * program name, which we want to skip. Note, the last fd may not exist + * because it was marked for close, hence the use of '>' below. + */ + maxfd = getmaxfd(); + if (maxfd - 3 > argc - 1) { + errx(EXIT_FAILURE, "TEST FAILED: found more fds %d than " + "arguments %d", maxfd - 3, argc - 1); + } + + for (int i = 1; i < argc; i++) { + char *endptr; + int targ_fd = i + STDERR_FILENO; + errno = 0; + long long val = strtoll(argv[i], &endptr, 0); + + if (errno != 0 || *endptr != '\0' || + (val < 0 || val > (FD_CLOEXEC | FD_CLOFORK))) { + errx(EXIT_FAILURE, "TEST FAILED: failed to parse " + "argument %d: %s", i, argv[i]); + } + + if (!verify_flags(targ_fd, (int)val)) + ret = EXIT_FAILURE; + } + + return (ret); +} diff --git a/cddl/contrib/opensolaris/tools/ctf/common/memory.c b/cddl/contrib/opensolaris/tools/ctf/common/memory.c index e16044a8b672..66296c5b114d 100644 --- a/cddl/contrib/opensolaris/tools/ctf/common/memory.c +++ b/cddl/contrib/opensolaris/tools/ctf/common/memory.c @@ -44,6 +44,20 @@ memory_bailout(void) exit(1); } +int +xasprintf(char **s, const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start(ap, fmt); + ret = vasprintf(s, fmt, ap); + va_end(ap); + if (ret == -1) + memory_bailout(); + return (ret); +} + void * xmalloc(size_t size) { diff --git a/cddl/contrib/opensolaris/tools/ctf/common/memory.h b/cddl/contrib/opensolaris/tools/ctf/common/memory.h index 88ca31bec65a..72706b5f7fdb 100644 --- a/cddl/contrib/opensolaris/tools/ctf/common/memory.h +++ b/cddl/contrib/opensolaris/tools/ctf/common/memory.h @@ -39,6 +39,7 @@ extern "C" { #endif +int xasprintf(char **, const char *, ...); void *xmalloc(size_t); void *xcalloc(size_t); char *xstrdup(const char *); diff --git a/cddl/contrib/opensolaris/tools/ctf/common/utils.c b/cddl/contrib/opensolaris/tools/ctf/common/utils.c index f74eb8de40fa..fda29486d94b 100644 --- a/cddl/contrib/opensolaris/tools/ctf/common/utils.c +++ b/cddl/contrib/opensolaris/tools/ctf/common/utils.c @@ -35,30 +35,6 @@ /*LINTLIBRARY*/ -static const char *pname; - -#pragma init(getpname) -const char * -getpname(void) -{ - const char *p, *q; - - if (pname != NULL) - return (pname); - - if ((p = getexecname()) != NULL) - q = strrchr(p, '/'); - else - q = NULL; - - if (q == NULL) - pname = p; - else - pname = q + 1; - - return (pname); -} - void vdie(const char *format, va_list alist) { diff --git a/cddl/contrib/opensolaris/tools/ctf/common/utils.h b/cddl/contrib/opensolaris/tools/ctf/common/utils.h index 99378bb4f251..6918bdab89aa 100644 --- a/cddl/contrib/opensolaris/tools/ctf/common/utils.h +++ b/cddl/contrib/opensolaris/tools/ctf/common/utils.h @@ -42,8 +42,6 @@ extern "C" { extern void vdie(const char *, va_list); extern void die(const char *, ...); -extern const char *getpname(void); - #ifdef __cplusplus } #endif diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c index 161927cf0663..c5be22ecfa1b 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/ctfmerge.c @@ -886,7 +886,7 @@ main(int argc, char **argv) for (i = 0; i < nifiles; i++) tifiles[i] = argv[optind + i]; - qsort(tifiles, nifiles, sizeof (char *), (int (*)())strcompare); + qsort(tifiles, nifiles, sizeof (char *), strcompare); ifiles[0] = tifiles[0]; for (idx = 0, tidx = 1; tidx < nifiles; tidx++) { @@ -912,14 +912,8 @@ main(int argc, char **argv) */ if (read_ctf(ifiles, nifiles, NULL, merge_ctf_cb, &wq, require_ctf) == 0) { - /* - * If we're verifying that C files have CTF, it's safe to - * assume that in this case, we're building only from assembly - * inputs. - */ - if (require_ctf) - exit(0); - terminate("No ctf sections found to merge\n"); + warning("No ctf sections found to merge\n"); + exit(0); } pthread_mutex_lock(&wq.wq_queue_lock); diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c index 2d686e53fed1..42faaad65db5 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/dwarf.c @@ -618,7 +618,7 @@ tdesc_intr_long(dwarf_t *dw) * caller can then use the copy as the type for a bitfield structure member. */ static tdesc_t * -tdesc_intr_clone(dwarf_t *dw, tdesc_t *old, size_t bitsz) +tdesc_intr_clone(dwarf_t *dw, tdesc_t *old, size_t bitsz, const char *suffix) { tdesc_t *new = xcalloc(sizeof (tdesc_t)); @@ -627,7 +627,7 @@ tdesc_intr_clone(dwarf_t *dw, tdesc_t *old, size_t bitsz) "unresolved type\n", old->t_id); } - new->t_name = xstrdup(old->t_name); + xasprintf(&new->t_name, "%s %s", old->t_name, suffix); new->t_size = old->t_size; new->t_id = mfgtid_next(dw); new->t_type = INTRINSIC; @@ -1004,7 +1004,9 @@ die_sou_create(dwarf_t *dw, Dwarf_Die str, Dwarf_Off off, tdesc_t *tdp, else ml->ml_size = tdesc_bitsize(ml->ml_type); - if (die_unsigned(dw, mem, DW_AT_bit_offset, &bitoff, 0)) { + if (die_unsigned(dw, mem, DW_AT_data_bit_offset, &bitoff, 0)) { + ml->ml_offset += bitoff; + } else if (die_unsigned(dw, mem, DW_AT_bit_offset, &bitoff, 0)) { #if BYTE_ORDER == _BIG_ENDIAN ml->ml_offset += bitoff; #else @@ -1158,7 +1160,8 @@ die_sou_resolve(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private) debug(3, "tdp %u: creating bitfield for %d bits\n", tdp->t_id, ml->ml_size); - ml->ml_type = tdesc_intr_clone(dw, mt, ml->ml_size); + ml->ml_type = tdesc_intr_clone(dw, mt, ml->ml_size, + "bitfield"); } } @@ -1366,7 +1369,7 @@ static const fp_size_map_t fp_encodings[] = { }; static uint_t -die_base_type2enc(dwarf_t *dw, Dwarf_Off off, Dwarf_Signed enc, size_t sz) +die_base_type2enc(dwarf_t *dw, Dwarf_Off off, Dwarf_Unsigned enc, size_t sz) { const fp_size_map_t *map = fp_encodings; uint_t szidx = dw->dw_ptrsz == sizeof (uint64_t); @@ -1397,9 +1400,9 @@ static intr_t * die_base_from_dwarf(dwarf_t *dw, Dwarf_Die base, Dwarf_Off off, size_t sz) { intr_t *intr = xcalloc(sizeof (intr_t)); - Dwarf_Signed enc; + Dwarf_Unsigned enc; - (void) die_signed(dw, base, DW_AT_encoding, &enc, DW_ATTR_REQ); + (void) die_unsigned(dw, base, DW_AT_encoding, &enc, DW_ATTR_REQ); switch (enc) { case DW_ATE_unsigned: diff --git a/cddl/contrib/opensolaris/tools/ctf/dump/dump.c b/cddl/contrib/opensolaris/tools/ctf/dump/dump.c index 06c00a7b0e7f..5cbf46af1b73 100644 --- a/cddl/contrib/opensolaris/tools/ctf/dump/dump.c +++ b/cddl/contrib/opensolaris/tools/ctf/dump/dump.c @@ -856,7 +856,7 @@ print_stats(void) static int print_usage(FILE *fp, int verbose) { - (void) fprintf(fp, "Usage: %s [-dfhlsSt] [-u file] file\n", getpname()); + (void) fprintf(fp, "Usage: %s [-dfhlsSt] [-u file] file\n", getprogname()); if (verbose) { (void) fprintf(fp, diff --git a/cddl/lib/Makefile b/cddl/lib/Makefile index 5ca0d56b291a..892798be347d 100644 --- a/cddl/lib/Makefile +++ b/cddl/lib/Makefile @@ -1,40 +1,32 @@ -# $FreeBSD$ - .include <src.opts.mk> -SUBDIR= drti \ - libavl \ +.if ${MK_DTRACE} == yes || ${MK_ZFS} == yes +SUBDIR= libspl +.endif + +SUBDIR.${MK_DTRACE}+= \ + drti \ libctf \ - libdtrace \ - ${_libicp} \ - ${_libicp_rescue} \ + libdtrace + +SUBDIR.${MK_TESTS}+= tests + +SUBDIR.${MK_ZFS}+= \ + libavl \ + libicp \ + libicp_rescue \ libnvpair \ - libspl \ - ${_libtpool} \ + libtpool \ libumem \ libuutil \ - ${_libzfs_core} \ - ${_libzfs} \ - ${_libzfsbootenv} \ - ${_libzpool} \ - ${_libzutil} \ - ${_pam_zfs_key} - -SUBDIR.${MK_TESTS}+= tests + libzdb \ + libzfs \ + libzfs_core \ + libzfsbootenv \ + libzpool \ + libzutil -.if ${MK_ZFS} != "no" -_libzfs_core= libzfs_core -_libicp= libicp -_libicp_rescue= libicp_rescue -_libzfs= libzfs -_libzutil= libzutil -_libzfsbootenv= libzfsbootenv -_libzpool= libzpool -_libtpool= libtpool -.if ${MK_OPENSSL} != "no" -_pam_zfs_key= pam_zfs_key -.endif -.endif +SUBDIR.${MK_ZFS}.${MK_OPENSSL} = pam_zfs_key SUBDIR_DEPEND_libavl= libspl SUBDIR_DEPEND_libctf= libspl diff --git a/cddl/lib/Makefile.inc b/cddl/lib/Makefile.inc index 8f9af1d17e9d..ebcc06f3e956 100644 --- a/cddl/lib/Makefile.inc +++ b/cddl/lib/Makefile.inc @@ -1,5 +1,3 @@ -# $FreeBSD$ - SHLIBDIR?= /lib SHLIB_MAJOR?= 2 diff --git a/cddl/lib/drti/Makefile b/cddl/lib/drti/Makefile index 321352c7100c..4a7a8350cac8 100644 --- a/cddl/lib/drti/Makefile +++ b/cddl/lib/drti/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libdtrace/common PACKAGE= dtrace diff --git a/cddl/lib/drti/Makefile.depend b/cddl/lib/drti/Makefile.depend index 422dbea77a29..2c564fe515ff 100644 --- a/cddl/lib/drti/Makefile.depend +++ b/cddl/lib/drti/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/lib/libavl/Makefile b/cddl/lib/libavl/Makefile index b5e3b458f982..ce77012def9f 100644 --- a/cddl/lib/libavl/Makefile +++ b/cddl/lib/libavl/Makefile @@ -1,8 +1,6 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/sys/contrib/openzfs/module/avl -PACKAGE= runtime +PACKAGE= libzfs LIB= avl LIBADD= spl SRCS= avl.c diff --git a/cddl/lib/libavl/Makefile.depend b/cddl/lib/libavl/Makefile.depend index 1c1a9bee1d67..409c3c86cc20 100644 --- a/cddl/lib/libavl/Makefile.depend +++ b/cddl/lib/libavl/Makefile.depend @@ -1,8 +1,9 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ + cddl/lib/libspl \ include \ + include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ diff --git a/cddl/lib/libctf/Makefile b/cddl/lib/libctf/Makefile index 860b327ca768..10854482cd21 100644 --- a/cddl/lib/libctf/Makefile +++ b/cddl/lib/libctf/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/cddl/contrib/opensolaris/common/ctf .PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libctf/common .PATH: ${SRCTOP}/sys/cddl/contrib/opensolaris/common/ctf diff --git a/cddl/lib/libctf/Makefile.depend b/cddl/lib/libctf/Makefile.depend index ec3b871042c4..7cbc01413fbc 100644 --- a/cddl/lib/libctf/Makefile.depend +++ b/cddl/lib/libctf/Makefile.depend @@ -1,7 +1,7 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ + cddl/lib/libspl \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git a/cddl/lib/libdtrace/Makefile b/cddl/lib/libdtrace/Makefile index f95517f10ebb..d086fffb07bc 100644 --- a/cddl/lib/libdtrace/Makefile +++ b/cddl/lib/libdtrace/Makefile @@ -1,10 +1,13 @@ -# $FreeBSD$ +SHLIBDIR?= /lib + +.include <src.opts.mk> .PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libdtrace/common .PATH: ${SRCTOP}/cddl/contrib/opensolaris/lib/libgen/common PACKAGE= dtrace LIB= dtrace + SRCS= dt_aggregate.c \ dt_as.c \ dt_buf.c \ @@ -84,6 +87,7 @@ CFLAGS+= -DHAVE_ISSETUGID CFLAGS+= -I${.OBJDIR} -I${.CURDIR} \ -I${SRCTOP}/sys/cddl/dev/dtrace/${MACHINE_ARCH} \ + -I${SRCTOP}/sys/cddl/dev/kinst \ -I${SRCTOP}/sys/cddl/compat/opensolaris \ -I${SRCTOP}/cddl/compat/opensolaris/include \ -I${OPENSOLARIS_USR_DISTDIR}/head \ @@ -121,13 +125,28 @@ CFLAGS+= -I${OPENSOLARIS_SYS_DISTDIR}/uts/intel .endif .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" -SRCS+= dis_tables.c +SRCS+= dis_tables.c instr_size.c DSRCS+= regs_x86.d .endif +.if ${MACHINE_CPUARCH} == "riscv" +SRCS+= instr_size.c +DSRCS+= regs_riscv.d +.endif + +.if ${MACHINE_CPUARCH} == "aarch64" +SRCS+= instr_size.c +DSRCS+= regs_aarch64.d +.endif + YFLAGS+=-d -LIBADD= ctf elf proc pthread rtld_db +.if ${MK_DTRACE_ASAN} != "no" +CFLAGS+= -fsanitize=address -fsanitize=undefined +LDFLAGS+= -fsanitize=address -fsanitize=undefined +.endif + +LIBADD= ctf elf proc pthread rtld_db xo CLEANFILES= dt_errtags.c dt_names.c diff --git a/cddl/lib/libdtrace/Makefile.depend b/cddl/lib/libdtrace/Makefile.depend index 68a8d3e9c520..92c6b0e658b5 100644 --- a/cddl/lib/libdtrace/Makefile.depend +++ b/cddl/lib/libdtrace/Makefile.depend @@ -1,9 +1,8 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ + bin/sh.host \ cddl/lib/libctf \ - gnu/lib/csu \ include \ include/arpa \ include/xlocale \ @@ -14,6 +13,7 @@ DIRDEPS = \ lib/libproc \ lib/librtld_db \ lib/libthr \ + usr.bin/awk.host \ usr.bin/yacc.host \ diff --git a/cddl/lib/libdtrace/errno.d b/cddl/lib/libdtrace/errno.d index 426d882b0db1..2045e3a7433d 100644 --- a/cddl/lib/libdtrace/errno.d +++ b/cddl/lib/libdtrace/errno.d @@ -21,8 +21,6 @@ * * Portions Copyright 2006-2008 John Birrell jb@freebsd.org * Portions Copyright 2018 Devin Teske dteske@freebsd.org - * - * $FreeBSD$ */ /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. diff --git a/cddl/lib/libdtrace/io.d b/cddl/lib/libdtrace/io.d index d643ad732a94..d576f57476ce 100644 --- a/cddl/lib/libdtrace/io.d +++ b/cddl/lib/libdtrace/io.d @@ -19,8 +19,6 @@ * CDDL HEADER END * * Portions Copyright 2018 Devin Teske dteske@freebsd.org - * - * $FreeBSD$ */ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. @@ -196,6 +194,8 @@ inline int DEVSTAT_TYPE_IF_IDE = 0x020; #pragma D binding "1.13" DEVSTAT_TYPE_IF_IDE inline int DEVSTAT_TYPE_IF_OTHER = 0x030; #pragma D binding "1.13" DEVSTAT_TYPE_IF_OTHER +inline int DEVSTAT_TYPE_IF_NVME = 0x040; +#pragma D binding "1.13" DEVSTAT_TYPE_IF_NVME inline int DEVSTAT_TYPE_IF_MASK = 0x0f0; #pragma D binding "1.13" DEVSTAT_TYPE_IF_MASK inline int DEVSTAT_TYPE_PASS = 0x100; @@ -230,6 +230,7 @@ inline string device_if_string[int type] = type == DEVSTAT_TYPE_IF_SCSI ? "SCSI" : type == DEVSTAT_TYPE_IF_IDE ? "IDE" : type == DEVSTAT_TYPE_IF_OTHER ? "OTHER" : + type == DEVSTAT_TYPE_IF_NVME ? "NVME" : strjoin("UNKNOWN(", strjoin(lltostr(type), ")")); #pragma D binding "1.13" device_if diff --git a/cddl/lib/libdtrace/ip.d b/cddl/lib/libdtrace/ip.d index f591a965af68..2fe98858efc2 100644 --- a/cddl/lib/libdtrace/ip.d +++ b/cddl/lib/libdtrace/ip.d @@ -17,8 +17,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD$ */ /* * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. @@ -264,8 +262,8 @@ inline int IFF_LOOPBACK = 0x8; #pragma D binding "1.5" translator translator ifinfo_t < struct ifnet *p > { - if_name = p->if_xname; - if_local = (p->if_flags & IFF_LOOPBACK) == 0 ? 0 : 1; + if_name = p == NULL ? "<unknown>" : p->if_xname; + if_local = p == NULL ? 0 : (p->if_flags & IFF_LOOPBACK) == 0 ? 0 : 1; if_addr = (uintptr_t)p; }; diff --git a/cddl/lib/libdtrace/libproc_compat.h b/cddl/lib/libdtrace/libproc_compat.h index 14f32506bb8f..7cdc8af18b56 100644 --- a/cddl/lib/libdtrace/libproc_compat.h +++ b/cddl/lib/libdtrace/libproc_compat.h @@ -25,8 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ /* @@ -58,10 +56,8 @@ #define Prd_agent proc_rdagent #define Prelease proc_detach #define Psetbkpt proc_bkptset -#define Psetflags proc_setflags #define Pstate proc_state #define Psymbol_iter_by_addr proc_iter_symbyaddr -#define Punsetflags proc_clearflags #define Pupdate_maps proc_rdagent #define Pupdate_syms proc_updatesyms #define Pxecbkpt proc_bkptexec diff --git a/cddl/lib/libdtrace/net.d b/cddl/lib/libdtrace/net.d index ee22c8ffb0cc..fef61ea31f4b 100644 --- a/cddl/lib/libdtrace/net.d +++ b/cddl/lib/libdtrace/net.d @@ -19,8 +19,6 @@ * CDDL HEADER END * * Portions Copyright 2006-2008 John Birrell jb@freebsd.org - * - * $FreeBSD$ */ /* diff --git a/cddl/lib/libdtrace/nfs.d b/cddl/lib/libdtrace/nfs.d index ae864ed363d2..4d55b39a809d 100644 --- a/cddl/lib/libdtrace/nfs.d +++ b/cddl/lib/libdtrace/nfs.d @@ -19,8 +19,6 @@ * CDDL HEADER END * * Portions Copyright 2006-2008 John Birrell jb@freebsd.org - * - * $FreeBSD$ */ /* diff --git a/cddl/lib/libdtrace/nfssrv.d b/cddl/lib/libdtrace/nfssrv.d index 37842f7963a1..b5231bf7a2ec 100644 --- a/cddl/lib/libdtrace/nfssrv.d +++ b/cddl/lib/libdtrace/nfssrv.d @@ -19,8 +19,6 @@ * CDDL HEADER END * * Portions Copyright 2006-2008 John Birrell jb@freebsd.org - * - * $FreeBSD$ */ /* diff --git a/cddl/lib/libdtrace/psinfo.d b/cddl/lib/libdtrace/psinfo.d index 0f5ca63c39a4..c0cd5b121064 100644 --- a/cddl/lib/libdtrace/psinfo.d +++ b/cddl/lib/libdtrace/psinfo.d @@ -20,8 +20,6 @@ * CDDL HEADER END * * Portions Copyright 2006 John Birrell jb@freebsd.org - * - * $FreeBSD$ */ /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. diff --git a/cddl/lib/libdtrace/regs_aarch64.d b/cddl/lib/libdtrace/regs_aarch64.d new file mode 100644 index 000000000000..7d20b5c546c5 --- /dev/null +++ b/cddl/lib/libdtrace/regs_aarch64.d @@ -0,0 +1,74 @@ +/* + * SPDX-License-Identifier: CDDL 1.0 + * + * Copyright 2023 Christos Margiolis <christos@FreeBSD.org> + */ + +inline int R_X0 = 0; +#pragma D binding "1.13" R_X0 +inline int R_X1 = 1; +#pragma D binding "1.13" R_X1 +inline int R_X2 = 2; +#pragma D binding "1.13" R_X2 +inline int R_X3 = 3; +#pragma D binding "1.13" R_X3 +inline int R_X4 = 4; +#pragma D binding "1.13" R_X4 +inline int R_X5 = 5; +#pragma D binding "1.13" R_X5 +inline int R_X6 = 6; +#pragma D binding "1.13" R_X6 +inline int R_X7 = 7; +#pragma D binding "1.13" R_X7 +inline int R_X8 = 8; +#pragma D binding "1.13" R_X8 +inline int R_X9 = 9; +#pragma D binding "1.13" R_X9 +inline int R_X10 = 10; +#pragma D binding "1.13" R_X10 +inline int R_X11 = 11; +#pragma D binding "1.13" R_X11 +inline int R_X12 = 12; +#pragma D binding "1.13" R_X12 +inline int R_X13 = 13; +#pragma D binding "1.13" R_X13 +inline int R_X14 = 14; +#pragma D binding "1.13" R_X14 +inline int R_X15 = 15; +#pragma D binding "1.13" R_X15 +inline int R_X16 = 16; +#pragma D binding "1.13" R_X16 +inline int R_X17 = 17; +#pragma D binding "1.13" R_X17 +inline int R_X18 = 18; +#pragma D binding "1.13" R_X18 +inline int R_X19 = 19; +#pragma D binding "1.13" R_X19 +inline int R_X20 = 20; +#pragma D binding "1.13" R_X20 +inline int R_X21 = 21; +#pragma D binding "1.13" R_X21 +inline int R_X22 = 22; +#pragma D binding "1.13" R_X22 +inline int R_X23 = 23; +#pragma D binding "1.13" R_X23 +inline int R_X24 = 24; +#pragma D binding "1.13" R_X24 +inline int R_X25 = 25; +#pragma D binding "1.13" R_X25 +inline int R_X26 = 26; +#pragma D binding "1.13" R_X26 +inline int R_X27 = 27; +#pragma D binding "1.13" R_X27 +inline int R_X28 = 28; +#pragma D binding "1.13" R_X28 +inline int R_X29 = 29; +#pragma D binding "1.13" R_X29 +inline int R_FP= 29; +#pragma D binding "1.13" R_FP +inline int R_LR = 30; +#pragma D binding "1.13" R_LR +inline int R_SP = 31; +#pragma D binding "1.13" R_SP +inline int R_PC = 32; +#pragma D binding "1.13" R_PC diff --git a/cddl/lib/libdtrace/regs_riscv.d b/cddl/lib/libdtrace/regs_riscv.d new file mode 100644 index 000000000000..e8a9667d2efd --- /dev/null +++ b/cddl/lib/libdtrace/regs_riscv.d @@ -0,0 +1,74 @@ +/* + * SPDX-License-Identifier: CDDL 1.0 + * + * Copyright 2023 Christos Margiolis <christos@FreeBSD.org> + */ + +inline int R_ZERO = 0; +#pragma D binding "1.13" R_ZERO +inline int R_RA = 1; +#pragma D binding "1.13" R_RA +inline int R_SP = 2; +#pragma D binding "1.13" R_SP +inline int R_GP = 3; +#pragma D binding "1.13" R_GP +inline int R_TP = 4; +#pragma D binding "1.13" R_TP +inline int R_T0 = 5; +#pragma D binding "1.13" R_T0 +inline int R_T1 = 6; +#pragma D binding "1.13" R_T1 +inline int R_T2 = 7; +#pragma D binding "1.13" R_T2 +inline int R_S0 = 8; +#pragma D binding "1.13" R_S0 +inline int R_FP = 8; +#pragma D binding "1.13" R_FP +inline int R_S1 = 9; +#pragma D binding "1.13" R_S1 +inline int R_A0 = 10; +#pragma D binding "1.13" R_A0 +inline int R_A1 = 11; +#pragma D binding "1.13" R_A1 +inline int R_A2 = 12; +#pragma D binding "1.13" R_A2 +inline int R_A3 = 13; +#pragma D binding "1.13" R_A3 +inline int R_A4 = 14; +#pragma D binding "1.13" R_A4 +inline int R_A5 = 15; +#pragma D binding "1.13" R_A5 +inline int R_A6 = 16; +#pragma D binding "1.13" R_A6 +inline int R_A7 = 17; +#pragma D binding "1.13" R_A7 +inline int R_S2 = 18; +#pragma D binding "1.13" R_S2 +inline int R_S3 = 19; +#pragma D binding "1.13" R_S3 +inline int R_S4 = 20; +#pragma D binding "1.13" R_S4 +inline int R_S5 = 21; +#pragma D binding "1.13" R_S5 +inline int R_S6 = 22; +#pragma D binding "1.13" R_S6 +inline int R_S7 = 23; +#pragma D binding "1.13" R_S7 +inline int R_S8 = 24; +#pragma D binding "1.13" R_S8 +inline int R_S9 = 25; +#pragma D binding "1.13" R_S9 +inline int R_S10 = 26; +#pragma D binding "1.13" R_S10 +inline int R_S11 = 27; +#pragma D binding "1.13" R_S11 +inline int R_T3 = 28; +#pragma D binding "1.13" R_T3 +inline int R_T4 = 29; +#pragma D binding "1.13" R_T4 +inline int R_T5 = 30; +#pragma D binding "1.13" R_T5 +inline int R_T6 = 31; +#pragma D binding "1.13" R_T6 +inline int R_PC = 32; +#pragma D binding "1.13" R_PC diff --git a/cddl/lib/libdtrace/regs_x86.d b/cddl/lib/libdtrace/regs_x86.d index 3f625f9f4445..2e31517fdd8d 100644 --- a/cddl/lib/libdtrace/regs_x86.d +++ b/cddl/lib/libdtrace/regs_x86.d @@ -20,8 +20,6 @@ * CDDL HEADER END * * Portions Copyright 2009 Stacey Son sson@FreeBSD.org - * - * $FreeBSD$ */ /* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. @@ -80,11 +78,11 @@ inline int R_R0 = R_EAX; inline int R_R1 = R_EBX; #pragma D binding "1.0" R_R1 -inline int R_RSP = 18 + 1 + 20; +inline int R_RSP = 18 + 1 + 24; #pragma D binding "1.0" R_RSP -inline int R_RFL = 18 + 1 + 19; +inline int R_RFL = 18 + 1 + 23; #pragma D binding "1.0" R_RFL -inline int R_RIP = 18 + 1 + 17; +inline int R_RIP = 18 + 1 + 21; #pragma D binding "1.0" R_RIP inline int R_RAX = 18 + 1 + 14; #pragma D binding "1.0" R_RAX diff --git a/cddl/lib/libdtrace/sched.d b/cddl/lib/libdtrace/sched.d index 82fdf3ab0c05..7eca118fc428 100644 --- a/cddl/lib/libdtrace/sched.d +++ b/cddl/lib/libdtrace/sched.d @@ -19,8 +19,6 @@ * CDDL HEADER END * * Portions Copyright 2006-2008 John Birrell jb@freebsd.org - * - * $FreeBSD$ */ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. diff --git a/cddl/lib/libdtrace/sctp.d b/cddl/lib/libdtrace/sctp.d index 5dc776bdb971..ef8c3bcc4a56 100644 --- a/cddl/lib/libdtrace/sctp.d +++ b/cddl/lib/libdtrace/sctp.d @@ -17,8 +17,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD$ */ /* * Copyright (c) 2018 Michael Tuexen <tuexen@FreeBSD.org> diff --git a/cddl/lib/libdtrace/siftr.d b/cddl/lib/libdtrace/siftr.d index 37bc30ff3e06..bca3a0f0df7f 100644 --- a/cddl/lib/libdtrace/siftr.d +++ b/cddl/lib/libdtrace/siftr.d @@ -17,10 +17,9 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD$ */ +#pragma D depends_on library ip.d #pragma D depends_on module kernel #pragma D depends_on module siftr #pragma D depends_on provider tcp @@ -29,9 +28,9 @@ * Convert a SIFTR direction value to a string */ #pragma D binding "1.12.1" SIFTR_IN -inline int SIFTR_IN = 1; +inline int SIFTR_IN = 0; #pragma D binding "1.12.1" SIFTR_OUT -inline int SIFTR_OUT = 2; +inline int SIFTR_OUT = 1; /* SIFTR direction strings. */ #pragma D binding "1.12.1" siftr_dir_string @@ -44,22 +43,23 @@ typedef struct siftrinfo { struct timeval tval; uint8_t direction; uint8_t ipver; - uint32_t hash; - uint16_t tcp_localport; - uint16_t tcp_foreignport; - uint64_t snd_cwnd; - u_long snd_wnd; - u_long rcv_wnd; - u_long snd_bwnd; - u_long snd_ssthresh; + uint16_t lport; + uint16_t rport; + string laddr; + string raddr; + uint32_t snd_cwnd; + uint32_t snd_wnd; + uint32_t rcv_wnd; + uint32_t t_flags2; + uint32_t snd_ssthresh; int conn_state; - u_int max_seg_size; - int smoothed_rtt; + uint32_t mss; + uint32_t srtt; u_char sack_enabled; u_char snd_scale; u_char rcv_scale; - u_int flags; - int rxt_length; + u_int t_flags; + uint32_t rto; u_int snd_buf_hiwater; u_int snd_buf_cc; u_int rcv_buf_hiwater; @@ -74,22 +74,29 @@ typedef struct siftrinfo { translator siftrinfo_t < struct pkt_node *p > { direction = p == NULL ? 0 : p->direction; ipver = p == NULL ? 0 : p->ipver; - hash = p == NULL ? 0 : p->hash; - tcp_localport = p == NULL ? 0 : ntohs(p->tcp_localport); - tcp_foreignport = p == NULL ? 0 : ntohs(p->tcp_foreignport); + lport = p == NULL ? 0 : ntohs(p->lport); + rport = p == NULL ? 0 : ntohs(p->fport); + laddr = p == NULL ? "<unknown>" : + p->ipver == INP_IPV4 ? + inet_ntoa(&p->laddr.id46_addr.ia46_addr4.s_addr) : + inet_ntoa6(&p->laddr.id6_addr); + raddr = p == NULL ? "<unknown>" : + p->ipver == INP_IPV4 ? + inet_ntoa(&p->faddr.id46_addr.ia46_addr4.s_addr) : + inet_ntoa6(&p->faddr.id6_addr); snd_cwnd = p == NULL ? 0 : p->snd_cwnd; snd_wnd = p == NULL ? 0 : p->snd_wnd; rcv_wnd = p == NULL ? 0 : p->rcv_wnd; - snd_bwnd = p == NULL ? 0 : p->snd_bwnd; + t_flags2 = p == NULL ? 0 : p->t_flags2; snd_ssthresh = p == NULL ? 0 : p->snd_ssthresh; conn_state = p == NULL ? 0 : p->conn_state; - max_seg_size = p == NULL ? 0 : p->max_seg_size; - smoothed_rtt = p == NULL ? 0 : p->smoothed_rtt; + mss = p == NULL ? 0 : p->mss; + srtt = p == NULL ? 0 : p->srtt; sack_enabled = p == NULL ? 0 : p->sack_enabled; snd_scale = p == NULL ? 0 : p->snd_scale; rcv_scale = p == NULL ? 0 : p->rcv_scale; - flags = p == NULL ? 0 : p->flags; - rxt_length = p == NULL ? 0 : p->rxt_length; + t_flags = p == NULL ? 0 : p->t_flags; + rto = p == NULL ? 0 : p->rto; snd_buf_hiwater = p == NULL ? 0 : p->snd_buf_hiwater; snd_buf_cc = p == NULL ? 0 : p->snd_buf_cc; rcv_buf_hiwater = p == NULL ? 0 : p->rcv_buf_hiwater; diff --git a/cddl/lib/libdtrace/signal.d b/cddl/lib/libdtrace/signal.d index cdd433883397..0f9b2567cc0d 100644 --- a/cddl/lib/libdtrace/signal.d +++ b/cddl/lib/libdtrace/signal.d @@ -21,8 +21,6 @@ * * Portions Copyright 2008 John Birrell jb@freebsd.org * Portions Copyright 2018 Devin Teske dteske@freebsd.org - * - * $FreeBSD$ */ inline int SIGHUP = 1; diff --git a/cddl/lib/libdtrace/socket.d b/cddl/lib/libdtrace/socket.d index da8f149b2d10..c8161f9b2d30 100644 --- a/cddl/lib/libdtrace/socket.d +++ b/cddl/lib/libdtrace/socket.d @@ -23,8 +23,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ - * * Translators and flags for the socket structure. FreeBSD specific code. */ diff --git a/cddl/lib/libdtrace/tcp.d b/cddl/lib/libdtrace/tcp.d index afcfdfadaf1e..8f51675df305 100644 --- a/cddl/lib/libdtrace/tcp.d +++ b/cddl/lib/libdtrace/tcp.d @@ -17,8 +17,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD$ */ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. @@ -83,21 +81,23 @@ inline int TCP_STATE_TIME_WAIT = TCPS_TIME_WAIT; /* TCP segment flags. */ #pragma D binding "1.6.3" TH_FIN -inline uint8_t TH_FIN = 0x01; +inline uint16_t TH_FIN = 0x01; #pragma D binding "1.6.3" TH_SYN -inline uint8_t TH_SYN = 0x02; +inline uint16_t TH_SYN = 0x02; #pragma D binding "1.6.3" TH_RST -inline uint8_t TH_RST = 0x04; +inline uint16_t TH_RST = 0x04; #pragma D binding "1.6.3" TH_PUSH -inline uint8_t TH_PUSH = 0x08; +inline uint16_t TH_PUSH = 0x08; #pragma D binding "1.6.3" TH_ACK -inline uint8_t TH_ACK = 0x10; +inline uint16_t TH_ACK = 0x10; #pragma D binding "1.6.3" TH_URG -inline uint8_t TH_URG = 0x20; +inline uint16_t TH_URG = 0x20; #pragma D binding "1.6.3" TH_ECE -inline uint8_t TH_ECE = 0x40; +inline uint16_t TH_ECE = 0x40; #pragma D binding "1.6.3" TH_CWR -inline uint8_t TH_CWR = 0x80; +inline uint16_t TH_CWR = 0x80; +#pragma D binding "1.6.3" TH_AE +inline uint16_t TH_AE = 0x100; /* TCP connection state strings. */ #pragma D binding "1.6.3" tcp_state_string @@ -175,7 +175,7 @@ typedef struct tcpinfo { uint32_t tcp_seq; /* sequence number */ uint32_t tcp_ack; /* acknowledgment number */ uint8_t tcp_offset; /* data offset, in bytes */ - uint8_t tcp_flags; /* flags */ + uint16_t tcp_flags; /* flags */ uint16_t tcp_window; /* window size */ uint16_t tcp_checksum; /* checksum */ uint16_t tcp_urgent; /* urgent data pointer */ @@ -194,7 +194,7 @@ typedef struct tcpinfoh { uint32_t tcp_seq; /* sequence number */ uint32_t tcp_ack; /* acknowledgment number */ uint8_t tcp_offset; /* data offset, in bytes */ - uint8_t tcp_flags; /* flags */ + uint16_t tcp_flags; /* flags */ uint16_t tcp_window; /* window size */ uint16_t tcp_checksum; /* checksum */ uint16_t tcp_urgent; /* urgent data pointer */ @@ -204,7 +204,7 @@ typedef struct tcpinfoh { #pragma D binding "1.6.3" translator translator csinfo_t < struct tcpcb *p > { cs_addr = NULL; - cs_cid = (uint64_t)(p == NULL ? 0 : p->t_inpcb); + cs_cid = (uint64_t)(p == NULL ? 0 : &p->t_inpcb); cs_pid = 0; cs_zoneid = 0; }; @@ -214,16 +214,16 @@ translator tcpsinfo_t < struct tcpcb *p > { tcps_addr = (uintptr_t)p; tcps_local = -1; /* XXX */ tcps_active = -1; /* XXX */ - tcps_lport = p == NULL ? 0 : ntohs(p->t_inpcb->inp_inc.inc_ie.ie_lport); - tcps_rport = p == NULL ? 0 : ntohs(p->t_inpcb->inp_inc.inc_ie.ie_fport); + tcps_lport = p == NULL ? 0 : ntohs(p->t_inpcb.inp_inc.inc_ie.ie_lport); + tcps_rport = p == NULL ? 0 : ntohs(p->t_inpcb.inp_inc.inc_ie.ie_fport); tcps_laddr = p == NULL ? "<unknown>" : - p->t_inpcb->inp_vflag == INP_IPV4 ? - inet_ntoa(&p->t_inpcb->inp_inc.inc_ie.ie_dependladdr.id46_addr.ia46_addr4.s_addr) : - inet_ntoa6(&p->t_inpcb->inp_inc.inc_ie.ie_dependladdr.id6_addr); + p->t_inpcb.inp_vflag == INP_IPV4 ? + inet_ntoa(&p->t_inpcb.inp_inc.inc_ie.ie_dependladdr.id46_addr.ia46_addr4.s_addr) : + inet_ntoa6(&p->t_inpcb.inp_inc.inc_ie.ie_dependladdr.id6_addr); tcps_raddr = p == NULL ? "<unknown>" : - p->t_inpcb->inp_vflag == INP_IPV4 ? - inet_ntoa(&p->t_inpcb->inp_inc.inc_ie.ie_dependfaddr.id46_addr.ia46_addr4.s_addr) : - inet_ntoa6(&p->t_inpcb->inp_inc.inc_ie.ie_dependfaddr.id6_addr); + p->t_inpcb.inp_vflag == INP_IPV4 ? + inet_ntoa(&p->t_inpcb.inp_inc.inc_ie.ie_dependfaddr.id46_addr.ia46_addr4.s_addr) : + inet_ntoa6(&p->t_inpcb.inp_inc.inc_ie.ie_dependfaddr.id6_addr); tcps_state = p == NULL ? -1 : p->t_state; tcps_iss = p == NULL ? 0 : p->iss; tcps_irs = p == NULL ? 0 : p->irs; @@ -250,9 +250,9 @@ translator tcpsinfo_t < struct tcpcb *p > { tcps_retransmit = p == NULL ? -1 : p->t_rxtshift > 0 ? 1 : 0; tcps_srtt = p == NULL ? -1 : p->t_srtt; /* smoothed RTT in units of (TCP_RTT_SCALE*hz) */ tcps_debug = p == NULL ? 0 : - p->t_inpcb->inp_socket->so_options & 1; + p->t_inpcb.inp_socket->so_options & 1; tcps_cookie = p == NULL ? -1 : - p->t_inpcb->inp_socket->so_user_cookie; + p->t_inpcb.inp_socket->so_user_cookie; tcps_dupacks = p == NULL ? -1 : p->t_dupacks; tcps_rtttime = p == NULL ? -1 : p->t_rtttime; tcps_rtseq = p == NULL ? -1 : p->t_rtseq; @@ -265,8 +265,8 @@ translator tcpinfo_t < struct tcphdr *p > { tcp_dport = p == NULL ? 0 : ntohs(p->th_dport); tcp_seq = p == NULL ? -1 : ntohl(p->th_seq); tcp_ack = p == NULL ? -1 : ntohl(p->th_ack); - tcp_offset = p == NULL ? -1 : (p->th_off >> 2); - tcp_flags = p == NULL ? 0 : p->th_flags; + tcp_offset = p == NULL ? -1 : (p->th_off << 2); + tcp_flags = p == NULL ? 0 : ((p->th_x2 << 8) | p->th_flags); tcp_window = p == NULL ? 0 : ntohs(p->th_win); tcp_checksum = p == NULL ? 0 : ntohs(p->th_sum); tcp_urgent = p == NULL ? 0 : ntohs(p->th_urp); @@ -284,8 +284,8 @@ translator tcpinfoh_t < struct tcphdr *p > { tcp_dport = p == NULL ? 0 : ntohs(p->th_dport); tcp_seq = p == NULL ? -1 : p->th_seq; tcp_ack = p == NULL ? -1 : p->th_ack; - tcp_offset = p == NULL ? -1 : (p->th_off >> 2); - tcp_flags = p == NULL ? 0 : p->th_flags; + tcp_offset = p == NULL ? -1 : (p->th_off << 2); + tcp_flags = p == NULL ? 0 : ((p->th_x2 << 8) | p->th_flags); tcp_window = p == NULL ? 0 : p->th_win; tcp_checksum = p == NULL ? 0 : ntohs(p->th_sum); tcp_urgent = p == NULL ? 0 : p->th_urp; @@ -313,17 +313,17 @@ inline int TA_DROP = 4; /* direction strings. */ -#pragma D binding "1.12.1" tcpdebug_dir_string +#pragma D binding "1.13" tcpdebug_dir_string inline string tcpdebug_dir_string[uint8_t direction] = direction == TA_INPUT ? "input" : direction == TA_OUTPUT ? "output" : direction == TA_USER ? "user" : direction == TA_RESPOND ? "respond" : - direction == TA_OUTPUT ? "drop" : + direction == TA_DROP ? "drop" : "unknown" ; -#pragma D binding "1.12.1" tcpflag_string -inline string tcpflag_string[uint8_t flags] = +#pragma D binding "1.13" tcpflag_string +inline string tcpflag_string[uint16_t flags] = flags & TH_FIN ? "FIN" : flags & TH_SYN ? "SYN" : flags & TH_RST ? "RST" : @@ -332,6 +332,7 @@ inline string tcpflag_string[uint8_t flags] = flags & TH_URG ? "URG" : flags & TH_ECE ? "ECE" : flags & TH_CWR ? "CWR" : + flags & TH_AE ? "AE" : "unknown" ; #pragma D binding "1.12.1" PRU_ATTACH diff --git a/cddl/lib/libdtrace/udp.d b/cddl/lib/libdtrace/udp.d index 603bbbd29617..fd28f5e2e7e9 100644 --- a/cddl/lib/libdtrace/udp.d +++ b/cddl/lib/libdtrace/udp.d @@ -17,8 +17,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD$ */ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. diff --git a/cddl/lib/libdtrace/udplite.d b/cddl/lib/libdtrace/udplite.d index e41a6faa36a8..88c1c8553ce5 100644 --- a/cddl/lib/libdtrace/udplite.d +++ b/cddl/lib/libdtrace/udplite.d @@ -17,8 +17,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD$ */ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. diff --git a/cddl/lib/libdtrace/unistd.d b/cddl/lib/libdtrace/unistd.d index 1ceffef2b215..ead9d23ce670 100644 --- a/cddl/lib/libdtrace/unistd.d +++ b/cddl/lib/libdtrace/unistd.d @@ -17,8 +17,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD$ */ /* * Copyright 2007 Sun Microsystems, Inc. All rights reserved. diff --git a/cddl/lib/libicp/Makefile b/cddl/lib/libicp/Makefile index 58ebb292c946..f097e7e6ff58 100644 --- a/cddl/lib/libicp/Makefile +++ b/cddl/lib/libicp/Makefile @@ -1,12 +1,9 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/sys/contrib/openzfs/module/icp -PACKAGE= utilities +PACKAGE= zfs LIB= icp LIBADD= - .if ${MACHINE_ARCH} == "amd64" ASM_SOURCES_C = asm-x86_64/aes/aeskey.c ASM_SOURCES_AS = \ @@ -15,30 +12,47 @@ ASM_SOURCES_AS = \ asm-x86_64/modes/gcm_pclmulqdq.S \ asm-x86_64/modes/aesni-gcm-x86_64.S \ asm-x86_64/modes/ghash-x86_64.S \ - asm-x86_64/sha2/sha256_impl.S \ - asm-x86_64/sha2/sha512_impl.S \ + asm-x86_64/sha2/sha256-x86_64.S \ + asm-x86_64/sha2/sha512-x86_64.S \ asm-x86_64/blake3/blake3_avx2.S \ asm-x86_64/blake3/blake3_avx512.S \ asm-x86_64/blake3/blake3_sse2.S \ asm-x86_64/blake3/blake3_sse41.S CFLAGS+= -D__amd64 -D_SYS_STACK_H -UHAVE_AES +.elif ${MACHINE_CPUARCH} == "arm" +ASM_SOURCES_C = +ASM_SOURCES_AS = \ + asm-arm/sha2/sha256-armv7.S \ + asm-arm/sha2/sha512-armv7.S .elif ${MACHINE_ARCH} == "aarch64" ASM_SOURCES_C = ASM_SOURCES_AS = \ asm-aarch64/blake3/b3_aarch64_sse2.S \ - asm-aarch64/blake3/b3_aarch64_sse41.S + asm-aarch64/blake3/b3_aarch64_sse41.S \ + asm-aarch64/sha2/sha256-armv8.S \ + asm-aarch64/sha2/sha512-armv8.S +.elif ${MACHINE_ARCH} == "powerpc64" +ASM_SOURCES_C = +ASM_SOURCES_AS = \ + asm-ppc64/sha2/sha256-ppc.S \ + asm-ppc64/sha2/sha512-ppc.S \ + asm-ppc64/sha2/sha256-p8.S \ + asm-ppc64/sha2/sha512-p8.S .elif ${MACHINE_ARCH} == "powerpc64le" ASM_SOURCES_C = ASM_SOURCES_AS = \ asm-ppc64/blake3/b3_ppc64le_sse2.S \ - asm-ppc64/blake3/b3_ppc64le_sse41.S + asm-ppc64/blake3/b3_ppc64le_sse41.S \ + asm-ppc64/sha2/sha256-ppc.S \ + asm-ppc64/sha2/sha512-ppc.S \ + asm-ppc64/sha2/sha256-p8.S \ + asm-ppc64/sha2/sha512-p8.S .else ASM_SOURCES_C = ASM_SOURCES_AS = .endif - KERNEL_C = \ spi/kcf_spi.c \ api/kcf_ctxops.c \ @@ -52,24 +66,21 @@ KERNEL_C = \ algs/blake3/blake3.c \ algs/blake3/blake3_generic.c \ algs/blake3/blake3_impl.c \ - algs/blake3/blake3_x86-64.c \ algs/edonr/edonr.c \ algs/modes/modes.c \ - algs/modes/cbc.c \ algs/modes/gcm_generic.c \ algs/modes/gcm_pclmulqdq.c \ algs/modes/gcm.c \ - algs/modes/ctr.c \ algs/modes/ccm.c \ - algs/modes/ecb.c \ - algs/sha2/sha2.c \ + algs/sha2/sha2_generic.c \ + algs/sha2/sha256_impl.c \ + algs/sha2/sha512_impl.c \ algs/skein/skein.c \ algs/skein/skein_block.c \ algs/skein/skein_iv.c \ illumos-crypto.c \ io/aes.c \ io/sha2_mod.c \ - io/skein_mod.c \ core/kcf_sched.c \ core/kcf_prov_lib.c \ core/kcf_callprov.c \ @@ -77,10 +88,8 @@ KERNEL_C = \ core/kcf_prov_tabs.c \ $(ASM_SOURCES_C) - - - - +.PATH: ${SRCTOP}/sys/contrib/openzfs/module/zfs +KERNEL_C+= zfs_impl.c SRCS= $(ASM_SOURCES_AS) $(KERNEL_C) @@ -94,26 +103,36 @@ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd CFLAGS+= -I${SRCTOP}/sys CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/module/icp/include +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h CFLAGS+= -DHAVE_ISSETUGID CFLAGS+= -include ${SRCTOP}/sys/modules/zfs/zfs_config.h - CFLAGS.aes_amd64.S+= -DLOCORE CFLAGS.aes_aesni.S+= -DLOCORE CFLAGS.gcm_pclmulqdq.S+= -DLOCORE CFLAGS.aesni-gcm-x86_64.S+= -DLOCORE CFLAGS.ghash-x86_64.S+= -DLOCORE -CFLAGS.sha256_impl.S+= -DLOCORE -CFLAGS.sha512_impl.S+= -DLOCORE +CFLAGS.sha256-x86_64.S+= -DLOCORE +CFLAGS.sha512-x86_64.S+= -DLOCORE CFLAGS.blake3_avx2.S = -DLOCORE CFLAGS.blake3_avx512.S = -DLOCORE CFLAGS.blake3_sse2.S = -DLOCORE CFLAGS.blake3_sse41.S = -DLOCORE CFLAGS.b3_aarch64_sse2.S = -DLOCORE CFLAGS.b3_aarch64_sse41.S = -DLOCORE +CFLAGS.sha256-armv7.S = -DLOCORE +CFLAGS.sha256-armv8.S = -DLOCORE +CFLAGS.sha512-armv7.S = -DLOCORE +CFLAGS.sha512-armv8.S = -DLOCORE CFLAGS.b3_ppc64le_sse2.S = -DLOCORE CFLAGS.b3_ppc64le_sse41.S = -DLOCORE +CFLAGS.sha256-p8.S = -DLOCORE +CFLAGS.sha256-ppc.S = -DLOCORE +CFLAGS.sha512-p8.S = -DLOCORE +CFLAGS.sha512-ppc.S = -DLOCORE + +LDFLAGS.bfd+= -Wl,-znoexecstack .include <bsd.lib.mk> diff --git a/cddl/lib/libicp/Makefile.depend b/cddl/lib/libicp/Makefile.depend new file mode 100644 index 000000000000..6ef78fac5cbf --- /dev/null +++ b/cddl/lib/libicp/Makefile.depend @@ -0,0 +1,15 @@ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/cddl/lib/libicp_rescue/Makefile b/cddl/lib/libicp_rescue/Makefile index 1237b1b05edf..3a8b6746fe61 100644 --- a/cddl/lib/libicp_rescue/Makefile +++ b/cddl/lib/libicp_rescue/Makefile @@ -1,12 +1,9 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/sys/contrib/openzfs/module/icp PACKAGE= utilities LIB= icp_rescue LIBADD= - .if ${MACHINE_ARCH} == "amd64" ASM_SOURCES_C = asm-x86_64/aes/aeskey.c ASM_SOURCES_AS = \ @@ -14,30 +11,47 @@ ASM_SOURCES_AS = \ asm-x86_64/aes/aes_aesni.S \ asm-x86_64/modes/gcm_pclmulqdq.S \ asm-x86_64/modes/aesni-gcm-x86_64.S \ - asm-x86_64/sha2/sha256_impl.S \ - asm-x86_64/sha2/sha512_impl.S \ + asm-x86_64/sha2/sha256-x86_64.S \ + asm-x86_64/sha2/sha512-x86_64.S \ asm-x86_64/blake3/blake3_avx2.S \ asm-x86_64/blake3/blake3_avx512.S \ asm-x86_64/blake3/blake3_sse2.S \ asm-x86_64/blake3/blake3_sse41.S CFLAGS+= -D__amd64 -D_SYS_STACK_H +.elif ${MACHINE_CPUARCH} == "arm" +ASM_SOURCES_C = +ASM_SOURCES_AS = \ + asm-arm/sha2/sha256-armv7.S \ + asm-arm/sha2/sha512-armv7.S .elif ${MACHINE_ARCH} == "aarch64" ASM_SOURCES_C = ASM_SOURCES_AS = \ asm-aarch64/blake3/b3_aarch64_sse2.S \ - asm-aarch64/blake3/b3_aarch64_sse41.S + asm-aarch64/blake3/b3_aarch64_sse41.S \ + asm-aarch64/sha2/sha256-armv8.S \ + asm-aarch64/sha2/sha512-armv8.S +.elif ${MACHINE_ARCH} == "powerpc64" +ASM_SOURCES_C = +ASM_SOURCES_AS = \ + asm-ppc64/sha2/sha256-ppc.S \ + asm-ppc64/sha2/sha512-ppc.S \ + asm-ppc64/sha2/sha256-p8.S \ + asm-ppc64/sha2/sha512-p8.S .elif ${MACHINE_ARCH} == "powerpc64le" ASM_SOURCES_C = ASM_SOURCES_AS = \ asm-ppc64/blake3/b3_ppc64le_sse2.S \ - asm-ppc64/blake3/b3_ppc64le_sse41.S + asm-ppc64/blake3/b3_ppc64le_sse41.S \ + asm-ppc64/sha2/sha256-ppc.S \ + asm-ppc64/sha2/sha512-ppc.S \ + asm-ppc64/sha2/sha256-p8.S \ + asm-ppc64/sha2/sha512-p8.S .else ASM_SOURCES_C = ASM_SOURCES_AS = .endif - KERNEL_C = \ spi/kcf_spi.c \ api/kcf_ctxops.c \ @@ -51,22 +65,19 @@ KERNEL_C = \ algs/blake3/blake3.c \ algs/blake3/blake3_generic.c \ algs/blake3/blake3_impl.c \ - algs/blake3/blake3_x86-64.c \ algs/edonr/edonr.c \ algs/modes/modes.c \ - algs/modes/cbc.c \ algs/modes/gcm_generic.c \ algs/modes/gcm_pclmulqdq.c \ algs/modes/gcm.c \ - algs/modes/ctr.c \ algs/modes/ccm.c \ - algs/modes/ecb.c \ - algs/sha2/sha2.c \ + algs/sha2/sha2_generic.c \ + algs/sha2/sha256_impl.c \ + algs/sha2/sha512_impl.c \ algs/skein/skein_block.c \ illumos-crypto.c \ io/aes.c \ io/sha2_mod.c \ - io/skein_mod.c \ core/kcf_sched.c \ core/kcf_prov_lib.c \ core/kcf_callprov.c \ @@ -74,6 +85,9 @@ KERNEL_C = \ core/kcf_prov_tabs.c \ $(ASM_SOURCES_C) +.PATH: ${SRCTOP}/sys/contrib/openzfs/module/zfs +KERNEL_C+= zfs_impl.c + SRCS= $(ASM_SOURCES_AS) $(KERNEL_C) WARNS?= 2 @@ -86,18 +100,18 @@ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd CFLAGS+= -I${SRCTOP}/sys CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/module/icp/include +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h CFLAGS+= -DHAVE_ISSETUGID -UHAVE_AVX -DRESCUE CFLAGS+= -include ${SRCTOP}/sys/modules/zfs/zfs_config.h - CFLAGS.aes_amd64.S+= -DLOCORE CFLAGS.aes_aesni.S+= -DLOCORE CFLAGS.gcm_pclmulqdq.S+= -DLOCORE CFLAGS.aesni-gcm-x86_64.S+= -DLOCORE CFLAGS.ghash-x86_64.S+= -DLOCORE -CFLAGS.sha256_impl.S+= -DLOCORE -CFLAGS.sha512_impl.S+= -DLOCORE +CFLAGS.sha256-x86_64.S+= -DLOCORE +CFLAGS.sha512-x86_64.S+= -DLOCORE CFLAGS.gcm.c+= -UCAN_USE_GCM_ASM CFLAGS.blake3_avx2.S = -DLOCORE CFLAGS.blake3_avx512.S = -DLOCORE @@ -105,8 +119,17 @@ CFLAGS.blake3_sse2.S = -DLOCORE CFLAGS.blake3_sse41.S = -DLOCORE CFLAGS.b3_aarch64_sse2.S = -DLOCORE CFLAGS.b3_aarch64_sse41.S = -DLOCORE +CFLAGS.sha256-armv7.S = -DLOCORE +CFLAGS.sha512-armv7.S = -DLOCORE +CFLAGS.sha256-armv8.S = -DLOCORE +CFLAGS.sha512-armv8.S = -DLOCORE CFLAGS.b3_ppc64le_sse2.S = -DLOCORE CFLAGS.b3_ppc64le_sse41.S = -DLOCORE +CFLAGS.sha256-ppc.S = -DLOCORE +CFLAGS.sha256-p8.S = -DLOCORE +CFLAGS.sha512-ppc.S = -DLOCORE +CFLAGS.sha512-p8.S = -DLOCORE +LDFLAGS.bfd+= -Wl,-znoexecstack .include <bsd.lib.mk> diff --git a/cddl/lib/libicp_rescue/Makefile.depend b/cddl/lib/libicp_rescue/Makefile.depend new file mode 100644 index 000000000000..6ef78fac5cbf --- /dev/null +++ b/cddl/lib/libicp_rescue/Makefile.depend @@ -0,0 +1,15 @@ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/cddl/lib/libnvpair/Makefile b/cddl/lib/libnvpair/Makefile index aaf76ed3fb28..2d9ef1c7af1e 100644 --- a/cddl/lib/libnvpair/Makefile +++ b/cddl/lib/libnvpair/Makefile @@ -1,13 +1,13 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/sys/contrib/openzfs/module/nvpair .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libnvpair +.PATH: ${SRCTOP}/sys/contrib/openzfs/include LIB= nvpair LIBADD= spl -PACKAGE= runtime +PACKAGE= libzfs # user +INCS= libnvpair.h SRCS= libnvpair.c \ libnvpair_json.c \ nvpair_alloc_system.c @@ -26,6 +26,4 @@ CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h CFLAGS+= -DHAVE_ISSETUGID -DHAVE_CONFIG_H -DHAVE_XDR_BYTESREC - -CFLAGS.nvpair.c+= -UHAVE_RPC_TYPES .include <bsd.lib.mk> diff --git a/cddl/lib/libnvpair/Makefile.depend b/cddl/lib/libnvpair/Makefile.depend index 5f1a802404d8..409c3c86cc20 100644 --- a/cddl/lib/libnvpair/Makefile.depend +++ b/cddl/lib/libnvpair/Makefile.depend @@ -1,13 +1,12 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ + cddl/lib/libspl \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ - lib/msun \ .include <dirdeps.mk> diff --git a/cddl/lib/libspl/Makefile b/cddl/lib/libspl/Makefile index 6a918c59e27e..d44e5cb19ab4 100644 --- a/cddl/lib/libspl/Makefile +++ b/cddl/lib/libspl/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .include <bsd.init.mk> .include <bsd.compiler.mk> @@ -8,10 +6,11 @@ LIB= spl LIBADD= -PACKAGE= runtime +PACKAGE= libzfs SRCS = \ assert.c \ + backtrace.c \ list.c \ mkdirp.c \ os/freebsd/zone.c \ diff --git a/cddl/lib/libspl/Makefile.depend b/cddl/lib/libspl/Makefile.depend new file mode 100644 index 000000000000..6ef78fac5cbf --- /dev/null +++ b/cddl/lib/libspl/Makefile.depend @@ -0,0 +1,15 @@ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/cddl/lib/libtpool/Makefile b/cddl/lib/libtpool/Makefile index 637385bc842e..7acf34219a47 100644 --- a/cddl/lib/libtpool/Makefile +++ b/cddl/lib/libtpool/Makefile @@ -1,12 +1,11 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libtpool .PATH: ${SRCTOP}/sys/contrib/openzfs/include LIB= tpool +SHLIBDIR?= /lib LIBADD= spl -PACKAGE= runtime +PACKAGE= libzfs INCS= thread_pool_impl.h SRCS= thread_pool.c @@ -24,4 +23,9 @@ CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccomp CFLAGS+= -DHAVE_ISSETUGID CFLAGS+= -include ${SRCTOP}/sys/modules/zfs/zfs_config.h +.include <src.opts.mk> + +HAS_TESTS= +SUBDIR.${MK_TESTS}+= tests + .include <bsd.lib.mk> diff --git a/cddl/lib/libtpool/Makefile.depend b/cddl/lib/libtpool/Makefile.depend new file mode 100644 index 000000000000..409c3c86cc20 --- /dev/null +++ b/cddl/lib/libtpool/Makefile.depend @@ -0,0 +1,16 @@ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + cddl/lib/libspl \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/cddl/lib/libtpool/tests/Makefile b/cddl/lib/libtpool/tests/Makefile new file mode 100644 index 000000000000..19e43cc18821 --- /dev/null +++ b/cddl/lib/libtpool/tests/Makefile @@ -0,0 +1,13 @@ +ZFSTOP= ${SRCTOP}/sys/contrib/openzfs + +ATF_TESTS_C+= libtpool_test + +TEST_METADATA+= timeout="10" + +CFLAGS+= -I${ZFSTOP}/include \ + -I${ZFSTOP}/lib/libspl/include + +LIBADD+= pthread tpool + +.include "${SRCTOP}/cddl/Makefile.inc" +.include <bsd.test.mk> diff --git a/cddl/lib/libtpool/tests/libtpool_test.c b/cddl/lib/libtpool/tests/libtpool_test.c new file mode 100644 index 000000000000..42bce269cb23 --- /dev/null +++ b/cddl/lib/libtpool/tests/libtpool_test.c @@ -0,0 +1,82 @@ +#include <sys/stdtypes.h> +#include <sys/sysctl.h> +#include <errno.h> +#include <pthread.h> + +#include <thread_pool.h> + +#include <atf-c.h> + +static void +tp_delay(void *arg) +{ + pthread_barrier_t *barrier = arg; + int r; + + /* Block this task until all thread pool workers have been created. */ + r = pthread_barrier_wait(barrier); + ATF_REQUIRE_MSG(r == 0 || r == PTHREAD_BARRIER_SERIAL_THREAD, + "pthread_barrier_wait failed: %s", strerror(r)); +} + +/* + * NB: we could reduce the test's resource cost by using rctl(4). But that + * isn't enabled by default. And even with a thread limit of 1500, it takes < + * 0.1s to run on my machine. So I don't think it's worth optimizing for the + * case where rctl is available. + */ +ATF_TC(complete_exhaustion); +ATF_TC_HEAD(complete_exhaustion, tc) +{ + atf_tc_set_md_var(tc, "descr", + "A thread pool should fail to schedule tasks if it is completely impossible to spawn any threads."); +} + +ATF_TC_BODY(complete_exhaustion, tc) +{ + pthread_barrier_t barrier; + tpool_t *tp0, *tp1; + size_t len; + int max_threads_per_proc = 0; + int nworkers; + int r, i; + + len = sizeof(max_threads_per_proc); + r = sysctlbyname("kern.threads.max_threads_per_proc", + &max_threads_per_proc, &len, NULL, 0); + ATF_REQUIRE_EQ_MSG(r, 0, "sysctlbyname: %s", strerror(errno)); + nworkers = max_threads_per_proc - 1; + pthread_barrier_init(&barrier, NULL, max_threads_per_proc); + + /* + * Create the first thread pool and spawn the maximum allowed number of + * processes. + */ + tp0 = tpool_create(nworkers, nworkers, 1, NULL); + ATF_REQUIRE(tp0 != NULL); + for (i = 0; i < nworkers; i++) { + ATF_REQUIRE_EQ(tpool_dispatch(tp0, tp_delay, &barrier), 0); + } + + /* + * Now create a second thread pool. Unable to create new threads, the + * dispatch function should return an error. + */ + tp1 = tpool_create(nworkers, 2 * nworkers, 1, NULL); + ATF_REQUIRE(tp1 != NULL); + ATF_REQUIRE_EQ(tpool_dispatch(tp1, tp_delay, NULL), -1); + + /* Cleanup */ + r = pthread_barrier_wait(&barrier); + ATF_REQUIRE_MSG(r == 0 || r == PTHREAD_BARRIER_SERIAL_THREAD, + "pthread_barrier_wait failed: %s", strerror(r)); + tpool_wait(tp1); + tpool_wait(tp0); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, complete_exhaustion); + + return (atf_no_error()); +} diff --git a/cddl/lib/libumem/Makefile b/cddl/lib/libumem/Makefile index ca8f5e665920..9164ba771fe6 100644 --- a/cddl/lib/libumem/Makefile +++ b/cddl/lib/libumem/Makefile @@ -1,8 +1,6 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/cddl/compat/opensolaris/lib/libumem -PACKAGE= runtime +PACKAGE= libzfs LIB= umem SRCS= umem.c WARNS?= 3 diff --git a/cddl/lib/libumem/Makefile.depend b/cddl/lib/libumem/Makefile.depend index 1c1a9bee1d67..93249906da4f 100644 --- a/cddl/lib/libumem/Makefile.depend +++ b/cddl/lib/libumem/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/lib/libuutil/Makefile b/cddl/lib/libuutil/Makefile index 169b8d8afe01..8c8a786ee039 100644 --- a/cddl/lib/libuutil/Makefile +++ b/cddl/lib/libuutil/Makefile @@ -1,8 +1,6 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libuutil -PACKAGE= runtime +PACKAGE= libzfs LIB= uutil SRCS=\ uu_alloc.c \ @@ -10,7 +8,6 @@ SRCS=\ uu_ident.c \ uu_list.c \ uu_misc.c \ - uu_pname.c \ uu_string.c WARNS?= 2 diff --git a/cddl/lib/libuutil/Makefile.depend b/cddl/lib/libuutil/Makefile.depend index 8d409f5263ac..808980b1879e 100644 --- a/cddl/lib/libuutil/Makefile.depend +++ b/cddl/lib/libuutil/Makefile.depend @@ -1,7 +1,8 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ + cddl/lib/libavl \ + cddl/lib/libspl \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git a/cddl/lib/libzdb/Makefile b/cddl/lib/libzdb/Makefile new file mode 100644 index 000000000000..0eb30c55d107 --- /dev/null +++ b/cddl/lib/libzdb/Makefile @@ -0,0 +1,26 @@ +.PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libzdb +.PATH: ${SRCTOP}/sys/contrib/openzfs/include + +LIB= zdb +PACKAGE= zfs + +INCS = libzdb.h + +SRCS = libzdb.c + +WARNS?= 2 +CSTD= c99 + +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/zfs +CFLAGS+= -I${SRCTOP}/sys +CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include +CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzutil +CFLAGS+= -DHAVE_ISSETUGID -DIN_BASE +CFLAGS+= -include ${SRCTOP}/sys/modules/zfs/zfs_config.h + +.include <bsd.lib.mk> diff --git a/cddl/lib/libzdb/Makefile.depend b/cddl/lib/libzdb/Makefile.depend new file mode 100644 index 000000000000..93249906da4f --- /dev/null +++ b/cddl/lib/libzdb/Makefile.depend @@ -0,0 +1,14 @@ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + include \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/cddl/lib/libzfs/Makefile b/cddl/lib/libzfs/Makefile index 63bfcb39d4d8..40553aa68719 100644 --- a/cddl/lib/libzfs/Makefile +++ b/cddl/lib/libzfs/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/sys/contrib/openzfs/module/icp .PATH: ${SRCTOP}/sys/contrib/openzfs/module/zcommon .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libzfs @@ -9,7 +7,7 @@ .PATH: ${SRCTOP}/sys/contrib/openzfs/module/zstd .PATH: ${SRCTOP}/sys/contrib/openzfs/module/zstd/lib -PACKAGE= runtime +PACKAGE= libzfs LIB= zfs LIBADD= \ avl \ @@ -20,6 +18,7 @@ LIBADD= \ md \ nvpair \ pthread \ + rt \ umem \ util \ uutil \ @@ -55,7 +54,6 @@ USER_C += \ os/freebsd/smb.c KERNEL_C = \ - algs/sha2/sha2.c \ cityhash.c \ zfeature_common.c \ zfs_comutil.c \ @@ -65,10 +63,10 @@ KERNEL_C = \ zfs_fletcher_superscalar4.c \ zfs_namecheck.c \ zfs_prop.c \ + zfs_valstr.c \ zpool_prop.c \ zprop_common.c - ARCH_C = .if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" ARCH_C += zfs_fletcher_intel.c \ @@ -94,15 +92,17 @@ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libshare +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include CFLAGS+= -I${SRCTOP}/sys/contrib/ck/include CFLAGS+= -I${SRCTOP}/sys CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/module/icp/include CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h CFLAGS+= -DHAVE_ISSETUGID +CFLAGS+= -DHAVE_EXECVPE CFLAGS+= -include ${SRCTOP}/sys/modules/zfs/zfs_config.h CFLAGS+= -DSYSCONFDIR=\"/etc\" CFLAGS+= -DPKGDATADIR=\"/usr/share/zfs\" - +CFLAGS+= -DZFSEXECDIR=\"${LIBEXECDIR}/zfs\" .include <bsd.lib.mk> diff --git a/cddl/lib/libzfs/Makefile.depend b/cddl/lib/libzfs/Makefile.depend index 54a7c43b42aa..1fead4b4f29d 100644 --- a/cddl/lib/libzfs/Makefile.depend +++ b/cddl/lib/libzfs/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ @@ -7,6 +6,7 @@ DIRDEPS = \ cddl/lib/libumem \ cddl/lib/libuutil \ cddl/lib/libzfs_core \ + cddl/lib/libzutil \ include \ include/xlocale \ lib/${CSU_DIR} \ @@ -15,10 +15,12 @@ DIRDEPS = \ lib/libexpat \ lib/libgeom \ lib/libmd \ + lib/librt \ lib/libthr \ lib/libutil \ lib/libz \ lib/msun \ + secure/lib/libcrypto \ .include <dirdeps.mk> diff --git a/cddl/lib/libzfs_core/Makefile b/cddl/lib/libzfs_core/Makefile index 5a7475f55428..bac81ca73497 100644 --- a/cddl/lib/libzfs_core/Makefile +++ b/cddl/lib/libzfs_core/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libzfs_core .PATH: ${SRCTOP}/sys/contrib/openzfs/include .PATH: ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/zfs @@ -8,7 +6,7 @@ LIB= zfs_core LIBADD= nvpair spl zutil -PACKAGE= runtime +PACKAGE= libzfs INCS= libzfs_core.h SRCS= libzfs_core.c \ @@ -19,9 +17,11 @@ WARNS?= 2 CSTD= c99 CFLAGS+= -DIN_BASE CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzfs_core CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzfs_core/common CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/zfs CFLAGS+= -I${SRCTOP}/sys CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include diff --git a/cddl/lib/libzfs_core/Makefile.depend b/cddl/lib/libzfs_core/Makefile.depend index 26e3937b68fd..fd295d12904d 100644 --- a/cddl/lib/libzfs_core/Makefile.depend +++ b/cddl/lib/libzfs_core/Makefile.depend @@ -1,14 +1,14 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ cddl/lib/libnvpair \ + cddl/lib/libspl \ + cddl/lib/libzutil \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ - lib/msun \ .include <dirdeps.mk> diff --git a/cddl/lib/libzfsbootenv/Makefile b/cddl/lib/libzfsbootenv/Makefile index be39af96124a..15ee5bfaeaa4 100644 --- a/cddl/lib/libzfsbootenv/Makefile +++ b/cddl/lib/libzfsbootenv/Makefile @@ -1,9 +1,7 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libzfsbootenv .PATH: ${SRCTOP}/sys/contrib/openzfs/include -PACKAGE= runtime +PACKAGE= zfs LIB= zfsbootenv SHLIB_MAJOR= 1 @@ -23,6 +21,7 @@ CFLAGS+= -DIN_BASE CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/module/icp/include CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h diff --git a/cddl/lib/libzfsbootenv/Makefile.depend b/cddl/lib/libzfsbootenv/Makefile.depend new file mode 100644 index 000000000000..7209d9b784ef --- /dev/null +++ b/cddl/lib/libzfsbootenv/Makefile.depend @@ -0,0 +1,17 @@ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + cddl/lib/libnvpair \ + cddl/lib/libzfs \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/cddl/lib/libzpool/Makefile b/cddl/lib/libzpool/Makefile index 92f1bda6d82a..5a69843d6c8e 100644 --- a/cddl/lib/libzpool/Makefile +++ b/cddl/lib/libzpool/Makefile @@ -1,7 +1,7 @@ -# $FreeBSD$ - ZFSTOP= ${SRCTOP}/sys/contrib/openzfs +.PATH: ${ZFSTOP}/lib/libzpool + # ZFS_COMMON_SRCS .PATH: ${ZFSTOP}/module/zfs .PATH: ${ZFSTOP}/module/zcommon @@ -14,10 +14,6 @@ ZFSTOP= ${SRCTOP}/sys/contrib/openzfs .PATH: ${ZFSTOP}/module/zstd/lib/compress .PATH: ${ZFSTOP}/module/zstd/lib/decompress -.PATH: ${ZFSTOP}/module/os/linux/zfs - -.PATH: ${ZFSTOP}/lib/libzpool - .if exists(${SRCTOP}/sys/cddl/contrib/opensolaris/common/atomic/${MACHINE_ARCH}/opensolaris_atomic.S) .PATH: ${SRCTOP}/sys/cddl/contrib/opensolaris/common/atomic/${MACHINE_ARCH} ATOMIC_SRCS= opensolaris_atomic.S @@ -32,14 +28,20 @@ ATOMIC_SRCS= opensolaris_atomic.c PICFLAG= -fPIC .endif +PACKAGE= zfs LIB= zpool USER_C = \ + arc_os.c \ kernel.c \ taskq.c \ - util.c + util.c \ + zfs_debug.c + +.PATH: ${ZFSTOP}/module/os/linux/zfs KERNEL_C = \ + simd_stat.c \ zfeature_common.c \ zfs_comutil.c \ zfs_deleg.c \ @@ -55,21 +57,24 @@ KERNEL_C = \ abd_os.c \ aggsum.c \ arc.c \ - arc_os.c \ blake3_zfs.c \ blkptr.c \ bplist.c \ bpobj.c \ bptree.c \ - btree.c \ bqueue.c \ + btree.c \ + brt.c \ cityhash.c \ dbuf.c \ dbuf_stats.c \ ddt.c \ + ddt_log.c \ + ddt_stats.c \ ddt_zap.c \ dmu.c \ dmu_diff.c \ + dmu_direct.c \ dmu_object.c \ dmu_objset.c \ dmu_recv.c \ @@ -116,10 +121,9 @@ KERNEL_C = \ refcount.c \ rrwlock.c \ sa.c \ - sha256.c \ + sha2_zfs.c \ skein_zfs.c \ spa.c \ - spa_boot.c \ spa_checkpoint.c \ spa_config.c \ spa_errlog.c \ @@ -134,7 +138,6 @@ KERNEL_C = \ uberblock.c \ unique.c \ vdev.c \ - vdev_cache.c \ vdev_draid.c \ vdev_draid_rand.c \ vdev_file.c \ @@ -143,6 +146,7 @@ KERNEL_C = \ vdev_indirect_mapping.c \ vdev_initialize.c \ vdev_label.c \ + vdev_label_os.c \ vdev_mirror.c \ vdev_missing.c \ vdev_queue.c \ @@ -171,7 +175,6 @@ KERNEL_C = \ zfeature.c \ zfs_byteswap.c \ zfs_chksum.c \ - zfs_debug.c \ zfs_fm.c \ zfs_fuid.c \ zfs_sa.c \ @@ -245,9 +248,10 @@ LUA_C = \ lvm.c \ lzio.c -UNICODE_C = u8_textprep.c uconv.c +UNICODE_C = u8_textprep.c + +SRCS+= ${USER_C} ${KERNEL_C} ${LUA_C} ${UNICODE_C} ${ARCH_C} -SRCS= ${USER_C} ${KERNEL_C} ${LUA_C} ${UNICODE_C} ${ARCH_C} WARNS?= 2 CFLAGS+= \ @@ -255,10 +259,12 @@ CFLAGS+= \ -I${ZFSTOP}/include \ -I${ZFSTOP}/lib/libspl/include \ -I${ZFSTOP}/lib/libspl/include/os/freebsd \ + -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include \ -I${SRCTOP}/sys \ -I${ZFSTOP}/include/os/freebsd/zfs \ -I${SRCTOP}/cddl/compat/opensolaris/include \ -I${ZFSTOP}/module/icp/include \ + -I${SRCTOP}/compat/linuxkpi/common/include/linux \ -include ${ZFSTOP}/include/os/freebsd/spl/sys/ccompile.h \ -DHAVE_ISSETUGID \ -include ${SRCTOP}/sys/modules/zfs/zfs_config.h \ @@ -277,9 +283,6 @@ CFLAGS.gcc+= -fms-extensions LIBADD= md pthread z spl icp nvpair avl umem -# atomic.S doesn't like profiling. -MK_PROFILE= no - CSTD= c99 # Since there are many asserts in this library, it makes no sense to compile @@ -287,6 +290,12 @@ CSTD= c99 CFLAGS+= -g -DDEBUG=1 +CFLAGS.gcc+= -Wno-pointer-to-int-cast + +# Pointer values are used as debugging "tags" to mark reference count +# ownerships and in some cases the tag reference is dropped after an +# object is freed. +CFLAGS.dbuf.c= ${NO_WUSE_AFTER_FREE} CFLAGS.entropy_common.c= -fno-tree-vectorize CFLAGS.entropy_common.c+= ${NO_WBITWISE_INSTEAD_OF_LOGICAL} CFLAGS.error_private.c= -fno-tree-vectorize diff --git a/cddl/lib/libzpool/Makefile.depend b/cddl/lib/libzpool/Makefile.depend index 06045f57b437..42b2995ff2d1 100644 --- a/cddl/lib/libzpool/Makefile.depend +++ b/cddl/lib/libzpool/Makefile.depend @@ -1,12 +1,11 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ cddl/lib/libavl \ cddl/lib/libicp \ cddl/lib/libnvpair \ + cddl/lib/libspl \ cddl/lib/libumem \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ @@ -15,7 +14,6 @@ DIRDEPS = \ lib/libmd \ lib/libthr \ lib/libz \ - lib/msun \ .include <dirdeps.mk> diff --git a/cddl/lib/libzutil/Makefile b/cddl/lib/libzutil/Makefile index 2e6b53658b22..07ca3b9bc156 100644 --- a/cddl/lib/libzutil/Makefile +++ b/cddl/lib/libzutil/Makefile @@ -1,12 +1,10 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libzutil .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libzutil/os/freebsd .PATH: ${SRCTOP}/sys/contrib/openzfs/module/os/freebsd/zfs LIB= zutil LIBADD= avl geom m tpool -PACKAGE= runtime +PACKAGE= libzfs INCS = zutil_import.h @@ -30,6 +28,7 @@ CSTD= c99 CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/zfs CFLAGS+= -I${SRCTOP}/sys CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include diff --git a/cddl/lib/libzutil/Makefile.depend b/cddl/lib/libzutil/Makefile.depend new file mode 100644 index 000000000000..ddad58a70480 --- /dev/null +++ b/cddl/lib/libzutil/Makefile.depend @@ -0,0 +1,19 @@ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + cddl/lib/libavl \ + cddl/lib/libtpool \ + include \ + include/xlocale \ + lib/${CSU_DIR} \ + lib/libc \ + lib/libcompiler_rt \ + lib/libgeom \ + lib/msun \ + + +.include <dirdeps.mk> + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif diff --git a/cddl/lib/pam_zfs_key/Makefile b/cddl/lib/pam_zfs_key/Makefile index cf43802090dd..517ca402d4da 100644 --- a/cddl/lib/pam_zfs_key/Makefile +++ b/cddl/lib/pam_zfs_key/Makefile @@ -1,7 +1,7 @@ .PATH: ${SRCTOP}/sys/contrib/openzfs/contrib/pam_zfs_key .PATH: ${SRCTOP}/sys/contrib/openzfs/include -PACKAGE= utilities +PACKAGE= zfs LIB= pam_zfs_key SHLIBDIR?= /usr/lib @@ -14,8 +14,10 @@ WARNS?= 2 CSTD= c99 CFLAGS+= -DIN_BASE CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/module/icp/include CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h diff --git a/cddl/lib/tests/Makefile b/cddl/lib/tests/Makefile index 3b3078f8612a..29b1b564beca 100644 --- a/cddl/lib/tests/Makefile +++ b/cddl/lib/tests/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/tests KYUAFILE= yes diff --git a/cddl/lib/tests/Makefile.depend b/cddl/lib/tests/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/lib/tests/Makefile.depend +++ b/cddl/lib/tests/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/sbin/Makefile b/cddl/sbin/Makefile index 99c4a91a3e69..80862bbf8e7d 100644 --- a/cddl/sbin/Makefile +++ b/cddl/sbin/Makefile @@ -1,15 +1,10 @@ -# $FreeBSD$ - .include <src.opts.mk> -SUBDIR= ${_zfs} ${_zpool} - SUBDIR.${MK_TESTS}+= tests -.if ${MK_ZFS} != "no" -_zfs= zfs -_zpool= zpool -.endif +SUBDIR.${MK_ZFS}+= \ + zfs \ + zpool SUBDIR_PARALLEL= diff --git a/cddl/sbin/Makefile.inc b/cddl/sbin/Makefile.inc index c5111d5cb286..12d1247d4e9c 100644 --- a/cddl/sbin/Makefile.inc +++ b/cddl/sbin/Makefile.inc @@ -1,5 +1,3 @@ -# $FreeBSD$ - BINDIR?= /sbin .include "../Makefile.inc" diff --git a/cddl/sbin/tests/Makefile b/cddl/sbin/tests/Makefile index 3b3078f8612a..29b1b564beca 100644 --- a/cddl/sbin/tests/Makefile +++ b/cddl/sbin/tests/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/tests KYUAFILE= yes diff --git a/cddl/sbin/tests/Makefile.depend b/cddl/sbin/tests/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/sbin/tests/Makefile.depend +++ b/cddl/sbin/tests/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/sbin/zfs/Makefile b/cddl/sbin/zfs/Makefile index 6a6ef62e4fce..9a0a5198602e 100644 --- a/cddl/sbin/zfs/Makefile +++ b/cddl/sbin/zfs/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - ZFSTOP= ${SRCTOP}/sys/contrib/openzfs .PATH: ${ZFSTOP}/cmd/zfs @@ -7,7 +5,7 @@ ZFSTOP= ${SRCTOP}/sys/contrib/openzfs .PATH: ${ZFSTOP}/man/man8 .PATH: ${ZFSTOP}/module/os/freebsd/spl -PACKAGE= runtime +PACKAGE= zfs PROG= zfs MAN= \ zfs.8 \ @@ -27,6 +25,7 @@ MAN= \ zfs-promote.8 \ zfs-receive.8 \ zfs-rename.8 \ + zfs-rewrite.8 \ zfs-rollback.8 \ zfs-send.8 \ zfs-set.8 \ @@ -77,3 +76,5 @@ CFLAGS+= \ LIBADD= jail avl nvpair geom uutil zfs_core spl tpool zutil zfs m crypto LDADD+= -pthread .include <bsd.prog.mk> + +CWARNFLAGS.zfs_main.c+= -Wno-unused-variable diff --git a/cddl/sbin/zfs/Makefile.depend b/cddl/sbin/zfs/Makefile.depend index b22dd60b0ef8..41b9cb996621 100644 --- a/cddl/sbin/zfs/Makefile.depend +++ b/cddl/sbin/zfs/Makefile.depend @@ -1,28 +1,24 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ cddl/lib/libavl \ cddl/lib/libnvpair \ - cddl/lib/libumem \ + cddl/lib/libspl \ + cddl/lib/libtpool \ cddl/lib/libuutil \ cddl/lib/libzfs \ cddl/lib/libzfs_core \ - gnu/lib/csu \ + cddl/lib/libzutil \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ - lib/libexpat \ lib/libgeom \ lib/libjail \ - lib/libmd \ - lib/libsbuf \ lib/libthr \ - lib/libutil \ - lib/libz \ lib/msun \ + secure/lib/libcrypto \ .include <dirdeps.mk> diff --git a/cddl/sbin/zpool/Makefile b/cddl/sbin/zpool/Makefile index 4c2a8b94de19..ab7b852b4d9a 100644 --- a/cddl/sbin/zpool/Makefile +++ b/cddl/sbin/zpool/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - ZFSTOP= ${SRCTOP}/sys/contrib/openzfs .PATH: ${ZFSTOP}/man/man4 @@ -10,10 +8,11 @@ ZFSTOP= ${SRCTOP}/sys/contrib/openzfs .PATH: ${ZFSTOP}/cmd/zpool/os/freebsd -PACKAGE= runtime +PACKAGE= zfs PROG= zpool MAN= \ spl.4 \ + vdevprops.7 \ zfs.4 \ zpool.8 \ zpool-add.8 \ @@ -23,6 +22,7 @@ MAN= \ zpool-create.8 \ zpool-destroy.8 \ zpool-detach.8 \ + zpool-ddtprune.8 \ zpool-events.8 \ zpool-export.8 \ zpool-features.7 \ @@ -34,6 +34,7 @@ MAN= \ zpool-labelclear.8 \ zpool-list.8 \ zpool-offline.8 \ + zpool-prefetch.8 \ zpool-reguid.8 \ zpool-remove.8 \ zpool-reopen.8 \ @@ -66,6 +67,7 @@ CFLAGS+= \ -I${ZFSTOP}/include \ -I${ZFSTOP}/lib/libspl/include \ -I${ZFSTOP}/lib/libspl/include/os/freebsd \ + -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include \ -I${SRCTOP}/sys \ -I${SRCTOP}/cddl/compat/opensolaris/include \ -I${ZFSTOP}/cmd/zpool \ diff --git a/cddl/sbin/zpool/Makefile.depend b/cddl/sbin/zpool/Makefile.depend index 53090da6e2fc..117ee30093fd 100644 --- a/cddl/sbin/zpool/Makefile.depend +++ b/cddl/sbin/zpool/Makefile.depend @@ -1,26 +1,21 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ cddl/lib/libavl \ cddl/lib/libnvpair \ - cddl/lib/libumem \ + cddl/lib/libspl \ + cddl/lib/libtpool \ cddl/lib/libuutil \ cddl/lib/libzfs \ cddl/lib/libzfs_core \ - gnu/lib/csu \ + cddl/lib/libzutil \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ - lib/libexpat \ lib/libgeom \ - lib/libmd \ - lib/libsbuf \ lib/libthr \ - lib/libutil \ - lib/libz \ lib/msun \ diff --git a/cddl/share/Makefile b/cddl/share/Makefile index 68670ffbe7e0..4fdb0cba9ba6 100644 --- a/cddl/share/Makefile +++ b/cddl/share/Makefile @@ -1,12 +1,6 @@ -# $FreeBSD$ - .include <src.opts.mk> -SUBDIR= ${_zfs} - -.if ${MK_ZFS} != "no" -_zfs= zfs -.endif +SUBDIR.${MK_ZFS}+= zfs SUBDIR_PARALLEL= diff --git a/cddl/share/zfs/Makefile b/cddl/share/zfs/Makefile index 98e10b60aae6..6e10ede77d07 100644 --- a/cddl/share/zfs/Makefile +++ b/cddl/share/zfs/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .include <src.opts.mk> SUBDIR= compatibility.d diff --git a/cddl/share/zfs/compatibility.d/Makefile b/cddl/share/zfs/compatibility.d/Makefile index 255f4a3542b3..6cdb64b0fccb 100644 --- a/cddl/share/zfs/compatibility.d/Makefile +++ b/cddl/share/zfs/compatibility.d/Makefile @@ -1,9 +1,9 @@ -# $FreeBSD$ - ZFSTOP= ${SRCTOP}/sys/contrib/openzfs .PATH: ${ZFSTOP}/cmd/zpool/compatibility.d +PACKAGE= zfs + FILES= \ compat-2018 \ compat-2019 \ @@ -13,7 +13,8 @@ FILES= \ freebsd-11.2 \ freebsd-11.3 \ freenas-9.10.2 \ - grub2 \ + grub2-2.06 \ + grub2-2.12 \ openzfsonosx-1.7.0 \ openzfsonosx-1.8.1 \ openzfsonosx-1.9.3 \ @@ -21,6 +22,8 @@ FILES= \ openzfs-2.0-linux \ openzfs-2.1-freebsd \ openzfs-2.1-linux \ + openzfs-2.2 \ + openzfs-2.3 \ zol-0.6.1 \ zol-0.6.4 \ zol-0.6.5 \ @@ -41,12 +44,23 @@ LINKS= \ ${FILESDIR}/freebsd-11.3 ${FILESDIR}/freebsd-12.0 \ ${FILESDIR}/freebsd-11.3 ${FILESDIR}/freebsd-12.1 \ ${FILESDIR}/freebsd-11.3 ${FILESDIR}/freebsd-12.2 \ + ${FILESDIR}/freebsd-11.3 ${FILESDIR}/freebsd-12.3 \ + ${FILESDIR}/freebsd-11.3 ${FILESDIR}/freebsd-12.4 \ ${FILESDIR}/freebsd-11.3 ${FILESDIR}/freenas-11.3 \ ${FILESDIR}/freenas-11.0 ${FILESDIR}/freenas-11.1 \ + ${FILESDIR}/grub2-2.12 ${FILESDIR}/grub2 \ ${FILESDIR}/openzfsonosx-1.9.3 ${FILESDIR}/openzfsonosx-1.9.4 \ ${FILESDIR}/openzfs-2.0-freebsd ${FILESDIR}/truenas-12.0 \ + ${FILESDIR}/openzfs-2.1-freebsd ${FILESDIR}/freebsd-13.0 \ + ${FILESDIR}/openzfs-2.1-freebsd ${FILESDIR}/freebsd-13.1 \ + ${FILESDIR}/openzfs-2.1-freebsd ${FILESDIR}/freebsd-13.2 \ ${FILESDIR}/zol-0.7 ${FILESDIR}/ubuntu-18.04 \ - ${FILESDIR}/zol-0.8 ${FILESDIR}/ubuntu-20.04 + ${FILESDIR}/zol-0.8 ${FILESDIR}/ubuntu-20.04 \ + ${FILESDIR}/openzfs-2.1-linux ${FILESDIR}/ubuntu-22.04 \ + ${FILESDIR}/openzfs-2.2 ${FILESDIR}/openzfs-2.2-linux \ + ${FILESDIR}/openzfs-2.2 ${FILESDIR}/openzfs-2.2-freebsd \ + ${FILESDIR}/openzfs-2.3 ${FILESDIR}/openzfs-2.3-linux \ + ${FILESDIR}/openzfs-2.3 ${FILESDIR}/openzfs-2.3-freebsd LINKMODE= ${NOBINMODE} diff --git a/cddl/tests/Makefile b/cddl/tests/Makefile index 3b3078f8612a..29b1b564beca 100644 --- a/cddl/tests/Makefile +++ b/cddl/tests/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/tests KYUAFILE= yes diff --git a/cddl/tests/Makefile.depend b/cddl/tests/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/tests/Makefile.depend +++ b/cddl/tests/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.bin/Makefile b/cddl/usr.bin/Makefile index 10d55215c0b3..571d1c59a544 100644 --- a/cddl/usr.bin/Makefile +++ b/cddl/usr.bin/Makefile @@ -1,22 +1,16 @@ -# $FreeBSD$ - .include <src.opts.mk> -SUBDIR= \ +SUBDIR.${MK_DTRACE}+= \ ctfconvert \ ctfdump \ - ctfmerge \ - ${_zinject} \ - ${_zstream} \ - ${_ztest} + ctfmerge SUBDIR.${MK_TESTS}+= tests -.if ${MK_ZFS} != "no" -_zinject= zinject -_ztest= ztest -_zstream = zstream -.endif +SUBDIR.${MK_ZFS}+= \ + zinject \ + ztest \ + zstream SUBDIR_PARALLEL= diff --git a/cddl/usr.bin/Makefile.inc b/cddl/usr.bin/Makefile.inc index 4cec6fe01a45..b87015c546ca 100644 --- a/cddl/usr.bin/Makefile.inc +++ b/cddl/usr.bin/Makefile.inc @@ -1,5 +1,3 @@ -# $FreeBSD$ - BINDIR?= /usr/bin .include "../Makefile.inc" diff --git a/cddl/usr.bin/ctfconvert/Makefile b/cddl/usr.bin/ctfconvert/Makefile index 78b65020452a..cd9f850f480c 100644 --- a/cddl/usr.bin/ctfconvert/Makefile +++ b/cddl/usr.bin/ctfconvert/Makefile @@ -1,10 +1,9 @@ -# $FreeBSD$ - .include <src.opts.mk> .PATH: ${SRCTOP}/cddl/contrib/opensolaris/tools/ctf/common .PATH: ${SRCTOP}/cddl/contrib/opensolaris/tools/ctf/cvt +PACKAGE= ctf-tools PROG= ctfconvert SRCS= alist.c \ ctf.c \ diff --git a/cddl/usr.bin/ctfconvert/Makefile.depend b/cddl/usr.bin/ctfconvert/Makefile.depend index eb40124b7c90..69aabda6c27e 100644 --- a/cddl/usr.bin/ctfconvert/Makefile.depend +++ b/cddl/usr.bin/ctfconvert/Makefile.depend @@ -1,11 +1,9 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ + cddl/lib/libspl \ include \ include/xlocale \ - cddl/lib/libspl \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ diff --git a/cddl/usr.bin/ctfconvert/ctfconvert.1 b/cddl/usr.bin/ctfconvert/ctfconvert.1 index c7b01c9315ce..8baf9895b0e1 100644 --- a/cddl/usr.bin/ctfconvert/ctfconvert.1 +++ b/cddl/usr.bin/ctfconvert/ctfconvert.1 @@ -1,4 +1,6 @@ .\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" .\" Copyright (c) 2010 The FreeBSD Foundation .\" All rights reserved. .\" @@ -26,51 +28,53 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd April 21, 2022 .Dt CTFCONVERT 1 .Os .Sh NAME .Nm ctfconvert -.Nd convert debug data to CTF data +.Nd convert debug data to Compact C Type Format data .Sh SYNOPSIS .Nm .Op Fl gis -.Fl l Ar label .Fl L Ar labelenv +.Fl l Ar label .Op Fl o Ar outfile object_file .Sh DESCRIPTION The .Nm -utility converts debug information from a binary file to CTF (Compact C Type -Format) data and replaces the debug section of that file with a CTF section +utility converts debug information from a binary file to CTF +.Pq Compact C Type Format +data and replaces the debug section of that file with a CTF section called SUNW_ctf. -This new section is added to the input file, unless the -o +This new section is added to the input file, unless the +.Fl o option is present. You can also opt to keep the original debugging section with the --g option. +.Fl g +option. .Pp The following options are available: -.Bl -tag -width indent -.It Fl l Ar label -Sets the label as -.Ar label . -.It Fl L Ar labelenv -Instructs -.Nm -to read the label from the environment variable -.Ar labelenv . +.Bl -tag -width "-L labelenv" .It Fl g Don't delete the original debugging section. .It Fl i Ignore object files built from other languages than C. -.It Fl s -Use the .dynsym ELF section instead of the .symtab ELF section. +.It Fl L Ar labelenv +Instructs +.Nm +to read the label from the +.Ev labelenv +environment variable. +.It Fl l Ar label +Sets the label as +.Ar label . .It Fl o Ar outfile Write the output to file in .Ar outfile . +.It Fl s +Use the .dynsym ELF section instead of the .symtab ELF section. .El .Sh EXIT STATUS .Ex -std diff --git a/cddl/usr.bin/ctfconvert/tests/Makefile b/cddl/usr.bin/ctfconvert/tests/Makefile index 431a1f25bd9f..d86ddbcd635f 100644 --- a/cddl/usr.bin/ctfconvert/tests/Makefile +++ b/cddl/usr.bin/ctfconvert/tests/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - ATF_TESTS_SH+= ctfconvert_test .include <bsd.test.mk> diff --git a/cddl/usr.bin/ctfconvert/tests/ctfconvert_test.sh b/cddl/usr.bin/ctfconvert/tests/ctfconvert_test.sh index 04723fd08ad3..f19383cfbb4f 100644 --- a/cddl/usr.bin/ctfconvert/tests/ctfconvert_test.sh +++ b/cddl/usr.bin/ctfconvert/tests/ctfconvert_test.sh @@ -23,7 +23,6 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD$ # usage_output='Usage: ctfconvert' diff --git a/cddl/usr.bin/ctfdump/Makefile b/cddl/usr.bin/ctfdump/Makefile index d7ddd45d9778..23ded7458bed 100644 --- a/cddl/usr.bin/ctfdump/Makefile +++ b/cddl/usr.bin/ctfdump/Makefile @@ -1,8 +1,7 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/cddl/contrib/opensolaris/tools/ctf/common .PATH: ${SRCTOP}/cddl/contrib/opensolaris/tools/ctf/dump +PACKAGE= ctf-tools PROG= ctfdump SRCS= dump.c \ symbol.c \ diff --git a/cddl/usr.bin/ctfdump/Makefile.depend b/cddl/usr.bin/ctfdump/Makefile.depend index ceebc6a83a34..edb476e399d9 100644 --- a/cddl/usr.bin/ctfdump/Makefile.depend +++ b/cddl/usr.bin/ctfdump/Makefile.depend @@ -1,8 +1,6 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git a/cddl/usr.bin/ctfdump/ctfdump.1 b/cddl/usr.bin/ctfdump/ctfdump.1 index 68764d11b0f9..27dfe6563645 100644 --- a/cddl/usr.bin/ctfdump/ctfdump.1 +++ b/cddl/usr.bin/ctfdump/ctfdump.1 @@ -26,8 +26,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd April 21, 2022 .Dt CTFDUMP 1 .Os diff --git a/cddl/usr.bin/ctfmerge/Makefile b/cddl/usr.bin/ctfmerge/Makefile index e9c8e505ed76..4cd9511f911c 100644 --- a/cddl/usr.bin/ctfmerge/Makefile +++ b/cddl/usr.bin/ctfmerge/Makefile @@ -1,8 +1,7 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/cddl/contrib/opensolaris/tools/ctf/common .PATH: ${SRCTOP}/cddl/contrib/opensolaris/tools/ctf/cvt +PACKAGE= ctf-tools PROG= ctfmerge SRCS= alist.c \ barrier.c \ diff --git a/cddl/usr.bin/ctfmerge/Makefile.depend b/cddl/usr.bin/ctfmerge/Makefile.depend index 32a1985bd180..e724f22559ff 100644 --- a/cddl/usr.bin/ctfmerge/Makefile.depend +++ b/cddl/usr.bin/ctfmerge/Makefile.depend @@ -1,8 +1,7 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ + cddl/lib/libspl \ include \ include/xlocale \ lib/${CSU_DIR} \ diff --git a/cddl/usr.bin/ctfmerge/ctfmerge.1 b/cddl/usr.bin/ctfmerge/ctfmerge.1 index b84bd8c84ead..2bc70db82dc9 100644 --- a/cddl/usr.bin/ctfmerge/ctfmerge.1 +++ b/cddl/usr.bin/ctfmerge/ctfmerge.1 @@ -26,8 +26,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd April 21, 2022 .Dt CTFMERGE 1 .Os diff --git a/cddl/usr.bin/tests/Makefile b/cddl/usr.bin/tests/Makefile index 3b3078f8612a..29b1b564beca 100644 --- a/cddl/usr.bin/tests/Makefile +++ b/cddl/usr.bin/tests/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/tests KYUAFILE= yes diff --git a/cddl/usr.bin/tests/Makefile.depend b/cddl/usr.bin/tests/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.bin/tests/Makefile.depend +++ b/cddl/usr.bin/tests/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.bin/zinject/Makefile b/cddl/usr.bin/zinject/Makefile index fcc472c24214..921d4df7a651 100644 --- a/cddl/usr.bin/zinject/Makefile +++ b/cddl/usr.bin/zinject/Makefile @@ -1,10 +1,9 @@ -# $FreeBSD$ - ZFSTOP= ${SRCTOP}/sys/contrib/openzfs .PATH: ${ZFSTOP}/cmd/zinject .PATH: ${ZFSTOP}/man/man8 +PACKAGE= zfs PROG= zinject INCS= zinject.h SRCS= zinject.c translate.c @@ -16,6 +15,7 @@ CFLAGS+= \ -I${ZFSTOP}/include \ -I${ZFSTOP}/lib/libspl/include \ -I${ZFSTOP}/lib/libspl/include/os/freebsd \ + -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include \ -I${SRCTOP}/sys \ -I${SRCTOP}/cddl/compat/opensolaris/include \ -I${ZFSTOP}/module/icp/include \ diff --git a/cddl/usr.bin/zinject/Makefile.depend b/cddl/usr.bin/zinject/Makefile.depend index dfb2563fa7d1..c36e0e5ad2e7 100644 --- a/cddl/usr.bin/zinject/Makefile.depend +++ b/cddl/usr.bin/zinject/Makefile.depend @@ -1,27 +1,21 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ cddl/lib/libavl \ cddl/lib/libnvpair \ + cddl/lib/libspl \ cddl/lib/libumem \ cddl/lib/libuutil \ cddl/lib/libzfs \ cddl/lib/libzfs_core \ cddl/lib/libzpool \ - gnu/lib/csu \ + cddl/lib/libzutil \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ - lib/libexpat \ lib/libgeom \ - lib/libmd \ - lib/libsbuf \ - lib/libthr \ - lib/libutil \ - lib/libz \ lib/msun \ diff --git a/cddl/usr.bin/zstream/Makefile b/cddl/usr.bin/zstream/Makefile index cfcff71a813f..b131901cb6a9 100644 --- a/cddl/usr.bin/zstream/Makefile +++ b/cddl/usr.bin/zstream/Makefile @@ -1,28 +1,31 @@ -# $FreeBSD$ - ZFSTOP= ${SRCTOP}/sys/contrib/openzfs .PATH: ${ZFSTOP}/cmd/zstream .PATH: ${ZFSTOP}/man/man8 +PACKAGE= zfs PROG= zstream MAN= zstream.8 MLINKS= zstream.8 zstreamdump.8 INCS= zstream.h SRCS= \ zstream.c \ + zstream_decompress.c \ zstream_dump.c \ + zstream_recompress.c \ zstream_redup.c \ zstream_token.c -SYMLINKS= ${BINDIR}/zstream ${BINDIR}/zstreamdump +SYMLINKS= zstream ${BINDIR}/zstreamdump WARNS?= 2 CFLAGS+= \ -DIN_BASE \ + -DZFS_DEBUG \ -I${ZFSTOP}/include \ -I${ZFSTOP}/lib/libspl/include \ -I${ZFSTOP}/lib/libspl/include/os/freebsd \ + -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include \ -I${SRCTOP}/sys \ -I${SRCTOP}/cddl/compat/opensolaris/include \ -I${ZFSTOP}/module/icp/include \ diff --git a/cddl/usr.bin/ztest/Makefile b/cddl/usr.bin/ztest/Makefile index 91118d13775d..ef4bd561b41a 100644 --- a/cddl/usr.bin/ztest/Makefile +++ b/cddl/usr.bin/ztest/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .include <src.opts.mk> ZFSTOP= ${SRCTOP}/sys/contrib/openzfs @@ -7,6 +5,7 @@ ZFSTOP= ${SRCTOP}/sys/contrib/openzfs .PATH: ${ZFSTOP}/cmd .PATH: ${ZFSTOP}/man/man1 +PACKAGE= zfs PROG= ztest MAN= ztest.1 @@ -16,6 +15,7 @@ CFLAGS+= \ -I${ZFSTOP}/include \ -I${ZFSTOP}/lib/libspl/include \ -I${ZFSTOP}/lib/libspl/include/os/freebsd \ + -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include \ -I${SRCTOP}/cddl/compat/opensolaris/include \ -I${ZFSTOP}/module/icp/include \ -include ${ZFSTOP}/include/os/freebsd/spl/sys/ccompile.h \ diff --git a/cddl/usr.bin/ztest/Makefile.depend b/cddl/usr.bin/ztest/Makefile.depend index dfb2563fa7d1..dd387951fe20 100644 --- a/cddl/usr.bin/ztest/Makefile.depend +++ b/cddl/usr.bin/ztest/Makefile.depend @@ -1,27 +1,23 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ cddl/lib/libavl \ + cddl/lib/libicp \ cddl/lib/libnvpair \ + cddl/lib/libspl \ cddl/lib/libumem \ cddl/lib/libuutil \ cddl/lib/libzfs \ cddl/lib/libzfs_core \ cddl/lib/libzpool \ - gnu/lib/csu \ + cddl/lib/libzutil \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ - lib/libexpat \ lib/libgeom \ - lib/libmd \ - lib/libsbuf \ lib/libthr \ - lib/libutil \ - lib/libz \ lib/msun \ diff --git a/cddl/usr.bin/ztest/tests/Makefile b/cddl/usr.bin/ztest/tests/Makefile index edf2a537dbe3..88bcfc3ccf72 100644 --- a/cddl/usr.bin/ztest/tests/Makefile +++ b/cddl/usr.bin/ztest/tests/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .include <bsd.own.mk> ATF_TESTS_SH+= ztest diff --git a/cddl/usr.bin/ztest/tests/ztest.sh b/cddl/usr.bin/ztest/tests/ztest.sh index 9945d1a45aa9..8bc377917992 100755 --- a/cddl/usr.bin/ztest/tests/ztest.sh +++ b/cddl/usr.bin/ztest/tests/ztest.sh @@ -1,6 +1,5 @@ # # Test Case: ztest -# $FreeBSD$ # atf_test_case ztest ztest_head() diff --git a/cddl/usr.libexec/Makefile b/cddl/usr.libexec/Makefile index 6280cbab5766..ab4c4cb6741c 100644 --- a/cddl/usr.libexec/Makefile +++ b/cddl/usr.libexec/Makefile @@ -1,12 +1,8 @@ -# $FreeBSD$ - .include <src.opts.mk> -SUBDIR= ${_zpool_influxdb} - -.if ${MK_ZFS} != "no" -_zpool_influxdb= zpool_influxdb -.endif +SUBDIR.${MK_ZFS}+= \ + zfs_prepare_disk \ + zpool_influxdb SUBDIR_PARALLEL= diff --git a/cddl/usr.libexec/zfs_prepare_disk/Makefile b/cddl/usr.libexec/zfs_prepare_disk/Makefile new file mode 100644 index 000000000000..0d3f9b56b28c --- /dev/null +++ b/cddl/usr.libexec/zfs_prepare_disk/Makefile @@ -0,0 +1,19 @@ +ZFSTOP= ${SRCTOP}/sys/contrib/openzfs + +.PATH: ${ZFSTOP}/scripts + +PACKAGE= zfs +SCRIPTS= zfs_prepare_disk +SCRIPTSDIR= ${LIBEXECDIR}/zfs + +.PATH: ${ZFSTOP}/man/man8 +MAN= zfs_prepare_disk.8 + +CLEANFILES+= zfs_prepare_disk.8 + +zfs_prepare_disk.8: zfs_prepare_disk.8.in + sed ${MAN_SUB} ${.ALLSRC} >${.TARGET} + +MAN_SUB+= -e 's|@zfsexecdir@|${LIBEXECDIR}/zfs|g' + +.include <bsd.prog.mk> diff --git a/cddl/usr.libexec/zpool_influxdb/Makefile b/cddl/usr.libexec/zpool_influxdb/Makefile index 2fb22f02ef32..064ac9b23e4a 100644 --- a/cddl/usr.libexec/zpool_influxdb/Makefile +++ b/cddl/usr.libexec/zpool_influxdb/Makefile @@ -1,10 +1,9 @@ -# $FreeBSD$ - ZFSTOP= ${SRCTOP}/sys/contrib/openzfs .PATH: ${ZFSTOP}/cmd/zpool_influxdb .PATH: ${ZFSTOP}/man/man8 +PACKAGE=zfs PROG= zpool_influxdb MAN= zpool_influxdb.8 BINDIR?= /usr/libexec/zfs diff --git a/cddl/usr.libexec/zpool_influxdb/Makefile.depend b/cddl/usr.libexec/zpool_influxdb/Makefile.depend index 53090da6e2fc..50b043094969 100644 --- a/cddl/usr.libexec/zpool_influxdb/Makefile.depend +++ b/cddl/usr.libexec/zpool_influxdb/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/Makefile b/cddl/usr.sbin/Makefile index 4dde136dc412..b7f43ffd23bf 100644 --- a/cddl/usr.sbin/Makefile +++ b/cddl/usr.sbin/Makefile @@ -1,24 +1,17 @@ -# $FreeBSD$ - .include <src.opts.mk> -SUBDIR= ${_dtrace} \ +SUBDIR.${MK_DTRACE}+= \ + ${_dtrace} \ ${_dwatch} \ ${_lockstat} \ - ${_plockstat} \ - ${_zdb} \ - ${_zfsd} \ - ${_zhack} + ${_plockstat} SUBDIR.${MK_TESTS}+= tests -.if ${MK_ZFS} != "no" -_zdb= zdb -_zhack= zhack -. if ${MK_CXX} != "no" -_zfsd= zfsd -. endif -.endif +SUBDIR.${MK_ZFS}+= \ + zdb \ + zhack \ + zfsd .if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" _dtrace= dtrace diff --git a/cddl/usr.sbin/Makefile.inc b/cddl/usr.sbin/Makefile.inc index 282198ea8d8c..b660f1cc6638 100644 --- a/cddl/usr.sbin/Makefile.inc +++ b/cddl/usr.sbin/Makefile.inc @@ -1,5 +1,3 @@ -# $FreeBSD$ - BINDIR?= /usr/sbin .include "../Makefile.inc" diff --git a/cddl/usr.sbin/dtrace/Makefile b/cddl/usr.sbin/dtrace/Makefile index d8510e62fb29..c72b55cc4903 100644 --- a/cddl/usr.sbin/dtrace/Makefile +++ b/cddl/usr.sbin/dtrace/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .include <src.opts.mk> .PATH: ${SRCTOP}/cddl/contrib/opensolaris/cmd/dtrace @@ -30,7 +28,12 @@ CFLAGS+= -DHAVE_ISSETUGID #CFLAGS+= -DNEED_ERRLOC #YFLAGS+= -d -LIBADD= dtrace ctf elf proc spl +.if ${MK_DTRACE_ASAN} != "no" +CFLAGS+= -fsanitize=address -fsanitize=undefined +LDFLAGS+= -fsanitize=address -fsanitize=undefined +.endif + +LIBADD= dtrace ctf elf proc spl xo .if ${MK_DTRACE_TESTS} != "no" SUBDIR+= tests diff --git a/cddl/usr.sbin/dtrace/Makefile.depend b/cddl/usr.sbin/dtrace/Makefile.depend index c37ef4acf01e..244baabbff3d 100644 --- a/cddl/usr.sbin/dtrace/Makefile.depend +++ b/cddl/usr.sbin/dtrace/Makefile.depend @@ -1,24 +1,17 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ cddl/lib/libctf \ cddl/lib/libdtrace \ - gnu/lib/csu \ + cddl/lib/libspl \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ - lib/libcxxrt \ lib/libelf \ - lib/libkvm \ lib/libproc \ - lib/libprocstat \ lib/librtld_db \ - lib/libthr \ - lib/libutil \ - lib/libz \ .include <dirdeps.mk> diff --git a/cddl/usr.sbin/dtrace/tests/Makefile b/cddl/usr.sbin/dtrace/tests/Makefile index a311126f38b5..7aa8600bf702 100644 --- a/cddl/usr.sbin/dtrace/tests/Makefile +++ b/cddl/usr.sbin/dtrace/tests/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .include <bsd.own.mk> TESTS_SUBDIRS+= common diff --git a/cddl/usr.sbin/dtrace/tests/Makefile.depend b/cddl/usr.sbin/dtrace/tests/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/amd64/Makefile b/cddl/usr.sbin/dtrace/tests/amd64/Makefile index 39ccd333bedf..100a66fa744c 100644 --- a/cddl/usr.sbin/dtrace/tests/amd64/Makefile +++ b/cddl/usr.sbin/dtrace/tests/amd64/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - TESTSDIR= ${TESTSBASE}/cddl/usr.sbin/dtrace/amd64 TESTS_SUBDIRS+= arrays diff --git a/cddl/usr.sbin/dtrace/tests/amd64/arrays/Makefile b/cddl/usr.sbin/dtrace/tests/amd64/arrays/Makefile index 0308ba5083e1..d06cfb032f58 100644 --- a/cddl/usr.sbin/dtrace/tests/amd64/arrays/Makefile +++ b/cddl/usr.sbin/dtrace/tests/amd64/arrays/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/Makefile b/cddl/usr.sbin/dtrace/tests/common/Makefile index c395269e7aa9..a7c3aac9c6f5 100644 --- a/cddl/usr.sbin/dtrace/tests/common/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # We exclude several subdirectories: nfs and sysevent do not compile on # FreeBSD, and docsExamples doesn't seem amenable to automated testing. @@ -32,6 +30,7 @@ TESTS_SUBDIRS+= aggs \ ip \ java_api \ json \ + kinst \ lexer \ llquantize \ mdb \ @@ -39,6 +38,7 @@ TESTS_SUBDIRS+= aggs \ misc \ multiaggs \ offsetof \ + oformat \ operators \ pid \ plockstat \ diff --git a/cddl/usr.sbin/dtrace/tests/common/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/aggs/Makefile b/cddl/usr.sbin/dtrace/tests/common/aggs/Makefile index b5e95bc8fd67..2ab9c05e2f80 100644 --- a/cddl/usr.sbin/dtrace/tests/common/aggs/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/aggs/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/aggs/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/aggs/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/aggs/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/aggs/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/arithmetic/Makefile b/cddl/usr.sbin/dtrace/tests/common/arithmetic/Makefile index 2abee2f8598e..e7b8177f51f9 100644 --- a/cddl/usr.sbin/dtrace/tests/common/arithmetic/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/arithmetic/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/arithmetic/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/arithmetic/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/arithmetic/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/arithmetic/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/arrays/Makefile b/cddl/usr.sbin/dtrace/tests/common/arrays/Makefile index abbc48322795..04f64f07221c 100644 --- a/cddl/usr.sbin/dtrace/tests/common/arrays/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/arrays/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/arrays/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/arrays/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/arrays/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/arrays/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/assocs/Makefile b/cddl/usr.sbin/dtrace/tests/common/assocs/Makefile index d7e64b8e4501..faee92dcfe00 100644 --- a/cddl/usr.sbin/dtrace/tests/common/assocs/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/assocs/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/assocs/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/assocs/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/assocs/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/assocs/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/begin/Makefile b/cddl/usr.sbin/dtrace/tests/common/begin/Makefile index 1c254bfe2958..733f2f73fa19 100644 --- a/cddl/usr.sbin/dtrace/tests/common/begin/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/begin/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/begin/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/begin/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/begin/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/begin/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/bitfields/Makefile b/cddl/usr.sbin/dtrace/tests/common/bitfields/Makefile index 903e19262f73..dc3637c7fd07 100644 --- a/cddl/usr.sbin/dtrace/tests/common/bitfields/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/bitfields/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/bitfields/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/bitfields/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/bitfields/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/bitfields/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/buffering/Makefile b/cddl/usr.sbin/dtrace/tests/common/buffering/Makefile index e9680e57088c..f5e2f40cb1a8 100644 --- a/cddl/usr.sbin/dtrace/tests/common/buffering/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/buffering/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/buffering/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/buffering/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/buffering/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/buffering/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/builtinvar/Makefile b/cddl/usr.sbin/dtrace/tests/common/builtinvar/Makefile index 962e8c9bddb8..a22dd3ea6d05 100644 --- a/cddl/usr.sbin/dtrace/tests/common/builtinvar/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/builtinvar/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/builtinvar/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/builtinvar/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/builtinvar/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/builtinvar/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/cg/Makefile b/cddl/usr.sbin/dtrace/tests/common/cg/Makefile index e98af5191aea..68baf9acd33b 100644 --- a/cddl/usr.sbin/dtrace/tests/common/cg/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/cg/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/cg/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/cg/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/cg/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/cg/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/clauses/Makefile b/cddl/usr.sbin/dtrace/tests/common/clauses/Makefile index 0e835239c35d..f72aa480efba 100644 --- a/cddl/usr.sbin/dtrace/tests/common/clauses/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/clauses/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/clauses/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/clauses/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/clauses/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/clauses/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/cpc/Makefile b/cddl/usr.sbin/dtrace/tests/common/cpc/Makefile index 7b8e85d904e7..ec489bb094b6 100644 --- a/cddl/usr.sbin/dtrace/tests/common/cpc/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/cpc/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/cpc/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/cpc/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/cpc/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/cpc/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/decls/Makefile b/cddl/usr.sbin/dtrace/tests/common/decls/Makefile index bd3bf7716feb..6b8fb677d8a6 100644 --- a/cddl/usr.sbin/dtrace/tests/common/decls/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/decls/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/decls/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/decls/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/decls/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/decls/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/docsExamples/Makefile b/cddl/usr.sbin/dtrace/tests/common/docsExamples/Makefile index 5ca7d0908fd7..1dae1ddb11b4 100644 --- a/cddl/usr.sbin/dtrace/tests/common/docsExamples/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/docsExamples/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/docsExamples/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/docsExamples/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/docsExamples/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/docsExamples/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/drops/Makefile b/cddl/usr.sbin/dtrace/tests/common/drops/Makefile index 4f1973c69b26..87ed77eb0c2d 100644 --- a/cddl/usr.sbin/dtrace/tests/common/drops/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/drops/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/drops/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/drops/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/drops/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/drops/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/dtraceUtil/Makefile b/cddl/usr.sbin/dtrace/tests/common/dtraceUtil/Makefile index dc77d8f0bc04..9371ab837a40 100644 --- a/cddl/usr.sbin/dtrace/tests/common/dtraceUtil/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/dtraceUtil/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/dtraceUtil/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/dtraceUtil/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/dtraceUtil/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/dtraceUtil/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/end/Makefile b/cddl/usr.sbin/dtrace/tests/common/end/Makefile index a05361ec4a39..957a2290d250 100644 --- a/cddl/usr.sbin/dtrace/tests/common/end/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/end/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/end/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/end/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/end/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/end/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/enum/Makefile b/cddl/usr.sbin/dtrace/tests/common/enum/Makefile index 9b78801d4c2f..b83f0251799b 100644 --- a/cddl/usr.sbin/dtrace/tests/common/enum/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/enum/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/enum/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/enum/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/enum/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/enum/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/env/Makefile b/cddl/usr.sbin/dtrace/tests/common/env/Makefile index 9c37c28b448b..0d7ee4b975dd 100644 --- a/cddl/usr.sbin/dtrace/tests/common/env/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/env/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/error/Makefile b/cddl/usr.sbin/dtrace/tests/common/error/Makefile index afd93dd222ee..7bf4f38b63bf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/error/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/error/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/error/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/error/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/error/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/error/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/exit/Makefile b/cddl/usr.sbin/dtrace/tests/common/exit/Makefile index 3732caa83335..d58baea479c5 100644 --- a/cddl/usr.sbin/dtrace/tests/common/exit/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/exit/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/exit/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/exit/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/exit/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/exit/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile b/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile index c773b78ba795..0dee8f807065 100644 --- a/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # @@ -8,6 +6,8 @@ PACKAGE= tests ${PACKAGE}FILES= \ err.D_PDESC_ZERO.notreturn.d \ + tst.argtest.ksh \ + tst.argtest.ksh.out \ tst.basic.d \ tst.functionentry.d \ tst.functionreturnvalue.d \ diff --git a/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/fbtprovider/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/funcs/Makefile b/cddl/usr.sbin/dtrace/tests/common/funcs/Makefile index 67d0b3cc4928..52bd1fc67ba7 100644 --- a/cddl/usr.sbin/dtrace/tests/common/funcs/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/funcs/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/funcs/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/funcs/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/funcs/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/funcs/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/grammar/Makefile b/cddl/usr.sbin/dtrace/tests/common/grammar/Makefile index b9b94f2c6b35..42cad7c69357 100644 --- a/cddl/usr.sbin/dtrace/tests/common/grammar/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/grammar/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/grammar/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/grammar/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/grammar/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/grammar/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/include/Makefile b/cddl/usr.sbin/dtrace/tests/common/include/Makefile index d84f25bef30d..5e8a18816dfa 100644 --- a/cddl/usr.sbin/dtrace/tests/common/include/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/include/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/include/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/include/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/include/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/include/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/inline/Makefile b/cddl/usr.sbin/dtrace/tests/common/inline/Makefile index 3a30b97d3cb6..f21a46a7b41a 100644 --- a/cddl/usr.sbin/dtrace/tests/common/inline/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/inline/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/inline/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/inline/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/inline/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/inline/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/io/Makefile b/cddl/usr.sbin/dtrace/tests/common/io/Makefile index 9075358230c4..e8af41d187da 100644 --- a/cddl/usr.sbin/dtrace/tests/common/io/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/io/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/io/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/io/Makefile.depend index cae7e645ef6a..d80b3a4991d1 100644 --- a/cddl/usr.sbin/dtrace/tests/common/io/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/io/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/ip/Makefile b/cddl/usr.sbin/dtrace/tests/common/ip/Makefile index 25a214b7f37b..e005b43d064d 100644 --- a/cddl/usr.sbin/dtrace/tests/common/ip/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/ip/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/ip/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/ip/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/ip/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/ip/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/java_api/Makefile b/cddl/usr.sbin/dtrace/tests/common/java_api/Makefile index 7c7fdef9c008..e902c1bc4562 100644 --- a/cddl/usr.sbin/dtrace/tests/common/java_api/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/java_api/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/java_api/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/java_api/Makefile.depend index cae7e645ef6a..d80b3a4991d1 100644 --- a/cddl/usr.sbin/dtrace/tests/common/java_api/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/java_api/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/json/Makefile b/cddl/usr.sbin/dtrace/tests/common/json/Makefile index 24400027c1e4..e3a0020149c2 100644 --- a/cddl/usr.sbin/dtrace/tests/common/json/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/json/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/json/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/json/Makefile.depend index cae7e645ef6a..d80b3a4991d1 100644 --- a/cddl/usr.sbin/dtrace/tests/common/json/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/json/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/kinst/Makefile b/cddl/usr.sbin/dtrace/tests/common/kinst/Makefile new file mode 100644 index 000000000000..c683a5ce0700 --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/kinst/Makefile @@ -0,0 +1,17 @@ +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +PACKAGE= tests + +${PACKAGE}FILES= \ + tst.basic.ksh \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../dtrace.test.mk" diff --git a/cddl/usr.sbin/dtrace/tests/common/lexer/Makefile b/cddl/usr.sbin/dtrace/tests/common/lexer/Makefile index d53872a0361b..8b7ec52c7f1f 100644 --- a/cddl/usr.sbin/dtrace/tests/common/lexer/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/lexer/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/lexer/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/lexer/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/lexer/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/lexer/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile b/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile index ed99dd1e116f..e4bb476f0df7 100644 --- a/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/llquantize/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/mdb/Makefile b/cddl/usr.sbin/dtrace/tests/common/mdb/Makefile index 26c26e7ba558..be8f66af0193 100644 --- a/cddl/usr.sbin/dtrace/tests/common/mdb/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/mdb/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/mdb/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/mdb/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/mdb/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/mdb/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/mib/Makefile b/cddl/usr.sbin/dtrace/tests/common/mib/Makefile index ed799e68a879..b6d335b03f7e 100644 --- a/cddl/usr.sbin/dtrace/tests/common/mib/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/mib/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/mib/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/mib/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/mib/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/mib/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/misc/Makefile b/cddl/usr.sbin/dtrace/tests/common/misc/Makefile index 87084ab5d593..bc96403cfe22 100644 --- a/cddl/usr.sbin/dtrace/tests/common/misc/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/misc/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/misc/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/misc/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/misc/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/misc/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/multiaggs/Makefile b/cddl/usr.sbin/dtrace/tests/common/multiaggs/Makefile index 2c0c4263a909..16bb602627bb 100644 --- a/cddl/usr.sbin/dtrace/tests/common/multiaggs/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/multiaggs/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/multiaggs/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/multiaggs/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/multiaggs/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/multiaggs/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/nfs/Makefile b/cddl/usr.sbin/dtrace/tests/common/nfs/Makefile index b50285991374..81af106bce7d 100644 --- a/cddl/usr.sbin/dtrace/tests/common/nfs/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/nfs/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/offsetof/Makefile b/cddl/usr.sbin/dtrace/tests/common/offsetof/Makefile index 2f56b12a035c..856f58d0afbd 100644 --- a/cddl/usr.sbin/dtrace/tests/common/offsetof/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/offsetof/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/offsetof/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/offsetof/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/offsetof/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/offsetof/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/oformat/Makefile b/cddl/usr.sbin/dtrace/tests/common/oformat/Makefile new file mode 100644 index 000000000000..219833285d0c --- /dev/null +++ b/cddl/usr.sbin/dtrace/tests/common/oformat/Makefile @@ -0,0 +1,42 @@ +# +# This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. +# + +PACKAGE= tests + +${PACKAGE}FILES= \ + tst.agg.avg.ksh \ + tst.agg.count.ksh \ + tst.agg.llquantize.ksh \ + tst.agg.lquantize.ksh \ + tst.agg.max.ksh \ + tst.agg.min.ksh \ + tst.agg.quantize.ksh \ + tst.agg.stddev.ksh \ + tst.agg.sum.ksh \ + tst.aggmod.ksh \ + tst.aggstack.ksh \ + tst.aggsym.ksh \ + tst.aggustack.ksh \ + tst.aggusym.ksh \ + tst.drop.ksh \ + tst.mod.ksh \ + tst.print.ksh \ + tst.printf.ksh \ + tst.printm.ksh \ + tst.stack.ksh \ + tst.sym.ksh \ + tst.trace.ksh \ + tst.tracemem.ksh \ + tst.umod.ksh \ + tst.ustack.ksh \ + tst.usym.ksh \ + +TESTEXES= \ + + +CFILES= \ + + + +.include "../../dtrace.test.mk" diff --git a/cddl/usr.sbin/dtrace/tests/common/operators/Makefile b/cddl/usr.sbin/dtrace/tests/common/operators/Makefile index daf530b93b62..6586e026fa0e 100644 --- a/cddl/usr.sbin/dtrace/tests/common/operators/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/operators/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/operators/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/operators/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/operators/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/operators/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/pid/Makefile b/cddl/usr.sbin/dtrace/tests/common/pid/Makefile index 0b9fdeb8bb6e..70fc2f3f34e6 100644 --- a/cddl/usr.sbin/dtrace/tests/common/pid/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/pid/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/pid/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/pid/Makefile.depend index cae7e645ef6a..d80b3a4991d1 100644 --- a/cddl/usr.sbin/dtrace/tests/common/pid/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/pid/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/plockstat/Makefile b/cddl/usr.sbin/dtrace/tests/common/plockstat/Makefile index 57e30ed99036..bf927d104601 100644 --- a/cddl/usr.sbin/dtrace/tests/common/plockstat/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/plockstat/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/plockstat/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/plockstat/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/plockstat/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/plockstat/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/pointers/Makefile b/cddl/usr.sbin/dtrace/tests/common/pointers/Makefile index af438aaaac2c..cfd83844f53c 100644 --- a/cddl/usr.sbin/dtrace/tests/common/pointers/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/pointers/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/pointers/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/pointers/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/pointers/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/pointers/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/pragma/Makefile b/cddl/usr.sbin/dtrace/tests/common/pragma/Makefile index 26b6920d0b0c..008bbeb50dcf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/pragma/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/pragma/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/pragma/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/pragma/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/pragma/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/pragma/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/predicates/Makefile b/cddl/usr.sbin/dtrace/tests/common/predicates/Makefile index bd14b43757f6..9de4716fdad8 100644 --- a/cddl/usr.sbin/dtrace/tests/common/predicates/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/predicates/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/predicates/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/predicates/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/predicates/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/predicates/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/preprocessor/Makefile b/cddl/usr.sbin/dtrace/tests/common/preprocessor/Makefile index f8b8917be205..a32410bab1c8 100644 --- a/cddl/usr.sbin/dtrace/tests/common/preprocessor/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/preprocessor/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/preprocessor/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/preprocessor/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/preprocessor/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/preprocessor/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/print/Makefile b/cddl/usr.sbin/dtrace/tests/common/print/Makefile index af4e20e30557..e072128c6b44 100644 --- a/cddl/usr.sbin/dtrace/tests/common/print/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/print/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/print/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/print/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/print/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/print/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/printa/Makefile b/cddl/usr.sbin/dtrace/tests/common/printa/Makefile index 8f5ac3613dcb..490a1976abe6 100644 --- a/cddl/usr.sbin/dtrace/tests/common/printa/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/printa/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/printa/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/printa/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/printa/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/printa/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/printf/Makefile b/cddl/usr.sbin/dtrace/tests/common/printf/Makefile index 86cfdbbd5d9b..1e4e418adbd2 100644 --- a/cddl/usr.sbin/dtrace/tests/common/printf/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/printf/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/printf/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/printf/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/printf/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/printf/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/privs/Makefile b/cddl/usr.sbin/dtrace/tests/common/privs/Makefile index 36f6106f8f96..7c06b13489e5 100644 --- a/cddl/usr.sbin/dtrace/tests/common/privs/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/privs/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/privs/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/privs/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/privs/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/privs/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/probes/Makefile b/cddl/usr.sbin/dtrace/tests/common/probes/Makefile index 7e02b9a73900..9bc11ba16362 100644 --- a/cddl/usr.sbin/dtrace/tests/common/probes/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/probes/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/probes/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/probes/Makefile.depend index cae7e645ef6a..d80b3a4991d1 100644 --- a/cddl/usr.sbin/dtrace/tests/common/probes/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/probes/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/proc/Makefile b/cddl/usr.sbin/dtrace/tests/common/proc/Makefile index 296634da3e38..6009b0dddd07 100644 --- a/cddl/usr.sbin/dtrace/tests/common/proc/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/proc/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/proc/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/proc/Makefile.depend index 564eb51e0156..ab828d5334d8 100644 --- a/cddl/usr.sbin/dtrace/tests/common/proc/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/proc/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile b/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile index 4e5a0157ecff..84f4706b61ee 100644 --- a/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile.depend index 03d33794d0e3..af9acf31579d 100644 --- a/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/providers/Makefile b/cddl/usr.sbin/dtrace/tests/common/providers/Makefile index 3972831ba5d5..e1c38944e3ff 100644 --- a/cddl/usr.sbin/dtrace/tests/common/providers/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/providers/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/providers/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/providers/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/providers/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/providers/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/raise/Makefile b/cddl/usr.sbin/dtrace/tests/common/raise/Makefile index 83af0e40de1f..61de9b115cc1 100644 --- a/cddl/usr.sbin/dtrace/tests/common/raise/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/raise/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/raise/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/raise/Makefile.depend index cae7e645ef6a..d80b3a4991d1 100644 --- a/cddl/usr.sbin/dtrace/tests/common/raise/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/raise/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/rates/Makefile b/cddl/usr.sbin/dtrace/tests/common/rates/Makefile index bc9ab0a9d446..7cce698dd37c 100644 --- a/cddl/usr.sbin/dtrace/tests/common/rates/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/rates/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/rates/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/rates/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/rates/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/rates/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/safety/Makefile b/cddl/usr.sbin/dtrace/tests/common/safety/Makefile index 51b302fd3ad7..5d7bd3b0dd77 100644 --- a/cddl/usr.sbin/dtrace/tests/common/safety/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/safety/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/safety/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/safety/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/safety/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/safety/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/scalars/Makefile b/cddl/usr.sbin/dtrace/tests/common/scalars/Makefile index 9f019068da35..a1942e1653cd 100644 --- a/cddl/usr.sbin/dtrace/tests/common/scalars/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/scalars/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/scalars/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/scalars/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/scalars/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/scalars/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/sched/Makefile b/cddl/usr.sbin/dtrace/tests/common/sched/Makefile index d1bf42553346..abd2a4bdc904 100644 --- a/cddl/usr.sbin/dtrace/tests/common/sched/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/sched/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/sched/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/sched/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/sched/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/sched/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/scripting/Makefile b/cddl/usr.sbin/dtrace/tests/common/scripting/Makefile index 1562629423ea..d46b1bb12546 100644 --- a/cddl/usr.sbin/dtrace/tests/common/scripting/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/scripting/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/scripting/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/scripting/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/scripting/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/scripting/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/sdt/Makefile b/cddl/usr.sbin/dtrace/tests/common/sdt/Makefile index ad0a43e4047e..fca9f42ddd97 100644 --- a/cddl/usr.sbin/dtrace/tests/common/sdt/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/sdt/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/sdt/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/sdt/Makefile.depend index cae7e645ef6a..d80b3a4991d1 100644 --- a/cddl/usr.sbin/dtrace/tests/common/sdt/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/sdt/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/sizeof/Makefile b/cddl/usr.sbin/dtrace/tests/common/sizeof/Makefile index 021d0099b213..72238f2b1436 100644 --- a/cddl/usr.sbin/dtrace/tests/common/sizeof/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/sizeof/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/sizeof/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/sizeof/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/sizeof/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/sizeof/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/speculation/Makefile b/cddl/usr.sbin/dtrace/tests/common/speculation/Makefile index 5afee0225e89..f39f9772bcc9 100644 --- a/cddl/usr.sbin/dtrace/tests/common/speculation/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/speculation/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/speculation/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/speculation/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/speculation/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/speculation/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/stability/Makefile b/cddl/usr.sbin/dtrace/tests/common/stability/Makefile index 826202d4de3f..5becc2451938 100644 --- a/cddl/usr.sbin/dtrace/tests/common/stability/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/stability/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/stability/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/stability/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/stability/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/stability/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/stack/Makefile b/cddl/usr.sbin/dtrace/tests/common/stack/Makefile index 2fc1e8164dc6..413bc56f57d8 100644 --- a/cddl/usr.sbin/dtrace/tests/common/stack/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/stack/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/stack/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/stack/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/stack/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/stack/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/stackdepth/Makefile b/cddl/usr.sbin/dtrace/tests/common/stackdepth/Makefile index e7beb43fa827..2cbdc34d5c35 100644 --- a/cddl/usr.sbin/dtrace/tests/common/stackdepth/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/stackdepth/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/stackdepth/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/stackdepth/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/stackdepth/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/stackdepth/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/stop/Makefile b/cddl/usr.sbin/dtrace/tests/common/stop/Makefile index 50a44bbd0a98..eb55979f3449 100644 --- a/cddl/usr.sbin/dtrace/tests/common/stop/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/stop/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/stop/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/stop/Makefile.depend index cae7e645ef6a..d80b3a4991d1 100644 --- a/cddl/usr.sbin/dtrace/tests/common/stop/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/stop/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/strlen/Makefile b/cddl/usr.sbin/dtrace/tests/common/strlen/Makefile index 19937d3055eb..ff61302bf8a5 100644 --- a/cddl/usr.sbin/dtrace/tests/common/strlen/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/strlen/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/strlen/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/strlen/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/strlen/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/strlen/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/strtoll/Makefile b/cddl/usr.sbin/dtrace/tests/common/strtoll/Makefile index 0ccc037d8bf3..80a6fd17082e 100644 --- a/cddl/usr.sbin/dtrace/tests/common/strtoll/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/strtoll/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/strtoll/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/strtoll/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/strtoll/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/strtoll/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/struct/Makefile b/cddl/usr.sbin/dtrace/tests/common/struct/Makefile index 35dd51a8067c..93c2a1cd94c0 100644 --- a/cddl/usr.sbin/dtrace/tests/common/struct/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/struct/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/struct/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/struct/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/struct/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/struct/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/sugar/Makefile b/cddl/usr.sbin/dtrace/tests/common/sugar/Makefile index 40fc86a45ce0..595c05b85fce 100644 --- a/cddl/usr.sbin/dtrace/tests/common/sugar/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/sugar/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/sugar/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/sugar/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/sugar/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/sugar/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/syscall/Makefile b/cddl/usr.sbin/dtrace/tests/common/syscall/Makefile index f759b6bd398f..e0d8f4d85ec0 100644 --- a/cddl/usr.sbin/dtrace/tests/common/syscall/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/syscall/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/syscall/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/syscall/Makefile.depend index cae7e645ef6a..d80b3a4991d1 100644 --- a/cddl/usr.sbin/dtrace/tests/common/syscall/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/syscall/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/sysevent/Makefile b/cddl/usr.sbin/dtrace/tests/common/sysevent/Makefile index d87b2bbaf042..980d8a587a08 100644 --- a/cddl/usr.sbin/dtrace/tests/common/sysevent/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/sysevent/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/tick-n/Makefile b/cddl/usr.sbin/dtrace/tests/common/tick-n/Makefile index 1800635351d7..455782bfc823 100644 --- a/cddl/usr.sbin/dtrace/tests/common/tick-n/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/tick-n/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/tick-n/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/tick-n/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/tick-n/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/tick-n/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/trace/Makefile b/cddl/usr.sbin/dtrace/tests/common/trace/Makefile index 19ff8e44230b..182e460410a5 100644 --- a/cddl/usr.sbin/dtrace/tests/common/trace/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/trace/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/trace/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/trace/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/trace/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/trace/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/tracemem/Makefile b/cddl/usr.sbin/dtrace/tests/common/tracemem/Makefile index 29b0ea26e691..accb6959b775 100644 --- a/cddl/usr.sbin/dtrace/tests/common/tracemem/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/tracemem/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/tracemem/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/tracemem/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/tracemem/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/tracemem/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/translators/Makefile b/cddl/usr.sbin/dtrace/tests/common/translators/Makefile index 6d38d1d63e36..f0f8f4db8970 100644 --- a/cddl/usr.sbin/dtrace/tests/common/translators/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/translators/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/translators/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/translators/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/translators/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/translators/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/typedef/Makefile b/cddl/usr.sbin/dtrace/tests/common/typedef/Makefile index d3edcfd071ed..100538f4b867 100644 --- a/cddl/usr.sbin/dtrace/tests/common/typedef/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/typedef/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/typedef/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/typedef/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/typedef/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/typedef/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/types/Makefile b/cddl/usr.sbin/dtrace/tests/common/types/Makefile index 89c2947f2632..e4a7a2b1479d 100644 --- a/cddl/usr.sbin/dtrace/tests/common/types/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/types/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/types/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/types/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/types/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/types/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/uctf/Makefile b/cddl/usr.sbin/dtrace/tests/common/uctf/Makefile index 945a853b69df..4847feccc770 100644 --- a/cddl/usr.sbin/dtrace/tests/common/uctf/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/uctf/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/uctf/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/uctf/Makefile.depend index cae7e645ef6a..d80b3a4991d1 100644 --- a/cddl/usr.sbin/dtrace/tests/common/uctf/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/uctf/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/union/Makefile b/cddl/usr.sbin/dtrace/tests/common/union/Makefile index 855869f05f04..e11f4831e7d9 100644 --- a/cddl/usr.sbin/dtrace/tests/common/union/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/union/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/union/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/union/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/union/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/union/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile b/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile index dd5571980d1d..8717fc68173c 100644 --- a/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile.depend index cae7e645ef6a..d80b3a4991d1 100644 --- a/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/usdt/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/ustack/Makefile b/cddl/usr.sbin/dtrace/tests/common/ustack/Makefile index 6ea0621a0c29..68a690df76aa 100644 --- a/cddl/usr.sbin/dtrace/tests/common/ustack/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/ustack/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/ustack/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/ustack/Makefile.depend index cae7e645ef6a..d80b3a4991d1 100644 --- a/cddl/usr.sbin/dtrace/tests/common/ustack/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/ustack/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/vars/Makefile b/cddl/usr.sbin/dtrace/tests/common/vars/Makefile index bced0bf6da53..db7f4df5e405 100644 --- a/cddl/usr.sbin/dtrace/tests/common/vars/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/vars/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/vars/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/vars/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/vars/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/vars/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/common/version/Makefile b/cddl/usr.sbin/dtrace/tests/common/version/Makefile index 3f1589f4249c..c472ecec588c 100644 --- a/cddl/usr.sbin/dtrace/tests/common/version/Makefile +++ b/cddl/usr.sbin/dtrace/tests/common/version/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/common/version/Makefile.depend b/cddl/usr.sbin/dtrace/tests/common/version/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/dtrace/tests/common/version/Makefile.depend +++ b/cddl/usr.sbin/dtrace/tests/common/version/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/dtrace/tests/dtrace.test.mk b/cddl/usr.sbin/dtrace/tests/dtrace.test.mk index 0da134c0cbc2..54e2aec68dcc 100644 --- a/cddl/usr.sbin/dtrace/tests/dtrace.test.mk +++ b/cddl/usr.sbin/dtrace/tests/dtrace.test.mk @@ -1,4 +1,3 @@ -# $FreeBSD$ TESTGROUP= ${.CURDIR:H:T}/${.CURDIR:T} TESTBASE= ${SRCTOP}/cddl/contrib/opensolaris/cmd/dtrace/test/tst @@ -13,7 +12,7 @@ ${TESTGROUP}EXEPACKAGE= ${PACKAGE} TESTWRAPPER= t_dtrace_contrib ATF_TESTS_SH+= ${TESTWRAPPER} -TEST_METADATA.t_dtrace_contrib+= required_files="/usr/local/bin/ksh" +TEST_METADATA.t_dtrace_contrib+= required_programs="ksh jq perl xmllint" TEST_METADATA.t_dtrace_contrib+= required_user="root" GENTEST?= ${.CURDIR:H:H}/tools/gentest.sh diff --git a/cddl/usr.sbin/dtrace/tests/i386/Makefile b/cddl/usr.sbin/dtrace/tests/i386/Makefile index bd6f7cf5ad5c..4150a33adde9 100644 --- a/cddl/usr.sbin/dtrace/tests/i386/Makefile +++ b/cddl/usr.sbin/dtrace/tests/i386/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - TESTSDIR= ${TESTSBASE}/cddl/usr.sbin/dtrace/i386 TESTS_SUBDIRS+= arrays \ funcs \ diff --git a/cddl/usr.sbin/dtrace/tests/i386/arrays/Makefile b/cddl/usr.sbin/dtrace/tests/i386/arrays/Makefile index e97c9c64fbba..d6025751a877 100644 --- a/cddl/usr.sbin/dtrace/tests/i386/arrays/Makefile +++ b/cddl/usr.sbin/dtrace/tests/i386/arrays/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/i386/funcs/Makefile b/cddl/usr.sbin/dtrace/tests/i386/funcs/Makefile index 64a00fa57d8b..1d8fed1849ac 100644 --- a/cddl/usr.sbin/dtrace/tests/i386/funcs/Makefile +++ b/cddl/usr.sbin/dtrace/tests/i386/funcs/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/i386/pid/Makefile b/cddl/usr.sbin/dtrace/tests/i386/pid/Makefile index 61fb328cbc7b..fac69dae8306 100644 --- a/cddl/usr.sbin/dtrace/tests/i386/pid/Makefile +++ b/cddl/usr.sbin/dtrace/tests/i386/pid/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/i386/ustack/Makefile b/cddl/usr.sbin/dtrace/tests/i386/ustack/Makefile index bc7c6a2d34c0..e1d274cb17a8 100644 --- a/cddl/usr.sbin/dtrace/tests/i386/ustack/Makefile +++ b/cddl/usr.sbin/dtrace/tests/i386/ustack/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # # This Makefile was generated by $srcdir/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/tools/dtest.sh b/cddl/usr.sbin/dtrace/tests/tools/dtest.sh index dc1f0244739c..a6634bea43a6 100755 --- a/cddl/usr.sbin/dtrace/tests/tools/dtest.sh +++ b/cddl/usr.sbin/dtrace/tests/tools/dtest.sh @@ -1,7 +1,5 @@ #!/bin/sh -# $FreeBSD$ - usage() { cat >&2 <<__EOF__ @@ -72,7 +70,7 @@ runtest() err.*.ksh|tst.*.ksh) expr "$TFILE" : 'err.*' >/dev/null && exstatus=1 - tst=$TFILE ksh "$TFILE" /usr/sbin/dtrace >$STDOUT 2>$STDERR + tst=$TFILE ksh -p "$TFILE" /usr/sbin/dtrace >$STDOUT 2>$STDERR status=$? if [ $status -ne $exstatus ]; then @@ -88,7 +86,7 @@ runtest() if [ $retval -eq 0 ] && \ head -n 1 $STDOUT | grep -q -E '^#!/.*ksh$'; then - ksh $STDOUT + ksh -p $STDOUT retval=$? fi @@ -102,7 +100,7 @@ readonly STDOUT=$(mktemp) readonly TFILE=$(basename $1) readonly EXOUT=${TFILE}.out -kldstat -q -m dtrace_test || kldload dtrace_test +kldload -n dtrace_test cd $(dirname $1) runtest RESULT=$? @@ -121,6 +119,10 @@ test stdout: -- $(cat $STDOUT) -- +test stdout diff: +-- +$(diff -u $EXOUT $STDOUT) +-- __EOF__ fi if [ $(stat -f '%z' $STDERR) -gt 0 ]; then diff --git a/cddl/usr.sbin/dtrace/tests/tools/exclude.sh b/cddl/usr.sbin/dtrace/tests/tools/exclude.sh index 26e875073edd..dce5a843b605 100755 --- a/cddl/usr.sbin/dtrace/tests/tools/exclude.sh +++ b/cddl/usr.sbin/dtrace/tests/tools/exclude.sh @@ -1,4 +1,3 @@ -# $FreeBSD$ # This file lists DTrace tests which are known to fail or hang/crash the # system. They were pulled from the legacy DTrace test infrastructure in diff --git a/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh b/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh index 4f756f7eaf3a..b3663a91d9ef 100755 --- a/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh +++ b/cddl/usr.sbin/dtrace/tests/tools/genmakefiles.sh @@ -1,4 +1,3 @@ -# $FreeBSD$ usage() { @@ -60,8 +59,6 @@ WITH_CTF=YES local makefile=$(mktemp) cat <<__EOF__ > $makefile -# \$FreeBSD$ - # # This Makefile was generated by \$srcdir${ORIGINDIR#${TOPDIR}}/genmakefiles.sh. # diff --git a/cddl/usr.sbin/dtrace/tests/tools/gentest.sh b/cddl/usr.sbin/dtrace/tests/tools/gentest.sh index 6bad066e5419..5d8912ac29b0 100755 --- a/cddl/usr.sbin/dtrace/tests/tools/gentest.sh +++ b/cddl/usr.sbin/dtrace/tests/tools/gentest.sh @@ -1,4 +1,3 @@ -# $FreeBSD$ usage() { diff --git a/cddl/usr.sbin/dwatch/Makefile b/cddl/usr.sbin/dwatch/Makefile index aa2873ec4681..a50774d56039 100644 --- a/cddl/usr.sbin/dwatch/Makefile +++ b/cddl/usr.sbin/dwatch/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .include <src.opts.mk> PACKAGE= dwatch diff --git a/cddl/usr.sbin/dwatch/dwatch b/cddl/usr.sbin/dwatch/dwatch index 8d90d8173dfe..c9af8258f4ac 100755 --- a/cddl/usr.sbin/dwatch/dwatch +++ b/cddl/usr.sbin/dwatch/dwatch @@ -27,7 +27,6 @@ ############################################################ IDENT(1) # # $Title: Watch processes as they trigger a particular DTrace probe $ -# $FreeBSD$ # ############################################################ CONFIGURATION @@ -1328,7 +1327,6 @@ PSARGS_ACTION=$( cat <&9 ) * SUCH DAMAGE. * * $TITLE dtrace(1) script to log process(es) triggering $PROBE $ - * \$FreeBSD$ */ $( echo "$DTRACE_PRAGMA" | awk ' diff --git a/cddl/usr.sbin/dwatch/dwatch.1 b/cddl/usr.sbin/dwatch/dwatch.1 index d5595a530c0e..81efb2c2c437 100644 --- a/cddl/usr.sbin/dwatch/dwatch.1 +++ b/cddl/usr.sbin/dwatch/dwatch.1 @@ -22,9 +22,7 @@ .\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd February 9, 2018 +.Dd April 18, 2025 .Dt DWATCH 1 .Os .Sh NAME @@ -68,7 +66,7 @@ utility uses .Xr dtrace 1 to display process info when a given DTrace probe point is triggered. Only the root user or users with -.Xr sudo 8 +.Xr sudo 8 Pq Pa ports/security/sudo access can run this command. .Pp .Nm @@ -558,7 +556,7 @@ dwatch -X kill .Ed .Pp Watch signals being passed between -.Xr bash 1 +.Xr bash 1 Pq Pa ports/shells/bash and .Xr vi 1 . .Bd -literal -offset indent diff --git a/cddl/usr.sbin/dwatch/examples/Makefile b/cddl/usr.sbin/dwatch/examples/Makefile index 344d67d27ec8..a0bfd3c5cd39 100644 --- a/cddl/usr.sbin/dwatch/examples/Makefile +++ b/cddl/usr.sbin/dwatch/examples/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - PACKAGE= dwatch FILESDIR= ${SHAREDIR}/examples/dwatch FILES= profile_template diff --git a/cddl/usr.sbin/dwatch/examples/profile_template b/cddl/usr.sbin/dwatch/examples/profile_template index 8bb3acfed2fb..c5b357c3f946 100644 --- a/cddl/usr.sbin/dwatch/examples/profile_template +++ b/cddl/usr.sbin/dwatch/examples/profile_template @@ -4,7 +4,6 @@ # # $Title: dwatch(8) profile for XXX entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/Makefile b/cddl/usr.sbin/dwatch/libexec/Makefile index 581556eeebd0..72ea5be686fb 100644 --- a/cddl/usr.sbin/dwatch/libexec/Makefile +++ b/cddl/usr.sbin/dwatch/libexec/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - PACKAGE= dwatch FILESDIR= ${LIBEXECDIR}/dwatch FILES= chmod \ @@ -22,6 +20,7 @@ FILES= chmod \ vop_rename \ vop_symlink +LINKMODE= ${SHAREMODE} LINKS= ${LIBEXECDIR}/dwatch/chmod ${LIBEXECDIR}/dwatch/fchmodat LINKS+= ${LIBEXECDIR}/dwatch/chmod ${LIBEXECDIR}/dwatch/lchmod LINKS+= ${LIBEXECDIR}/dwatch/io ${LIBEXECDIR}/dwatch/io-done diff --git a/cddl/usr.sbin/dwatch/libexec/chmod b/cddl/usr.sbin/dwatch/libexec/chmod index d131109a0d66..6ec7140613e6 100644 --- a/cddl/usr.sbin/dwatch/libexec/chmod +++ b/cddl/usr.sbin/dwatch/libexec/chmod @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for [l]chmod(2), fchmodat(2), or similar entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/errno b/cddl/usr.sbin/dwatch/libexec/errno index 42fce4ab8faa..d899906a1313 100644 --- a/cddl/usr.sbin/dwatch/libexec/errno +++ b/cddl/usr.sbin/dwatch/libexec/errno @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for syscall errno logging $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/io b/cddl/usr.sbin/dwatch/libexec/io index 26c58593ead3..6aafb624c820 100644 --- a/cddl/usr.sbin/dwatch/libexec/io +++ b/cddl/usr.sbin/dwatch/libexec/io @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for dtrace_io(4) $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/ip b/cddl/usr.sbin/dwatch/libexec/ip index 8de385f568bf..9032e37dc043 100644 --- a/cddl/usr.sbin/dwatch/libexec/ip +++ b/cddl/usr.sbin/dwatch/libexec/ip @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for dtrace_ip(4) $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/kill b/cddl/usr.sbin/dwatch/libexec/kill index c30e951381c3..06960d11f8da 100644 --- a/cddl/usr.sbin/dwatch/libexec/kill +++ b/cddl/usr.sbin/dwatch/libexec/kill @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for kill(2) [or similar] entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/nanosleep b/cddl/usr.sbin/dwatch/libexec/nanosleep index acc4cf352af7..d645d8a2a026 100644 --- a/cddl/usr.sbin/dwatch/libexec/nanosleep +++ b/cddl/usr.sbin/dwatch/libexec/nanosleep @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for nanosleep(2) [or similar] entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/open b/cddl/usr.sbin/dwatch/libexec/open index 5185a97aca03..849f8865c55d 100644 --- a/cddl/usr.sbin/dwatch/libexec/open +++ b/cddl/usr.sbin/dwatch/libexec/open @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for open[at](2) [or similar] entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/proc b/cddl/usr.sbin/dwatch/libexec/proc index 0f67394a84d5..02d4d9d1fb8d 100644 --- a/cddl/usr.sbin/dwatch/libexec/proc +++ b/cddl/usr.sbin/dwatch/libexec/proc @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for dtrace_proc(4) activity $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/rw b/cddl/usr.sbin/dwatch/libexec/rw index 32aa58c34f15..6e726c54d8f7 100644 --- a/cddl/usr.sbin/dwatch/libexec/rw +++ b/cddl/usr.sbin/dwatch/libexec/rw @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for read(2), write(2), or similar entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/sched b/cddl/usr.sbin/dwatch/libexec/sched index acbe47d92989..2058f199f40a 100644 --- a/cddl/usr.sbin/dwatch/libexec/sched +++ b/cddl/usr.sbin/dwatch/libexec/sched @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for dtrace_sched(4) $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/sendrecv b/cddl/usr.sbin/dwatch/libexec/sendrecv index 7227e41b5731..05ac339dfa05 100644 --- a/cddl/usr.sbin/dwatch/libexec/sendrecv +++ b/cddl/usr.sbin/dwatch/libexec/sendrecv @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for send(2)/recv(2) $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/systop b/cddl/usr.sbin/dwatch/libexec/systop index b5a29354eee9..7408e41ffffb 100644 --- a/cddl/usr.sbin/dwatch/libexec/systop +++ b/cddl/usr.sbin/dwatch/libexec/systop @@ -4,7 +4,6 @@ # # $Title: dwatch(8) profile for top-like syscall $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/tcp b/cddl/usr.sbin/dwatch/libexec/tcp index 344cdb4ee6e8..a97cde17ef51 100644 --- a/cddl/usr.sbin/dwatch/libexec/tcp +++ b/cddl/usr.sbin/dwatch/libexec/tcp @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for dtrace_tcp(4) connections $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/udp b/cddl/usr.sbin/dwatch/libexec/udp index 1f896a71805d..048f0c9a4102 100644 --- a/cddl/usr.sbin/dwatch/libexec/udp +++ b/cddl/usr.sbin/dwatch/libexec/udp @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for dtrace_udp(4) $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/udplite b/cddl/usr.sbin/dwatch/libexec/udplite index 093c0857f865..44f55de146fe 100644 --- a/cddl/usr.sbin/dwatch/libexec/udplite +++ b/cddl/usr.sbin/dwatch/libexec/udplite @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for dtrace_udplite(4) $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/vop_create b/cddl/usr.sbin/dwatch/libexec/vop_create index 3c544815b758..d36812a4a0d8 100644 --- a/cddl/usr.sbin/dwatch/libexec/vop_create +++ b/cddl/usr.sbin/dwatch/libexec/vop_create @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for VOP_CREATE(9) [or similar] entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/vop_readdir b/cddl/usr.sbin/dwatch/libexec/vop_readdir index 8114bae6527a..6a07b98973f4 100644 --- a/cddl/usr.sbin/dwatch/libexec/vop_readdir +++ b/cddl/usr.sbin/dwatch/libexec/vop_readdir @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for VOP_READDIR(9) [or similar] entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/vop_rename b/cddl/usr.sbin/dwatch/libexec/vop_rename index a9dbf16e73fa..8eca72505558 100644 --- a/cddl/usr.sbin/dwatch/libexec/vop_rename +++ b/cddl/usr.sbin/dwatch/libexec/vop_rename @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for VOP_RENAME(9) [or similar] entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/dwatch/libexec/vop_symlink b/cddl/usr.sbin/dwatch/libexec/vop_symlink index ca75d350af47..dbf7702b2629 100644 --- a/cddl/usr.sbin/dwatch/libexec/vop_symlink +++ b/cddl/usr.sbin/dwatch/libexec/vop_symlink @@ -4,7 +4,6 @@ # # $Title: dwatch(8) module for VOP_SYMLINK(9) [or similar] entry $ # $Copyright: 2014-2018 Devin Teske. All rights reserved. $ -# $FreeBSD$ # ############################################################ DESCRIPTION # diff --git a/cddl/usr.sbin/lockstat/Makefile b/cddl/usr.sbin/lockstat/Makefile index a4bec42df367..c87a37ef1504 100644 --- a/cddl/usr.sbin/lockstat/Makefile +++ b/cddl/usr.sbin/lockstat/Makefile @@ -1,4 +1,4 @@ -# $FreeBSD$ +.include <src.opts.mk> .PATH: ${SRCTOP}/cddl/contrib/opensolaris/cmd/lockstat @@ -26,6 +26,11 @@ CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris \ -I${SRCTOP}/sys CFLAGS+= -DHAVE_ISSETUGID +.if ${MK_DTRACE_ASAN} != "no" +CFLAGS+= -fsanitize=address -fsanitize=undefined +LDFLAGS+= -fsanitize=address -fsanitize=undefined +.endif + CFLAGS+= -DNEED_ERRLOC -g #YFLAGS+= -d diff --git a/cddl/usr.sbin/lockstat/Makefile.depend b/cddl/usr.sbin/lockstat/Makefile.depend index 04b96e83f1c7..2df10f761ad0 100644 --- a/cddl/usr.sbin/lockstat/Makefile.depend +++ b/cddl/usr.sbin/lockstat/Makefile.depend @@ -1,25 +1,16 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - cddl/lib/libctf \ cddl/lib/libdtrace \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ - lib/libcxxrt \ lib/libelf \ - lib/libkvm \ lib/libproc \ - lib/libprocstat \ lib/librt \ lib/librtld_db \ - lib/libthr \ - lib/libutil \ - lib/libz \ .include <dirdeps.mk> diff --git a/cddl/usr.sbin/plockstat/Makefile b/cddl/usr.sbin/plockstat/Makefile index 22610870c846..3e35c5c5b8f7 100644 --- a/cddl/usr.sbin/plockstat/Makefile +++ b/cddl/usr.sbin/plockstat/Makefile @@ -1,4 +1,4 @@ -# $FreeBSD$ +.include <src.opts.mk> .PATH: ${SRCTOP}/cddl/contrib/opensolaris/cmd/plockstat @@ -26,6 +26,11 @@ CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris \ -I${SRCTOP}/sys CFLAGS+= -DHAVE_ISSETUGID +.if ${MK_DTRACE_ASAN} != "no" +CFLAGS+= -fsanitize=address -fsanitize=undefined +LDFLAGS+= -fsanitize=address -fsanitize=undefined +.endif + LIBADD= dtrace proc .include <bsd.prog.mk> diff --git a/cddl/usr.sbin/plockstat/Makefile.depend b/cddl/usr.sbin/plockstat/Makefile.depend index c37ef4acf01e..22b6f0fded18 100644 --- a/cddl/usr.sbin/plockstat/Makefile.depend +++ b/cddl/usr.sbin/plockstat/Makefile.depend @@ -1,24 +1,15 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - cddl/lib/libctf \ cddl/lib/libdtrace \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ - lib/libcxxrt \ lib/libelf \ - lib/libkvm \ lib/libproc \ - lib/libprocstat \ lib/librtld_db \ - lib/libthr \ - lib/libutil \ - lib/libz \ .include <dirdeps.mk> diff --git a/cddl/usr.sbin/plockstat/plockstat.1 b/cddl/usr.sbin/plockstat/plockstat.1 index d02c962771b4..264d01b89df2 100644 --- a/cddl/usr.sbin/plockstat/plockstat.1 +++ b/cddl/usr.sbin/plockstat/plockstat.1 @@ -26,8 +26,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd September 13, 2010 .Dt PLOCKSTAT 1 .Os diff --git a/cddl/usr.sbin/tests/Makefile b/cddl/usr.sbin/tests/Makefile index 3b3078f8612a..29b1b564beca 100644 --- a/cddl/usr.sbin/tests/Makefile +++ b/cddl/usr.sbin/tests/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/tests KYUAFILE= yes diff --git a/cddl/usr.sbin/tests/Makefile.depend b/cddl/usr.sbin/tests/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/cddl/usr.sbin/tests/Makefile.depend +++ b/cddl/usr.sbin/tests/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/cddl/usr.sbin/zdb/Makefile b/cddl/usr.sbin/zdb/Makefile index efd8c746128f..7d1e41e1690e 100644 --- a/cddl/usr.sbin/zdb/Makefile +++ b/cddl/usr.sbin/zdb/Makefile @@ -1,10 +1,9 @@ -# $FreeBSD$ - ZFSTOP= ${SRCTOP}/sys/contrib/openzfs .PATH: ${ZFSTOP}/cmd/zdb .PATH: ${ZFSTOP}/man/man8 +PACKAGE= zfs PROG= zdb MAN= zdb.8 INCS= zdb.h @@ -19,11 +18,12 @@ CFLAGS+= \ -I${ZFSTOP}/lib/libspl/include \ -I${ZFSTOP}/lib/libspl/include/os/freebsd \ -I${ZFSTOP}/lib/libspl/include/os/freebsd/spl \ + -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include \ -I${SRCTOP}/sys \ -include ${ZFSTOP}/include/os/freebsd/spl/sys/ccompile.h \ -DHAVE_ISSETUGID -LIBADD= nvpair umem uutil zfs spl avl zutil zpool +LIBADD= nvpair umem uutil zdb zfs_core zfs spl avl zutil zpool crypto CFLAGS.gcc+= -fms-extensions # Since there are many asserts in this program, it makes no sense to compile diff --git a/cddl/usr.sbin/zdb/Makefile.depend b/cddl/usr.sbin/zdb/Makefile.depend index dfb2563fa7d1..d9ae0ff3c82e 100644 --- a/cddl/usr.sbin/zdb/Makefile.depend +++ b/cddl/usr.sbin/zdb/Makefile.depend @@ -1,28 +1,20 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ cddl/lib/libavl \ cddl/lib/libnvpair \ + cddl/lib/libspl \ cddl/lib/libumem \ cddl/lib/libuutil \ cddl/lib/libzfs \ - cddl/lib/libzfs_core \ cddl/lib/libzpool \ - gnu/lib/csu \ + cddl/lib/libzutil \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ - lib/libexpat \ - lib/libgeom \ - lib/libmd \ - lib/libsbuf \ - lib/libthr \ - lib/libutil \ - lib/libz \ - lib/msun \ + secure/lib/libcrypto \ .include <dirdeps.mk> diff --git a/cddl/usr.sbin/zfsd/Makefile b/cddl/usr.sbin/zfsd/Makefile index 88eb9220a8cc..2f8134098b35 100644 --- a/cddl/usr.sbin/zfsd/Makefile +++ b/cddl/usr.sbin/zfsd/Makefile @@ -1,9 +1,8 @@ -# $FreeBSD$ - .include <src.opts.mk> .include "Makefile.common" +PACKAGE= zfs PROG_CXX= zfsd MAN= zfsd.8 diff --git a/cddl/usr.sbin/zfsd/Makefile.common b/cddl/usr.sbin/zfsd/Makefile.common index 68d921c90e37..487caf54a0ce 100644 --- a/cddl/usr.sbin/zfsd/Makefile.common +++ b/cddl/usr.sbin/zfsd/Makefile.common @@ -1,5 +1,3 @@ -# $FreeBSD$ - SRCS= callout.cc \ case_file.cc \ zfsd_event.cc \ @@ -19,12 +17,13 @@ CFLAGS+= -DIN_BASE CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include CFLAGS+= -I${SRCTOP}/sys CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h CFLAGS+= -I${SRCTOP}/cddl/usr.sbin -# use issetugid(2) CFLAGS+= -DHAVE_ISSETUGID +CFLAGS+= -DHAVE_EXECVPE LIBADD+= devdctl zfs util geom bsdxml sbuf nvpair avl uutil zutil diff --git a/cddl/usr.sbin/zfsd/Makefile.depend b/cddl/usr.sbin/zfsd/Makefile.depend index 023a4456ec68..4b9049efecdc 100644 --- a/cddl/usr.sbin/zfsd/Makefile.depend +++ b/cddl/usr.sbin/zfsd/Makefile.depend @@ -1,14 +1,11 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ cddl/lib/libavl \ cddl/lib/libnvpair \ - cddl/lib/libumem \ cddl/lib/libuutil \ cddl/lib/libzfs \ - cddl/lib/libzfs_core \ - gnu/lib/csu \ + cddl/lib/libzutil \ include \ include/xlocale \ lib/${CSU_DIR} \ @@ -19,11 +16,8 @@ DIRDEPS = \ lib/libdevdctl \ lib/libexpat \ lib/libgeom \ - lib/libmd \ lib/libsbuf \ - lib/libthr \ lib/libutil \ - lib/libz \ lib/msun \ diff --git a/cddl/usr.sbin/zfsd/callout.cc b/cddl/usr.sbin/zfsd/callout.cc index 3e5cd5779559..c141e6550f41 100644 --- a/cddl/usr.sbin/zfsd/callout.cc +++ b/cddl/usr.sbin/zfsd/callout.cc @@ -28,8 +28,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Justin T. Gibbs (Spectra Logic Corporation) - * - * $FreeBSD$ */ /** diff --git a/cddl/usr.sbin/zfsd/callout.h b/cddl/usr.sbin/zfsd/callout.h index d6b83bcfe5f5..69a4cf123162 100644 --- a/cddl/usr.sbin/zfsd/callout.h +++ b/cddl/usr.sbin/zfsd/callout.h @@ -28,8 +28,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Justin T. Gibbs (Spectra Logic Corporation) - * - * $FreeBSD$ */ /** diff --git a/cddl/usr.sbin/zfsd/case_file.cc b/cddl/usr.sbin/zfsd/case_file.cc index 8da711fc10cb..7adfb08b75c6 100644 --- a/cddl/usr.sbin/zfsd/case_file.cc +++ b/cddl/usr.sbin/zfsd/case_file.cc @@ -53,6 +53,7 @@ #include <syslog.h> #include <unistd.h> +#include <libzutil.h> #include <libzfs.h> #include <list> @@ -73,9 +74,6 @@ #include "zfsd.h" #include "zfsd_exception.h" #include "zpool_list.h" - -__FBSDID("$FreeBSD$"); - /*============================ Namespace Control =============================*/ using std::hex; using std::ifstream; @@ -94,7 +92,6 @@ using DevdCtl::ParseException; CaseFileList CaseFile::s_activeCases; const string CaseFile::s_caseFilePath = "/var/db/zfsd/cases"; -const timeval CaseFile::s_removeGracePeriod = { 60 /*sec*/, 0 /*usec*/}; //- CaseFile Static Public Methods --------------------------------------------- CaseFile * @@ -116,6 +113,26 @@ CaseFile::Find(Guid poolGUID, Guid vdevGUID) return (NULL); } +void +CaseFile::Find(Guid poolGUID, Guid vdevGUID, CaseFileList &cases) +{ + for (CaseFileList::iterator curCase = s_activeCases.begin(); + curCase != s_activeCases.end(); curCase++) { + if (((*curCase)->PoolGUID() != poolGUID && + Guid::InvalidGuid() != poolGUID) || + (*curCase)->VdevGUID() != vdevGUID) + continue; + + /* + * We can have multiple cases for spare vdevs + */ + cases.push_back(*curCase); + if (!(*curCase)->IsSpare()) { + return; + } + } +} + CaseFile * CaseFile::Find(const string &physPath) { @@ -217,6 +234,12 @@ CaseFile::PurgeAll() } +int +CaseFile::IsSpare() +{ + return (m_is_spare); +} + //- CaseFile Public Methods ---------------------------------------------------- bool CaseFile::RefreshVdevState() @@ -232,6 +255,7 @@ CaseFile::RefreshVdevState() m_vdevState = vd.State(); m_vdevPhysPath = vd.PhysicalPath(); + m_vdevName = vd.Name(casePool, false); return (true); } @@ -240,6 +264,7 @@ CaseFile::ReEvaluate(const string &devPath, const string &physPath, Vdev *vdev) { ZpoolList zpl(ZpoolList::ZpoolByGUID, &m_poolGUID); zpool_handle_t *pool(zpl.empty() ? NULL : zpl.front()); + int flags = ZFS_ONLINE_CHECKREMOVE | ZFS_ONLINE_UNSPARE; if (pool == NULL || !RefreshVdevState()) { /* @@ -263,7 +288,7 @@ CaseFile::ReEvaluate(const string &devPath, const string &physPath, Vdev *vdev) return (/*consumed*/false); } - if (VdevState() > VDEV_STATE_CANT_OPEN) { + if (VdevState() > VDEV_STATE_FAULTED) { /* * For now, newly discovered devices only help for * devices that are missing. In the future, we might @@ -280,9 +305,10 @@ CaseFile::ReEvaluate(const string &devPath, const string &physPath, Vdev *vdev) || vdev->PoolGUID() == Guid::InvalidGuid()) && vdev->GUID() == m_vdevGUID) { + if (IsSpare()) + flags |= ZFS_ONLINE_SPARE; if (zpool_vdev_online(pool, vdev->GUIDString().c_str(), - ZFS_ONLINE_CHECKREMOVE | ZFS_ONLINE_UNSPARE, - &m_vdevState) != 0) { + flags, &m_vdevState) != 0) { syslog(LOG_ERR, "Failed to online vdev(%s/%s:%s): %s: %s\n", zpool_get_name(pool), vdev->GUIDString().c_str(), @@ -360,7 +386,7 @@ CaseFile::ReEvaluate(const ZfsEvent &event) { bool consumed(false); - if (event.Value("type") == "misc.fs.zfs.vdev_remove") { + if (event.Value("type") == "sysevent.fs.zfs.vdev_remove") { /* * The Vdev we represent has been removed from the * configuration. This case is no longer of value. @@ -368,12 +394,12 @@ CaseFile::ReEvaluate(const ZfsEvent &event) Close(); return (/*consumed*/true); - } else if (event.Value("type") == "misc.fs.zfs.pool_destroy") { + } else if (event.Value("type") == "sysevent.fs.zfs.pool_destroy") { /* This Pool has been destroyed. Discard the case */ Close(); return (/*consumed*/true); - } else if (event.Value("type") == "misc.fs.zfs.config_sync") { + } else if (event.Value("type") == "sysevent.fs.zfs.config_sync") { RefreshVdevState(); if (VdevState() < VDEV_STATE_HEALTHY) consumed = ActivateSpare(); @@ -445,7 +471,8 @@ CaseFile::ReEvaluate(const ZfsEvent &event) consumed = true; } else if (event.Value("class") == "ereport.fs.zfs.io" || - event.Value("class") == "ereport.fs.zfs.checksum") { + event.Value("class") == "ereport.fs.zfs.checksum" || + event.Value("class") == "ereport.fs.zfs.delay") { m_tentativeEvents.push_front(event.DeepCopy()); RegisterCallout(event); @@ -490,8 +517,7 @@ bool CaseFile::ActivateSpare() { nvlist_t *config, *nvroot, *parent_config; nvlist_t **spares; - char *devPath, *vdev_type; - const char *poolname; + const char *devPath, *poolname, *vdev_type; u_int nspares, i; int error; @@ -518,7 +544,7 @@ CaseFile::ActivateSpare() { parent_config = find_parent(config, nvroot, m_vdevGUID); if (parent_config != NULL) { - char *parent_type; + const char *parent_type; /* * Don't activate spares for members of a "replacing" vdev. @@ -585,15 +611,55 @@ CaseFile::ActivateSpare() { return (Replace(vdev_type, devPath, /*isspare*/true)); } +/* Does the argument event refer to a checksum error? */ +static bool +IsChecksumEvent(const Event* const event) +{ + return ("ereport.fs.zfs.checksum" == event->Value("type")); +} + +/* Does the argument event refer to an IO error? */ +static bool +IsIOEvent(const Event* const event) +{ + return ("ereport.fs.zfs.io" == event->Value("type")); +} + +/* Does the argument event refer to an IO delay? */ +static bool +IsDelayEvent(const Event* const event) +{ + return ("ereport.fs.zfs.delay" == event->Value("type")); +} + void CaseFile::RegisterCallout(const Event &event) { timeval now, countdown, elapsed, timestamp, zero, remaining; + /** + * The time ZFSD waits before promoting a tentative event + * into a permanent event. + */ + int sec = -1; + if (IsChecksumEvent(&event)) + sec = CaseFile::GetVdevProp(VDEV_PROP_CHECKSUM_T); + else if (IsIOEvent(&event)) + sec = CaseFile::GetVdevProp(VDEV_PROP_IO_T); + else if (IsDelayEvent(&event)) + sec = CaseFile::GetVdevProp(VDEV_PROP_SLOW_IO_T); + + if (sec == -1) + sec = 60; /* default */ + + timeval removeGracePeriod = { + sec, /*sec*/ + 0 /*usec*/ + }; gettimeofday(&now, 0); timestamp = event.GetTimestamp(); timersub(&now, ×tamp, &elapsed); - timersub(&s_removeGracePeriod, &elapsed, &countdown); + timersub(&removeGracePeriod, &elapsed, &countdown); /* * If countdown is <= zero, Reset the timer to the * smallest positive time value instead @@ -791,7 +857,8 @@ CaseFile::CaseFile(const Vdev &vdev) : m_poolGUID(vdev.PoolGUID()), m_vdevGUID(vdev.GUID()), m_vdevState(vdev.State()), - m_vdevPhysPath(vdev.PhysicalPath()) + m_vdevPhysPath(vdev.PhysicalPath()), + m_is_spare(vdev.IsSpare()) { stringstream guidString; @@ -801,6 +868,10 @@ CaseFile::CaseFile(const Vdev &vdev) guidString << m_poolGUID; m_poolGUIDString = guidString.str(); + ZpoolList zpl(ZpoolList::ZpoolByGUID, &m_poolGUID); + zpool_handle_t *zhp(zpl.empty() ? NULL : zpl.front()); + m_vdevName = vdev.Name(zhp, false); + s_activeCases.push_back(this); syslog(LOG_INFO, "Creating new CaseFile:\n"); @@ -1132,32 +1203,56 @@ CaseFile::Replace(const char* vdev_type, const char* path, bool isspare) { return (retval); } -/* Does the argument event refer to a checksum error? */ -static bool -IsChecksumEvent(const Event* const event) +/* Lookup the vdev prop. Used for checksum, IO, or slow IO props */ +int +CaseFile::GetVdevProp(vdev_prop_t vdev_prop) const { - return ("ereport.fs.zfs.checksum" == event->Value("type")); -} + char val[ZFS_MAXPROPLEN]; + zprop_source_t srctype; + DevdCtl::Guid poolGUID = PoolGUID(); + ZpoolList zpl(ZpoolList::ZpoolByGUID, &poolGUID); + zpool_handle_t *zhp(zpl.empty() ? NULL : zpl.front()); -/* Does the argument event refer to an IO error? */ -static bool -IsIOEvent(const Event* const event) -{ - return ("ereport.fs.zfs.io" == event->Value("type")); + char *prop_str = (char *) vdev_prop_to_name(vdev_prop); + if (zhp == NULL || zpool_get_vdev_prop(zhp, m_vdevName.c_str(), + vdev_prop, prop_str, val, sizeof (val), &srctype, B_FALSE) != 0) + return (-1); + + /* we'll get "-" from libzfs for a prop that is not set */ + if (zfs_isnumber(val) == B_FALSE) + return (-1); + + return (atoi(val)); } bool CaseFile::ShouldDegrade() const { + int checksum_n = GetVdevProp(VDEV_PROP_CHECKSUM_N); + if (checksum_n == -1) + checksum_n = DEFAULT_ZFS_DEGRADE_IO_COUNT; return (std::count_if(m_events.begin(), m_events.end(), - IsChecksumEvent) > ZFS_DEGRADE_IO_COUNT); + IsChecksumEvent) > checksum_n); } bool CaseFile::ShouldFault() const { - return (std::count_if(m_events.begin(), m_events.end(), - IsIOEvent) > ZFS_DEGRADE_IO_COUNT); + bool should_fault_for_io, should_fault_for_delay; + int io_n = GetVdevProp(VDEV_PROP_IO_N); + int slow_io_n = GetVdevProp(VDEV_PROP_SLOW_IO_N); + + if (io_n == -1) + io_n = DEFAULT_ZFS_DEGRADE_IO_COUNT; + if (slow_io_n == -1) + slow_io_n = DEFAULT_ZFS_FAULT_SLOW_IO_COUNT; + + should_fault_for_io = std::count_if(m_events.begin(), m_events.end(), + IsIOEvent) > io_n; + should_fault_for_delay = std::count_if(m_events.begin(), m_events.end(), + IsDelayEvent) > slow_io_n; + + return (should_fault_for_io || should_fault_for_delay); } nvlist_t * diff --git a/cddl/usr.sbin/zfsd/case_file.h b/cddl/usr.sbin/zfsd/case_file.h index b4dc2dee5d96..199918c4fead 100644 --- a/cddl/usr.sbin/zfsd/case_file.h +++ b/cddl/usr.sbin/zfsd/case_file.h @@ -28,8 +28,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Justin T. Gibbs (Spectra Logic Corporation) - * - * $FreeBSD$ */ /** @@ -99,6 +97,19 @@ public: static CaseFile *Find(DevdCtl::Guid poolGUID, DevdCtl::Guid vdevGUID); /** + * \brief Find multiple CaseFile objects by a vdev's pool/vdev + * GUID tuple (special case for spare vdevs) + * + * \param poolGUID Pool GUID for the vdev of the CaseFile to find. + * If InvalidGuid, then only match the vdev GUID + * instead of both pool and vdev GUIDs. + * \param vdevGUID Vdev GUID for the vdev of the CaseFile to find. + * \param caseList List of cases associated with the vdev. + */ + static void Find(DevdCtl::Guid poolGUID, DevdCtl::Guid vdevGUID, + CaseFileList &caseList); + + /** * \brief Find a CaseFile object by a vdev's current/last known * physical path. * @@ -219,14 +230,32 @@ public: */ bool ShouldFault() const; + /** + * \brief If this vdev is spare + */ + int IsSpare(); + + /** + * \brief Get case vdev's specified property + */ + int GetVdevProp(vdev_prop_t) const; + protected: enum { + /* + * Use these defaults if we can't get the corresponding vdev + * prop or if the prop is not set + */ /** * The number of soft errors on a vdev required * to transition a vdev from healthy to degraded - * status. + * status */ - ZFS_DEGRADE_IO_COUNT = 50 + DEFAULT_ZFS_DEGRADE_IO_COUNT = 50, + /** + * The number of delay errors on a vdev required to fault it + */ + DEFAULT_ZFS_FAULT_SLOW_IO_COUNT = 8, }; static CalloutFunc_t OnGracePeriodEnded; @@ -360,12 +389,6 @@ protected: static const string s_caseFilePath; /** - * \brief The time ZFSD waits before promoting a tentative event - * into a permanent event. - */ - static const timeval s_removeGracePeriod; - - /** * \brief A list of soft error events counted against the health of * a vdev. */ @@ -384,6 +407,8 @@ protected: string m_poolGUIDString; string m_vdevGUIDString; string m_vdevPhysPath; + string m_vdevName; + int m_is_spare; /** * \brief Callout activated when a grace period diff --git a/cddl/usr.sbin/zfsd/tests/Makefile b/cddl/usr.sbin/zfsd/tests/Makefile index 1b776b217776..fdda8011b21d 100644 --- a/cddl/usr.sbin/zfsd/tests/Makefile +++ b/cddl/usr.sbin/zfsd/tests/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - .include "${.CURDIR}/../Makefile.common" .PATH: ${.CURDIR:H} diff --git a/cddl/usr.sbin/zfsd/tests/libmocks.c b/cddl/usr.sbin/zfsd/tests/libmocks.c index e3c90a46920f..64eb02b1d480 100644 --- a/cddl/usr.sbin/zfsd/tests/libmocks.c +++ b/cddl/usr.sbin/zfsd/tests/libmocks.c @@ -28,8 +28,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Alan Somers (Spectra Logic Corporation) - * - * $FreeBSD$ */ #include <stdio.h> diff --git a/cddl/usr.sbin/zfsd/tests/libmocks.h b/cddl/usr.sbin/zfsd/tests/libmocks.h index 130f4389f70a..ffa2f0673e1d 100644 --- a/cddl/usr.sbin/zfsd/tests/libmocks.h +++ b/cddl/usr.sbin/zfsd/tests/libmocks.h @@ -28,8 +28,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Alan Somers (Spectra Logic Corporation) - * - * $FreeBSD$ */ #ifndef _LIBMOCKS_H_ diff --git a/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc b/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc index e2833170f9ac..6c9a49a8ebbf 100644 --- a/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc +++ b/cddl/usr.sbin/zfsd/tests/zfsd_unittest.cc @@ -62,9 +62,6 @@ #include <zfsd/zpool_list.h> #include "libmocks.h" - -__FBSDID("$FreeBSD$"); - /*================================== Macros ==================================*/ #define NUM_ELEMENTS(x) (sizeof(x) / sizeof(*x)) @@ -85,6 +82,9 @@ struct zpool_handle zpool_handle_t *zpool_next; char zpool_name[ZFS_MAX_DATASET_NAME_LEN]; int zpool_state; + unsigned int zpool_n_propnames; +#define ZHP_MAX_PROPNAMES 4 + const char *zpool_propnames[ZHP_MAX_PROPNAMES]; size_t zpool_config_size; nvlist_t *zpool_config; nvlist_t *zpool_old_config; @@ -137,6 +137,7 @@ public: MOCK_CONST_METHOD0(PoolGUID, Guid()); MOCK_CONST_METHOD0(State, vdev_state()); MOCK_CONST_METHOD0(PhysicalPath, string()); + MOCK_CONST_METHOD2(Name, string(zpool_handle_t * zhp, bool verbose)); }; MockVdev::MockVdev(nvlist_t *vdevConfig) @@ -400,7 +401,7 @@ TEST_F(ZfsEventTest, ProcessPoolEventGetsCalled) { string evString("!system=ZFS " "subsystem=ZFS " - "type=misc.fs.zfs.vdev_remove " + "type=sysevent.fs.zfs.vdev_remove " "pool_name=foo " "pool_guid=9756779504028057996 " "vdev_guid=1631193447431603339 " @@ -434,6 +435,8 @@ protected: m_vdev = new MockVdev(m_vdevConfig); ON_CALL(*m_vdev, GUID()) .WillByDefault(::testing::Return(Guid(123))); + ON_CALL(*m_vdev, Name(::testing::_, ::testing::_)) + .WillByDefault(::testing::Return(string("/dev/da999"))); ON_CALL(*m_vdev, PoolGUID()) .WillByDefault(::testing::Return(Guid(456))); ON_CALL(*m_vdev, State()) @@ -515,7 +518,7 @@ TEST_F(CaseFileTest, PoolDestroy) "pool_guid=456 " "subsystem=ZFS " "timestamp=1348867914 " - "type=misc.fs.zfs.pool_destroy "); + "type=sysevent.fs.zfs.pool_destroy "); m_event = Event::CreateEvent(*m_eventFactory, evString); ZfsEvent *zfs_event = static_cast<ZfsEvent*>(m_event); EXPECT_CALL(*m_caseFile, Close()); @@ -523,6 +526,72 @@ TEST_F(CaseFileTest, PoolDestroy) } /* + * A Vdev with a very large number of Delay errors should fault + * For performance reasons, RefreshVdevState should be called at most once + */ +TEST_F(CaseFileTest, VeryManyDelayErrors) +{ + EXPECT_CALL(*m_caseFile, RefreshVdevState()) + .Times(::testing::AtMost(1)) + .WillRepeatedly(::testing::Return(true)); + + for(int i=0; i<100; i++) { + stringstream evStringStream; + evStringStream << + "!system=ZFS " + "class=ereport.fs.zfs.delay " + "ena=12091638756982918145 " + "parent_guid=13237004955564865395 " + "parent_type=raidz " + "pool=testpool.4415 " + "pool_context=0 " + "pool_failmode=wait " + "pool_guid=456 " + "pool_state= 0" + "subsystem=ZFS " + "time="; + evStringStream << i << "0000000000000000 "; + evStringStream << "timestamp=" << i << " "; + evStringStream << + "type=ereport.fs.zfs.delay " + "vdev_ashift=12 " + "vdev_cksum_errors=0 " + "vdev_complete_ts=948336226469 " + "vdev_delays=77 " + "vdev_delta_ts=123998485899 " + "vdev_guid=123 " + "vdev_path=/dev/da400 " + "vdev_read_errors=0 " + "vdev_spare_guids= " + "vdev_type=disk " + "vdev_write_errors=0 " + "zio_blkid=622 " + "zio_delay=31000041101 " + "zio_delta=123998485899 " + "zio_err=0 " + "zio_flags=1572992 " + "zio_level=-2 " + "zio_object=0 " + "zio_objset=37 " + "zio_offset=25598976 " + "zio_pipeline=48234496 " + "zio_priority=3 " + "zio_size=1024" + "zio_stage=33554432 " + "zio_timestamp=824337740570 "; + Event *event(Event::CreateEvent(*m_eventFactory, + evStringStream.str())); + ZfsEvent *zfs_event = static_cast<ZfsEvent*>(event); + EXPECT_TRUE(m_caseFile->ReEvaluate(*zfs_event)); + delete event; + } + + m_caseFile->SpliceEvents(); + EXPECT_FALSE(m_caseFile->ShouldDegrade()); + EXPECT_TRUE(m_caseFile->ShouldFault()); +} + +/* * A Vdev with a very large number of IO errors should fault * For performance reasons, RefreshVdevState should be called at most once */ @@ -685,7 +754,7 @@ string ReEvaluateByGuidTest::s_evString( "pool_name=foo " "subsystem=ZFS " "timestamp=1360620391 " - "type=misc.fs.zfs.config_sync"); + "type=sysevent.fs.zfs.config_sync"); /* @@ -769,3 +838,40 @@ TEST_F(ReEvaluateByGuidTest, ReEvaluateByGuid_five) delete CaseFile4; delete CaseFile5; } + +/* + * Test VdevIterator + */ +class VdevIteratorTest : public ::testing::Test +{ +}; + +bool VdevIteratorTestCB(Vdev &vdev, void *cbArg) { + return (false); +} + +/* + * VdevIterator::Next should not crash when run on a pool that has a previously + * removed vdev. Regression for + * https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273663 + */ +TEST_F(VdevIteratorTest, VdevRemoval) +{ + nvlist_t* poolConfig, *rootVdev; + + ASSERT_EQ(0, nvlist_alloc(&rootVdev, NV_UNIQUE_NAME, 0)); + ASSERT_EQ(0, nvlist_add_uint64(rootVdev, ZPOOL_CONFIG_GUID, 0x5678)); + /* + * Note: pools with previously-removed top-level VDEVs will contain a + * TLV in their labels that has 0 children. + */ + ASSERT_EQ(0, nvlist_add_nvlist_array(rootVdev, ZPOOL_CONFIG_CHILDREN, + NULL, 0)); + ASSERT_EQ(0, nvlist_alloc(&poolConfig, NV_UNIQUE_NAME, 0)); + ASSERT_EQ(0, nvlist_add_uint64(poolConfig, + ZPOOL_CONFIG_POOL_GUID, 0x1234)); + ASSERT_EQ(0, nvlist_add_nvlist(poolConfig, ZPOOL_CONFIG_VDEV_TREE, + rootVdev)); + + VdevIterator(poolConfig).Each(VdevIteratorTestCB, NULL); +} diff --git a/cddl/usr.sbin/zfsd/tests/zfsd_unittest.supp b/cddl/usr.sbin/zfsd/tests/zfsd_unittest.supp index 138ef6907e62..377ca1e10746 100644 --- a/cddl/usr.sbin/zfsd/tests/zfsd_unittest.supp +++ b/cddl/usr.sbin/zfsd/tests/zfsd_unittest.supp @@ -29,7 +29,6 @@ # # Authors: Alan Somers (Spectra Logic Corporation) # -# $FreeBSD$ # This is a valgrind suppression file used for running zfsd_unittest with diff --git a/cddl/usr.sbin/zfsd/vdev.cc b/cddl/usr.sbin/zfsd/vdev.cc index 508af8cda925..1a37340fb76e 100644 --- a/cddl/usr.sbin/zfsd/vdev.cc +++ b/cddl/usr.sbin/zfsd/vdev.cc @@ -28,8 +28,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Justin T. Gibbs (Spectra Logic Corporation) - * - * $FreeBSD$ */ /** @@ -65,8 +63,6 @@ #include "zfsd.h" #include "zfsd_exception.h" #include "zpool_list.h" - -__FBSDID("$FreeBSD$"); /*============================ Namespace Control =============================*/ using std::string; using std::stringstream; @@ -336,7 +332,7 @@ Vdev::Name(zpool_handle_t *zhp, bool verbose) const string Vdev::Path() const { - char *path(NULL); + const char *path(NULL); if ((m_config != NULL) && (nvlist_lookup_string(m_config, ZPOOL_CONFIG_PATH, &path) == 0)) @@ -348,7 +344,7 @@ Vdev::Path() const string Vdev::PhysicalPath() const { - char *path(NULL); + const char *path(NULL); if ((m_config != NULL) && (nvlist_lookup_string(m_config, ZPOOL_CONFIG_PHYS_PATH, &path) == 0)) diff --git a/cddl/usr.sbin/zfsd/vdev.h b/cddl/usr.sbin/zfsd/vdev.h index 322efc8f4e53..42278a3d7229 100644 --- a/cddl/usr.sbin/zfsd/vdev.h +++ b/cddl/usr.sbin/zfsd/vdev.h @@ -28,8 +28,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Justin T. Gibbs (Spectra Logic Corporation) - * - * $FreeBSD$ */ /** @@ -132,7 +130,7 @@ public: nvlist_t *Config() const; Vdev Parent(); Vdev RootVdev(); - std::string Name(zpool_handle_t *, bool verbose) const; + virtual std::string Name(zpool_handle_t *, bool verbose) const; bool IsSpare(); bool IsAvailableSpare() const; bool IsActiveSpare() const; diff --git a/cddl/usr.sbin/zfsd/vdev_iterator.cc b/cddl/usr.sbin/zfsd/vdev_iterator.cc index b5a4f22c1c60..e9283108ed3c 100644 --- a/cddl/usr.sbin/zfsd/vdev_iterator.cc +++ b/cddl/usr.sbin/zfsd/vdev_iterator.cc @@ -28,8 +28,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Justin T. Gibbs (Spectra Logic Corporation) - * - * $FreeBSD$ */ /** @@ -78,8 +76,10 @@ VdevIterator::Reset() { nvlist_t *rootVdev; nvlist **cache_child; + nvlist **spare_child; int result; uint_t cache_children; + uint_t spare_children; result = nvlist_lookup_nvlist(m_poolConfig, ZPOOL_CONFIG_VDEV_TREE, @@ -95,6 +95,13 @@ VdevIterator::Reset() if (result == 0) for (uint_t c = 0; c < cache_children; c++) m_vdevQueue.push_back(cache_child[c]); + result = nvlist_lookup_nvlist_array(rootVdev, + ZPOOL_CONFIG_SPARES, + &spare_child, + &spare_children); + if (result == 0) + for (uint_t c = 0; c < spare_children; c++) + m_vdevQueue.push_back(spare_child[c]); } nvlist_t * @@ -102,10 +109,7 @@ VdevIterator::Next() { nvlist_t *vdevConfig; - if (m_vdevQueue.empty()) - return (NULL); - - for (;;) { + for (vdevConfig = NULL; !m_vdevQueue.empty();) { nvlist_t **vdevChildren; int result; u_int numChildren; diff --git a/cddl/usr.sbin/zfsd/vdev_iterator.h b/cddl/usr.sbin/zfsd/vdev_iterator.h index 435582ec1f84..439f987ba6e1 100644 --- a/cddl/usr.sbin/zfsd/vdev_iterator.h +++ b/cddl/usr.sbin/zfsd/vdev_iterator.h @@ -28,8 +28,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Justin T. Gibbs (Spectra Logic Corporation) - * - * $FreeBSD$ */ /** diff --git a/cddl/usr.sbin/zfsd/zfsd.8 b/cddl/usr.sbin/zfsd/zfsd.8 index ce7550b891a3..d668e0e8ee9e 100644 --- a/cddl/usr.sbin/zfsd/zfsd.8 +++ b/cddl/usr.sbin/zfsd/zfsd.8 @@ -23,9 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd April 18, 2020 +.Dd February 20, 2024 .Dt ZFSD 8 .Os .Sh NAME @@ -57,7 +55,7 @@ directly. Instead, they control its behavior indirectly through zpool configuration. There are two ways to influence .Nm : -assigning hotspares and setting pool properties. +assigning hot spares and setting pool properties. Currently, only the .Em autoreplace property has any effect. @@ -71,7 +69,7 @@ will attempt to resolve the following types of fault: .It device removal When a leaf vdev disappears, .Nm -will activate any available hotspare. +will activate any available hot spare. .It device arrival When a new GEOM device appears, .Nm @@ -79,40 +77,71 @@ will attempt to read its ZFS label, if any. If it matches a previously removed vdev on an active pool, .Nm will online it. -Once resilvering completes, any active hotspare will detach automatically. +Once resilvering completes, any active hot spare will detach automatically. .Pp If the new device has no ZFS label but its physical path matches the physical path of a previously removed vdev on an active pool, and that pool has the autoreplace property set, then .Nm will replace the missing vdev with the newly arrived device. -Once resilvering completes, any active hotspare will detach automatically. +Once resilvering completes, any active hot spare will detach automatically. .It vdev degrade or fault events If a vdev becomes degraded or faulted, .Nm -will activate any available hotspare. +will activate any available hot spare. .It I/O errors -If a leaf vdev generates more than 50 I/O errors in a 60 second period, then +By default, if a leaf vdev generates more than 50 I/O errors in a 60 second +period, then +.Nm +will mark that vdev as +.Em FAULTED . +ZFS will no longer issue any I/Os to it. +.Nm +will activate a hot spare if one is available. The defaults can be changed by +setting the +.Em io_n +and/or +.Em io_t +vdev properties. See +.Xr vdevprops 7 +for details. +.It I/O delays +By default, if a leaf vdev generates more than delayed 8 I/O events in a 60 +second period, then .Nm will mark that vdev as .Em FAULTED . ZFS will no longer issue any I/Os to it. .Nm -will activate a hotspare if one is available. +will activate a hot spare if one is available. The defaults can be changed by +setting the +.Em slow_io_n +and/or +.Em slow_io_t +vdev properties. See +.Xr vdevprops 7 +for details. .It Checksum errors -If a leaf vdev generates more than 50 checksum errors in a 60 second -period, then +By default, if a leaf vdev generates more than 50 checksum errors in a 60 +second period, then .Nm will mark that vdev as .Em DEGRADED . -ZFS will still use it, but zfsd will activate a spare anyway. +ZFS will still use it, but zfsd will also activate a hot spare if one is +available. The defaults can be changed by setting the +.Em checksum_n +and/or +.Em checksum_t +vdev properties. See +.Xr vdevprops 7 +for details. .It Spare addition -If the system administrator adds a hotspare to a pool that is already degraded, +If the system administrator adds a hot spare to a pool that is already degraded, .Nm will activate the spare. .It Resilver complete .Nm -will detach any hotspare once a permanent replacement finishes resilvering. +will detach any hot spare once a permanent replacement finishes resilvering. .It Physical path change If the physical path of an existing disk changes, .Nm @@ -125,7 +154,6 @@ will log interesting events and its actions to syslog with facility .Em daemon and identity .Op zfsd . -.El .Sh FILES .Bl -tag -width a -compact .It Pa /var/db/zfsd/cases @@ -136,6 +164,7 @@ then reads them back in when next it starts up. .El .Sh SEE ALSO .Xr devctl 4 , +.Xr vdevprops 7 , .Xr zpool 8 .Sh HISTORY .Nm diff --git a/cddl/usr.sbin/zfsd/zfsd.cc b/cddl/usr.sbin/zfsd/zfsd.cc index 876cca836e9e..210cc4b85a44 100644 --- a/cddl/usr.sbin/zfsd/zfsd.cc +++ b/cddl/usr.sbin/zfsd/zfsd.cc @@ -74,9 +74,6 @@ #include "zfsd.h" #include "zfsd_exception.h" #include "zpool_list.h" - -__FBSDID("$FreeBSD$"); - /*================================== Macros ==================================*/ #define NUM_ELEMENTS(x) (sizeof(x) / sizeof(*x)) @@ -248,7 +245,7 @@ ZfsDaemon::BuildCaseFiles() snprintf(evString, 160, "!system=ZFS subsystem=ZFS " - "type=misc.fs.zfs.config_sync sub_type=synthesized " + "type=sysevent.fs.zfs.config_sync sub_type=synthesized " "pool_name=%s pool_guid=%" PRIu64 "\n", poolname, poolGUID); event = Event::CreateEvent(GetFactory(), string(evString)); if (event != NULL) { @@ -276,7 +273,7 @@ ZfsDaemon::RescanSystem() result = geom_gettree(&mesh); if (result != 0) { syslog(LOG_ERR, "ZfsDaemon::RescanSystem: " - "geom_gettree faild with error %d\n", result); + "geom_gettree failed with error %d\n", result); return; } diff --git a/cddl/usr.sbin/zfsd/zfsd.h b/cddl/usr.sbin/zfsd/zfsd.h index 7b4019c7ae10..8c7c63a7c9c4 100644 --- a/cddl/usr.sbin/zfsd/zfsd.h +++ b/cddl/usr.sbin/zfsd/zfsd.h @@ -28,8 +28,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Justin T. Gibbs (Spectra Logic Corporation) - * - * $FreeBSD$ */ /** diff --git a/cddl/usr.sbin/zfsd/zfsd_event.cc b/cddl/usr.sbin/zfsd/zfsd_event.cc index 688e7c0354a2..7a19b95abeed 100644 --- a/cddl/usr.sbin/zfsd/zfsd_event.cc +++ b/cddl/usr.sbin/zfsd/zfsd_event.cc @@ -68,8 +68,6 @@ #include "zfsd.h" #include "zfsd_exception.h" #include "zpool_list.h" - -__FBSDID("$FreeBSD$"); /*============================ Namespace Control =============================*/ using DevdCtl::Event; using DevdCtl::Guid; @@ -229,7 +227,9 @@ bool GeomEvent::OnlineByLabel(const string &devPath, const string& physPath, nvlist_t *devConfig) { + bool ret = false; try { + CaseFileList case_list; /* * A device with ZFS label information has been * inserted. If it matches a device for which we @@ -238,10 +238,12 @@ GeomEvent::OnlineByLabel(const string &devPath, const string& physPath, syslog(LOG_INFO, "Interrogating VDEV label for %s\n", devPath.c_str()); Vdev vdev(devConfig); - CaseFile *caseFile(CaseFile::Find(vdev.PoolGUID(), - vdev.GUID())); - if (caseFile != NULL) - return (caseFile->ReEvaluate(devPath, physPath, &vdev)); + CaseFile::Find(vdev.PoolGUID(),vdev.GUID(), case_list); + for (CaseFileList::iterator curr = case_list.begin(); + curr != case_list.end(); curr++) { + ret |= (*curr)->ReEvaluate(devPath, physPath, &vdev); + } + return (ret); } catch (ZfsdException &exp) { string context("GeomEvent::OnlineByLabel: " + devPath + ": "); @@ -249,7 +251,7 @@ GeomEvent::OnlineByLabel(const string &devPath, const string& physPath, exp.GetString().insert(0, context); exp.Log(); } - return (false); + return (ret); } @@ -281,7 +283,7 @@ ZfsEvent::Process() const } /* On config syncs, replay any queued events first. */ - if (Value("type").find("misc.fs.zfs.config_sync") == 0) { + if (Value("type").find("sysevent.fs.zfs.config_sync") == 0) { /* * Even if saved events are unconsumed the second time * around, drop them. Any events that still can't be @@ -292,7 +294,7 @@ ZfsEvent::Process() const CaseFile::ReEvaluateByGuid(PoolGUID(), *this); } - if (Value("type").find("misc.fs.zfs.") == 0) { + if (Value("type").find("sysevent.fs.zfs.") == 0) { /* Configuration changes, resilver events, etc. */ ProcessPoolEvent(); return (false); @@ -405,7 +407,7 @@ ZfsEvent::ProcessPoolEvent() const bool degradedDevice(false); /* The pool is destroyed. Discard any open cases */ - if (Value("type") == "misc.fs.zfs.pool_destroy") { + if (Value("type") == "sysevent.fs.zfs.pool_destroy") { Log(LOG_INFO); CaseFile::ReEvaluateByGuid(PoolGUID(), *this); return; @@ -420,7 +422,7 @@ ZfsEvent::ProcessPoolEvent() const Log(LOG_INFO); caseFile->ReEvaluate(*this); } - else if (Value("type") == "misc.fs.zfs.resilver_finish") + else if (Value("type") == "sysevent.fs.zfs.resilver_finish") { /* * It's possible to get a resilver_finish event with no @@ -431,7 +433,7 @@ ZfsEvent::ProcessPoolEvent() const CleanupSpares(); } - if (Value("type") == "misc.fs.zfs.vdev_remove" + if (Value("type") == "sysevent.fs.zfs.vdev_remove" && degradedDevice == false) { /* See if any other cases can make use of this device. */ diff --git a/cddl/usr.sbin/zfsd/zfsd_event.h b/cddl/usr.sbin/zfsd/zfsd_event.h index fd3f9f7c5200..6398cb3c0c13 100644 --- a/cddl/usr.sbin/zfsd/zfsd_event.h +++ b/cddl/usr.sbin/zfsd/zfsd_event.h @@ -28,8 +28,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Justin T. Gibbs (Spectra Logic Corporation) - * - * $FreeBSD$ */ /** diff --git a/cddl/usr.sbin/zfsd/zfsd_exception.cc b/cddl/usr.sbin/zfsd/zfsd_exception.cc index 7ebb74ca8c6a..d5b3cab24f02 100644 --- a/cddl/usr.sbin/zfsd/zfsd_exception.cc +++ b/cddl/usr.sbin/zfsd/zfsd_exception.cc @@ -52,8 +52,6 @@ #include "vdev.h" #include "zfsd_exception.h" - -__FBSDID("$FreeBSD$"); /*============================ Namespace Control =============================*/ using std::endl; using std::string; @@ -106,7 +104,7 @@ ZfsdException::Log() const output << "Pool "; - char *poolName; + const char *poolName; if (nvlist_lookup_string(m_poolConfig, ZPOOL_CONFIG_POOL_NAME, &poolName) == 0) output << poolName; diff --git a/cddl/usr.sbin/zfsd/zfsd_exception.h b/cddl/usr.sbin/zfsd/zfsd_exception.h index 5170b2d0dbb1..6cb182e7223b 100644 --- a/cddl/usr.sbin/zfsd/zfsd_exception.h +++ b/cddl/usr.sbin/zfsd/zfsd_exception.h @@ -28,8 +28,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Justin T. Gibbs (Spectra Logic Corporation) - * - * $FreeBSD$ */ /** diff --git a/cddl/usr.sbin/zfsd/zfsd_main.cc b/cddl/usr.sbin/zfsd/zfsd_main.cc index f090631e21f2..cc9ce6044384 100644 --- a/cddl/usr.sbin/zfsd/zfsd_main.cc +++ b/cddl/usr.sbin/zfsd/zfsd_main.cc @@ -55,9 +55,6 @@ #include "vdev_iterator.h" #include "zfsd.h" - -__FBSDID("$FreeBSD$"); - /*=============================== Program Main ===============================*/ static void usage() diff --git a/cddl/usr.sbin/zfsd/zpool_list.cc b/cddl/usr.sbin/zfsd/zpool_list.cc index 82c35736df13..65612ca0591c 100644 --- a/cddl/usr.sbin/zfsd/zpool_list.cc +++ b/cddl/usr.sbin/zfsd/zpool_list.cc @@ -28,8 +28,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Justin T. Gibbs (Spectra Logic Corporation) - * - * $FreeBSD$ */ /** diff --git a/cddl/usr.sbin/zfsd/zpool_list.h b/cddl/usr.sbin/zfsd/zpool_list.h index 6ee30892aedd..3043d35731eb 100644 --- a/cddl/usr.sbin/zfsd/zpool_list.h +++ b/cddl/usr.sbin/zfsd/zpool_list.h @@ -28,8 +28,6 @@ * POSSIBILITY OF SUCH DAMAGES. * * Authors: Justin T. Gibbs (Spectra Logic Corporation) - * - * $FreeBSD$ */ /** @@ -95,7 +93,7 @@ public: static PoolFilter_t ZpoolByName; /** - * \brief ZpoolList contructor + * \brief ZpoolList constructor * * \param filter The filter function to use when constructing * the ZpoolList. This may be one of the static diff --git a/cddl/usr.sbin/zhack/Makefile b/cddl/usr.sbin/zhack/Makefile index ffac0785d18d..c4fc25dcfb8f 100644 --- a/cddl/usr.sbin/zhack/Makefile +++ b/cddl/usr.sbin/zhack/Makefile @@ -1,7 +1,6 @@ -# $FreeBSD$ - .PATH: ${SRCTOP}/sys/contrib/openzfs/cmd +PACKAGE= zfs PROG= zhack MAN= @@ -13,6 +12,7 @@ CFLAGS+= -DIN_BASE CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd +CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libzpool/include CFLAGS+= -I${SRCTOP}/sys CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/module/icp/include diff --git a/cddl/usr.sbin/zhack/Makefile.depend b/cddl/usr.sbin/zhack/Makefile.depend index dfb2563fa7d1..6e162364b929 100644 --- a/cddl/usr.sbin/zhack/Makefile.depend +++ b/cddl/usr.sbin/zhack/Makefile.depend @@ -1,28 +1,16 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - cddl/lib/libavl \ cddl/lib/libnvpair \ - cddl/lib/libumem \ - cddl/lib/libuutil \ + cddl/lib/libspl \ cddl/lib/libzfs \ - cddl/lib/libzfs_core \ cddl/lib/libzpool \ - gnu/lib/csu \ + cddl/lib/libzutil \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ - lib/libexpat \ - lib/libgeom \ - lib/libmd \ - lib/libsbuf \ - lib/libthr \ - lib/libutil \ - lib/libz \ - lib/msun \ .include <dirdeps.mk> |