Blame SOURCES/rhbz1643997.0001-testsuite-systemtap.bpf-diagnose-a-bug-in-print_form.patch

583230
From 16e9cfa909a183d8e61142d80575189408a2a244 Mon Sep 17 00:00:00 2001
583230
From: Serhei Makarov <smakarov@redhat.com>
583230
Date: Wed, 24 Oct 2018 15:56:44 -0400
583230
Subject: [PATCH 01/32] testsuite/systemtap.bpf :: diagnose a bug in
583230
 print_format("%s%s", ...)
583230
583230
---
583230
 testsuite/systemtap.bpf/asm_tests/string-basic.stp | 19 ++++++++++
583230
 testsuite/systemtap.bpf/bpf_tests/string3.stp      | 44 ++++++++++++++++++++++
583230
 2 files changed, 63 insertions(+)
583230
 create mode 100644 testsuite/systemtap.bpf/asm_tests/string-basic.stp
583230
 create mode 100644 testsuite/systemtap.bpf/bpf_tests/string3.stp
583230
583230
diff --git a/testsuite/systemtap.bpf/asm_tests/string-basic.stp b/testsuite/systemtap.bpf/asm_tests/string-basic.stp
583230
new file mode 100644
583230
index 000000000..7377e4399
583230
--- /dev/null
583230
+++ b/testsuite/systemtap.bpf/asm_tests/string-basic.stp
583230
@@ -0,0 +1,19 @@
583230
+/* narrowing down a bug that turned out unrelated to assembly */
583230
+function foo:string() %{ /* bpf */ /* pure */
583230
+  0xbf, $$, "test", -, -;
583230
+%}
583230
+
583230
+probe begin {
583230
+  printf("U %s %s\n", foo(), "test"/*bar (5)*/)
583230
+}
583230
+
583230
+probe kernel.function("vfs_read") {
583230
+  printf("K 1 %s\n", foo()) // <- this worked
583230
+  printf("K 2 %s\n", "test") // <- this worked
583230
+  printf("K 3 %s %s\n", foo(), "test") // <- this didn't
583230
+  printf("K 4 %s %s\n", "test", "test") // <- this didn't
583230
+  printf("K 5 %s %s\n", foo(), foo()) // <- this didn't
583230
+  printf("K 6 %s", "test") printf(" %s\n", "test") // <- this did
583230
+  printf("K %d %s\n", 7, "test") // <- this did
583230
+  exit()
583230
+}
583230
diff --git a/testsuite/systemtap.bpf/bpf_tests/string3.stp b/testsuite/systemtap.bpf/bpf_tests/string3.stp
583230
new file mode 100644
583230
index 000000000..cf6ec071d
583230
--- /dev/null
583230
+++ b/testsuite/systemtap.bpf/bpf_tests/string3.stp
583230
@@ -0,0 +1,44 @@
583230
+// stapbpf string manipulation -- store string in global from kernel space
583230
+// XXX: the 'locking' scheme here is kind of dumb but it seems to work
583230
+
583230
+global counter = 0
583230
+global var
583230
+global tab1
583230
+global tab2
583230
+
583230
+@define test_print
583230
+%(
583230
+  /* Test multiple %s in one printf */
583230
+  printf("[")
583230
+  printf("%s%s%s", "str0", var, tab1[17])
583230
+  printf("%s]", tab2["key"])
583230
+%)
583230
+
583230
+probe begin {
583230
+  printf("BEGIN")
583230
+}
583230
+
583230
+probe kernel.function("vfs_read") {
583230
+  if (counter == 0) {
583230
+    var = "str1"
583230
+    tab1[17] = "str2"
583230
+    tab2["key"] = "str3"
583230
+    printf("probe0")
583230
+    @test_print
583230
+    counter = 1
583230
+  }
583230
+}
583230
+
583230
+probe kernel.function("vfs_read") {
583230
+  if (counter == 1) {
583230
+    printf("probe1")
583230
+    @test_print
583230
+    exit()
583230
+  }
583230
+}
583230
+
583230
+probe end {
583230
+  printf("end")
583230
+  @test_print
583230
+  printf("END\n")
583230
+}
583230
-- 
583230
2.14.5
583230