From: dv Date: Sat, 2 Sep 2023 19:28:46 +0000 (+0000) Subject: btrace(8): allow empty statements in probes. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e817eab93a21b67f02b737b37322f820c9496c38;p=openbsd btrace(8): allow empty statements in probes. Allows for probes like `BEGIN {}`, in parity with bpftrace. Also fixes an incorrect syntax error parsing argN builtins in subsequent probes after an empty BEGIN block. ok mpi@ --- diff --git a/regress/usr.sbin/btrace/Makefile b/regress/usr.sbin/btrace/Makefile index e1d39991082..a5b37cbab83 100644 --- a/regress/usr.sbin/btrace/Makefile +++ b/regress/usr.sbin/btrace/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.28 2023/08/28 21:23:46 dv Exp $ +# $OpenBSD: Makefile,v 1.29 2023/09/02 19:28:46 dv Exp $ BTRACE?= /usr/sbin/btrace ALLOWDT!= sysctl -n kern.allowdt 2>/dev/null @@ -14,7 +14,7 @@ BT_LANG_SCRIPTS= arithm beginend beginend-argn boolean comments delete \ BT_ARG_LANG_SCRIPTS= staticv str # scripts that use kernel probes -BT_KERN_SCRIPTS= filters mapoverwrite multiprobe +BT_KERN_SCRIPTS= empty-stmts filters mapoverwrite multiprobe REGRESS_EXPECTED_FAILURES= run-maxoperand diff --git a/regress/usr.sbin/btrace/empty-stmts.bt b/regress/usr.sbin/btrace/empty-stmts.bt new file mode 100644 index 00000000000..87cd947d5e8 --- /dev/null +++ b/regress/usr.sbin/btrace/empty-stmts.bt @@ -0,0 +1,18 @@ +// Test support for empty statement lists. +BEGIN +{ + exit(); +} + +syscall:open:return +{ +} + +syscall:close:return +/comm != "ksh"/ +{ +} + +END +{ +} \ No newline at end of file diff --git a/regress/usr.sbin/btrace/empty-stmts.ok b/regress/usr.sbin/btrace/empty-stmts.ok new file mode 100644 index 00000000000..e69de29bb2d diff --git a/usr.sbin/btrace/bt_parse.y b/usr.sbin/btrace/bt_parse.y index b2c3bef3b80..b2c3e65854b 100644 --- a/usr.sbin/btrace/bt_parse.y +++ b/usr.sbin/btrace/bt_parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: bt_parse.y,v 1.51 2023/08/28 21:23:46 dv Exp $ */ +/* $OpenBSD: bt_parse.y,v 1.52 2023/09/02 19:28:46 dv Exp $ */ /* * Copyright (c) 2019-2021 Martin Pieuchot @@ -266,6 +266,7 @@ block : action ; action : '{' stmtlist '}' { $$ = $2; } + | '{' '}' { $$ = NULL; } ; %%