Make sure all probes are listed in default case
PATCH v2 1/1 Make sure all probes are listed in default case
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>
Reviewed-by Nick Alcock <[email protected]>
--- 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
INCOMPATIBILITIES +1 -1
@@ -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.
cmd/dtrace.c +11 -0
@@ -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 */ }
test/unittest/dtrace-util/tst.ListProbes.r new file +14 -0
@@ -0,0 +1,14 @@ +cpc +dtrace +fbt +io +ip +lockstat +proc +profile +rawfbt +rawtp +sched +sdt +syscall +tcp
test/unittest/dtrace-util/tst.ListProbes.sh new file +83 -0
83 lines not on this page · raw message
Signature · 1 line
2.43.5
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.)
Quoted 157 lines · On 8/5/25 15:08, [email protected] wrote:
From: Eugene Loh <[email protected]>
Signed-off-by Eugene Loh <[email protected]>Reviewed-by Nick Alcock <[email protected]>--- 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.shINCOMPATIBILITIES +1
-1@@ -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.cmd/dtrace.c +11
-0@@ -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 */ }test/unittest/dtrace-util/tst.ListProbes.r new file +14
-0@@ -0,0 +1,14 @@ +cpc +dtrace +fbt +io +ip +lockstat +proc +profile +rawfbt +rawtp +sched +sdt +syscall +tcptest/unittest/dtrace-util/tst.ListProbes.sh new file +83
-0@@ -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 $?