[DTrace-devel] [PATCH v2] sdt and syscall probe descriptions broken when multiple probes

Kris Van Hees kris.van.hees at oracle.com
Tue Oct 20 18:26:04 PDT 2020


Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>

On Tue, Oct 20, 2020 at 06:01:22PM -0400, eugene.loh at oracle.com wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> The sdt and syscall providers are broken in that, when a probe
> description corresponds to multiple probes, a BPF program is
> attached to only one of the probes.  E.g., syscall:::entry will
> attach a BPF program to only one probe, even though hundreds of
> probes are indicated!  The problem is that the attach function
> looks for an event_id, skipping the probe if there is no such ID,
> but the ID exists for only the "representative probe."
> 
> Therefore, call dt_probe_info() when we append probes to the
> dt_enablings list.
> 
> What is surprising is that, with this fix, there are no XPASS
> tests.  That is, there had presumably been no XFAIL tests
> ("expected fails") that had been failing due *only* to this
> problem.  A quick survey of tests suggests that this is likely;
> remarkably few tests rely on such functionality, and those that
> do still fail due to other missing support (such as strings or
> other providers).
> 
> Therefore, add a test to check the fix.
> 
> Orabug: 32036431
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
>  libdtrace/dt_program.c            |  6 +++++-
>  test/unittest/syscall/tst.entry.d | 20 ++++++++++++++++++++
>  test/unittest/syscall/tst.entry.r |  5 +++++
>  3 files changed, 30 insertions(+), 1 deletion(-)
>  create mode 100644 test/unittest/syscall/tst.entry.d
>  create mode 100644 test/unittest/syscall/tst.entry.r
> 
> diff --git a/libdtrace/dt_program.c b/libdtrace/dt_program.c
> index b82cc85c..a5f21617 100644
> --- a/libdtrace/dt_program.c
> +++ b/libdtrace/dt_program.c
> @@ -146,8 +146,12 @@ typedef struct pi_state {
>  static int
>  dt_stmt_probe(dtrace_hdl_t *dtp, dt_probe_t *prp, pi_state_t *st)
>  {
> -	if (!dt_in_list(&dtp->dt_enablings, prp))
> +	if (!dt_in_list(&dtp->dt_enablings, prp)) {
> +		dtrace_probeinfo_t p;
> +
> +		dt_probe_info(dtp, prp->desc, &p);
>  		dt_list_append(&dtp->dt_enablings, prp);
> +	}
>  
>  	dt_probe_add_clause(dtp, prp, st->idp);
>  	(*st->cnt)++;
> diff --git a/test/unittest/syscall/tst.entry.d b/test/unittest/syscall/tst.entry.d
> new file mode 100644
> index 00000000..f2d56150
> --- /dev/null
> +++ b/test/unittest/syscall/tst.entry.d
> @@ -0,0 +1,20 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 2020, 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.
> + */
> +
> +/* @@trigger: syscall-tst-args */
> +/* @@trigger-timing: before */
> +/* @@runtest-opts: $_pid */
> +
> +/* check that syscall:::entry picks up mmap:entry */
> +/* (mmap is called repeatedly by the trigger) */
> +/* trigger-timing and runtest-opts are used since -c is not yet supported */
> +
> +syscall:::entry
> +/pid == $1/
> +{
> +    exit(0);
> +}
> diff --git a/test/unittest/syscall/tst.entry.r b/test/unittest/syscall/tst.entry.r
> new file mode 100644
> index 00000000..8066c23f
> --- /dev/null
> +++ b/test/unittest/syscall/tst.entry.r
> @@ -0,0 +1,5 @@
> +                   FUNCTION:NAME
> +                      mmap:entry 
> +
> +-- @@stderr --
> +dtrace: script 'test/unittest/syscall/tst.entry.d' matched 333 probes
> -- 
> 2.18.4
> 
> 
> _______________________________________________
> 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