+++ /dev/null
-#! stap -p2
-
-@define foo
--- /dev/null
+#! stap -p2
+
+# use before define
+@kaprobe (begin)
+
+@define kaprobe(
+ a)
+
+%(
+ probe @a {
+ foo = 2+2
+ print(foo)
+ }
+%)
--- /dev/null
+#! stap -p2
+
+# interpreted as empty one-line macro
+# contrast parseok/macros11.stp and parseok/macros12.stp
+@define whatemptyfoo(a,b,c)
+
+%( @a
++ @b
++ @c %) # not taken as the macro body!
--- /dev/null
+#! stap -p2
+
+# "expected %( for multiline macro
+
+@define foo(bar,
+ baz)
+ this is not a good macro body
--- /dev/null
+#! stap -p2
+
+# empty definition
+@define foo
+
+probe begin @foo { print(42) }
--- /dev/null
+#! stap -p2
+
+@define oneline(a,b) ((@a)+(@b))
+@define foo(a) @a
+
+probe @foo(begin) { print(@oneline(2,2)) }
--- /dev/null
+#! stap -p2
+
+# special case of multiline macro parsing
+# note macro signature spills over multiple lines
+@define kaprobe(
+ a)
+
+%(
+ probe @a {
+ foo = 2+2
+ print(foo)
+ }
+%)
+
+@kaprobe(begin)
--- /dev/null
+#! stap -p2
+
+@define empty(ingored)
+
+# next, a conditional -- NOT the macro body
+%( kernel_v > "3.0" %?
+ probe begin { printf("foo") }
+%:
+ probe begin { printf("bar") }
+%)
--- /dev/null
+#! stap -p2
+
+@define irrelevant(foo,
+ bar) %( what about this? %)
+
+probe begin { print("Hello, World!\n") }