0d840a
commit ffb40c659a690f4341e43051f6d5114732b3fe46
0d840a
Author: Frank Ch. Eigler <fche@redhat.com>
0d840a
Date:   Thu Mar 5 07:17:04 2020 -0500
0d840a
0d840a
    RHBZ1810216: fix ftrace() tapset function related autoconf test
0d840a
    
0d840a
    It was reported that the ftrace() tapset function stopped working at
0d840a
    some point - due to an autoconf-* false negative.  We failed to notice
0d840a
    because the tapset function was quietly mapped to a nop in this case.
0d840a
    Now ftrace() will #error in -p4 if autoconf doesn't detect a suitable
0d840a
    kernel facility.  A forked testcase buildok/logging-embedded2.stp
0d840a
    checks for it.
0d840a
    
0d840a
    Suggested-by: Oleksandr Natalenko <onatalen@redhat.com>
0d840a
0d840a
diff --git a/runtime/linux/autoconf-trace-printk.c b/runtime/linux/autoconf-trace-printk.c
0d840a
index 8330a58..c7515bc 100644
0d840a
--- a/runtime/linux/autoconf-trace-printk.c
0d840a
+++ b/runtime/linux/autoconf-trace-printk.c
0d840a
@@ -1,4 +1,5 @@
0d840a
 #include <linux/kernel.h>
0d840a
+#include <linux/string.h>
0d840a
 
0d840a
 int bar (void) {
0d840a
   static char *fmt = "%s\n";
0d840a
diff --git a/tapset/linux/logging.stp b/tapset/linux/logging.stp
0d840a
index 6192cf6..b13b5cc 100644
0d840a
--- a/tapset/linux/logging.stp
0d840a
+++ b/tapset/linux/logging.stp
0d840a
@@ -25,6 +25,8 @@ function ftrace (msg:string) %{ /* unmodified-fnargs */
0d840a
        to defeat trace_printk -> __trace_bprintk optimization.  That's
0d840a
        because bprintk doesn't save the incoming strings, only their
0d840a
        addresses. */
0d840a
+#else
0d840a
+  #error "trace_printk not supported"
0d840a
 #endif
0d840a
 %}
0d840a
 
0d840a
diff --git a/testsuite/buildok/logging-embedded.stp b/testsuite/buildok/logging-embedded.stp
0d840a
index c97bd5a..7e2f15d 100755
0d840a
--- a/testsuite/buildok/logging-embedded.stp
0d840a
+++ b/testsuite/buildok/logging-embedded.stp
0d840a
@@ -8,6 +8,6 @@ probe begin {
0d840a
       exit()
0d840a
       error("error")
0d840a
       stp_print_binary(1, 0, 0, 0, 0)
0d840a
-      ftrace("ftrace")
0d840a
+      // ftrace() tested in logging-embedded2.stp
0d840a
       printk(0,"Zoink!  The paper tape punch is burning chads!")
0d840a
 }
0d840a
diff --git a/testsuite/buildok/logging-embedded2.stp b/testsuite/buildok/logging-embedded2.stp
0d840a
new file mode 100755
0d840a
index 0000000..528d5d0
0d840a
--- /dev/null
0d840a
+++ b/testsuite/buildok/logging-embedded2.stp
0d840a
@@ -0,0 +1,7 @@
0d840a
+#! stap -gp4
0d840a
+
0d840a
+// build-test the logging tapset functions - ftrace() only usable if STAPCONF detects it
0d840a
+
0d840a
+probe begin {
0d840a
+      ftrace("ftrace")
0d840a
+}