diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 index 42367b99b786..1745519c2c1a 100644 --- a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 +++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 @@ -1,823 +1,821 @@ .\" 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) 2006, Sun Microsystems, Inc. All Rights Reserved. .\" -.\" $FreeBSD$ -.\" .Dd February 24, 2023 .Dt DTRACE 1 .Os .Sh NAME .Nm dtrace .Nd dynamic tracing compiler and tracing utility .Sh SYNOPSIS .Nm .Op Fl 32 | Fl 64 .Op Fl aACdeFGhHlqSvVwZ .Op Fl b Ar bufsz .Op Fl c Ar cmd .Op Fl D Ar name Op Ns = Ns value .Op Fl I Ar path .Op Fl L Ar path .Op Fl o Ar output .Op Fl s Ar script .Op Fl U Ar name .Op Fl x Ar arg Op Ns = Ns value .Op Fl X Cm a | c | s | t .Op Fl p Ar pid .Op Fl P Ar provider Oo Oo Ar predicate Oc Ar action Oc .Op Fl m Oo Ar provider : Oc Ar module Oo Oo Ar predicate Oc Ar action Oc .Op Fl f Oo Oo Ar provider : Oc Ar module : Oc Ar function Oo Oo Ar predicate \ Oc Ar action Oc .Op Fl n Oo Oo Oo Ar provider : Oc Ar module : Oc Ar function : Oc Ar name \ Oo Oo Ar predicate Oc Ar action Oc .Op Fl i Ar probe-id Oo Oo Ar predicate Oc Ar action Oc .Sh DESCRIPTION DTrace is a comprehensive dynamic tracing framework ported from Solaris. DTrace provides a powerful infrastructure that permits administrators, developers, and service personnel to concisely answer arbitrary questions about the behavior of the operating system and user programs. .Pp The .Nm command provides a generic interface to the essential services provided by the DTrace facility, including: .Bl -bullet -offset indent .It Options that list the set of probes and providers currently published by DTrace .It Options that enable probes directly using any of the probe description specifiers (provider, module, function, name) .It Options that run the D compiler and compile one or more D program files or programs written directly on the command line .It Options that generate anonymous tracing programs .It Options that generate program stability reports .It Options that modify DTrace tracing and buffering behavior and enable additional D compiler features .El .Pp You can use .Nm to create D scripts by using it in a shebang declaration to create an interpreter file. You can also use .Nm to attempt to compile D programs and determine their properties without actually enabling traces using the .Fl e option. .Sh OPTIONS The arguments accepted by the .Fl P , .Fl m , .Fl f , .Fl n , and .Fl i options can include an optional D language .Ar predicate enclosed in slashes and an optional D language .Ar action statement list enclosed in braces. D program code specified on the command line must be appropriately quoted to avoid interpretation of meta-characters by the shell. .Pp The following options are supported: .Bl -tag -width indent .It Fl 32 | Fl 64 The D compiler produces programs using the native data model of the operating system kernel. If the .Fl 32 option is specified, .Nm forces the D compiler to compile a D program using the 32-bit data model. If the .Fl 64 option is specified, .Nm forces the D compiler to compile a D program using the 64-bit data model. These options are typically not required as .Nm selects the native data model as the default. The data model affects the sizes of integer types and other language properties. D programs compiled for either data model can be executed on both 32-bit and 64-bit kernels. The .Fl 32 and .Fl 64 options also determine the .Xr elf 5 file format (ELF32 or ELF64) produced by the .Fl G option. .It Fl a Claim anonymous tracing state and display the traced data. You can combine the .Fl a option with the .Fl e option to force .Nm to exit immediately after consuming the anonymous tracing state rather than continuing to wait for new data. .It Fl A Generate directives for anonymous tracing and write them to .Pa /boot/dtrace.dof . This option constructs a set of dtrace configuration file directives to enable the specified probes for anonymous tracing and then exits. By default, .Nm attempts to store the directives to the file .Pa /boot/dtrace.dof . This behavior can be modified using the .Fl o option to specify an alternate output file. .It Fl b Ar bufsz Set the principal trace buffer size to .Ar bufsz . The trace buffer size can include any of the size suffixes k, m, g, or t. If the buffer space cannot be allocated, .Nm dtrace attempts to reduce the buffer size or exit depending on the setting of the bufresize property. .It Fl c Ar cmd Run the specified command .Ar cmd and exit upon its completion. If more than one .Fl c option is present on the command line, .Nm dtrace exits when all commands have exited, reporting the exit status for each child process as it terminates. The process ID of the first command is made available to any D programs specified on the command line or using the .Fl s option through the .Li $target macro variable. .It Fl C Run the C preprocessor .Xr cpp 1 over D programs before compiling them. You can pass options to the C preprocessor using the .Fl D , .Fl U , .Fl I , and .Fl H options. You can select the degree of C standard conformance if you use the .Fl X 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 when invoking .Xr cpp 1 (enabled using the .Fl C option). If you specify an additional .Ar value , the name is assigned the corresponding value. This option passes the .Fl D option to each .Xr cpp 1 invocation. .It Fl e Exit after compiling any requests and consuming anonymous tracing state .Fl ( a option) but prior to enabling any probes. You can combine this option with the .Fl a option to print anonymous tracing data and exit. You can also combine this option with D compiler options. This combination verifies that the programs compile without actually executing them and enabling the corresponding instrumentation. .It Fl f Oo Oo Ar provider : Oc Ar module : Oc Ar function Oo Oo Ar predicate \ Oc Ar action Oc Specify function name to trace or list .Fl ( l option). The corresponding argument can include any of the probe description forms .Ar provider:module:function , .Ar module:function , or .Ar function . Unspecified probe description fields are left blank and match any probes regardless of the values in those fields. If no qualifiers other than .Ar function are specified in the description, all probes with the corresponding .Ar function are matched. The .Fl f argument can be suffixed with an optional D probe clause. You can specify more than one .Fl f option on the command line at a time. .It Fl F Coalesce trace output by identifying function entry and return. Function entry probe reports are indented and their output is prefixed with .Ql -> . Function return probe reports are unindented and their output is prefixed with .Ql <- . System call entry probe reports are indented and their output is prefixed with .Ql => . System call return probe reports are unindented and their output is prefixed with .Ql <= . .It Fl G Generate an ELF file containing an embedded DTrace program. The DTrace probes specified in the program are saved inside of a relocatable ELF object which can be linked into another program. If the .Fl o option is present, the ELF file is saved using the pathname specified as the argument for this operand. If the .Fl o option is not present and the DTrace program is contained with a file whose name is .Ar filename.d , then the ELF file is saved using the name .Ar filename.o . Otherwise the ELF file is saved using the name d.out. .It Fl h Generate a header file containing macros that correspond to probes in the specified provider definitions. This option should be used to generate a header file that is included by other source files for later use with the .Fl G option. If the .Fl o option is present, the header file is saved using the pathname specified as the argument for that option. If the .Fl o option is not present and the DTrace program is contained within a file whose name is .Ar filename.d , then the header file is saved using the name .Ar filename.h . .It Fl H Print the pathnames of included files when invoking .Xr cpp 1 (enabled using the .Fl C option). This option passes the .Fl H option to each .Xr cpp 1 invocation, causing it to display the list of pathnames, one for each line, to standard error. .It Fl i Ar probe-id Op Oo Ar predicate Oc Ar action Specify probe identifier .Ar ( probe-id ) to trace or list .Ar ( l option). You can specify probe IDs using decimal integers as shown by `dtrace -l`. The .Fl i argument can be suffixed with an optional D probe clause. You can specify more than one .Fl i option at a time. .It Fl I Ar path Add the specified directory .Ar path to the search path for #include files when invoking .Xr cpp 1 (enabled using the .Fl C option). This option passes the .Fl I option to each .Xr cpp 1 invocation. The specified .Ar path is inserted into the search path ahead of the default directory list. .It Fl l List probes instead of enabling them. If the .Fl l option is specified, .Nm produces a report of the probes matching the descriptions given using the .Fl P , m , f , n , i , and .Fl s options. If none of these options are specified, this option lists all probes. .It Fl L Ar path Add the specified directory .Ar path to the search path for DTrace libraries. DTrace libraries are used to contain common definitions that can be used when writing D programs. The specified .Ar path is added after the default library search path. .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 option). The corresponding argument can include any of the probe description forms .Ar provider:module or .Ar module . Unspecified probe description fields are left blank and match any probes regardless of the values in those fields. If no qualifiers other than .Ar module are specified in the description, all probes with a corresponding .Ar module are matched. The .Fl m argument can be suffixed with an optional D probe clause. More than one .Fl m option can be specified on the command line at a time. .It Fl n Oo Oo Oo Ar provider : Oc Ar module : Oc Ar function : Oc Ar name \ Oo Oo Ar predicate Oc Ar action Oc Specify probe name to trace or list .Fl ( l option). The corresponding argument can include any of the probe description forms .Ar provider:module:function:name , module:function:name , function:name , or .Ar name . Unspecified probe description fields are left blank and match any probes regardless of the values in those fields. If no qualifiers other than .Ar name are specified in the description, all probes with a corresponding .Ar name are matched. The .Fl n 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 Ar output Specify the .Ar output file for the .Fl A , G , and .Fl l options, or for the traced data itself. If the .Fl A option is present and .Fl o is not present, the default output file is .Pa /boot/dtrace.dof . If the .Fl G option is present and the .Fl s option's argument is of the form .Ar filename.d and .Fl o is not present, the default output file is .Ar filename.o . Otherwise the default output file is .Ar d.out . .It Fl p Ar pid Grab the specified process-ID .Ar pid , cache its symbol tables, and exit upon its completion. If more than one .Fl p option is present on the command line, .Nm exits when all commands have exited, reporting the exit status for each process as it terminates. The first process-ID is made available to any D programs specified on the command line or using the .Fl s option through the .Li $target macro variable. .It Fl P Ar provider Oo Oo Ar predicate Oc Ar action Oc Specify provider name to trace or list .Fl ( l option). The remaining probe description fields module, function, and name are left blank and match any probes regardless of the values in those fields. The .Fl P argument can be suffixed with an optional D probe clause. You can specify more than one .Fl P option on the command line at a time. .It Fl q Set quiet mode. .Nm suppresses messages such as the number of probes matched by the specified options and D programs and does not print column headers, the CPU ID, the probe ID, or insert newlines into the output. Only data traced and formatted by D program statements such as .Ql dtrace() and .Ql printf() is displayed to standard output. .It Fl s Ar script Compile the specified D program source file. If the .Fl e option is present, the program is compiled but instrumentation is not enabled. If the .Fl l option is present, the program is compiled and the set of probes matched by it is listed, but instrumentation is not enabled. If none of .Fl e , l , G , or .Fl A are present, the instrumentation specified by the D program is enabled and tracing begins. .It Fl S Show D compiler intermediate code. The D compiler produces a report of the intermediate code generated for each D program to standard error. .It Fl U Ar name Undefine the specified .Ar name when invoking .Xr cpp 1 (enabled using the .Fl C option). This option passes the .Fl U option to each .Xr cpp 1 invocation. .It Fl v Set verbose mode. If the .Fl v option is specified, .Nm produces a program stability report showing the minimum interface stability and dependency level for the specified D programs. .It Fl V Report the highest D programming interface version supported by .Nm . The version information is printed to standard output and the .Nm command exits. .It Fl w Permit destructive actions in D programs specified using the .Fl s , P , m , f , n , or .Fl i options. If the .Fl w option is not specified, .Nm does not permit the compilation or enabling of a D program that contains destructive actions. .It Fl x Ar arg Op Ns = Ns value Enable or modify a DTrace runtime option or D compiler option. Boolean options are enabled by specifying their name. Options with values are set by separating the option name and value with an equals sign (=). .Pp A .Ar size argument may be suffixed with one of .Cm K , .Cm M , .Cm G or .Cm T (either upper or lower case) to indicate a multiple of Kilobytes, Megabytes, Gigabytes or Terabytes respectively. .Pp A .Ar time argument may be suffixed with one of .Cm ns , .Cm nsec , .Cm us , .Cm usec , .Cm ms , .Cm msec , .Cm s , .Cm sec , .Cm m , .Cm min , .Cm h , .Cm hour , .Cm d , .Cm day , .Cm hz . If no suffix is specified .Cm hz will be used as the unit. .Bl -tag -width indent .It Sy aggrate Ns = Ns Ar time Rate of aggregation reading. .It Sy aggsize Ns = Ns Ar size Size of the aggregation buffer. .It Sy bufpolicy Ns = Ns Cm fill Ns | Ns Cm switch Ns | Ns Cm ring Specifies the buffer policy for the principal buffer. .It Sy bufresize Ns = Ns Cm auto Ns | Ns Cm manual Buffer resizing policy. .It Sy bufsize Ns = Ns Ar size Size of the per-CPU principal buffer. Same as the .Fl b flag. .It Sy cleanrate Ns = Ns Ar time Cleaning rate. Must be specified in number-per-second with the .Dq Li hz suffix. .It Sy cpu Ns = Ns Ar scalar Specifies the CPU on which to enable tracing. .It Sy cpp Run a C preprocessor over input files. Same as the .Fl C flag. .It Sy cpppath Ns = Ns Ar path Use the specified path for the C preprocessor rather than searching for .Dq cpp in .Ev PATH . .It Sy defaultargs Allow references to unspecified macro arguments. .It Sy destructive Allow destructive actions. Same as the .Fl w flag. .It Sy dynvarsize Ns = Ns Ar size Size of the dynamic variable space. .It Sy flowindent Turn on flow indentation. Same as the .Fl F flag. .It Sy grabanon Claim anonymous state. Same as the .Fl a flag. .It Sy jstackframes Ns = Ns Ar scalar Number of default stack frames for .Fn jstack . .It Sy jstackstrsize Ns = Ns Ar scalar Default string space size for .Fn jstack . .It Sy ldpath Ns = Ns Ar path When .Fl G is specified, use the specified path for a static linker rather than searching for .Dq "ld" in .Ev PATH . .It Sy libdir Ns = Ns Ar path Add a directory to the system library path. .It Sy nspec Ns = Ns Ar scalar Number of speculations. .It Sy nolibs Do not load D system libraries. .It Sy quiet Set quiet mode. Same as the .Fl q flag. .It Sy specsize Ns = Ns Ar size Size of the speculation buffer. .It Sy strsize Ns = Ns Ar size Maximum size of strings. .It Sy stackframes Ns = Ns Ar scalar Maximum number of kernelspace stack frames to unwind when executing the .Fn stack action. .It Sy stackindent Ns = Ns Ar scalar Number of whitespace characters to use when indenting .Fn stack and .Fn ustack output. .It Sy statusrate Ns = Ns Ar time Rate of status checking. .It Sy switchrate Ns = Ns Ar time Rate of buffer switching. .It Sy syslibdir Ns = Ns Ar path Path to system libraries. Defaults to .Pa /usr/lib/dtrace . .It Sy ustackframes Ns = Ns Ar scalar Maximum number of userspace stack frames to unwind when executing the .Fn ustack action. .El .It Fl X Cm a | c | s | t Specify the degree of conformance to the ISO C standard that should be selected when invoking .Xr cpp 1 (enabled using the .Fl C option). The .Fl X option argument affects the value and presence of the __STDC__ macro depending upon the value of the argument letter. .sp The .Fl X option supports the following arguments: .Bl -tag -width indent .It a Default. ISO C plus K&R compatibility extensions, with semantic changes required by ISO C. This is the default mode if .Fl X is not specified. The predefined macro __STDC__ has a value of 0 when .Xr cpp 1 is invoked in conjunction with the .Fl Xa option. .It c Conformance. Strictly conformant ISO C, without K&R C compatibility extensions. The predefined macro __STDC__ has a value of 1 when .Xr cpp 1 is invoked in conjunction with the .Fl \&Xc option. .It s K&R C only. The macro __STDC__ is not defined when .Xr cpp 1 is invoked in conjunction with the .Fl Xs option. .It t Transition. ISO C plus K&R C compatibility extensions, without semantic changes required by ISO C. The predefined macro __STDC__ has a value of 0 when .Xr cpp 1 is invoked in conjunction with the .Fl Xt option. .El .Pp As the .Fl X option only affects how the D compiler invokes the C preprocessor, the .Fl Xa and .Fl Xt options are equivalent from the perspective of D and both are provided only to ease re-use of settings from a C build environment. .Pp Regardless of the .Fl X mode, the following additional C preprocessor definitions are always specified and valid in all modes: .Bl -bullet -offset indent .It __sun .It __unix .It __SVR4 .It __sparc (on SPARC systems only) .It __sparcv9 (on SPARC systems only when 64-bit programs are compiled) .It __i386 (on x86 systems only when 32-bit programs are compiled) .It __amd64 (on x86 systems only when 64-bit programs are compiled) .It __`uname -s`_`uname -r` (for example, .Ql FreeBSD_9.2-RELEASE . .It __SUNW_D=1 .It .No __SUNW_D_VERSION=0x Ns Ar MMmmmuuu .Pp Where .Ar MM is the major release value in hexadecimal, .Ar mmm is the minor release value in hexadecimal, and .Ar uuu is the micro release value in hexadecimal. .El .It Fl Z Permit probe descriptions that match zero probes. If the .Fl Z option is not specified, .Nm reports an error and exits if any probe descriptions specified in D program files .Fl ( s option) or on the command line .Fl ( P , m , f , n , or .Fl i options) contain descriptions that do not match any known probes. .El .Sh OPERANDS You can specify zero or more additional arguments on the .Nm command line to define a set of macro variables and so forth). The additional arguments can be used in D programs specified using the .Fl s option or on the command line. .Sh FILES .Bl -tag -width /boot/dtrace.dof -compact .It Pa /boot/dtrace.dof File for anonymous tracing directives. .El .Sh EXIT STATUS The following exit statuses are returned: .Bl -tag -width indent .It 0 Successful completion. .Pp For D program requests, an exit status of 0 indicates that programs were successfully compiled, probes were successfully enabled, or anonymous state was successfully retrieved. .Nm returns 0 even if the specified tracing requests encountered errors or drops. .It 1 An error occurred. .Pp For D program requests, an exit status of 1 indicates that program compilation failed or that the specified request could not be satisfied. .It 2 Invalid command line options or arguments were specified. .El .Sh SEE ALSO .Xr cpp 1 , .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/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 @@ -1,407 +1,405 @@ '\" te .\" 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) 2008, Sun Microsystems, Inc. All Rights Reserved. .\" -.\" $FreeBSD$ -.\" .Dd February 25, 2020 .Dt LOCKSTAT 1 .Os .Sh NAME .Nm lockstat .Nd report kernel lock and profiling statistics .Sh SYNOPSIS .Nm .Op Fl ACEHIV .Op Fl e Ar event-list .Op Fl i Ar rate .Op Fl b | t | h | s Ar depth .Op Fl n Ar num-records .Op Fl l Ar lock Oo Ns , Ns Ar size Oc .Op Fl d Ar duration .Op Fl f Ar function Oo Ns , Ns Ar size Oc .Op Fl T .Op Fl kgwWRpP .Op Fl D Ar count .Op Fl o filename .Op Fl x Ar opt Oo Ns = Ns Ar val Oc .Ar command .Op Oo Ar args Oc .Sh DESCRIPTION The .Nm utility gathers and displays kernel locking and profiling statistics. .Nm allows you to specify which events to watch (for example, spin on adaptive mutex, block on read access to rwlock due to waiting writers, and so forth), how much data to gather for each event, and how to display the data. By default, .Nm monitors all lock contention events, gathers frequency and timing data about those events, and displays the data in decreasing frequency order, so that the most common events appear first. .Pp .Nm gathers data until the specified command completes. For example, to gather statistics for a fixed-time interval, use .Xr sleep 1 as the command, as follows: .Pp .Dl # lockstat sleep 5 .Pp When the .Fl I option is specified, .Nm lockstat establishes a per-processor high-level periodic interrupt source to gather profiling data. The interrupt handler simply generates a .Nm event whose caller is the interrupted PC (program counter). The profiling event is just like any other .Nm lockstat event, so all of the normal .Nm lockstat options are applicable. .Pp .Nm relies on DTrace to modify the running kernel's text to intercept events of interest. This imposes a small but measurable overhead on all system activity, so access to .Nm is restricted to super-user by default. .Sh OPTIONS The following options are supported: .Bl -tag -width indent .It Fl V Print the D program used to gather the requested data. .El .Ss Event Selection If no event selection options are specified, the default is .Fl C . .Bl -tag -width indent .It Fl A Watch all lock events. .Fl A is equivalent to .Fl CH . .It Fl C Watch contention events. .It Fl E Watch error events. .It Fl e Ar event-list Only watch the specified events. .Ar event-list is a comma-separated list of events or ranges of events such as 1,4-7,35. Run .Nm with no arguments to get a brief description of all events. .It Fl H Watch hold events. .It Fl I Watch profiling interrupt events. .It Fl i Ar rate Interrupt rate (per second) for .Fl I . The default is 97 Hz, so that profiling doesn't run in lockstep with the clock interrupt (which runs at 100 Hz). .El .Ss Data Gathering .Bl -tag -width indent .It Fl x Ar arg Oo Ns = Ns Ar val Oc Enable or modify a .Xr dtrace 1 runtime option or D compiler option. Boolean options are enabled by specifying their name. Options with values are set by separating the option name and value with an equals sign. .El .Ss "Data Gathering (Mutually Exclusive)" .Bl -tag -width indent .It Fl b Basic statistics: lock, caller, number of events. .It Fl h Histogram: timing plus time-distribution histograms. .It Fl s Ar depth Stack trace: histogram plus stack traces up to .Ar depth frames deep. .It Fl t Timing: Basic plus timing for all events (default). .El .Ss "Data Filtering" .Bl -tag -width indent .It Fl d Ar duration Only watch events longer than .Ar duration . .It Fl f Ar func Ns Oo Ns , Ns Ar size Oc Ns Only watch events generated by .Ar func , which can be specified as a symbolic name or hex address. .Ar size defaults to the ELF symbol size if available, or 1 if not. .It Fl l Ar lock Ns Oo Ns , Ns Ar size Oc Ns Only watch .Ar lock , which can be specified as a symbolic name or hex address. .Ar size defaults to the ELF symbol size or 1 if the symbol size is not available. .It Fl n Ar num-records Maximum number of data records. .It Fl T Trace (rather than sample) events. This is off by default. .El .Ss Data Reporting .Bl -tag -width indent .It Fl D Ar count Only display the top .Ar count events of each type. .It Fl g Show total events generated by function. For example, if .Fn foo calls .Fn bar in a loop, the work done by .Fn bar counts as work generated by .Fn foo (along with any work done by .Fn foo itself). The .Fl g option works by counting the total number of stack frames in which each function appears. This implies two things: (1) the data reported by .Fl g can be misleading if the stack traces are not deep enough, and (2) functions that are called recursively might show greater than 100% activity. In light of issue (1), the default data gathering mode when using .Fl g is .Fl s 50 . .It Fl k Coalesce PCs within functions. .It Fl o Ar filename Direct output to .Ar filename . .It Fl P Sort data by (\fIcount * time\fR) product. .It Fl p Parsable output format. .It Fl R Display rates (events per second) rather than counts. .It Fl W Whichever: distinguish events only by caller, not by lock. .It Fl w Wherever: distinguish events only by lock, not by caller. .El .Sh DISPLAY FORMATS The following headers appear over various columns of data. .Bl -tag -width indent .It Count or ops/s Number of times this event occurred, or the rate (times per second) if .Fl R was specified. .It indv Percentage of all events represented by this individual event. .It genr Percentage of all events generated by this function. .It cuml Cumulative percentage; a running total of the individuals. .It rcnt Average reference count. This will always be 1 for exclusive locks (mutexes, spin locks, rwlocks held as writer) but can be greater than 1 for shared locks (rwlocks held as reader). .It nsec Average duration of the events in nanoseconds, as appropriate for the event. For the profiling event, duration means interrupt latency. .It Lock Address of the lock; displayed symbolically if possible. .It CPU+Pri_Class CPU plus the priority class of the interrupted thread. For example, if CPU 4 is interrupted while running a timeshare thread, this will be reported as .Ql cpu[4]+TShar . .It Caller Address of the caller; displayed symbolically if possible. .El .Sh EXAMPLES .Bl -tag -width 0n .It Example 1 Measuring Kernel Lock Contention .Pp .Li # lockstat sleep 5 .Bd -literal Adaptive mutex spin: 41411 events in 5.011 seconds (8263 events/sec) Count indv cuml rcnt nsec Lock Caller ------------------------------------------------------------------------------- 13750 33% 33% 0.00 72 vm_page_queue_free_mtx vm_page_free_toq+0x12e 13648 33% 66% 0.00 66 vm_page_queue_free_mtx vm_page_alloc+0x138 4023 10% 76% 0.00 51 vm_dom+0x80 vm_page_dequeue+0x68 2672 6% 82% 0.00 186 vm_dom+0x80 vm_page_enqueue+0x63 618 1% 84% 0.00 31 0xfffff8000cd83a88 qsyncvp+0x37 506 1% 85% 0.00 164 0xfffff8000cb3f098 vputx+0x5a 477 1% 86% 0.00 69 0xfffff8000c7eb180 uma_dbg_getslab+0x5b 288 1% 87% 0.00 77 0xfffff8000cd8b000 vn_finished_write+0x29 263 1% 88% 0.00 103 0xfffff8000cbad448 vinactive+0xdc 259 1% 88% 0.00 53 0xfffff8000cd8b000 vfs_ref+0x24 237 1% 89% 0.00 20 0xfffff8000cbad448 vfs_hash_get+0xcc 233 1% 89% 0.00 22 0xfffff8000bfd9480 uma_dbg_getslab+0x5b 223 1% 90% 0.00 20 0xfffff8000cb3f098 cache_lookup+0x561 193 0% 90% 0.00 16 0xfffff8000cb40ba8 vref+0x27 175 0% 91% 0.00 34 0xfffff8000cbad448 vputx+0x5a 169 0% 91% 0.00 51 0xfffff8000cd8b000 vfs_unbusy+0x27 164 0% 92% 0.00 31 0xfffff8000cb40ba8 vputx+0x5a [...] Adaptive mutex block: 10 events in 5.011 seconds (2 events/sec) Count indv cuml rcnt nsec Lock Caller ------------------------------------------------------------------------------- 3 30% 30% 0.00 17592 vm_page_queue_free_mtx vm_page_alloc+0x138 2 20% 50% 0.00 20528 vm_dom+0x80 vm_page_enqueue+0x63 2 20% 70% 0.00 55502 0xfffff8000cb40ba8 vputx+0x5a 1 10% 80% 0.00 12007 vm_page_queue_free_mtx vm_page_free_toq+0x12e 1 10% 90% 0.00 9125 0xfffff8000cbad448 vfs_hash_get+0xcc 1 10% 100% 0.00 7864 0xfffff8000cd83a88 qsyncvp+0x37 ------------------------------------------------------------------------------- [...] .Ed .It Example 2 Measuring Hold Times .Pp .Li # lockstat -H -D 10 sleep 1 .Bd -literal Adaptive mutex hold: 109589 events in 1.039 seconds (105526 events/sec) Count indv cuml rcnt nsec Lock Caller ------------------------------------------------------------------------------- 8998 8% 8% 0.00 617 0xfffff8000c7eb180 uma_dbg_getslab+0xd4 5901 5% 14% 0.00 917 vm_page_queue_free_mtx vm_object_terminate+0x16a 5040 5% 18% 0.00 902 vm_dom+0x80 vm_page_free_toq+0x88 4884 4% 23% 0.00 1056 vm_page_queue_free_mtx vm_page_alloc+0x44e 4664 4% 27% 0.00 759 vm_dom+0x80 vm_fault_hold+0x1a13 4011 4% 31% 0.00 888 vm_dom vm_page_advise+0x11b 4010 4% 34% 0.00 957 vm_dom+0x80 _vm_page_deactivate+0x5c 3743 3% 38% 0.00 582 0xfffff8000cf04838 pmap_is_prefaultable+0x158 2254 2% 40% 0.00 952 vm_dom vm_page_free_toq+0x88 1639 1% 41% 0.00 591 0xfffff800d60065b8 trap_pfault+0x1f7 ------------------------------------------------------------------------------- [...] R/W writer hold: 64314 events in 1.039 seconds (61929 events/sec) Count indv cuml rcnt nsec Lock Caller ------------------------------------------------------------------------------- 7421 12% 12% 0.00 2994 pvh_global_lock pmap_page_is_mapped+0xb6 4668 7% 19% 0.00 3313 pvh_global_lock pmap_enter+0x9ae 1639 3% 21% 0.00 733 0xfffff80168d10200 vm_object_deallocate+0x683 1639 3% 24% 0.00 3061 0xfffff80168d10200 unlock_and_deallocate+0x2b 1639 3% 26% 0.00 2966 0xfffff80168d10200 vm_fault_hold+0x16ee 1567 2% 29% 0.00 733 0xfffff80168d10200 vm_fault_hold+0x19bc 821 1% 30% 0.00 786 0xfffff801eb0cc000 vm_object_madvise+0x32d 649 1% 31% 0.00 4918 0xfffff80191105300 vm_fault_hold+0x16ee 648 1% 32% 0.00 8112 0xfffff80191105300 unlock_and_deallocate+0x2b 647 1% 33% 0.00 1261 0xfffff80191105300 vm_object_deallocate+0x683 ------------------------------------------------------------------------------- .Ed .It Example 3 Measuring Hold Times for Stack Traces Containing a Specific Function .Pp .Li # lockstat -H -f tcp_input -s 50 -D 10 sleep 1 .Bd -literal Adaptive mutex hold: 68 events in 1.026 seconds (66 events/sec) ------------------------------------------------------------------------------- Count indv cuml rcnt nsec Lock Caller 32 47% 47% 0.00 1631 0xfffff800686f50d8 tcp_do_segment+0x284b nsec ------ Time Distribution ------ count Stack 1024 |@@@@@@@@@@ 11 tcp_input+0xf54 2048 |@@@@@@@@@@@@@ 14 ip_input+0xc8 4096 |@@@@@ 6 swi_net+0x192 8192 | 1 intr_event_execute_handlers+0x93 ithread_loop+0xa6 fork_exit+0x84 0xffffffff808cf9ee ------------------------------------------------------------------------------- Count indv cuml rcnt nsec Lock Caller 29 43% 90% 0.00 4851 0xfffff800686f50d8 sowakeup+0xf8 nsec ------ Time Distribution ------ count Stack 4096 |@@@@@@@@@@@@@@@ 15 tcp_do_segment+0x2423 8192 |@@@@@@@@@@@@ 12 tcp_input+0xf54 16384 |@@ 2 ip_input+0xc8 swi_net+0x192 intr_event_execute_handlers+0x93 ithread_loop+0xa6 fork_exit+0x84 0xffffffff808cf9ee ------------------------------------------------------------------------------- [...] .Ed .El .Sh SEE ALSO .Xr dtrace 1 , .Xr ksyms 4 , .Xr locking 9 .Sh HISTORY The .Nm utility first appeared in .Fx 7.1 . .Sh NOTES Tail-call elimination can affect call sites. For example, if .Fn foo Ns +0x50 calls .Fn bar and the last thing .Fn bar does is call .Fn mtx_unlock , the compiler can arrange for .Fn bar to branch to .Fn mtx_unlock with a return address of .Fn foo Ns +0x58. Thus, the .Fn mtx_unlock in .Fn bar will appear as though it occurred at .Fn foo Ns +0x58. .Pp The PC in the stack frame in which an interrupt occurs can be bogus because, between function calls, the compiler is free to use the return address register for local storage. .Pp When using the .Fl I and .Fl s options together, the interrupted PC will usually not appear anywhere in the stack since the interrupt handler is entered asynchronously, not by a function call from that PC. diff --git a/cddl/usr.sbin/dwatch/dwatch b/cddl/usr.sbin/dwatch/dwatch index 9adde7eb8d49..c9af8258f4ac 100755 --- a/cddl/usr.sbin/dwatch/dwatch +++ b/cddl/usr.sbin/dwatch/dwatch @@ -1,1396 +1,1395 @@ #!/bin/sh #- # Copyright (c) 2014-2018 Devin Teske # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 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 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 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) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # 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. # ############################################################ IDENT(1) # # $Title: Watch processes as they trigger a particular DTrace probe $ # ############################################################ CONFIGURATION # # DTrace pragma settings # DTRACE_PRAGMA=" option quiet option dynvarsize=16m option switchrate=10hz " # END-QUOTE # # Profiles # : ${DWATCH_PROFILES_PATH="/usr/libexec/dwatch:/usr/local/libexec/dwatch"} ############################################################ GLOBALS VERSION='$Version: 1.4 $' # -V pgm="${0##*/}" # Program basename # # Command-line arguments # PROBE_ARG= # # Command-line defaults # _MAX_ARGS=64 # -B num _MAX_DEPTH=64 # -K num # # Command-line options # CONSOLE= # -y CONSOLE_FORCE= # -y [ -t 1 ] && CONSOLE=1 # -y COUNT=0 # -N count CUSTOM_DETAILS= # -E code CUSTOM_TEST= # -t test DEBUG= # -d DESTRUCTIVE_ACTIONS= # -w DEVELOPER= # -dev EXECNAME= # -k name EXECREGEX= # -z regex EXIT_AFTER_COMPILE= # -e FILTER= # -r regex PROBE_COALESCE= # -F GROUP= # -g group JID= # -j jail LIST= # -l LIST_PROFILES= # -Q MAX_ARGS=$_MAX_ARGS # -B num MAX_DEPTH=$_MAX_DEPTH # -K num ONELINE= # -1 OUTPUT= # -o file OUTPUT_CMD= # -O cmd PID= # -p pid PROBE_TYPE= # -f -m -n -P PROFILE= # -X profile PSTREE= # -R QUIET= # -q TIMEOUT= # -T time TRACE= # -x USER= # -u user USE_PROFILE= # -X profile VERBOSE= # -v # # Global exit status # SUCCESS=0 FAILURE=1 # # Miscellaneous # ACTIONS= EVENT_DETAILS= EVENT_TAG='printf("%d.%d %s[%d]: ", this->uid0, this->gid0, execname, this->pid0);' EVENT_TEST= FILE= ID=3 MODULE_CHECKED= PROBE= PSARGS=1 RGID= RUID= SUDO= export SUDO_PROMPT="[sudo] Password:" TITLE=\$Title: ############################################################ FUNCTIONS ansi() { local fmt="$2 $4"; [ "$CONSOLE" ] && fmt="\\033[$1m$2\\033[$3m $4"; shift 4; printf "$fmt\n" "$@"; } die() { exec >&2; [ "$*" ] && echo "$pgm:" "$@"; exit $FAILURE; } info() { [ "$QUIET" ] || ansi 35 "INFO" 39 "$@" >&2; } usage() { local optfmt="\t%-10s %s\n" exec >&2 [ "$*" ] && printf "%s: %s\n" "$pgm" "$*" printf "Usage: %s [-1defFmnPqRvVwxy] [%s] [%s] [%s] [%s]\n" "$pgm" \ "-B num" "-E code" "-g group" "-j jail" printf "\t [%s] [%s] [%s] [%s] [%s] [%s]\n" \ "-k name" "-K num" "-N count" "-o file" "-O cmd" "-p pid" printf "\t [%s] [%s] [%s] [%s] [%s] [%s]\n" \ "-r regex" "-t test" "-T time" "-u user" "-X profile" \ "-z regex" printf "\t probe[,...] [args ...]\n" printf " %s -l [-fmnPqy] [-r regex] [probe ...]\n" "$pgm" printf " %s -Q [-1qy] [-r regex]\n" "$pgm" printf "\n" printf "$optfmt" "-1" \ "Print one line per process/profile (Default; disables \`-R')." printf "$optfmt" "-B num" \ "Maximum process arguments to display (Default $_MAX_ARGS)." printf "$optfmt" "-d" \ "Debug. Send dtrace(1) script to stdout instead of executing." printf "$optfmt" "-e" \ "Exit after compiling request but prior to enabling probes." printf "$optfmt" "-E code" \ "DTrace code for event details. If \`-', read from stdin." printf "$optfmt" "-f" \ "Enable probe matching the specified function name." printf "$optfmt" "-F" \ "Coalesce trace output by function." printf "$optfmt" "-g group" \ "Group filter. Only show processes matching group name/gid." printf "$optfmt" "-j jail" \ "Jail filter. Only show processes matching jail name/jid." printf "$optfmt" "-k name" \ "Only show processes matching name." printf "$optfmt" "-K num" \ "Maximum directory depth to display (Default $_MAX_DEPTH)." printf "$optfmt" "-l" \ "List available probes on standard output and exit." printf "$optfmt" "-m" \ "Enable probe matching the specified module name." printf "$optfmt" "-n" \ "Enable probe matching the specified probe name." printf "$optfmt" "-N count" \ "Exit after count matching entries (Default 0 for disabled)." printf "$optfmt" "-o file" \ "Set output file. If \`-', the path \`/dev/stdout' is used." printf "$optfmt" "-O cmd" \ "Execute cmd for each event." printf "$optfmt" "-p pid" \ "Process id filter. Only show processes with matching pid." printf "$optfmt" "-P" \ "Enable probe matching the specified provider name." printf "$optfmt" "-q" \ "Quiet. Hide informational messages and all dtrace(1) errors." printf "$optfmt" "-Q" \ "List available profiles in DWATCH_PROFILES_PATH and exit." printf "$optfmt" "-r regex" \ "Filter. Only show blocks matching awk(1) regular expression." printf "$optfmt" "-R" \ "Show parent, grandparent, and ancestor of process." printf "$optfmt" "-t test" \ "Test clause (predicate) to limit events (Default none)." printf "$optfmt" "-T time" \ "Timeout. Format is \`\#[smhd]' or simply \`\#' for seconds." printf "$optfmt" "-u user" \ "User filter. Only show processes matching user name/uid." printf "$optfmt" "-v" \ "Verbose. Show all errors from dtrace(1)." printf "$optfmt" "-V" \ "Report dwatch version on standard output and exit." printf "$optfmt" "-w" \ "Permit destructive actions (copyout*, stop, panic, etc.)." printf "$optfmt" "-x" \ "Trace. Print \`' when a probe is triggered." printf "$optfmt" "-X profile" \ "Load profile name from DWATCH_PROFILES_PATH." printf "$optfmt" "-y" \ "Always treat stdout as console (enable colors/columns/etc.)." printf "$optfmt" "-z regex" \ "Only show processes matching awk(1) regular expression." die } dtrace_cmd() { local status stdout local timeout= if [ "$1" = "-t" ]; then shift [ "$TIMEOUT" ] && timeout=1 fi exec 3>&1 stdout=3 # # Filter dtrace(1) stderr while preserving exit status # status=$( exec 4>&1 to_status=4 ( trap 'echo $? >&$to_status' EXIT eval $SUDO ${timeout:+timeout \"\$TIMEOUT\"} dtrace \ \"\$@\" 2>&1 ${QUIET:+2> /dev/null} >&$stdout ) | dtrace_stderr_filter >&2 ) return $status } dtrace_stderr_filter() { if [ "$VERBOSE" ]; then cat return # NOTREACHED fi awk ' # Start awk(1) stderr-filter /[[:digit:]]+ drops? on CPU [[:digit:]]+/ { next } /failed to write to : No such file or directory/ { next } /failed to write to : Broken pipe/ { next } /processing aborted: Broken pipe/ { next } /invalid address \(0x[[:xdigit:]]+\) in action #[[:digit:]]+/ { next } /out of scratch space in action #[[:digit:]]+/ { next } /^Bus error$/ { next } { print; fflush() } ' # END-QUOTE } expand_probe() { local OPTIND=1 OPTARG flag local type= while getopts t: flag; do case "$flag" in t) type="$OPTARG" ;; esac done shift $(( $OPTIND - 1 )) local probe="$1" case "$probe" in *:*) echo "$probe" return $SUCCESS ;; esac dtrace_cmd -l | awk -v probe="$probe" -v type="$type" ' # Start awk(1) processor #################################################### BEGIN BEGIN { getline dtrace_header } #################################################### FUNCTIONS function dump(unused1,unused2) { if (n) { if (NcF[n] == 1) f = N2F[n] if (NcM[n] == 1) m = N2M[n] if (NcP[n] == 1) p = N2P[n] } else if (f) { if (FcM[f] == 1) m = F2M[f] if (FcP[f] == 1) p = F2P[f] if (FcN[f] == 0 && found) n = "entry" } else if (m) { if (McP[m] == 1) p = M2P[m] } printf "%s:%s:%s:%s\n", p, m, f, n exit !found } function inFMP() { return probe in F || probe in M || probe in P } function inNMP() { return probe in N || probe in M || probe in P } function inNFP() { return probe in N || probe in F || probe in P } function inNFM() { return probe in N || probe in F || probe in M } function diva(value, peerA, peerB, peerC) { return value >= peerA && value >= peerB && value >= peerC } #################################################### MAIN type == "name" && $NF != probe { next } type == "function" && NF >=4 && $(NF-1) != probe { next } type == "module" && NF == 5 && $(NF-2) != probe { next } type == "provider" && $2 != probe { next } type || $2 == probe || $3 == probe || $4 == probe || $5 == probe { P[_p = $2]++ M[_m = (NF >= 5 ? $(NF-2) : "")]++ F[_f = (NF >= 4 ? $(NF-1) : "")]++ N[_n = $NF]++ if (N2F[_n] != _f) NcF[_n]++; N2F[_n] = _f if (N2M[_n] != _m) NcM[_n]++; N2M[_n] = _m if (N2P[_n] != _p) NcP[_n]++; N2P[_n] = _p if (_n !~ /entry|return/) { if (F2N[_f] != _n) FcN[_f]++ F2N[_f] = _n } if (F2M[_f] != _m) FcM[_f]++; F2M[_f] = _m if (F2P[_f] != _p) FcP[_f]++; F2P[_f] = _p if (M2P[_m] != _p) McP[_m]++; M2P[_m] = _p } #################################################### END END { if (type == "name") dump(n = probe, found = probe in N) if (type == "function") dump(f = probe, found = probe in F) if (type == "module") dump(m = probe, found = probe in M) if (type == "provider") dump(p = probe, found = probe in P) if (probe in N) { found = 1 if (!inFMP()) dump(n = probe) if (diva(F[probe], N[probe], M[probe], P[probe])) dump(f = probe) if (diva(M[probe], N[probe], F[probe], P[probe])) dump(m = probe) if (diva(P[probe], N[probe], F[probe], M[probe])) dump(p = probe) dump(n = probe) # N is the diva } else if (probe in F) { found = 1 if (!inNMP()) dump(f = probe) if (diva(N[probe], F[probe], M[probe], P[probe])) dump(n = probe) if (diva(M[probe], F[probe], N[probe], P[probe])) dump(m = probe) if (diva(P[probe], F[probe], N[probe], M[probe])) dump(p = probe) dump(f = probe) # F is the diva } else if (probe in M) { found = 1 if (!inNFP()) dump(m = probe) if (diva(N[probe], M[probe], F[probe], P[probe])) dump(n = probe) if (diva(F[probe], M[probe], N[probe], P[probe])) dump(f = probe) if (diva(P[probe], M[probe], N[probe], F[probe])) dump(p = probe) dump(m = probe) # M is the diva } else if (probe in P) { found = 1 if (!inNFM()) dump(p = probe) if (diva(N[probe], P[probe], F[probe], M[probe])) dump(n = probe) if (diva(F[probe], P[probe], N[probe], M[probe])) dump(f = probe) if (diva(M[probe], P[probe], N[probe], F[probe])) dump(m = probe) dump(p = probe) # P is the diva } if (!found) print probe exit !found } ' # END-QUOTE } list_probes() { local OPTIND=1 OPTARG flag local column=0 header="PROVIDER:MODULE:FUNCTION:NAME" local filter= quiet= type= while getopts f:qt: flag; do case "$flag" in f) filter="$OPTARG" ;; q) quiet=1 ;; t) type="$OPTARG" ;; esac done shift $(( $OPTIND - 1 )) if [ $# -eq 0 ]; then case "$type" in provider) column=1 header="PROVIDER" ;; module) column=2 header="MODULE" ;; function) column=3 header="FUNCTION" ;; name) column=4 header="NAME" ;; esac fi [ "$quiet" ] || echo "$header" local arg probe= for arg in "$@"; do arg=$( expand_probe -t "$type" -- "$arg" ) probe="$probe${probe:+, }$arg" done dtrace_cmd -l${probe:+n "$probe"} | awk -v pattern="$( # Prevent backslashes from being lost echo "$filter" | awk 'gsub(/\\/,"&&")||1' )" -v want="$column" -v console="$CONSOLE" ' BEGIN { getline dtrace_header } function ans(seq) { return console ? "\033[" seq "m" : "" } NF > 3 && $(NF-1) ~ /^#/ { next } !_[$0 = column[0] = sprintf("%s:%s:%s:%s", column[1] = $2, column[2] = (NF >= 5 ? $(NF-2) : ""), column[3] = (NF >= 4 ? $(NF-1) : ""), column[4] = $NF)]++ && !__[$0 = column[want]]++ && gsub(pattern, ans("31;1") "&" ans("39;22")) { print | "sort" } END { close("sort") } ' # END-QUOTE exit $SUCCESS } list_profiles() { local OPTIND=1 OPTARG flag local filter= oneline= quiet= while getopts 1f:q flag; do case "$flag" in 1) oneline=1 ;; f) filter="$OPTARG" ;; q) quiet=1 ;; esac done shift $(( $OPTIND - 1 )) # Prevent backslashes from being lost filter=$( echo "$filter" | awk 'gsub(/\\/,"&&")||1' ) # Build a list of profiles available local profiles profiles=$( { IFS=: for dir in $DWATCH_PROFILES_PATH; do [ -d "$dir" ] || continue for path in $dir/*; do [ -f "$path" ] || continue name="${path##*/}" [ "$name" = "${name%%[!0-9A-Za-z_-]*}" ] || continue echo $name done done } | sort -u ) # Get the longest profile name local longest_profile_name longest_profile_name=$( echo "$profiles" | awk -v N=0 '(L = length($0)) > N { N = L } END { print N }' ) # Get the width of the terminal local max_size="$( stty size 2> /dev/null )" : ${max_size:=24 80} local max_width="${max_size#*[$IFS]}" # Determine how many columns we can display local x=$longest_profile_name ncols=1 [ "$QUIET" ] || x=$(( $x + 8 )) # Accommodate leading tab character x=$(( $x + 3 + $longest_profile_name )) # Preload end of next column while [ $x -lt $max_width ]; do ncols=$(( $ncols + 1 )) x=$(( $x + 3 + $longest_profile_name )) done # Output single lines if sent to a pipe if [ "$oneline" ]; then echo "$profiles" | awk -v filter="$filter" -v cons="$CONSOLE" ' function ans(s) { return cons ? "\033[" s "m" : "" } gsub(filter, ans("31;1") "&" ans("39;22")) ' # END-QUOTE exit $SUCCESS fi [ "$quiet" ] || echo PROFILES: echo "$profiles" | awk \ -v colsize=$longest_profile_name \ -v console="$CONSOLE" \ -v ncols=$ncols \ -v quiet="$quiet" \ -v filter="$filter" \ ' # Begin awk(1) processor function ans(seq) { return console ? "\033[" seq "m" : "" } BEGIN { row_item[1] = "" replace = ans("31;1") "&" ans("39;22") ansi_offset = length(replace) - 1 } function print_row() { cs = colsize + ansi_offset * \ gsub(filter, replace, row_item[1]) printf "%s%-*s", quiet ? "" : "\t", cs, row_item[1] for (i = 2; i <= cur_col; i++) { cs = colsize + ansi_offset * \ gsub(filter, replace, row_item[i]) printf " %-*s", cs, row_item[i] } printf "\n" } $0 ~ filter { n++ cur_col = ((n - 1) % ncols) + 1 row_item[cur_col] = $0 if (cur_col == ncols) print_row() } END { if (cur_col < ncols) print_row() } ' # END-QUOTE exit $SUCCESS } shell_escape() { echo "$*" | awk 'gsub(/'\''/, "&\\\\&&")||1' } load_profile() { local profile="$1" [ "$profile" ] || die "missing profile argument (\`$pgm -Q' to list profiles)" local oldIFS="$IFS" local dir found= local ARGV= [ $COUNT -gt 0 ] && ARGV="$ARGV -N $COUNT" [ "$DEBUG" ] && ARGV="$ARGV -d" [ "$DESTRUCTIVE_ACTIONS" ] && ARGV="$ARGV -w" [ "$EXIT_AFTER_COMPILE" ] && ARGV="$ARGV -e" [ "$GROUP" ] && ARGV="$ARGV -g $GROUP" [ "$JID" ] && ARGV="$ARGV -j $JID" [ $MAX_ARGS -ne $_MAX_ARGS ] && ARGV="$ARGV -B $MAX_ARGS" [ $MAX_DEPTH -ne $_MAX_DEPTH ] && ARGV="$ARGV -K $MAX_DEPTH" [ "$ONELINE" ] && ARGV="$ARGV -1" [ "$PID" ] && ARGV="$ARGV -p $PID" [ "$PSTREE" ] && ARGV="$ARGV -R" [ "$QUIET" ] && ARGV="$ARGV -q" [ "$TIMEOUT" ] && ARGV="$ARGV -T $TIMEOUT" [ "$TRACE" ] && ARGV="$ARGV -x" [ "$USER" ] && ARGV="$ARGV -u $USER" [ "$VERBOSE" ] && ARGV="$ARGV -v" [ "$FILTER" ] && ARGV="$ARGV -r '$( shell_escape "$FILTER" )'" [ "$EXECREGEX" ] && ARGV="$ARGV -z '$( shell_escape "$EXECREGEX" )'" [ "$CUSTOM_DETAILS" ] && ARGV="$ARGV -E '$( shell_escape "$EVENT_DETAILS" )'" [ "$CUSTOM_TEST" ] && ARGV="$ARGV -t '$( shell_escape "$CUSTOM_TEST" )'" [ "$OUTPUT" ] && ARGV="$ARGV -o '$( shell_escape "$OUTPUT" )'" [ "$OUTPUT_CMD" ] && ARGV="$ARGV -O '$( shell_escape "$OUTPUT_CMD" )'" case "$PROBE_TYPE" in provider) ARGV="$ARGV -P" ;; module) ARGV="$ARGV -m" ;; function) ARGV="$ARGV -f" ;; name) ARGV="$ARGV -n" ;; esac IFS=: for dir in $DWATCH_PROFILES_PATH; do [ -d "$dir" ] || continue [ -f "$dir/$profile" ] || continue PROFILE="$profile" found=1 info "Sourcing $profile profile [found in %s]" "$dir" . "$dir/$profile" break done IFS="$oldIFS" [ "$found" ] || die "no module named \`$profile' (\`$pgm -Q' to list profiles)" } pproc() { local OPTIND=1 OPTARG flag local P= N=0 while getopts P: flag; do case "$flag" in P) P="$OPTARG" ;; esac done shift $(( OPTIND - 1 )) local proc=$1 if [ ! "$proc" ]; then if [ "$P" = "0" ]; then proc="curthread->td_proc" else proc="this->proc ? this->proc->p_pptr : NULL" fi fi awk 'NR > 1 && $0 { $0 = "\t" $0 } gsub(/\\\t/, "\t") || 1 ' <<-EOFPREAMBLE this->proc = $proc; this->uid$P = this->proc ? this->proc->p_ucred->cr_uid : -1; this->gid$P = this->proc ? this->proc->p_ucred->cr_rgid : -1; this->pid$P = this->proc ? this->proc->p_pid : -1; this->jid$P = this->proc ? this->proc->p_ucred->cr_prison->pr_id : -1; this->p_args = this->proc ? this->proc->p_args : 0; this->ar_length = this->p_args ? this->p_args->ar_length : 0; this->ar_args = (char *)(this->p_args ? this->p_args->ar_args : 0); this->args$P = this->arg${P}_$N = this->ar_length > 0 ? \ this->ar_args : stringof(this->proc->p_comm); this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0; this->ar_args += this->len; this->ar_length -= this->len; EOFPREAMBLE awk -v P=$P -v MAX_ARGS=$MAX_ARGS ' $0 { $0 = "\t" $0 } buf = buf $0 "\n" { } END { while (++N <= MAX_ARGS) { $0 = buf gsub(/P/, P) gsub(/N/, N) gsub(/\\\t/, "\t") sub(/\n$/, "") print } } ' <<-EOFARGS this->argP_N = this->ar_length > 0 ? this->ar_args : ""; this->argsP = strjoin(this->argsP, \ strjoin(this->argP_N != "" ? " " : "", this->argP_N)); this->len = this->ar_length > 0 ? strlen(this->ar_args) + 1 : 0; this->ar_args += this->len; this->ar_length -= this->len; EOFARGS N=$(( $MAX_ARGS + 1 )) awk 'sub(/^\\\t/, "\t") || 1, $0 = "\t" $0' <<-EOFPROC this->arg${P}_$N = this->ar_length > 0 ? "..." : ""; this->args$P = strjoin(this->args$P, \ strjoin(this->arg${P}_$N != "" ? " " : "", this->arg${P}_$N)); EOFPROC } pproc_dump() { local OPTIND=1 OPTARG flag local verbose= while getopts v flag; do case "$flag" in v) verbose=1 ;; esac done shift $(( $OPTIND - 1 )) local P=$1 if [ "$verbose" ]; then awk -v P=$P ' BEGIN { printf "\t" } NR > 1 && $0 { $0 = "\t" $0 } buf = buf $0 "\n" { } END { $0 = buf if (P < 3) S = sprintf("%" 7-2*(P+1) "s", "") gsub(/S/, S) gsub(/B/, P < 3 ? "\\" : "") gsub(/\\\t/, "\t") sub(/\n$/, "") print } ' <<-EOFPREAMBLE printf(" SB-+= %05d %d.%d %s\n", \ this->pid$P, this->uid$P, this->gid$P, this->args$P); EOFPREAMBLE else cat <<-EOFPREAMBLE printf("%s", this->args$P); EOFPREAMBLE fi } ############################################################ MAIN # If we're running as root, no need for sudo(8) [ "$( id -u )" != 0 ] && type sudo > /dev/null 2>&1 && SUDO=sudo # # Process command-line options # while getopts 1B:deE:fFg:j:k:K:lmnN:o:O:p:PqQr:Rt:T:u:vVwxX:yz: flag; do case "$flag" in 1) ONELINE=1 PSTREE= ;; B) MAX_ARGS="$OPTARG" ;; d) DEBUG=1 ;; e) EXIT_AFTER_COMPILE=1 ;; E) CUSTOM_DETAILS=1 EVENT_DETAILS="${EVENT_DETAILS%;}" [ "$EVENT_DETAILS" ] && EVENT_DETAILS="$EVENT_DETAILS; printf(\" \"); " # END-QUOTE # Read event code from stdin if `-' is argument [ "$OPTARG" = "-" ] && OPTARG=$( cat ) EVENT_DETAILS="$EVENT_DETAILS$OPTARG" ;; f) PROBE_TYPE=function ;; F) PROBE_COALESCE=1 ;; g) GROUP="$OPTARG" ;; j) JID="$OPTARG" ;; k) EXECNAME="$EXECNAME${EXECNAME:+ }$OPTARG" case "$OPTARG" in \**\*) name="${OPTARG%\*}" predicate="strstr(execname, \"${name#\*}\") != NULL" ;; \**) name="${OPTARG#\*}" predicate="strstr(execname, \"$name\") == (execname +" predicate="$predicate strlen(execname) - ${#name})" ;; *\*) predicate="strstr(execname, \"${OPTARG%\*}\") == execname" ;; *) predicate="execname == \"$OPTARG\"" esac EVENT_TEST="$predicate${EVENT_TEST:+ || ($EVENT_TEST)}" ;; K) MAX_DEPTH="$OPTARG" ;; l) LIST=1 ;; m) PROBE_TYPE=module ;; n) PROBE_TYPE=name ;; N) COUNT="$OPTARG" ;; o) OUTPUT="$OPTARG" ;; O) OUTPUT_CMD="$OPTARG" ;; p) PID="$OPTARG" ;; P) PROBE_TYPE=provider ;; q) QUIET=1 ;; Q) LIST_PROFILES=1 ;; r) FILTER="$OPTARG" ;; R) PSTREE=1 ;; t) CUSTOM_TEST="${CUSTOM_TEST:+($CUSTOM_TEST) && }$OPTARG" ;; T) TIMEOUT="$OPTARG" ;; u) USER="$OPTARG" ;; v) VERBOSE=1 ;; V) vers="${VERSION#\$*[:\$]}" vers="${vers% \$}" printf "%s: %s\n" "$pgm" "${vers# }" exit ;; w) DESTRUCTIVE_ACTIONS=1 ;; x) TRACE=1 ;; X) USE_PROFILE=1 PROFILE="$OPTARG" ;; y) CONSOLE=1 CONSOLE_FORCE=1 ;; z) EXECREGEX="$OPTARG" ;; *) usage # NOTREACHED esac done shift $(( $OPTIND - 1 )) # # List probes if `-l' was given # [ "$LIST" ] && list_probes -f "$FILTER" ${QUIET:+-q} -t "$PROBE_TYPE" -- "$@" # NOTREACHED # # List profiles if `-Q' was given # [ "$LIST_PROFILES" ] && list_profiles ${ONELINE:+-1} -f "$FILTER" ${QUIET:+-q} # NOTREACHED # # Validate number of arguments # if [ ! "$PROFILE" ]; then # If not given `-X profile' then a probe argument is required [ $# -gt 0 ] || usage # NOTREACHED fi # # Validate `-N count' option argument # case "$COUNT" in "") usage "-N option requires a number argument" ;; # NOTREACHED *[!0-9]*) usage "-N argument must be a number" ;; # NOTREACHED esac # # Validate `-B num' option argument # case "$MAX_ARGS" in "") usage "-B option requires a number argument" ;; # NOTREACHED *[!0-9]*) usage "-B argument must be a number" ;; # NOTREACHED esac # # Validate `-K num' option argument # case "$MAX_DEPTH" in "") usage "-K option requires a number argument" ;; # NOTREACHED *[!0-9]*) usage "-K argument must be a number" ;; # NOTREACHED esac # # Validate `-j jail' option argument # case "$JID" in "") : fall through ;; *[!0-9]*) JID=$( jls -j "$JID" jid ) || exit ;; esac # # Validate `-u user' option argument # case "$USER" in "") : fall through ;; *[![:alnum:]_-]*) RUID="$USER" ;; *[!0-9]*) RUID=$( id -u "$USER" 2> /dev/null ) || die "No such user: $USER" ;; *) RUID=$USER esac # # Validate `-g group' option argument # case "$GROUP" in "") : fall-through ;; *[![:alnum:]_-]*) RGID="$GROUP" ;; *[!0-9]*) RGID=$( getent group | awk -F: -v group="$GROUP" ' $1 == group { print $3; exit found=1 } END { exit !found } ' ) || die "No such group: $GROUP" ;; *) RGID=$GROUP esac # # Expand probe argument into probe(s) # case "$1" in -*) : Assume dtrace options such as "-c cmd" or "-p pid" ;; # No probe(s) given *) PROBE_ARG="$1" shift esac if [ "$PROBE_ARG" ]; then oldIFS="$IFS" IFS="$IFS," for arg in $PROBE_ARG; do arg=$( expand_probe -t "$PROBE_TYPE" -- "$arg" ) PROBE="$PROBE${PROBE:+, }$arg" done IFS="$oldIFS" fi # # Developer switch # [ "$DEBUG" -a "$EXIT_AFTER_COMPILE" -a "$VERBOSE" ] && DEVELOPER=1 DEBUG= # # Set default event details if `-E code' was not given # [ "$CUSTOM_DETAILS" ] || EVENT_DETAILS=$( pproc_dump 0 ) # # Load profile if given `-X profile' # [ "$USE_PROFILE" ] && load_profile "$PROFILE" [ "$PROBE" ] || die "PROBE not defined by profile and none given as argument" # # Show the user what's being watched # [ "$DEBUG$EXIT_AFTER_COMPILE" ] || info "Watching '$PROBE' ..." # # Header for watched probe entry # case "$PROBE" in *,*) : fall-through ;; *:execve:entry|execve:entry) ACTIONS=$( awk 'gsub(/\\\t/, "\t") || 1' <<-EOF $PROBE /* probe ID $ID */ {${TRACE:+ \ printf("<$ID>");} \ this->caller_execname = execname; } EOF ) PROBE="${PROBE%entry}return" ID=$(( $ID + 1 )) EVENT_TEST="execname != this->caller_execname${EVENT_TEST:+ && ($EVENT_TEST)}" EVENT_TAG='printf("%d.%d %s[%d]: ", this->uid1, this->gid1, this->caller_execname, this->pid1);' ;; esac # # Jail clause/predicate # if [ "$JID" ]; then prison_id="curthread->td_proc->p_ucred->cr_prison->pr_id" EVENT_TEST="$prison_id == $JID${EVENT_TEST:+ && ($EVENT_TEST)}" fi # # Custom test clause/predicate # if [ "$CUSTOM_TEST" ]; then case "$EVENT_TEST" in "") EVENT_TEST="$CUSTOM_TEST" ;; *) EVENT_TEST="$EVENT_TEST && ($CUSTOM_TEST)" esac fi # # Make sure dynamic code has trailing semi-colons if non-NULL # EVENT_TAG="${EVENT_TAG%;}${EVENT_TAG:+;}" EVENT_DETAILS="${EVENT_DETAILS%;}${EVENT_DETAILS:+;}" # # DTrace script # # If `-d' is given, script is sent to stdout for debugging # If `-c count", `-g group', `-r regex', or `-u user' is given, run script with # dtrace and send output to awk(1) post-processor (making sure to preserve the # exit code returned by dtrace invocation). Otherwise, simply run script with # dtrace and then exit. # exec 9<"); } /* * Examine process, parent process, and grandparent process details */ /******************* CURPROC *******************/ $( pproc -P0 ) /******************* PPARENT *******************/ $( if [ "$PSTREE" ]; then pproc -P1; else echo -n \ "this->proc = this->proc ? this->proc->p_pptr : NULL; this->pid1 = this->proc ? this->proc->p_pid : -1; this->uid1 = this->proc ? this->proc->p_ucred->cr_uid : -1; this->gid1 = this->proc ? this->proc->p_ucred->cr_rgid : -1; this->jid1 = this->proc ? this->proc->p_ucred->cr_prison->pr_id : -1;" fi ) /******************* GPARENT *******************/ $( [ "$PSTREE" ] && pproc -P2 ) /******************* APARENT *******************/ $( [ "$PSTREE" ] && pproc -P3 ) } EOF PSARGS_ACTION=$( cat <&9 ) [ "$OUTPUT" -a ! "$CONSOLE_FORCE" ] && CONSOLE= { if [ "$DEBUG" ]; then # Send script to stdout cat exit fi if [ "$CUSTOM_TEST$EXECNAME$JID$OUTPUT$TIMEOUT$TRACE$VERBOSE" -a \ ! "$QUIET" ] then msg=Setting [ "$CUSTOM_TEST" ] && msg="$msg test: $CUSTOM_TEST" [ "$EXECNAME" ] && msg="$msg execname: $EXECNAME" [ "$JID" ] && msg="$msg jid: $JID" [ "$OUTPUT" ] && msg="$msg output: $OUTPUT" [ "$TIMEOUT" ] && msg="$msg timeout: $TIMEOUT" [ "$TRACE" ] && msg="$msg trace: $TRACE" [ "$VERBOSE" ] && msg="$msg verbose: $VERBOSE" info "$msg" fi exec 3>&1 console_stdout=3 # # Developer debugging aide # if [ "$DEVELOPER" ]; then # # Run, capture the error line, and focus it # # Example error text to capture line number from: # dtrace: failed to compile script /dev/stdin: line 669: ... # errline= stdin_buf=$( cat ) stderr_buf=$( echo "$stdin_buf" | dtrace_cmd -t -es /dev/stdin "$@" 2>&1 > /dev/null ) status=$? if [ "$stderr_buf" ]; then errline=$( echo "$stderr_buf" | awk ' BEGIN { ti = "\033[31m" te = "\033[39m" } { line = $0 } sub(/.*: line /, "") && sub(/:.*/, "") { print # to errline sub("line " $0, ti "&" te, line) } { print line > "/dev/stderr" } ' 2>&3 ) fi if [ "$errline" ]; then echo "$stdin_buf" | awk -v line="${errline%%[^0-9]*}" ' BEGIN { start = line < 10 ? 1 : line - 10 end = line + 10 slen = length(sprintf("%u", start)) elen = length(sprintf("%u", end)) N = elen > slen ? elen : slen ti[line] = "\033[31m" te[line] = "\033[39m" fmt = "%s%*u %s%s\n" } NR < start { next } NR == start, NR == end { printf(fmt, ti[NR], N, NR, $0, te[NR]) } NR > end { exit } ' # END-QUOTE fi exit $status fi if [ $COUNT -eq 0 -a ! "$EXECREGEX$FILTER$GROUP$OUTPUT_CMD$PID$USER" ] then case "$OUTPUT" in -) output_path=/dev/stdout ;; *) output_path="$OUTPUT" esac # Run script without pipe to awk post-processor dtrace_cmd -t \ ${DESTRUCTIVE_ACTIONS:+-w} \ ${EXIT_AFTER_COMPILE:+-e} \ ${OUTPUT:+-o "$output_path"} \ -s /dev/stdin \ "$@" exit fi # Prevent backslashes from being lost FILTER=$( echo "$FILTER" | awk 'gsub(/\\/,"&&")||1' ) EXECREGEX=$( echo "$EXECREGEX" | awk 'gsub(/\\/,"&&")||1' ) if [ ! "$QUIET" ]; then msg=Filtering [ "$EXECREGEX" ] && msg="$msg execregex: $EXECREGEX" [ "$FILTER" ] && msg="$msg filter: $FILTER" [ "$GROUP" ] && msg="$msg group: $GROUP" [ "$OUTPUT_CMD" ] && msg="$msg cmd: $OUTPUT_CMD" [ "$PID" ] && msg="$msg pid: $PID" [ "$USER" ] && msg="$msg user: $USER" [ $COUNT -gt 0 ] && msg="$msg count: $COUNT" info "$msg" fi # # Send script output to post-processor for filtering # status=$( exec 4>&1 to_status=4 ( exec 5>&1; to_dtrace_stderr_filter=5; ( trap 'echo $? >&$to_status' EXIT eval $SUDO ${TIMEOUT:+timeout \"\$TIMEOUT\"} dtrace \ ${EXIT_AFTER_COMPILE:+-e} \ ${DESTRUCTIVE_ACTIONS:+-w} \ -s /dev/stdin \ \"\$@\" \ 2>&$to_dtrace_stderr_filter \ ${QUIET:+2> /dev/null} ) | $SUDO awk \ -v cmd="$OUTPUT_CMD" \ -v console="$CONSOLE" \ -v count=$COUNT \ -v execregex="$EXECREGEX" \ -v filter="$FILTER" \ -v gid="$RGID" \ -v output="$OUTPUT" \ -v pid="$PID" \ -v pstree=$PSTREE \ -v quiet=$QUIET \ -v tty=$( ps -o tty= -p $$ ) \ -v uid="$RUID" \ ' # Start awk(1) post-processor ############################################ BEGIN BEGIN { true = 1 ansi = "(\\033\\[[[:digit:];]+m)?" num = year = day = "[[:digit:]]+" month = "[[:alpha:]]+" date = year " " month " +" day time = "[012][0-9]:[0-5][0-9]:[0-5][0-9]" date_time = ansi date " +" time ansi name1 = "[^\\[]*" name2 = "[^\\n]*" if (output == "-") output = "/dev/stdout" # # Field definitions # nexecmatches = 2 execstart[1] = sprintf( \ "^(%s) (%s)\\.(%s) (%s)\\[(%s)\\]: ", date_time, num, num, name1, num) execstart[2] = sprintf( \ "\\n +\\\\?-\\+= (%s) (%s)\\.(%s) ", num, num, num) npidmatches = 2 pidstart[1] = sprintf("^(%s) (%s)\\.(%s) (%s)\\[", date_time, num, num, name1) pidstart[2] = "\\n +\\\\?-\\+= " pidpreen[2] = "^0*" piddeflt[2] = "0" ngidmatches = 2 gidstart[1] = sprintf("^(%s) (%s)\\.", date_time, num) gidstart[2] = sprintf("\\n +\\\\?-\\+= (%s) (%s)\\.", ansi num ansi, num) nuidmatches = 2 uidstart[1] = sprintf("^(%s) ", date_time) uidstart[2] = sprintf("\\n +\\\\?-\\+= (%s) ", ansi num ansi) } ############################################ FUNCTIONS function strip(s) { gsub(/\033\[[0-9;]*m/, "", s); return s } function esc(str) { gsub(/'\''/, "&\\\\&&", str); return str } function arg(str) { return "'\''" esc(str) "'\''" } function env(var, str) { return var "=" arg(str) " " } function ans(seq) { return console ? "\033[" seq "m" : "" } function runcmd() { return system(sprintf("%s/bin/sh -c %s", env("TAG", strip(tag)) \ env("DETAILS", strip(details)), arg(cmd))) } function filter_block() { if (length(lines) < 1) return 0 block_match = 0 newstr = "" start = 1 if (match(lines, "^(" date_time ") ")) { newstr = newstr substr(lines, 1, RSTART + RLENGTH - 1) start = RSTART + RLENGTH } replace = ans("31;1") "&" ans("39;22") workstr = substr(lines, start) if (gsub(filter, replace, workstr)) block_match = 1 lines = newstr workstr return block_match } function filter_field(startre, fieldre, matchre, isword, preenre, defaultstr) { if (length(lines) < 1) return 0 field_match = 0 newstr = "" start = 1 while ((workstr = substr(lines, start)) && (workstr ~ (startre fieldre))) { match(workstr, startre) start += end = RSTART + RLENGTH - 1 newstr = newstr substr(workstr, 1, end) workstr = substr(workstr, end + 1) match(workstr, fieldre) start += end = RSTART + RLENGTH - 1 field = matchstr = substr(workstr, 1, end) sub(preenre, "", matchstr) if (!matchstr) matchstr = defaultstr if (isword) { if (match(matchstr, matchre) && RSTART == 1 && RLENGTH == length(matchstr)) { field_match = 1 field = ans(7) field ans(27) } } else { replace = ans(7) "&" ans(27) if (gsub(matchre, replace, matchstr)) { field_match = 1 field = matchstr } } newstr = newstr field } lines = newstr workstr return field_match } function dump() { lines = block block = "" found = 0 if (execregex != "") { for (n = 1; n <= nexecmatches; n++) if (filter_field(execstart[n], name2, execregex)) found = 1 if (!found) return } if (pid != "") { for (n = 1; n <= npidmatches; n++) if (filter_field(pidstart[n], num, pid, true, pidpreen[n], piddeflt[n])) found = 1 if (!found) return } if (gid != "") { for (n = 1; n <= ngidmatches; n++) if (filter_field(gidstart[n], num, gid, true)) found = 1 if (!found) return } if (uid != "") { for (n = 1; n <= nuidmatches; n++) if (filter_field(uidstart[n], num, uid, true)) found = 1 if (!found) return } if (filter != "" && !filter_block()) return if (lines) { stdout = 1 if (output) { stdout = 0 if (!console) lines = strip(lines) print lines > output } else if (cmd) { if (!quiet) print lines tag = details = lines sub(/: .*/, "", tag) sub(/.*: /, "", details) if (!console) tag = strip(tag) runcmd() } else print lines } fflush() ++matches } ############################################ MAIN { block = (block ? block "\n" : block) $0 } !pstree { dump() } $0 ~ sprintf("^%6s\\\\-\\+= %s ", "", num) { dump() } count && matches >= count { exit } ############################################ END END { dump() system(sprintf("pkill -t %s dtrace %s", tty, quiet ? "2> /dev/null" : "")) } ' >&$console_stdout ) | dtrace_stderr_filter >&2 ) # status exit $status } < * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 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 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 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) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * 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. * * $TITLE dtrace(1) script to log process(es) triggering $PROBE $ - * \$FreeBSD$ */ $( echo "$DTRACE_PRAGMA" | awk ' !/^[[:space:]]*(#|$)/, sub(/^[[:space:]]*/, "#pragma D ")||1 ' ) int console; dtrace:::BEGIN { console = ${CONSOLE:-0} } /* probe ID 1 */ /*********************************************************/ ${PSARGS:+$PSARGS_ACTION} ${ACTIONS:+ /*********************************************************/ $ACTIONS } /*********************************************************/ $PROBE${EVENT_TEST:+ / $EVENT_TEST /} /* probe ID $ID */ {${TRACE:+ printf("<$ID>"); } /***********************************************/ printf("%s%Y%s ", console ? "\033[32m" : "", walltimestamp, console ? "\033[39m" : ""); /****************** EVENT_TAG ******************/ ${EVENT_TAG#[[:space:]]} ${PROBE_COALESCE:+ /**************** PROBE_COALESCE ***************/ printf("%s%s:%s:%s:%s ", probename == "entry" ? "-> " : probename == "return" ? "<- " : probename == "start" ? "-> " : probename == "done" ? "<- " : " | ", probeprov, probemod, probefunc, probename); } /**************** EVENT_DETAILS ****************/ ${EVENT_DETAILS#[[:space:]]} /***********************************************/ printf("\\n"); ${PSTREE:+ /* * Print process, parent, grandparent, and ancestor details */ $( pproc_dump -v 3 pproc_dump -v 2 pproc_dump -v 1 pproc_dump -v 0 )} } EOF # NOTREACHED ################################################################################ # END ################################################################################ diff --git a/include/rpc/rpcb_prot.x b/include/rpc/rpcb_prot.x index a34bcc12502a..b5de5c6d865d 100644 --- a/include/rpc/rpcb_prot.x +++ b/include/rpc/rpcb_prot.x @@ -1,553 +1,551 @@ %/*- -% * $FreeBSD$ -% * % * Copyright (c) 2009, Sun Microsystems, Inc. % * All rights reserved. % * % * Redistribution and use in source and binary forms, with or without % * modification, are permitted provided that the following conditions are met: % * - Redistributions of source code must retain the above copyright notice, % * this list of conditions and the following disclaimer. % * - 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. % * - Neither the name of Sun Microsystems, Inc. nor the names of its % * contributors may be used to endorse or promote products derived % * from this software without specific prior written permission. % * % * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 THE COPYRIGHT HOLDER 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) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN % * CONTRACT, STRICT 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. % */ %/* % * Copyright (c) 1988 by Sun Microsystems, Inc. % */ %/* from rpcb_prot.x */ #ifdef RPC_HDR % %/* #pragma ident "@(#)rpcb_prot.x 1.5 94/04/29 SMI" */ % %#ifndef _KERNEL % #endif /* * rpcb_prot.x * rpcbind protocol, versions 3 and 4, in RPC Language */ % %/* % * The following procedures are supported by the protocol in version 3: % * % * RPCBPROC_NULL() returns () % * takes nothing, returns nothing % * % * RPCBPROC_SET(rpcb) returns (bool_t) % * TRUE is success, FALSE is failure. Registers the tuple % * [prog, vers, address, owner, netid]. % * Finds out owner and netid information on its own. % * % * RPCBPROC_UNSET(rpcb) returns (bool_t) % * TRUE is success, FALSE is failure. Un-registers tuple % * [prog, vers, netid]. addresses is ignored. % * If netid is NULL, unregister all. % * % * RPCBPROC_GETADDR(rpcb) returns (string). % * 0 is failure. Otherwise returns the universal address where the % * triple [prog, vers, netid] is registered. Ignore address and owner. % * % * RPCBPROC_DUMP() RETURNS (rpcblist_ptr) % * used to dump the entire rpcbind maps % * % * RPCBPROC_CALLIT(rpcb_rmtcallargs) % * RETURNS (rpcb_rmtcallres); % * Calls the procedure on the remote machine. If it is not registered, % * this procedure is quiet; i.e. it does not return error information!!! % * This routine only passes null authentication parameters. % * It has no interface to xdr routines for RPCBPROC_CALLIT. % * % * RPCBPROC_GETTIME() returns (int). % * Gets the remote machines time % * % * RPCBPROC_UADDR2TADDR(strint) RETURNS (struct netbuf) % * Returns the netbuf address from universal address. % * % * RPCBPROC_TADDR2UADDR(struct netbuf) RETURNS (string) % * Returns the universal address from netbuf address. % * % * END OF RPCBIND VERSION 3 PROCEDURES % */ %/* % * Except for RPCBPROC_CALLIT, the procedures above are carried over to % * rpcbind version 4. Those below are added or modified for version 4. % * NOTE: RPCBPROC_BCAST HAS THE SAME FUNCTIONALITY AND PROCEDURE NUMBER % * AS RPCBPROC_CALLIT. % * % * RPCBPROC_BCAST(rpcb_rmtcallargs) % * RETURNS (rpcb_rmtcallres); % * Calls the procedure on the remote machine. If it is not registered, % * this procedure IS quiet; i.e. it DOES NOT return error information!!! % * This routine should be used for broadcasting and nothing else. % * % * RPCBPROC_GETVERSADDR(rpcb) returns (string). % * 0 is failure. Otherwise returns the universal address where the % * triple [prog, vers, netid] is registered. Ignore address and owner. % * Same as RPCBPROC_GETADDR except that if the given version number % * is not available, the address is not returned. % * % * RPCBPROC_INDIRECT(rpcb_rmtcallargs) % * RETURNS (rpcb_rmtcallres); % * Calls the procedure on the remote machine. If it is not registered, % * this procedure is NOT quiet; i.e. it DOES return error information!!! % * as any normal application would expect. % * % * RPCBPROC_GETADDRLIST(rpcb) returns (rpcb_entry_list_ptr). % * Same as RPCBPROC_GETADDR except that it returns a list of all the % * addresses registered for the combination (prog, vers) (for all % * transports). % * % * RPCBPROC_GETSTAT(void) returns (rpcb_stat_byvers) % * Returns the statistics about the kind of requests received by rpcbind. % */ % %/* % * A mapping of (program, version, network ID) to address % */ struct rpcb { rpcprog_t r_prog; /* program number */ rpcvers_t r_vers; /* version number */ string r_netid<>; /* network id */ string r_addr<>; /* universal address */ string r_owner<>; /* owner of this service */ }; #ifdef RPC_HDR % %typedef rpcb RPCB; % #endif % %/* % * A list of mappings % * % * Below are two definitions for the rpcblist structure. This is done because % * xdr_rpcblist() is specified to take a struct rpcblist **, rather than a % * struct rpcblist * that rpcgen would produce. One version of the rpcblist % * structure (actually called rp__list) is used with rpcgen, and the other is % * defined only in the header file for compatibility with the specified % * interface. % */ struct rp__list { rpcb rpcb_map; struct rp__list *rpcb_next; }; typedef rp__list *rpcblist_ptr; /* results of RPCBPROC_DUMP */ #ifdef RPC_HDR % %typedef struct rp__list rpcblist; %typedef struct rp__list RPCBLIST; % %#ifndef __cplusplus %struct rpcblist { % RPCB rpcb_map; % struct rpcblist *rpcb_next; %}; %#endif % %#ifdef __cplusplus %extern "C" { %#endif %extern bool_t xdr_rpcblist(XDR *, rpcblist**); %#ifdef __cplusplus %} %#endif % #endif % %/* % * Arguments of remote calls % */ struct rpcb_rmtcallargs { rpcprog_t prog; /* program number */ rpcvers_t vers; /* version number */ rpcproc_t proc; /* procedure number */ opaque args<>; /* argument */ }; #ifdef RPC_HDR % %/* % * Client-side only representation of rpcb_rmtcallargs structure. % * % * The routine that XDRs the rpcb_rmtcallargs structure must deal with the % * opaque arguments in the "args" structure. xdr_rpcb_rmtcallargs() needs to % * be passed the XDR routine that knows the args' structure. This routine % * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since % * the application being called already knows the args structure. So we use a % * different "XDR" structure on the client side, r_rpcb_rmtcallargs, which % * includes the args' XDR routine. % */ %struct r_rpcb_rmtcallargs { % rpcprog_t prog; % rpcvers_t vers; % rpcproc_t proc; % struct { % u_int args_len; % char *args_val; % } args; % xdrproc_t xdr_args; /* encodes args */ %}; % #endif /* def RPC_HDR */ % %/* % * Results of the remote call % */ struct rpcb_rmtcallres { string addr<>; /* remote universal address */ opaque results<>; /* result */ }; #ifdef RPC_HDR % %/* % * Client-side only representation of rpcb_rmtcallres structure. % */ %struct r_rpcb_rmtcallres { % char *addr; % struct { % u_int32_t results_len; % char *results_val; % } results; % xdrproc_t xdr_res; /* decodes results */ %}; #endif /* RPC_HDR */ % %/* % * rpcb_entry contains a merged address of a service on a particular % * transport, plus associated netconfig information. A list of rpcb_entrys % * is returned by RPCBPROC_GETADDRLIST. See netconfig.h for values used % * in r_nc_* fields. % */ struct rpcb_entry { string r_maddr<>; /* merged address of service */ string r_nc_netid<>; /* netid field */ unsigned int r_nc_semantics; /* semantics of transport */ string r_nc_protofmly<>; /* protocol family */ string r_nc_proto<>; /* protocol name */ }; % %/* % * A list of addresses supported by a service. % */ struct rpcb_entry_list { rpcb_entry rpcb_entry_map; struct rpcb_entry_list *rpcb_entry_next; }; typedef rpcb_entry_list *rpcb_entry_list_ptr; % %/* % * rpcbind statistics % */ % const rpcb_highproc_2 = RPCBPROC_CALLIT; const rpcb_highproc_3 = RPCBPROC_TADDR2UADDR; const rpcb_highproc_4 = RPCBPROC_GETSTAT; const RPCBSTAT_HIGHPROC = 13; /* # of procs in rpcbind V4 plus one */ const RPCBVERS_STAT = 3; /* provide only for rpcbind V2, V3 and V4 */ const RPCBVERS_4_STAT = 2; const RPCBVERS_3_STAT = 1; const RPCBVERS_2_STAT = 0; % %/* Link list of all the stats about getport and getaddr */ struct rpcbs_addrlist { rpcprog_t prog; rpcvers_t vers; int success; int failure; string netid<>; struct rpcbs_addrlist *next; }; % %/* Link list of all the stats about rmtcall */ struct rpcbs_rmtcalllist { rpcprog_t prog; rpcvers_t vers; rpcproc_t proc; int success; int failure; int indirect; /* whether callit or indirect */ string netid<>; struct rpcbs_rmtcalllist *next; }; typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; typedef rpcbs_addrlist *rpcbs_addrlist_ptr; typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; struct rpcb_stat { rpcbs_proc info; int setinfo; int unsetinfo; rpcbs_addrlist_ptr addrinfo; rpcbs_rmtcalllist_ptr rmtinfo; }; % %/* % * One rpcb_stat structure is returned for each version of rpcbind % * being monitored. % */ typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; #ifdef RPC_HDR % %/* % * We don't define netbuf in RPCL, since it would contain structure member % * names that would conflict with the definition of struct netbuf in % * . Instead we merely declare the XDR routine xdr_netbuf() here, % * and implement it ourselves in rpc/rpcb_prot.c. % */ %#ifdef __cplusplus %extern "C" bool_t xdr_netbuf(XDR *, struct netbuf *); % %#else /* __STDC__ */ %extern bool_t xdr_netbuf(XDR *, struct netbuf *); % %#endif #endif /* def RPC_HDR */ /* * rpcbind procedures */ program RPCBPROG { version RPCBVERS { bool RPCBPROC_SET(rpcb) = 1; bool RPCBPROC_UNSET(rpcb) = 2; string RPCBPROC_GETADDR(rpcb) = 3; rpcblist_ptr RPCBPROC_DUMP(void) = 4; rpcb_rmtcallres RPCBPROC_CALLIT(rpcb_rmtcallargs) = 5; unsigned int RPCBPROC_GETTIME(void) = 6; struct netbuf RPCBPROC_UADDR2TADDR(string) = 7; string RPCBPROC_TADDR2UADDR(struct netbuf) = 8; } = 3; version RPCBVERS4 { bool RPCBPROC_SET(rpcb) = 1; bool RPCBPROC_UNSET(rpcb) = 2; string RPCBPROC_GETADDR(rpcb) = 3; rpcblist_ptr RPCBPROC_DUMP(void) = 4; /* * NOTE: RPCBPROC_BCAST has the same functionality as CALLIT; * the new name is intended to indicate that this * procedure should be used for broadcast RPC, and * RPCBPROC_INDIRECT should be used for indirect calls. */ rpcb_rmtcallres RPCBPROC_BCAST(rpcb_rmtcallargs) = RPCBPROC_CALLIT; unsigned int RPCBPROC_GETTIME(void) = 6; struct netbuf RPCBPROC_UADDR2TADDR(string) = 7; string RPCBPROC_TADDR2UADDR(struct netbuf) = 8; string RPCBPROC_GETVERSADDR(rpcb) = 9; rpcb_rmtcallres RPCBPROC_INDIRECT(rpcb_rmtcallargs) = 10; rpcb_entry_list_ptr RPCBPROC_GETADDRLIST(rpcb) = 11; rpcb_stat_byvers RPCBPROC_GETSTAT(void) = 12; } = 4; } = 100000; #ifdef RPC_HDR % %#define RPCBVERS_3 RPCBVERS %#define RPCBVERS_4 RPCBVERS4 % %#define _PATH_RPCBINDSOCK "/var/run/rpcbind.sock" % %#else /* ndef _KERNEL */ %#ifdef __cplusplus %extern "C" { %#endif % %/* % * A mapping of (program, version, network ID) to address % */ %struct rpcb { % rpcprog_t r_prog; /* program number */ % rpcvers_t r_vers; /* version number */ % char *r_netid; /* network id */ % char *r_addr; /* universal address */ % char *r_owner; /* owner of the mapping */ %}; %typedef struct rpcb RPCB; % %/* % * A list of mappings % */ %struct rpcblist { % RPCB rpcb_map; % struct rpcblist *rpcb_next; %}; %typedef struct rpcblist RPCBLIST; %typedef struct rpcblist *rpcblist_ptr; % %/* % * Remote calls arguments % */ %struct rpcb_rmtcallargs { % rpcprog_t prog; /* program number */ % rpcvers_t vers; /* version number */ % rpcproc_t proc; /* procedure number */ % u_int32_t arglen; /* arg len */ % caddr_t args_ptr; /* argument */ % xdrproc_t xdr_args; /* XDR routine for argument */ %}; %typedef struct rpcb_rmtcallargs rpcb_rmtcallargs; % %/* % * Remote calls results % */ %struct rpcb_rmtcallres { % char *addr_ptr; /* remote universal address */ % u_int32_t resultslen; /* results length */ % caddr_t results_ptr; /* results */ % xdrproc_t xdr_results; /* XDR routine for result */ %}; %typedef struct rpcb_rmtcallres rpcb_rmtcallres; % %struct rpcb_entry { % char *r_maddr; % char *r_nc_netid; % unsigned int r_nc_semantics; % char *r_nc_protofmly; % char *r_nc_proto; %}; %typedef struct rpcb_entry rpcb_entry; % %/* % * A list of addresses supported by a service. % */ % %struct rpcb_entry_list { % rpcb_entry rpcb_entry_map; % struct rpcb_entry_list *rpcb_entry_next; %}; %typedef struct rpcb_entry_list rpcb_entry_list; % %typedef rpcb_entry_list *rpcb_entry_list_ptr; % %/* % * rpcbind statistics % */ % %#define rpcb_highproc_2 RPCBPROC_CALLIT %#define rpcb_highproc_3 RPCBPROC_TADDR2UADDR %#define rpcb_highproc_4 RPCBPROC_GETSTAT %#define RPCBSTAT_HIGHPROC 13 %#define RPCBVERS_STAT 3 %#define RPCBVERS_4_STAT 2 %#define RPCBVERS_3_STAT 1 %#define RPCBVERS_2_STAT 0 % %/* Link list of all the stats about getport and getaddr */ % %struct rpcbs_addrlist { % rpcprog_t prog; % rpcvers_t vers; % int success; % int failure; % char *netid; % struct rpcbs_addrlist *next; %}; %typedef struct rpcbs_addrlist rpcbs_addrlist; % %/* Link list of all the stats about rmtcall */ % %struct rpcbs_rmtcalllist { % rpcprog_t prog; % rpcvers_t vers; % rpcproc_t proc; % int success; % int failure; % int indirect; % char *netid; % struct rpcbs_rmtcalllist *next; %}; %typedef struct rpcbs_rmtcalllist rpcbs_rmtcalllist; % %typedef int rpcbs_proc[RPCBSTAT_HIGHPROC]; % %typedef rpcbs_addrlist *rpcbs_addrlist_ptr; % %typedef rpcbs_rmtcalllist *rpcbs_rmtcalllist_ptr; % %struct rpcb_stat { % rpcbs_proc info; % int setinfo; % int unsetinfo; % rpcbs_addrlist_ptr addrinfo; % rpcbs_rmtcalllist_ptr rmtinfo; %}; %typedef struct rpcb_stat rpcb_stat; % %/* % * One rpcb_stat structure is returned for each version of rpcbind % * being monitored. % */ % %typedef rpcb_stat rpcb_stat_byvers[RPCBVERS_STAT]; % %#ifdef __cplusplus %} %#endif % %#endif /* ndef _KERNEL */ #endif /* RPC_HDR */ diff --git a/lib/ofed/libirdma/Makefile b/lib/ofed/libirdma/Makefile index 368bd536c587..349590672b44 100644 --- a/lib/ofed/libirdma/Makefile +++ b/lib/ofed/libirdma/Makefile @@ -1,22 +1,20 @@ -# $FreeBSD: releng/12.1/lib/ofed/libirdma/Makefile 336568 2018-07-20 23:49:57Z kib $ - _spath= ${SRCTOP}/contrib/ofed/libirdma _ipath= ${SRCTOP}/contrib/ofed/include lin_inc=/usr/src/sys/compat/linuxkpi/common/include .PATH: ${_spath} SHLIBDIR?= /lib LIB= irdma SHLIB_MAJOR= 1 MK_PROFILE= no SRCS= \ irdma_umain.c \ irdma_uverbs.c \ irdma_uk.c \ LIBADD= ibverbs pthread CFLAGS+= -I${_spath} -I${SRCTOP}/contrib/ofed/libibverbs VERSION_MAP= ${_spath}/libirdma.map .include diff --git a/share/man/man4/pcf8591.4 b/share/man/man4/pcf8591.4 index 6133d6cfa0d8..9acaf6502b38 100644 --- a/share/man/man4/pcf8591.4 +++ b/share/man/man4/pcf8591.4 @@ -1,122 +1,120 @@ .\" .\" SPDX-License-Identifier: BSD-2-Clause .\" .\" Copyright (c) 2020 Andriy Gapon .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 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 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 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) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" 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: head/share/man/man4/cp2112.4 364144 2020-08-12 09:42:05Z avg $ -.\" .Dd November 6, 2021 .Dt PCF8591 4 .Os .Sh NAME .Nm pcf8591 .Nd driver for the PCF8591 8-bit A/D and D/A converter .Sh SYNOPSIS To compile this driver into the kernel, place the following lines in your kernel configuration file: .Bd -ragged -offset indent .Cd "device pcf8591" .Cd "device iicbus" .Ed .Pp Alternatively, to load the driver as a module at boot time, place the following line in .Xr loader.conf 5 : .Bd -literal -offset indent pcf8591_load="YES" .Ed .Sh DESCRIPTION The .Nm driver supports reading four inputs and setting one output over I2C. The hardware supports configuring the input lines as: .Bl -bullet .It four single-ended inputs .It three differential inputs (one input line is shared between all three inputs) .It two single-ended inputs and one differential input .It two differential inputs. .El .Pp The .Nm driver reports data via .Xr sysctl 8 entries in the device's node in the .Xr sysctl 8 tree: .Bl -tag -width inputs.%d .It Va inputs.%d The input level of the corresponding input in steps between 0 and 255. Absolute voltage depends on an actual reference voltage. .El .Pp On an .Xr FDT 4 based system the following properties must be set: .Bl -tag -width "compatible" .It Va compatible Must be set to "nxp,pcf8591". .It Va reg The I2C address of .Nm . It should be in the range from 0x40 to 0x4f (7-bit). .El .Pp The DTS part for a .Nm device usually looks like: .Bd -literal / { ... pcf8591adc { compatible = "nxp,pcf8591"; reg = <0x48>; }; }; .Ed .Sh SEE ALSO .Xr fdt 4 , .Xr iicbus 4 , .Xr sysctl 8 .Sh HISTORY The .Nm driver and this manual page was written by .An Andriy Gapon Aq Mt avg@FreeBSD.org . .Sh BUGS The .Nm driver does not support changing the input configuration. All input lines are configured as single-ended inputs. .Pp The .Nm driver does not support setting the output. It is always disabled (tri-state). diff --git a/share/vt/keymaps/colemak-dh.acc.kbd b/share/vt/keymaps/colemak-dh.acc.kbd index 82c5faa2c6a6..b3f1b7d5ba83 100644 --- a/share/vt/keymaps/colemak-dh.acc.kbd +++ b/share/vt/keymaps/colemak-dh.acc.kbd @@ -1,143 +1,141 @@ -# $FreeBSD $ -# # Colemak Mod-DH (rev. 2) layout for FreeBSD console # 2006-01-01 Shai Coleman (http://colemak.com/), # 2014-10-27 Steve P (http://colemakmods.github.io/mod-dh/). # Public domain. # alt # scan cntrl alt alt cntrl lock # code base shift cntrl shift alt shift cntrl shift state # ------------------------------------------------------------------ 000 nop nop nop nop nop nop nop nop O 001 esc esc esc esc esc esc debug debug O 002 '1' '!' nop nop '`' '`' nop nop O 003 '2' '@' nul nul '@' '@' nul nul O 004 '3' '#' nop nop '#' '#' nop nop O 005 '4' '$' 0xa4 0xa4 '4' '$' nop nop O 006 '5' '%' nop nop '5' '%' nop nop O 007 '6' '^' rs rs '^' '^' rs rs O 008 '7' '&' nop nop '[' '[' esc esc O 009 '8' '*' nop nop '8' '*' nop nop O 010 '9' '(' nop nop ']' ']' gs gs O 011 '0' ')' nop nop '{' '{' nop nop O 012 '-' '_' us us '|' '|' us us O 013 '=' '+' nop nop '}' '}' nop nop O 014 bs bs del del bs bs del del O 015 ht btab nop nop ht btab nop nop O 016 'q' 'Q' dc1 dc1 'q' 'Q' dc1 dc1 C 017 'w' 'W' etb etb 'w' 'W' etb etb C 018 'f' 'F' ack ack 'f' 'F' ack ack C 019 'p' 'P' dle dle 'p' 'P' dle dle C 020 'b' 'B' stx stx 'b' 'B' stx stx C 021 'j' 'J' nl nl 'j' 'J' nl nl C 022 'l' 'L' ff ff 'l' 'L' ff ff C 023 'u' 'U' nak nak 'u' 'U' nak nak C 024 'y' 'Y' em em 'y' 'Y' em em C 025 ';' ':' nop nop ';' ':' nop nop O 026 '[' '{' esc esc '[' '{' esc esc O 027 ']' '}' gs gs ']' '}' gs gs O 028 cr cr nl nl cr cr nl nl O 029 lctrl lctrl lctrl lctrl lctrl lctrl lctrl lctrl O 030 'a' 'A' soh soh 'a' 'A' soh soh C 031 'r' 'R' dc2 dc2 'r' 'R' dc2 dc2 C 032 's' 'S' dc3 dc3 's' 'S' dc3 dc3 C 033 't' 'T' dc4 dc4 't' 'T' dc4 dc4 C 034 'g' 'G' bel bel 'g' 'G' bel bel C 035 'k' 'K' vt vt 'k' 'K' vt vt C 036 'n' 'N' so so 'n' 'N' so so C 037 'e' 'E' enq enq 0x20ac 'E' enq enq C 038 'i' 'I' ht ht 'i' 'I' ht ht C 039 'o' 'O' si si 'o' 'O' si si C 040 ''' '"' nop nop 0xf5 0xd5 nop nop O 041 '`' '~' nop nop dtil '~' nop nop O 042 lshift lshift lshift lshift lshift lshift lshift lshift O 043 '\' '|' fs fs '~' '~' fs fs O 044 'z' 'Z' sub sub 0xe6 0xc6 sub sub C 045 'x' 'X' can can dcir '~' can can C 046 'c' 'C' etx etx 0xe7 0xc7 etx etx C 047 'd' 'D' eot eot 0xbd 0xbc syn syn C 048 'v' 'V' stx stx '~' '~' stx stx C 049 'm' 'M' vt vt drin '~' vt vt C 050 'h' 'H' cr cr '~' '~' cr cr C 051 ',' '<' nop nop dced '~' nop nop O 052 '.' '>' nop nop '~' '~' nop nop O 053 '/' '?' nop nop 0xbf '~' nop nop O 054 rshift rshift rshift rshift rshift rshift rshift rshift O 055 '*' '*' '*' '*' '*' '*' '*' '*' O 056 lalt lalt lalt lalt lalt lalt lalt lalt O 057 ' ' ' ' nul nul ' ' ' ' susp susp O 058 clock clock clock clock clock clock clock clock O 059 fkey01 fkey13 fkey25 fkey37 scr01 scr11 scr01 scr11 O 060 fkey02 fkey14 fkey26 fkey38 scr02 scr12 scr02 scr12 O 061 fkey03 fkey15 fkey27 fkey39 scr03 scr13 scr03 scr13 O 062 fkey04 fkey16 fkey28 fkey40 scr04 scr14 scr04 scr14 O 063 fkey05 fkey17 fkey29 fkey41 scr05 scr15 scr05 scr15 O 064 fkey06 fkey18 fkey30 fkey42 scr06 scr16 scr06 scr16 O 065 fkey07 fkey19 fkey31 fkey43 scr07 scr07 scr07 scr07 O 066 fkey08 fkey20 fkey32 fkey44 scr08 scr08 scr08 scr08 O 067 fkey09 fkey21 fkey33 fkey45 scr09 scr09 scr09 scr09 O 068 fkey10 fkey22 fkey34 fkey46 scr10 scr10 scr10 scr10 O 069 nlock nlock nlock nlock nlock nlock nlock nlock O 070 slock slock slock slock slock slock slock slock O 071 fkey49 '7' '7' '7' '7' '7' '7' '7' N 072 fkey50 '8' '8' '8' '8' '8' '8' '8' N 073 fkey51 '9' '9' '9' '9' '9' '9' '9' N 074 fkey52 '-' '-' '-' '-' '-' '-' '-' N 075 fkey53 '4' '4' '4' '4' '4' '4' '4' N 076 fkey54 '5' '5' '5' '5' '5' '5' '5' N 077 fkey55 '6' '6' '6' '6' '6' '6' '6' N 078 fkey56 '+' '+' '+' '+' '+' '+' '+' N 079 fkey57 '1' '1' '1' '1' '1' '1' '1' N 080 fkey58 '2' '2' '2' '2' '2' '2' '2' N 081 fkey59 '3' '3' '3' '3' '3' '3' '3' N 082 fkey60 '0' '0' '0' '0' '0' '0' '0' N 083 del '.' '.' '.' '.' '.' boot boot N 084 nop nop nop nop nop nop nop nop O 085 nop nop nop nop nop nop nop nop O 086 '\' '|' fs fs '\' '|' fs fs O 087 fkey11 fkey23 fkey35 fkey47 scr11 scr11 scr11 scr11 O 088 fkey12 fkey24 fkey36 fkey48 scr12 scr12 scr12 scr12 O 089 cr cr nl nl cr cr nl nl O 090 rctrl rctrl rctrl rctrl rctrl rctrl rctrl rctrl O 091 '/' '/' '/' '/' '/' '/' '/' '/' N 092 nscr pscr debug debug nop nop nop nop O 093 ralt ralt ralt ralt ralt ralt ralt ralt O 094 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 O 095 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 O 096 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 O 097 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 O 098 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 O 099 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 O 100 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 O 101 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 O 102 fkey60 paste fkey60 fkey60 fkey60 fkey60 fkey60 fkey60 O 103 fkey61 fkey61 fkey61 fkey61 fkey61 fkey61 boot fkey61 O 104 slock saver slock saver susp nop susp nop O 105 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 fkey62 O 106 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 fkey63 O 107 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 fkey64 O 108 nop nop nop nop nop nop nop nop O dgra '`' ( 'a' 0xe0 ) ( 'A' 0xc0 ) ( 'e' 0xe8 ) ( 'E' 0xc8 ) ( 'i' 0xec ) ( 'I' 0xcc ) ( 'o' 0xf2 ) ( 'O' 0xd2 ) ( 'u' 0xf9 ) ( 'U' 0xd9 ) dacu 0xb4 ( 'a' 0xe1 ) ( 'A' 0xc1 ) ( 'e' 0xe9 ) ( 'E' 0xc9 ) ( 'i' 0xed ) ( 'I' 0xcd ) ( 'o' 0xf3 ) ( 'O' 0xd3 ) ( 'u' 0xfa ) ( 'U' 0xda ) ( 'y' 0xfd ) ( 'Y' 0xdd ) dcir '^' ( 'a' 0xe2 ) ( 'A' 0xc2 ) ( 'e' 0xea ) ( 'E' 0xca ) ( 'i' 0xee ) ( 'I' 0xce ) ( 'o' 0xf4 ) ( 'O' 0xd4 ) ( 'u' 0xfb ) ( 'U' 0xdb ) dtil '~' ( 'a' 0xe3 ) ( 'A' 0xc3 ) ( 'n' 0xf1 ) ( 'N' 0xd1 ) ( 'o' 0xf5 ) ( 'O' 0xd5 ) duml 0xa8 ( 'a' 0xe4 ) ( 'A' 0xc4 ) ( 'e' 0xeb ) ( 'E' 0xcb ) ( 'i' 0xef ) ( 'I' 0xcf ) ( 'o' 0xf6 ) ( 'O' 0xd6 ) ( 'u' 0xfc ) ( 'U' 0xdc ) ( 'y' 0xff ) drin 0xb0 ( 'a' 0xe5 ) ( 'A' 0xc5 ) dced 0xb8 ( 'c' 0xe7 ) ( 'C' 0xc7 ) diff --git a/stand/kboot/arch/powerpc64/ldscript.powerpc b/stand/kboot/arch/powerpc64/ldscript.powerpc index 662871eb7c09..f9fcc37f02d8 100644 --- a/stand/kboot/arch/powerpc64/ldscript.powerpc +++ b/stand/kboot/arch/powerpc64/ldscript.powerpc @@ -1,139 +1,137 @@ -/* $FreeBSD: user/nwhitehorn/kboot/powerpc/kboot/ldscript.powerpc 272888 2014-10-10 06:24:09Z bapt $ */ - OUTPUT_FORMAT("elf32-powerpc-freebsd", "elf32-powerpc-freebsd", "elf32-powerpc-freebsd") OUTPUT_ARCH(powerpc:common) ENTRY(_start) SEARCH_DIR(/usr/lib); PROVIDE (__stack = 0); SECTIONS { /* Read-only sections, merged into text segment: */ . = 0x100000; .interp : { *(.interp) } :text .hash : { *(.hash) } .dynsym : { *(.dynsym) } .dynstr : { *(.dynstr) } .gnu.version : { *(.gnu.version) } .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } .rela.text : { *(.rela.text) *(.rela.gnu.linkonce.t*) } .rela.data : { *(.rela.data) *(.rela.gnu.linkonce.d*) } .rela.rodata : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } .rela.got : { *(.rela.got) } .rela.got1 : { *(.rela.got1) } .rela.got2 : { *(.rela.got2) } .rela.ctors : { *(.rela.ctors) } .rela.dtors : { *(.rela.dtors) } .rela.init : { *(.rela.init) } .rela.fini : { *(.rela.fini) } .rela.bss : { *(.rela.bss) } .rela.plt : { *(.rela.plt) } .rela.sdata : { *(.rela.sdata) } .rela.sbss : { *(.rela.sbss) } .rela.sdata2 : { *(.rela.sdata2) } .rela.sbss2 : { *(.rela.sbss2) } .text : { *(.text) /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) *(.gnu.linkonce.t*) } =0 _etext = .; PROVIDE (etext = .); .init : { *(.init) } =0 .fini : { *(.fini) } =0 .rodata : { *(.rodata) *(.gnu.linkonce.r*) } .rodata1 : { *(.rodata1) } .sdata2 : { *(.sdata2) } .sbss2 : { *(.sbss2) } /* Adjust the address for the data segment to the next page up. */ . = ((. + 0x1000) & ~(0x1000 - 1)); .data.rel.ro : { *(.data.rel.ro*) } .data : { *(.data) *(.gnu.linkonce.d*) CONSTRUCTORS } .data1 : { *(.data1) } .got1 : { *(.got1) } .dynamic : { *(.dynamic) } /* Put .ctors and .dtors next to the .got2 section, so that the pointers get relocated with -mrelocatable. Also put in the .fixup pointers. The current compiler no longer needs this, but keep it around for 2.7.2 */ PROVIDE (_GOT2_START_ = .); .got2 : { *(.got2) } PROVIDE (__CTOR_LIST__ = .); .ctors : { *(.ctors) } PROVIDE (__CTOR_END__ = .); PROVIDE (__DTOR_LIST__ = .); .dtors : { *(.dtors) } PROVIDE (__DTOR_END__ = .); PROVIDE (_FIXUP_START_ = .); .fixup : { *(.fixup) } PROVIDE (_FIXUP_END_ = .); PROVIDE (_GOT2_END_ = .); PROVIDE (_GOT_START_ = .); .got : { *(.got) } .got.plt : { *(.got.plt) } PROVIDE (_GOT_END_ = .); /* We want the small data sections together, so single-instruction offsets can access them all, and initialized data all before uninitialized, so we can shorten the on-disk segment size. */ .sdata : { *(.sdata) } _edata = .; PROVIDE (edata = .); .sbss : { PROVIDE (__sbss_start = .); *(.sbss) *(.scommon) *(.dynsbss) PROVIDE (__sbss_end = .); } .plt : { *(.plt) } .bss : { PROVIDE (__bss_start = .); *(.dynbss) *(.bss) *(COMMON) } . = ALIGN(4096); _end = . ; PROVIDE (end = .); /* Stabs debugging sections. */ .stab 0 : { *(.stab) } .stabstr 0 : { *(.stabstr) } /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. */ /* DWARF 1 */ .debug 0 : { *(.debug) } .line 0 : { *(.line) } /* GNU DWARF 1 extensions */ .debug_srcinfo 0 : { *(.debug_srcinfo) } .debug_sfnames 0 : { *(.debug_sfnames) } /* DWARF 1.1 and DWARF 2 */ .debug_aranges 0 : { *(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } /* DWARF 2 */ .debug_info 0 : { *(.debug_info) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 : { *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : { *(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } /* SGI/MIPS DWARF 2 extensions */ .debug_weaknames 0 : { *(.debug_weaknames) } .debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : { *(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) } /* These must appear regardless of . */ } diff --git a/sys/dev/firmware/xilinx/zynqmp_firmware_if.m b/sys/dev/firmware/xilinx/zynqmp_firmware_if.m index 1007d721952d..53b9fa5399bb 100644 --- a/sys/dev/firmware/xilinx/zynqmp_firmware_if.m +++ b/sys/dev/firmware/xilinx/zynqmp_firmware_if.m @@ -1,109 +1,107 @@ #- # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2023 Beckhoff Automation GmbH & Co. KG # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 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 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 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) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # 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$ INTERFACE zynqmp_firmware; METHOD int clock_enable { device_t dev; uint32_t clkid; }; METHOD int clock_disable { device_t dev; uint32_t clkid; }; METHOD int clock_getstate { device_t dev; uint32_t clkid; bool *enabled; }; METHOD int clock_setdivider { device_t dev; uint32_t clkid; uint32_t div; }; METHOD int clock_getdivider { device_t dev; uint32_t clkid; uint32_t *div; }; METHOD int clock_setparent { device_t dev; uint32_t clkid; uint32_t parentid; }; METHOD int clock_getparent { device_t dev; uint32_t clkid; uint32_t *parentid; }; METHOD int pll_get_mode { device_t dev; uint32_t pllid; uint32_t *mode; }; METHOD int pll_get_frac_data { device_t dev; uint32_t pllid; uint32_t *data; }; METHOD int clock_get_fixedfactor { device_t dev; uint32_t clkid; uint32_t *mult; uint32_t *div; }; METHOD int query_data { device_t dev; uint32_t qid; uint32_t arg1; uint32_t arg2; uint32_t arg3; uint32_t *data; }; METHOD int reset_assert { device_t dev; uint32_t resetid; bool enable; }; METHOD int reset_get_status { device_t dev; uint32_t resetid; bool *status; }; diff --git a/sys/modules/ath12k/Makefile b/sys/modules/ath12k/Makefile index e72d061d0c08..674a68e12813 100644 --- a/sys/modules/ath12k/Makefile +++ b/sys/modules/ath12k/Makefile @@ -1,37 +1,35 @@ -# $FreeBSD$ - DEVATH12KDIR= ${SRCTOP}/sys/contrib/dev/athk/ath12k .PATH: ${DEVATH12KDIR} WITH_CONFIG_ATH12K_TRACING= 0 KMOD= if_ath12k SRCS+= core.c hal.c hal_tx.c hal_rx.c SRCS+= wmi.c mac.c reg.c htc.c qmi.c SRCS+= dp.c dp_tx.c dp_rx.c dp_mon.c debug.c SRCS+= ce.c peer.c dbring.c hw.c SRCS+= mhi.c pci.c .if defined(WITH_CONFIG_ATH12K_TRACING) && ${WITH_CONFIG_ATH12K_TRACING} > 0 CFLAGS+= -DCONFIG_ATH12K_TRACING=${WITH_CONFIG_ATH12K_TRACING} SRCS+= trace.c .endif # Other SRCS+= ${LINUXKPI_GENSRCS} SRCS+= opt_wlan.h opt_inet6.h opt_inet.h opt_acpi.h CFLAGS+= -DKBUILD_MODNAME='"ath12k"' CFLAGS+= -I${DEVATH12KDIR} CFLAGS+= -I${DEVATH12KDIR}/.. CFLAGS+= ${LINUXKPI_INCLUDES} # Helpful after fresh imports. #CFLAGS+= -ferror-limit=0 CFLAGS+= -DCONFIG_ATH12K_DEBUG .include diff --git a/sys/modules/mt76/mt7996/Makefile b/sys/modules/mt76/mt7996/Makefile index 3a4a56d839a5..a43721b6079e 100644 --- a/sys/modules/mt76/mt7996/Makefile +++ b/sys/modules/mt76/mt7996/Makefile @@ -1,29 +1,27 @@ -# $FreeBSD$ - DEVDIR= ${SRCTOP}/sys/contrib/dev/mediatek/mt76/mt7996 .PATH: ${DEVDIR} WITH_DEBUGFS= 0 WITH_DEV_COREDUMP= 1 KMOD= if_mt7996 # Common stuff. SRCS= init.c main.c mac.c mcu.c mmio.c eeprom.c SRCS+= pci.c dma.c .if defined(WITH_DEBUGFS) && ${WITH_DEBUGFS} > 0 SRCS+= debugfs.c CFLAGS+= -DCONFIG_MT7996_DEBUGFS=${WITH_DEBUGFS} .endif .if defined(WITH_DEV_COREDUMP) && ${WITH_DEV_COREDUMP} > 0 SRCS+= coredump.c CFLAGS+= -DCONFIG_DEV_COREDUMP=${WITH_DEV_COREDUMP} .endif CFLAGS+= -DKBUILD_MODNAME='"mt7996"' CFLAGS+= -I${DEVDIR} .include diff --git a/tools/tools/editing/freebsd.vim b/tools/tools/editing/freebsd.vim index fa7977b30361..e515f81890df 100644 --- a/tools/tools/editing/freebsd.vim +++ b/tools/tools/editing/freebsd.vim @@ -1,68 +1,66 @@ " Copyright (c) 2007-2008 Sean C. Farley " All rights reserved. " " Redistribution and use in source and binary forms, with or without " modification, are permitted provided that the following conditions " are met: " 1. Redistributions of source code must retain the above copyright " notice, this list of conditions and the following disclaimer, " without modification, immediately at the beginning of the file. " 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 THE AUTHOR ``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 THE AUTHOR 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) HOWEVER CAUSED AND ON ANY " THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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$ " This is a plugin for Vim (tested with Vim v7.1) to follow the FreeBSD style(9) " indentation. It registers a macro (see below) for changing a buffer's " indentation rules but does not change the indentation of existing code. " Load only once. if exists('loaded_FreeBSD') finish endif let loaded_FreeBSD = 1 " FreeBSD mapping to switch current buffer to style(9). This is generally '\f'. nmap f :call FreeBSD_Style() " Ignore indents caused by parentheses in FreeBSD style. function! IgnoreParenIndent() let indent = cindent(v:lnum) if indent > 4000 if cindent(v:lnum - 1) > 4000 return indent(v:lnum - 1) else return indent(v:lnum - 1) + 4 endif else return (indent) endif endfun " Follow the FreeBSD style(9). function! FreeBSD_Style() setlocal cindent setlocal cinoptions=(4200,u4200,+0.5s,*500,:0,t0,U4200 setlocal indentexpr=IgnoreParenIndent() setlocal indentkeys=0{,0},0),:,0#,!^F,o,O,e setlocal noexpandtab setlocal shiftwidth=8 setlocal tabstop=8 setlocal textwidth=80 endfun diff --git a/tools/tools/locale/etc/charmaps.xml b/tools/tools/locale/etc/charmaps.xml index dcf1644e4371..0193912b9a01 100644 --- a/tools/tools/locale/etc/charmaps.xml +++ b/tools/tools/locale/etc/charmaps.xml @@ -1,714 +1,713 @@ - "; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; "" ]]> "; ""; ""; ""; ""; ""; ""; "

"; ""; ""; "

"; "

" ]]> "; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; "" ]]> "; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; "" ]]> "; ""; ""; ""; ""; ""; "

