[DTrace-devel] [PATCH v4 1/5] Implement setopt()

Kris Van Hees kris.van.hees at oracle.com
Thu Sep 8 20:58:01 UTC 2022


On Thu, Sep 08, 2022 at 04:47:56PM -0400, Eugene Loh via DTrace-devel wrote:
> Reviewed-by: Eugene Loh <eugene.loh at oracle.com>

Thanks.

> noting...
> 
> On 9/8/22 15:40, Kris Van Hees via DTrace-devel wrote:
> > The basic mechanics of the setopt() action are implemented in this
> > patch.  Each dynamic runtime option that can be set using setopt()
> > must provide support for it.
> > 
> > Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> > ---
> >   libdtrace/dt_cg.c                             | 11 ++++
> >   libdtrace/dt_consume.c                        | 53 +++++++++++++++----
> >   .../unittest/actions/setopt/err.D_PROTO_ARG.d | 19 +++++++
> >   .../unittest/actions/setopt/err.D_PROTO_ARG.r |  4 ++
> >   .../setopt/err.D_PROTO_LEN.missing_arg.d      | 19 +++++++
> >   .../setopt/err.D_PROTO_LEN.missing_arg.r      |  2 +
> >   .../setopt/err.D_PROTO_LEN.too_many_args.d}   |  6 +--
> >   .../setopt/err.D_PROTO_LEN.too_many_args.r    |  2 +
> >   .../{misc => actions/setopt}/tst.badopt.d     |  5 +-
> >   test/unittest/actions/setopt/tst.badopt.r     | 16 ++++++
> >   test/unittest/misc/tst.badopt.r               | 16 ------
> >   .../unittest/setopt/err.D_PROTO_LEN.toomany.r |  2 -
> >   12 files changed, 121 insertions(+), 34 deletions(-)
> >   create mode 100644 test/unittest/actions/setopt/err.D_PROTO_ARG.d
> >   create mode 100644 test/unittest/actions/setopt/err.D_PROTO_ARG.r
> >   create mode 100644 test/unittest/actions/setopt/err.D_PROTO_LEN.missing_arg.d
> >   create mode 100644 test/unittest/actions/setopt/err.D_PROTO_LEN.missing_arg.r
> >   rename test/unittest/{setopt/err.D_PROTO_LEN.toomany.d => actions/setopt/err.D_PROTO_LEN.too_many_args.d} (67%)
> >   create mode 100644 test/unittest/actions/setopt/err.D_PROTO_LEN.too_many_args.r
> >   rename test/unittest/{misc => actions/setopt}/tst.badopt.d (74%)
> >   create mode 100644 test/unittest/actions/setopt/tst.badopt.r
> >   delete mode 100644 test/unittest/misc/tst.badopt.r
> >   delete mode 100644 test/unittest/setopt/err.D_PROTO_LEN.toomany.r
> > 
> > diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> > index cb51c474..06ab0974 100644
> > --- a/libdtrace/dt_cg.c
> > +++ b/libdtrace/dt_cg.c
> > @@ -1751,6 +1751,17 @@ dt_cg_act_raise(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
> >   static void
> >   dt_cg_act_setopt(dt_pcb_t *pcb, dt_node_t *dnp, dtrace_actkind_t kind)
> >   {
> > +	dt_node_t	*opt = dnp->dn_args;
> > +	dt_node_t	*val = opt->dn_list;
> > +
> > +	TRACE_REGSET("setopt(): Begin ");
> > +	dt_cg_store_val(pcb, opt, DTRACEACT_LIBACT, NULL, DT_ACT_SETOPT);
> > +
> > +	/* If no value is given, we default to NULL. */
> > +	if (val == NULL)
> > +		val = dt_node_int(0);
> > +	dt_cg_store_val(pcb, val, DTRACEACT_LIBACT, NULL, DT_ACT_SETOPT);
> > +	TRACE_REGSET("setopt(): End   ");
> >   }
> 
> Again, there is no other documentation of the interface here between
> producer and consumer.  So the documentation on each end should be
> consistent.  The consumer does not check for NULL.  It checks for
> alignment.  The producer should explain that that's what it's doing.

The producer is explaining what it is doing.
The consumer is using that information and uses a valid test based on the
information it has access to.

> > diff --git a/libdtrace/dt_consume.c b/libdtrace/dt_consume.c
> > index 44d7e935..932b6cb4 100644
> > --- a/libdtrace/dt_consume.c
> > +++ b/libdtrace/dt_consume.c
> > @@ -2150,6 +2150,7 @@ dt_consume_one_probe(dtrace_hdl_t *dtp, FILE *fp, char *data, uint32_t size,
> >   		     void *arg)
> >   {
> >   	dtrace_epid_t		epid;
> > +	dtrace_datadesc_t	*epd = pdat->dtpda_ddesc;
> >   	dt_spec_buf_t		tmpl;
> >   	dt_spec_buf_t		*dtsb;
> >   	int			specid;
> 
> Still slipping through.

Because you are replying to v4 rather than the v5 you asked for :)

> > diff --git a/test/unittest/actions/setopt/err.D_PROTO_ARG.d b/test/unittest/actions/setopt/err.D_PROTO_ARG.d
> > new file mode 100644
> > index 00000000..c327bebb
> > --- /dev/null
> > +++ b/test/unittest/actions/setopt/err.D_PROTO_ARG.d
> > @@ -0,0 +1,19 @@
> > +/*
> > + * Oracle Linux DTrace.
> > + * Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
> 
> Drop 2006.  Any connection to 2006 is extremely tenuous.

Ah yes, thanks.

> > + * Licensed under the Universal Permissive License v 1.0 as shown at
> > + * http://oss.oracle.com/licenses/upl.
> > + */
> > +
> > +/*
> > + * ASSERTION: The setopt() action requires a string as first argument.
> > + *
> > + * SECTION: Actions and Subroutines/setopt()
> > + *
> > + */
> > +
> > +BEGIN
> > +{
> > +	setopt(1);
> > +	exit(0);
> > +}
> > diff --git a/test/unittest/actions/setopt/err.D_PROTO_ARG.r b/test/unittest/actions/setopt/err.D_PROTO_ARG.r
> > new file mode 100644
> > index 00000000..6c57ed13
> > --- /dev/null
> > +++ b/test/unittest/actions/setopt/err.D_PROTO_ARG.r
> > @@ -0,0 +1,4 @@
> > +-- @@stderr --
> > +dtrace: failed to compile script test/unittest/actions/setopt/err.D_PROTO_ARG.d: [D_PROTO_ARG] line 17: setopt( ) argument #1 is incompatible with prototype:
> > +	prototype: char *
> > +	 argument: int
> > diff --git a/test/unittest/actions/setopt/err.D_PROTO_LEN.missing_arg.d b/test/unittest/actions/setopt/err.D_PROTO_LEN.missing_arg.d
> > new file mode 100644
> > index 00000000..74d57271
> > --- /dev/null
> > +++ b/test/unittest/actions/setopt/err.D_PROTO_LEN.missing_arg.d
> > @@ -0,0 +1,19 @@
> > +/*
> > + * Oracle Linux DTrace.
> > + * Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
> 
> Ditto on 2006.

Indeed.

> > + * Licensed under the Universal Permissive License v 1.0 as shown at
> > + * http://oss.oracle.com/licenses/upl.
> > + */
> > +
> > +/*
> > + * ASSERTION: Test setop() with no arguments.
> 
> s/setop/setopt/

Thanks.

> > + *
> > + * SECTION: Actions and Subroutines/setopt()
> > + *
> > + */
> > +
> > +BEGIN
> > +{
> > +	setopt();
> > +	exit(0);
> > +}
> > diff --git a/test/unittest/actions/setopt/err.D_PROTO_LEN.missing_arg.r b/test/unittest/actions/setopt/err.D_PROTO_LEN.missing_arg.r
> > new file mode 100644
> > index 00000000..4c0a6c60
> > --- /dev/null
> > +++ b/test/unittest/actions/setopt/err.D_PROTO_LEN.missing_arg.r
> > @@ -0,0 +1,2 @@
> > +-- @@stderr --
> > +dtrace: failed to compile script test/unittest/actions/setopt/err.D_PROTO_LEN.missing_arg.d: [D_PROTO_LEN] line 17: setopt( ) prototype mismatch: 0 args passed, at least 1 expected
> > diff --git a/test/unittest/setopt/err.D_PROTO_LEN.toomany.d b/test/unittest/actions/setopt/err.D_PROTO_LEN.too_many_args.d
> > similarity index 67%
> > rename from test/unittest/setopt/err.D_PROTO_LEN.toomany.d
> > rename to test/unittest/actions/setopt/err.D_PROTO_LEN.too_many_args.d
> > index f8bf47d6..b70d554c 100644
> > --- a/test/unittest/setopt/err.D_PROTO_LEN.toomany.d
> > +++ b/test/unittest/actions/setopt/err.D_PROTO_LEN.too_many_args.d
> > @@ -1,13 +1,12 @@
> >   /*
> >    * Oracle Linux DTrace.
> > - * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
> > + * Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
> >    * Licensed under the Universal Permissive License v 1.0 as shown at
> >    * http://oss.oracle.com/licenses/upl.
> >    */
> >   /*
> > - * ASSERTION:
> > - *  Test setop() with too many arguments.
> > + * ASSERTION: Test setop() with too many arguments.
> 
> s/setop/setopt/
> 
> >    *
> >    * SECTION: Actions and Subroutines/setopt()
> >    *
> > @@ -16,4 +15,5 @@
> >   BEGIN
> >   {
> >   	setopt("bufsize", "20m", "dummy");
> > +	exit(0);
> >   }
> > diff --git a/test/unittest/actions/setopt/err.D_PROTO_LEN.too_many_args.r b/test/unittest/actions/setopt/err.D_PROTO_LEN.too_many_args.r
> > new file mode 100644
> > index 00000000..6ea249c5
> > --- /dev/null
> > +++ b/test/unittest/actions/setopt/err.D_PROTO_LEN.too_many_args.r
> > @@ -0,0 +1,2 @@
> > +-- @@stderr --
> > +dtrace: failed to compile script test/unittest/actions/setopt/err.D_PROTO_LEN.too_many_args.d: [D_PROTO_LEN] line 17: setopt( ) prototype mismatch: 3 args passed, at most 2 expected
> > diff --git a/test/unittest/misc/tst.badopt.d b/test/unittest/actions/setopt/tst.badopt.d
> > similarity index 74%
> > rename from test/unittest/misc/tst.badopt.d
> > rename to test/unittest/actions/setopt/tst.badopt.d
> > index c5d4d746..05b5687c 100644
> > --- a/test/unittest/misc/tst.badopt.d
> > +++ b/test/unittest/actions/setopt/tst.badopt.d
> > @@ -1,10 +1,9 @@
> >   /*
> >    * Oracle Linux DTrace.
> > - * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
> > + * Copyright (c) 2006, 2022, Oracle and/or its affiliates. All rights reserved.
> >    * Licensed under the Universal Permissive License v 1.0 as shown at
> >    * http://oss.oracle.com/licenses/upl.
> >    */
> > -/* @@xfail: dtv2 */
> >   #pragma D option quiet
> > @@ -14,7 +13,7 @@ BEGIN
> >   	setopt("Harding");
> >   	setopt("Hoover");
> >   	setopt("Bush");
> > -	setopt("quiet", "hell no");
> > +	setopt("quiet", "um, no");
> >   	setopt("aggrate", "0.5hz");
> >   	setopt("bufsize", "1m");
> >   	exit(0);
> > diff --git a/test/unittest/actions/setopt/tst.badopt.r b/test/unittest/actions/setopt/tst.badopt.r
> > new file mode 100644
> > index 00000000..29e39fd4
> > --- /dev/null
> > +++ b/test/unittest/actions/setopt/tst.badopt.r
> > @@ -0,0 +1,16 @@
> > +
> > +-- @@stderr --
> > +dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): couldn't set option "Nixon" to "1": Invalid option name
> > +
> > +dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): couldn't set option "Harding" to "1": Invalid option name
> > +
> > +dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): couldn't set option "Hoover" to "1": Invalid option name
> > +
> > +dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): couldn't set option "Bush" to "1": Invalid option name
> > +
> > +dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): couldn't set option "quiet" to "um, no": Invalid value for specified option
> > +
> > +dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): couldn't set option "aggrate" to "0.5hz": Invalid value for specified option
> > +
> > +dtrace: error on enabled probe ID 2 (ID 1: dtrace:::BEGIN): couldn't set option "bufsize" to "1m": Operation illegal when tracing is active
> > +
> > diff --git a/test/unittest/misc/tst.badopt.r b/test/unittest/misc/tst.badopt.r
> > deleted file mode 100644
> > index 9cb25fd7..00000000
> > --- a/test/unittest/misc/tst.badopt.r
> > +++ /dev/null
> > @@ -1,16 +0,0 @@
> > -
> > --- @@stderr --
> > -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): couldn't set option "Nixon" to "1": Invalid option name
> > -
> > -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): couldn't set option "Harding" to "1": Invalid option name
> > -
> > -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): couldn't set option "Hoover" to "1": Invalid option name
> > -
> > -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): couldn't set option "Bush" to "1": Invalid option name
> > -
> > -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): couldn't set option "quiet" to "hell no": Invalid value for specified option
> > -
> > -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): couldn't set option "aggrate" to "0.5hz": Invalid value for specified option
> > -
> > -dtrace: error on enabled probe ID 1 (ID 1: dtrace:::BEGIN): couldn't set option "bufsize" to "1m": Operation illegal when tracing is active
> > -
> > diff --git a/test/unittest/setopt/err.D_PROTO_LEN.toomany.r b/test/unittest/setopt/err.D_PROTO_LEN.toomany.r
> > deleted file mode 100644
> > index 773bc104..00000000
> > --- a/test/unittest/setopt/err.D_PROTO_LEN.toomany.r
> > +++ /dev/null
> > @@ -1,2 +0,0 @@
> > --- @@stderr --
> > -dtrace: failed to compile script test/unittest/setopt/err.D_PROTO_LEN.toomany.d: [D_PROTO_LEN] line 18: setopt( ) prototype mismatch: 3 args passed, at most 2 expected
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list