aboutsummaryrefslogtreecommitdiff
path: root/cddl
diff options
context:
space:
mode:
Diffstat (limited to 'cddl')
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/dtrace.154
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.ticks.d54
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c73
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.h1
-rw-r--r--cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile1
5 files changed, 155 insertions, 28 deletions
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1 b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1
index 1836707d72df..da8cbd9ffe50 100644
--- a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1
+++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.1
@@ -20,7 +20,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 14, 2025
+.Dd July 16, 2025
.Dt DTRACE 1
.Os
.Sh NAME
@@ -617,6 +617,52 @@ Same as the
flag.
.It Sy dynvarsize Ns = Ns Ar size
Size of the dynamic variable space.
+.Sm off
+.It Sy evaltime = Cm exec | preinit | postinit | main
+.Sm on
+Process create mode.
+When using
+.Fl c Ar cmd
+to start a command,
+.Nm
+will first stop the newly started
+.Ar cmd ,
+evaluate the
+.Xr d 7
+program,
+and then resume the
+.Ar cmd .
+The
+.Cm evaltime
+option controls the exact moment when this happens.
+.Pp
+The following table describes supported modes.
+.Bl -column -offset indent "postinit" "D Program Evaluation Time"
+.It Sy Mode Ta Sy D Program Evaluation Time
+.It Cm exec Ta
+Right at the first instruction of the command
+.Ar cmd
+execution.
+.It Cm preinit Ta
+Before
+.Xr elf 5 Ap s
+.Dq .init
+sections.
+.It Cm postinit Ta
+After
+.Xr elf 5 Ap s
+.Dq .init
+sections.
+Default on
+.Fx .
+.It Cm main Ta
+Before the first instruction of the
+.Fn main
+function.
+.El
+.Pp
+Usually, there is no reason to change the default mode,
+but it might be handy in situations such as shared library tracing.
.It Sy flowindent
Turn on flow indentation.
Same as the
@@ -1221,18 +1267,24 @@ Invalid command line options or arguments were specified.
.El
.Sh SEE ALSO
.Xr cpp 1 ,
+.Xr dwatch 1 ,
.Xr dtrace_audit 4 ,
+.Xr dtrace_dtrace 4 ,
+.Xr dtrace_fbt 4 ,
.Xr dtrace_io 4 ,
.Xr dtrace_ip 4 ,
.Xr dtrace_kinst 4 ,
.Xr dtrace_lockstat 4 ,
.Xr dtrace_proc 4 ,
+.Xr dtrace_profile 4 ,
.Xr dtrace_sched 4 ,
.Xr dtrace_sctp 4 ,
.Xr dtrace_tcp 4 ,
.Xr dtrace_udp 4 ,
.Xr dtrace_udplite 4 ,
.Xr elf 5 ,
+.Xr d 7 ,
+.Xr tracing 7 ,
.Xr SDT 9
.Rs
.%T Solaris Dynamic Tracing Guide
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.ticks.d b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.ticks.d
new file mode 100644
index 000000000000..4061db9858c1
--- /dev/null
+++ b/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/profile-n/tst.ticks.d
@@ -0,0 +1,54 @@
+/*
+ * 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 2025 Mark Johnston <markj@FreeBSD.org>
+ */
+
+/*
+ * For 10s, verify that the value of `ticks goes up by `hz each second.
+ */
+
+#pragma D option quiet
+
+BEGIN
+{
+ i = 0;
+}
+
+tick-1s
+{
+ if (i == 0) {
+ t = *(int *)&`ticks;
+ i++;
+ } else {
+ u = *(int *)&`ticks;
+ if (u - t != `hz) {
+ printf("ticks: %d, expected %d\n", u - t, `hz);
+ exit(1);
+ }
+ t = u;
+ i++;
+ if (i == 10) {
+ exit(0);
+ }
+ }
+}
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c
index d1ebaa8791da..8cc504856567 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c
@@ -1918,6 +1918,14 @@ dt_node_op1(int op, dt_node_t *cp)
return (cp);
}
+ /*
+ * When applying the addressof operator to an identifier, it's okay if
+ * we can't find type information for the identifier, so flag the node
+ * to ensure that we don't raise an error.
+ */
+ if (op == DT_TOK_ADDROF && cp->dn_kind == DT_NODE_IDENT)
+ cp->dn_flags |= DT_NF_IDENTADDR;
+
dnp = dt_node_alloc(DT_NODE_OP1);
assert(op <= USHRT_MAX);
dnp->dn_op = (ushort_t)op;
@@ -2786,10 +2794,21 @@ dt_xcook_ident(dt_node_t *dnp, dt_idhash_t *dhp, uint_t idkind, int create)
dt_module_modelname(dtp->dt_ddefs));
}
- xyerror(D_SYM_NOTYPES,
+ /*
+ * If we're taking the address of an identifier that
+ * doesn't have type info, try to make it a void *.
+ * This lets us use identifiers that are defined in
+ * assembly and don't have type information.
+ */
+ if ((dnp->dn_flags & DT_NF_IDENTADDR) == 0 ||
+ dtrace_lookup_by_type(dtp, DTRACE_OBJ_CDEFS,
+ "void", &dtt) != 0) {
+ xyerror(D_SYM_NOTYPES,
"no symbolic type information is available for "
- "%s%s%s: %s\n", dts.dts_object, mark, dts.dts_name,
- dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ "%s%s%s: %s\n", dts.dts_object, mark,
+ dts.dts_name,
+ dtrace_errmsg(dtp, dtrace_errno(dtp)));
+ }
}
idp = dt_ident_create(name, DT_IDENT_SYMBOL, 0, 0,
@@ -4506,30 +4525,30 @@ dt_cook_none(dt_node_t *dnp, uint_t idflags)
return (dnp);
}
-static dt_node_t *(*dt_cook_funcs[])(dt_node_t *, uint_t) = {
- dt_cook_none, /* DT_NODE_FREE */
- dt_cook_none, /* DT_NODE_INT */
- dt_cook_none, /* DT_NODE_STRING */
- dt_cook_ident, /* DT_NODE_IDENT */
- dt_cook_var, /* DT_NODE_VAR */
- dt_cook_none, /* DT_NODE_SYM */
- dt_cook_none, /* DT_NODE_TYPE */
- dt_cook_func, /* DT_NODE_FUNC */
- dt_cook_op1, /* DT_NODE_OP1 */
- dt_cook_op2, /* DT_NODE_OP2 */
- dt_cook_op3, /* DT_NODE_OP3 */
- dt_cook_statement, /* DT_NODE_DEXPR */
- dt_cook_statement, /* DT_NODE_DFUNC */
- dt_cook_aggregation, /* DT_NODE_AGG */
- dt_cook_none, /* DT_NODE_PDESC */
- dt_cook_clause, /* DT_NODE_CLAUSE */
- dt_cook_inline, /* DT_NODE_INLINE */
- dt_cook_member, /* DT_NODE_MEMBER */
- dt_cook_xlator, /* DT_NODE_XLATOR */
- dt_cook_none, /* DT_NODE_PROBE */
- dt_cook_provider, /* DT_NODE_PROVIDER */
- dt_cook_none, /* DT_NODE_PROG */
- dt_cook_none, /* DT_NODE_IF */
+static dt_node_t *(* const dt_cook_funcs[])(dt_node_t *, uint_t) = {
+ [DT_NODE_FREE] = dt_cook_none,
+ [DT_NODE_INT] = dt_cook_none,
+ [DT_NODE_STRING] = dt_cook_none,
+ [DT_NODE_IDENT] = dt_cook_ident,
+ [DT_NODE_VAR] = dt_cook_var,
+ [DT_NODE_SYM] = dt_cook_none,
+ [DT_NODE_TYPE] = dt_cook_none,
+ [DT_NODE_FUNC] = dt_cook_func,
+ [DT_NODE_OP1] = dt_cook_op1,
+ [DT_NODE_OP2] = dt_cook_op2,
+ [DT_NODE_OP3] = dt_cook_op3,
+ [DT_NODE_DEXPR] = dt_cook_statement,
+ [DT_NODE_DFUNC] = dt_cook_statement,
+ [DT_NODE_AGG] = dt_cook_aggregation,
+ [DT_NODE_PDESC] = dt_cook_none,
+ [DT_NODE_CLAUSE] = dt_cook_clause,
+ [DT_NODE_INLINE] = dt_cook_inline,
+ [DT_NODE_MEMBER] = dt_cook_member,
+ [DT_NODE_XLATOR] = dt_cook_xlator,
+ [DT_NODE_PROBE] = dt_cook_none,
+ [DT_NODE_PROVIDER] = dt_cook_provider,
+ [DT_NODE_PROG] = dt_cook_none,
+ [DT_NODE_IF] = dt_cook_none,
};
/*
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.h
index 3a146c5d2592..1d2f33beee0f 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.h
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.h
@@ -182,6 +182,7 @@ typedef struct dt_node {
#define DT_NF_WRITABLE 0x10 /* node is writable (can be modified) */
#define DT_NF_BITFIELD 0x20 /* node is an integer bitfield */
#define DT_NF_USERLAND 0x40 /* data is a userland address */
+#define DT_NF_IDENTADDR 0x80 /* node is an identifier address */
#define DT_TYPE_NAMELEN 128 /* reasonable size for ctf_type_name() */
diff --git a/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile b/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile
index 84f4706b61ee..ceb52fcf5bd0 100644
--- a/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile
+++ b/cddl/usr.sbin/dtrace/tests/common/profile-n/Makefile
@@ -37,6 +37,7 @@ ${PACKAGE}FILES= \
tst.profileusec.d \
tst.profileusec.d.out \
tst.sym.ksh \
+ tst.ticks.d \
tst.ufunc.ksh \
tst.ufuncsort.ksh \
tst.ufuncsort.ksh.out \