Linux DTrace development list
 help / color / mirror / Atom feed
From: Eugene Loh <eugene.loh@oracle.com>
To: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH v2] Make sure all probes are listed in default case
Date: Tue, 5 Aug 2025 16:21:56 -0400	[thread overview]
Message-ID: <d4666188-72de-e118-8f56-711a36ba664c@oracle.com> (raw)
In-Reply-To: <20250805190836.18761-1-eugene.loh@oracle.com>

This patch is withdrawn.  The v1 is apparently already queued up, so I 
just posted a different patch to amend the v1.  (The problem was that 
tcp support was added since this patch was originally posted.)

On 8/5/25 15:08, eugene.loh@oracle.com wrote:
> From: Eugene Loh <eugene.loh@oracle.com>
>
> Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
> Reviewed-by: Nick Alcock <nick.alcock@oracle.com>
> ---
>   INCOMPATIBILITIES                           |  2 +-
>   cmd/dtrace.c                                | 11 +++
>   test/unittest/dtrace-util/tst.ListProbes.r  | 14 ++++
>   test/unittest/dtrace-util/tst.ListProbes.sh | 83 +++++++++++++++++++++
>   4 files changed, 109 insertions(+), 1 deletion(-)
>   create mode 100644 test/unittest/dtrace-util/tst.ListProbes.r
>   create mode 100755 test/unittest/dtrace-util/tst.ListProbes.sh
>
> diff --git a/INCOMPATIBILITIES b/INCOMPATIBILITIES
> index 035c3675b..bf55019ec 100644
> --- a/INCOMPATIBILITIES
> +++ b/INCOMPATIBILITIES
> @@ -8,7 +8,7 @@ Missing providers
>   Difficulty: Medium
>   Likelihood: High
>   
> -A number of providers are missing, including pid, fbt, and net.
> +Some providers are missing.
>   
>   
>   
> diff --git a/cmd/dtrace.c b/cmd/dtrace.c
> index e0e778db0..ed517abff 100644
> --- a/cmd/dtrace.c
> +++ b/cmd/dtrace.c
> @@ -1443,6 +1443,17 @@ main(int argc, char *argv[])
>   			list_prog(&g_cmdv[i]);
>   
>   		if (g_cmdc == 0) {
> +			dtrace_cmd_t pseudo_cmd;
> +
> +			/*
> +			 * If we are listing the default case "dtrace -l",
> +			 * compile the string ":::" to give providers an
> +			 * attempt to provide probes.
> +			 */
> +			pseudo_cmd.dc_spec = DTRACE_PROBESPEC_NAME;
> +			pseudo_cmd.dc_arg = ":::";
> +			compile_str(&pseudo_cmd);
> +
>   			if (dtrace_probe_iter(g_dtp, NULL, list_probe, NULL) < 0)
>   				dfatal(NULL); /* dtrace_errmsg() only */
>   		}
> diff --git a/test/unittest/dtrace-util/tst.ListProbes.r b/test/unittest/dtrace-util/tst.ListProbes.r
> new file mode 100644
> index 000000000..ad557253f
> --- /dev/null
> +++ b/test/unittest/dtrace-util/tst.ListProbes.r
> @@ -0,0 +1,14 @@
> +cpc
> +dtrace
> +fbt
> +io
> +ip
> +lockstat
> +proc
> +profile
> +rawfbt
> +rawtp
> +sched
> +sdt
> +syscall
> +tcp
> diff --git a/test/unittest/dtrace-util/tst.ListProbes.sh b/test/unittest/dtrace-util/tst.ListProbes.sh
> new file mode 100755
> index 000000000..a747a0458
> --- /dev/null
> +++ b/test/unittest/dtrace-util/tst.ListProbes.sh
> @@ -0,0 +1,83 @@
> +#!/bin/bash
> +#
> +# Oracle Linux DTrace.
> +# Copyright (c) 2025, 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:
> +# Testing -l option gives reasonable numbers of probes for each provider.
> +#
> +# SECTION: dtrace Utility/-ln Option
> +##
> +
> +dtrace=$1
> +
> +# Decide whether to expect lockstat (disabled prior to 5.10).
> +read MAJOR MINOR <<< `uname -r | grep -Eo '^[0-9]+\.[0-9]+' | tr '.' ' '`
> +if [ $MAJOR -gt 5 ]; then
> +        expect_lockstat=1
> +elif [ $MAJOR -eq 5 -a $MINOR -ge 10 ]; then
> +        expect_lockstat=1
> +else
> +        expect_lockstat=0
> +fi
> +
> +# Run "dtrace -l", print the providers, aggregate by provider, then confirm counts.
> +$dtrace $dt_flags -l \
> +| gawk '{ print $2 }' \
> +| sort | uniq -c \
> +| gawk -v LCKSTT=$expect_lockstat '
> +
> +    BEGIN {
> +        nerr = 0;
> +
> +        # Fake lockstat if not expected.
> +        if (LCKSTT == 0) print "lockstat";
> +    }
> +
> +    function mycheck(lbl, val, valmin, valmax) {
> +        print lbl;
> +        if (val < valmin) { print "ERROR:", lbl, val, "< MIN =", valmin; nerr++ }
> +        if (val > valmax) { print "ERROR:", lbl, val, "> MAX =", valmax; nerr++ }
> +    }
> +
> +    # Skip the banner.
> +    /^ +1 PROVIDER$/ { next }
> +
> +    # Wrong number of fields.
> +    NF != 2 {
> +        print "ERROR: wrong number of fields", $0;
> +        nerr++;
> +        next;
> +    }
> +
> +    # Recognize some providers; apply sanity check on number of probes.
> +    $2 == "cpc"      { mycheck($2, $1,     5,    500); next }
> +    $2 == "dtrace"   { mycheck($2, $1,     3,      3); next }
> +    $2 == "fbt"      { mycheck($2, $1, 30000, 300000); next }
> +    $2 == "io"       { mycheck($2, $1,     2,     20); next }
> +    $2 == "ip"       { mycheck($2, $1,     2,     20); next }
> +    $2 == "lockstat" { mycheck($2, $1,     4,     40); next }
> +    # nothing for pid
> +    $2 == "proc"     { mycheck($2, $1,     6,     30); next }
> +    $2 == "profile"  { mycheck($2, $1,     6,     30); next }
> +    $2 == "rawfbt"   { mycheck($2, $1, 30000, 300000); next }
> +    $2 == "rawtp"    { mycheck($2, $1,   600,   6000); next }
> +    $2 == "sched"    { mycheck($2, $1,     3,     30); next }
> +    $2 == "sdt"      { mycheck($2, $1,   600,   6000); next }
> +    $2 == "syscall"  { mycheck($2, $1,   300,   3000); next }
> +    $2 == "tcp"      { mycheck($2, $1,     8,      8); next }
> +    # nothing for usdt
> +
> +    # Unrecognized line.
> +    {
> +        print "ERROR: unrecognized line", $0;
> +        nerr++;
> +    }
> +
> +    END { exit(nerr == 0 ? 0 : 1) }'
> +
> +exit $?

      reply	other threads:[~2025-08-05 20:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-05 19:08 [PATCH v2] Make sure all probes are listed in default case eugene.loh
2025-08-05 20:21 ` Eugene Loh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d4666188-72de-e118-8f56-711a36ba664c@oracle.com \
    --to=eugene.loh@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox