]> sourceware.org Git - systemtap.git/commitdiff
PR13838: add floating point to systemtap.examples
authorAlice Zhang <alizhang@redhat.com>
Thu, 5 Nov 2020 04:07:11 +0000 (23:07 -0500)
committerAlice Zhang <alizhang@redhat.com>
Thu, 5 Nov 2020 18:12:58 +0000 (13:12 -0500)
testsuite/systemtap.examples/general/floatingpoint.*: add a demo for extracting
fp and performing some basic fp operations.

printing out results of every operation, print out combinations of two to three
operations.

testsuite/systemtap.examples/general/floatingpoint.meta [new file with mode: 0644]
testsuite/systemtap.examples/general/floatingpoint.stp [new file with mode: 0644]
testsuite/systemtap.examples/general/floatingpoint.txt [new file with mode: 0644]

diff --git a/testsuite/systemtap.examples/general/floatingpoint.meta b/testsuite/systemtap.examples/general/floatingpoint.meta
new file mode 100644 (file)
index 0000000..a0ba6b4
--- /dev/null
@@ -0,0 +1,7 @@
+title: SystemTap "Floating Point" Program
+name: floatingpoint.stp
+keywords: simple floatingpoint
+description: A basic "Floating Point" program implemented in SystemTap script. It extracts floating point from benchmark-sdt section in main.cxx and takes one pseudo floating point, printing out results of various simple floating point operations.
+test_check: stap -p4 floatingpoint.stp -c "stap --benchmark-sdt"
+test_installcheck: stap floatingpoint.stp -c "stap --benchmark-sdt"
+
diff --git a/testsuite/systemtap.examples/general/floatingpoint.stp b/testsuite/systemtap.examples/general/floatingpoint.stp
new file mode 100644 (file)
index 0000000..3e7751b
--- /dev/null
@@ -0,0 +1,20 @@
+#! /usr/bin/env stap
+
+function printlnfp(a) { println(fp_to_string(a,5)) }
+
+probe process("stap").function("sdt_benchmark_thread") {
+    a = user_long($fpointer)
+
+    b = string_to_fp("3.14")
+    c = long_to_fp(2)
+
+    printf("round 3.14 to long : %ld\n", fp_to_long(b, 0, 0))
+    
+    print("a + b * c = ")
+    printlnfp(fp_add(a, fp_mul(b, c)))
+
+    printf("sqrt(b) >= b / c : ")
+    println(fp_lt(fp_sqrt(b), fp_div(b, c)))
+
+    exit()
+}
diff --git a/testsuite/systemtap.examples/general/floatingpoint.txt b/testsuite/systemtap.examples/general/floatingpoint.txt
new file mode 100644 (file)
index 0000000..6ad6a74
--- /dev/null
@@ -0,0 +1,5 @@
+% stap -v floatingpoint.stp -c "stap --benchmark-sdt"
+
+round 3.14 to long : 3
+a + b * c = 8.99828
+sqrt(b) >= b / c : 0
This page took 0.031787 seconds and 5 git commands to generate.