"; "

"; ""; "

"; "

"; "" ]]> "; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; "" ]]> "; ""; ""; ""; ""; ""; "

"; "

"; ""; "

"; "

"; "" ]]> "; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; "" ]]> "; ""; ""; ""; ""; ""; ""; ""; ""; ""; ""; "" ]]> diff --git a/usr.sbin/ypldap/ypldap.c b/usr.sbin/ypldap/ypldap.c index 9a6dc303dd9d..ff1965dd6e2c 100644 --- a/usr.sbin/ypldap/ypldap.c +++ b/usr.sbin/ypldap/ypldap.c @@ -1,652 +1,651 @@ /* $OpenBSD: ypldap.c,v 1.16 2015/11/02 10:06:06 jmatthew Exp $ */ -/* $FreeBSD */ /* * Copyright (c) 2008 Pierre-Yves Ritschard * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ypldap.h" enum ypldap_process_type ypldap_process; __dead2 void usage(void); int check_child(pid_t, const char *); void main_sig_handler(int, short, void *); void main_shutdown(void); void main_dispatch_client(int, short, void *); void main_configure_client(struct env *); void main_init_timer(int, short, void *); void main_start_update(struct env *); void main_trash_update(struct env *); void main_end_update(struct env *); int main_create_user_groups(struct env *); void purge_config(struct env *); void reconfigure(struct env *); int pipe_main2client[2]; pid_t client_pid = 0; char *conffile = YPLDAP_CONF_FILE; int opts = 0; void usage(void) { extern const char *__progname; fprintf(stderr, "usage: %s [-dnv] [-D macro=value] [-f file]\n", __progname); exit(1); } int check_child(pid_t pid, const char *pname) { int status; if (waitpid(pid, &status, WNOHANG) > 0) { if (WIFEXITED(status)) { log_warnx("check_child: lost child %s exited", pname); return (1); } if (WIFSIGNALED(status)) { log_warnx("check_child: lost child %s terminated; " "signal %d", pname, WTERMSIG(status)); return (1); } } return (0); } /* ARGUSED */ void main_sig_handler(int sig, short event, void *p) { int die = 0; switch (sig) { case SIGTERM: case SIGINT: die = 1; /* FALLTHROUGH */ case SIGCHLD: if (check_child(client_pid, "ldap client")) { client_pid = 0; die = 1; } if (die) main_shutdown(); break; case SIGHUP: /* reconfigure */ break; default: fatalx("unexpected signal"); } } void main_shutdown(void) { _exit(0); } void main_start_update(struct env *env) { env->update_trashed = 0; log_debug("starting directory update"); env->sc_user_line_len = 0; env->sc_group_line_len = 0; if ((env->sc_user_names_t = calloc(1, sizeof(*env->sc_user_names_t))) == NULL || (env->sc_group_names_t = calloc(1, sizeof(*env->sc_group_names_t))) == NULL) fatal(NULL); RB_INIT(env->sc_user_names_t); RB_INIT(env->sc_group_names_t); } /* * XXX: Currently this function should only be called when updating is * finished. A notification should be send to ldapclient that it should stop * sending new pwd/grp entries before it can be called from different places. */ void main_trash_update(struct env *env) { struct userent *ue; struct groupent *ge; env->update_trashed = 1; while ((ue = RB_ROOT(env->sc_user_names_t)) != NULL) { RB_REMOVE(user_name_tree, env->sc_user_names_t, ue); free(ue->ue_line); free(ue->ue_netid_line); free(ue); } free(env->sc_user_names_t); env->sc_user_names_t = NULL; while ((ge = RB_ROOT(env->sc_group_names_t)) != NULL) { RB_REMOVE(group_name_tree, env->sc_group_names_t, ge); free(ge->ge_line); free(ge); } free(env->sc_group_names_t); env->sc_group_names_t = NULL; } int main_create_user_groups(struct env *env) { struct userent *ue; struct userent ukey; struct groupent *ge; gid_t pw_gid; char *bp, *cp; char *p; const char *errstr = NULL; size_t len; RB_FOREACH(ue, user_name_tree, env->sc_user_names_t) { bp = cp = ue->ue_line; /* name */ bp += strlen(bp) + 1; /* password */ bp += strcspn(bp, ":") + 1; /* uid */ bp += strcspn(bp, ":") + 1; /* gid */ bp[strcspn(bp, ":")] = '\0'; pw_gid = (gid_t)strtonum(bp, 0, GID_MAX, &errstr); if (errstr) { log_warnx("main: failed to parse gid for uid: %d\n", ue->ue_uid); return (-1); } /* bring gid column back to its proper state */ bp[strlen(bp)] = ':'; if ((ue->ue_netid_line = calloc(1, LINE_WIDTH)) == NULL) { return (-1); } if (snprintf(ue->ue_netid_line, LINE_WIDTH-1, "%d:%d", ue->ue_uid, pw_gid) >= LINE_WIDTH) { return (-1); } ue->ue_gid = pw_gid; } RB_FOREACH(ge, group_name_tree, env->sc_group_names_t) { bp = cp = ge->ge_line; /* name */ bp += strlen(bp) + 1; /* password */ bp += strcspn(bp, ":") + 1; /* gid */ bp += strcspn(bp, ":") + 1; cp = bp; if (*bp == '\0') continue; bp = cp; for (;;) { if (!(cp = strsep(&bp, ","))) break; ukey.ue_line = cp; if ((ue = RB_FIND(user_name_tree, env->sc_user_names_t, &ukey)) == NULL) { /* User not found */ log_warnx("main: unknown user %s in group %s\n", ukey.ue_line, ge->ge_line); if (bp != NULL) *(bp-1) = ','; continue; } if (bp != NULL) *(bp-1) = ','; /* Make sure the new group doesn't equal to the main gid */ if (ge->ge_gid == ue->ue_gid) continue; len = strlen(ue->ue_netid_line); p = ue->ue_netid_line + len; if ((snprintf(p, LINE_WIDTH-len-1, ",%d", ge->ge_gid)) >= (int)(LINE_WIDTH-len)) { return (-1); } } } return (0); } void main_end_update(struct env *env) { struct userent *ue; struct groupent *ge; if (env->update_trashed) return; log_debug("updates are over, cleaning up trees now"); if (main_create_user_groups(env) == -1) { main_trash_update(env); return; } if (env->sc_user_names == NULL) { env->sc_user_names = env->sc_user_names_t; env->sc_user_lines = NULL; env->sc_user_names_t = NULL; env->sc_group_names = env->sc_group_names_t; env->sc_group_lines = NULL; env->sc_group_names_t = NULL; flatten_entries(env); goto make_uids; } /* * clean previous tree. */ while ((ue = RB_ROOT(env->sc_user_names)) != NULL) { RB_REMOVE(user_name_tree, env->sc_user_names, ue); free(ue->ue_netid_line); free(ue); } free(env->sc_user_names); free(env->sc_user_lines); env->sc_user_names = env->sc_user_names_t; env->sc_user_lines = NULL; env->sc_user_names_t = NULL; while ((ge = RB_ROOT(env->sc_group_names)) != NULL) { RB_REMOVE(group_name_tree, env->sc_group_names, ge); free(ge); } free(env->sc_group_names); free(env->sc_group_lines); env->sc_group_names = env->sc_group_names_t; env->sc_group_lines = NULL; env->sc_group_names_t = NULL; flatten_entries(env); /* * trees are flat now. build up uid, gid and netid trees. */ make_uids: RB_INIT(&env->sc_user_uids); RB_INIT(&env->sc_group_gids); RB_FOREACH(ue, user_name_tree, env->sc_user_names) RB_INSERT(user_uid_tree, &env->sc_user_uids, ue); RB_FOREACH(ge, group_name_tree, env->sc_group_names) RB_INSERT(group_gid_tree, &env->sc_group_gids, ge); } void main_dispatch_client(int fd, short events, void *p) { int n; int shut = 0; struct env *env = p; struct imsgev *iev = env->sc_iev; struct imsgbuf *ibuf = &iev->ibuf; struct idm_req ir; struct imsg imsg; if ((events & (EV_READ | EV_WRITE)) == 0) fatalx("unknown event"); if (events & EV_READ) { if ((n = imsg_read(ibuf)) == -1 && errno != EAGAIN) fatal("imsg_read error"); if (n == 0) shut = 1; } if (events & EV_WRITE) { if ((n = msgbuf_write(&ibuf->w)) == -1 && errno != EAGAIN) fatal("msgbuf_write"); if (n == 0) shut = 1; goto done; } for (;;) { if ((n = imsg_get(ibuf, &imsg)) == -1) fatal("main_dispatch_client: imsg_get error"); if (n == 0) break; switch (imsg.hdr.type) { case IMSG_START_UPDATE: main_start_update(env); break; case IMSG_PW_ENTRY: { struct userent *ue; size_t len; if (env->update_trashed) break; (void)memcpy(&ir, imsg.data, sizeof(ir)); if ((ue = calloc(1, sizeof(*ue))) == NULL || (ue->ue_line = strdup(ir.ir_line)) == NULL) { /* * should cancel tree update instead. */ fatal("out of memory"); } ue->ue_uid = ir.ir_key.ik_uid; len = strlen(ue->ue_line) + 1; ue->ue_line[strcspn(ue->ue_line, ":")] = '\0'; if (RB_INSERT(user_name_tree, env->sc_user_names_t, ue) != NULL) { /* dup */ free(ue->ue_line); free(ue); } else env->sc_user_line_len += len; break; } case IMSG_GRP_ENTRY: { struct groupent *ge; size_t len; if (env->update_trashed) break; (void)memcpy(&ir, imsg.data, sizeof(ir)); if ((ge = calloc(1, sizeof(*ge))) == NULL || (ge->ge_line = strdup(ir.ir_line)) == NULL) { /* * should cancel tree update instead. */ fatal("out of memory"); } ge->ge_gid = ir.ir_key.ik_gid; len = strlen(ge->ge_line) + 1; ge->ge_line[strcspn(ge->ge_line, ":")] = '\0'; if (RB_INSERT(group_name_tree, env->sc_group_names_t, ge) != NULL) { /* dup */ free(ge->ge_line); free(ge); } else env->sc_group_line_len += len; break; } case IMSG_TRASH_UPDATE: main_trash_update(env); break; case IMSG_END_UPDATE: { main_end_update(env); break; } default: log_debug("main_dispatch_client: unexpected imsg %d", imsg.hdr.type); break; } imsg_free(&imsg); } done: if (!shut) imsg_event_add(iev); else { log_debug("king bula sez: ran into dead pipe"); event_del(&iev->ev); event_loopexit(NULL); } } void main_configure_client(struct env *env) { struct idm *idm; struct imsgev *iev = env->sc_iev; imsg_compose_event(iev, IMSG_CONF_START, 0, 0, -1, env, sizeof(*env)); TAILQ_FOREACH(idm, &env->sc_idms, idm_entry) { imsg_compose_event(iev, IMSG_CONF_IDM, 0, 0, -1, idm, sizeof(*idm)); } imsg_compose_event(iev, IMSG_CONF_END, 0, 0, -1, NULL, 0); } void main_init_timer(int fd, short event, void *p) { struct env *env = p; main_configure_client(env); } void purge_config(struct env *env) { struct idm *idm; while ((idm = TAILQ_FIRST(&env->sc_idms)) != NULL) { TAILQ_REMOVE(&env->sc_idms, idm, idm_entry); free(idm); } } int main(int argc, char *argv[]) { int c; int debug; struct passwd *pw; struct env env; struct event ev_sigint; struct event ev_sigterm; struct event ev_sigchld; struct event ev_sighup; struct event ev_timer; struct timeval tv; debug = 0; ypldap_process = PROC_MAIN; log_init(1); while ((c = getopt(argc, argv, "dD:nf:v")) != -1) { switch (c) { case 'd': debug = 2; break; case 'D': if (cmdline_symset(optarg) < 0) log_warnx("could not parse macro definition %s", optarg); break; case 'n': debug = 2; opts |= YPLDAP_OPT_NOACTION; break; case 'f': conffile = optarg; break; case 'v': opts |= YPLDAP_OPT_VERBOSE; break; default: usage(); } } argc -= optind; argv += optind; if (argc) usage(); RB_INIT(&env.sc_user_uids); RB_INIT(&env.sc_group_gids); if (parse_config(&env, conffile, opts)) exit(1); if (opts & YPLDAP_OPT_NOACTION) { fprintf(stderr, "configuration OK\n"); exit(0); } if (geteuid()) errx(1, "need root privileges"); log_init(debug); if (!debug) { if (daemon(1, 0) == -1) err(1, "failed to daemonize"); } log_info("startup%s", (debug > 1)?" [debug mode]":""); if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, PF_UNSPEC, pipe_main2client) == -1) fatal("socketpair"); client_pid = ldapclient(pipe_main2client); setproctitle("parent"); event_init(); signal_set(&ev_sigint, SIGINT, main_sig_handler, &env); signal_set(&ev_sigterm, SIGTERM, main_sig_handler, &env); signal_set(&ev_sighup, SIGHUP, main_sig_handler, &env); signal_set(&ev_sigchld, SIGCHLD, main_sig_handler, &env); signal_add(&ev_sigint, NULL); signal_add(&ev_sigterm, NULL); signal_add(&ev_sighup, NULL); signal_add(&ev_sigchld, NULL); close(pipe_main2client[1]); if ((env.sc_iev = calloc(1, sizeof(*env.sc_iev))) == NULL) fatal(NULL); imsg_init(&env.sc_iev->ibuf, pipe_main2client[0]); env.sc_iev->handler = main_dispatch_client; env.sc_iev->events = EV_READ; env.sc_iev->data = &env; event_set(&env.sc_iev->ev, env.sc_iev->ibuf.fd, env.sc_iev->events, env.sc_iev->handler, &env); event_add(&env.sc_iev->ev, NULL); yp_init(&env); if ((pw = getpwnam(YPLDAP_USER)) == NULL) fatal("getpwnam"); #ifndef DEBUG if (setgroups(1, &pw->pw_gid) || setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) || setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) fatal("cannot drop privileges"); #else #warning disabling privilege revocation in debug mode #endif memset(&tv, 0, sizeof(tv)); evtimer_set(&ev_timer, main_init_timer, &env); evtimer_add(&ev_timer, &tv); yp_enable_events(); event_dispatch(); main_shutdown(); return (0); } void imsg_event_add(struct imsgev *iev) { if (iev->handler == NULL) { imsg_flush(&iev->ibuf); return; } iev->events = EV_READ; if (iev->ibuf.w.queued) iev->events |= EV_WRITE; event_del(&iev->ev); event_set(&iev->ev, iev->ibuf.fd, iev->events, iev->handler, iev->data); event_add(&iev->ev, NULL); } int imsg_compose_event(struct imsgev *iev, u_int16_t type, u_int32_t peerid, pid_t pid, int fd, void *data, u_int16_t datalen) { int ret; if ((ret = imsg_compose(&iev->ibuf, type, peerid, pid, fd, data, datalen)) != -1) imsg_event_add(iev); return (ret); }