summaryrefslogtreecommitdiff
path: root/regress/usr.sbin/btrace
diff options
context:
space:
mode:
authorDave Voutila <dv@cvs.openbsd.org>2023-08-28 21:23:47 +0000
committerDave Voutila <dv@cvs.openbsd.org>2023-08-28 21:23:47 +0000
commitb971e146a300036233b149e1299a7499ef5fab0c (patch)
treebc780aa18c7fbc007ee074d275d3753532d627cc /regress/usr.sbin/btrace
parent2510c085cc4e18102f8257c1c5c7c5870401d3b7 (diff)
btrace(8): prohibit use of argN builtins in BEGIN/END.
The argN builtins are undefined for BEGIN and END special probes. Similar to bpftrace, produce an error from the parser. Adds a regress test, as well. ok mpi@
Diffstat (limited to 'regress/usr.sbin/btrace')
-rw-r--r--regress/usr.sbin/btrace/Makefile6
-rw-r--r--regress/usr.sbin/btrace/beginend-argn.bt8
-rw-r--r--regress/usr.sbin/btrace/beginend-argn.ok6
3 files changed, 17 insertions, 3 deletions
diff --git a/regress/usr.sbin/btrace/Makefile b/regress/usr.sbin/btrace/Makefile
index 29f90cef4b9..e1d39991082 100644
--- a/regress/usr.sbin/btrace/Makefile
+++ b/regress/usr.sbin/btrace/Makefile
@@ -1,11 +1,11 @@
-# $OpenBSD: Makefile,v 1.27 2023/08/13 09:49:47 mpi Exp $
+# $OpenBSD: Makefile,v 1.28 2023/08/28 21:23:46 dv Exp $
BTRACE?= /usr/sbin/btrace
ALLOWDT!= sysctl -n kern.allowdt 2>/dev/null
# scripts that don't need /dev/dt
-BT_LANG_SCRIPTS= arithm beginend boolean comments delete exit \
- histempty if \
+BT_LANG_SCRIPTS= arithm beginend beginend-argn boolean comments delete \
+ exit histempty if \
map mapclear mapempty mapsyntax mapzero map-unnamed \
maxoperand min+max+sum multismts nsecs+var \
precedence print read-map-after-clear staticv-empty \
diff --git a/regress/usr.sbin/btrace/beginend-argn.bt b/regress/usr.sbin/btrace/beginend-argn.bt
new file mode 100644
index 00000000000..7260ad40121
--- /dev/null
+++ b/regress/usr.sbin/btrace/beginend-argn.bt
@@ -0,0 +1,8 @@
+// Test catching invalid use of argN in BEGIN and END contexts.
+BEGIN {
+ print(arg0);
+}
+
+END {
+ print(arg0);
+}
diff --git a/regress/usr.sbin/btrace/beginend-argn.ok b/regress/usr.sbin/btrace/beginend-argn.ok
new file mode 100644
index 00000000000..3c0fb6780e0
--- /dev/null
+++ b/regress/usr.sbin/btrace/beginend-argn.ok
@@ -0,0 +1,6 @@
+beginend-argn.bt:3:11: the arg0 builtin cannot be used with BEGIN or END probes:
+ print(arg0);
+ ^
+beginend-argn.bt:7:11: the arg0 builtin cannot be used with BEGIN or END probes:
+ print(arg0);
+ ^