]> sourceware.org Git - systemtap.git/commitdiff
Support softfloat by dyninst backend.
authorStan Cox <scox@redhat.com>
Wed, 13 Oct 2021 16:43:35 +0000 (12:43 -0400)
committerStan Cox <scox@redhat.com>
Wed, 13 Oct 2021 16:43:35 +0000 (12:43 -0400)
The softfloat library has conflicting types for some types defined in
stdint.h, which -dyninst includes, so avoid by using cpp to redefine
them.  Add a float test to sdt_types.c.  Only test dyninst with
V3_uprobe.  Add x8664 float registers to register definition used by
dyninst.

runtime/loc2c-runtime.h
runtime/softfloat.c
testsuite/systemtap.base/sdt_misc.exp
testsuite/systemtap.base/sdt_types.c
testsuite/systemtap.base/sdt_types.stp

index e6c624d37478a0ae24fc0de850a4030f4e30ae97..073ba04d2cece477f6d524a9027692736803bcf3 100644 (file)
 #define pt_dwarf_register_13(regs)     regs->r13
 #define pt_dwarf_register_14(regs)     regs->r14
 #define pt_dwarf_register_15(regs)     regs->r15
-#define pt_regs_maxno 15
+#define pt_dwarf_register_17(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm0, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_18(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm1, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_19(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm2, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_20(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm3, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_21(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm4, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_22(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm5, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_23(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm6, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_24(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm7, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_25(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm8, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_26(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm9, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_27(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm10, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_28(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm11, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_29(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm12, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_30(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm13, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_31(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm14, %0" : "=r"(v)); v;})
+#define pt_dwarf_register_32(regs) ({uint64_t v; __asm__ __volatile__("movq %%xmm15, %0" : "=r"(v)); v;})
+#define pt_regs_maxno 32
   
 #elif defined __powerpc__
 
index 6951933709a8b59e432778911ef2f5786d03951c..709e45d2f4ca9358a4f4cc131e2db8f1f0fcad04 100644 (file)
@@ -35,6 +35,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 //#include <stdbool.h>
 //#include <stdint.h>
+/* --dyninst includes stdint.h so avoid stdint.h conflicts
+ * INT64_C and UINT64_C are macros so undef them
+ * *fast* are typedefs so define them
+ * TODO: Consider changing softfloat to use stdint defs
+ */
+#undef INT64_C
+#undef UINT64_C
+#define int_fast16_t sf_int_fast16_t
+#define uint_fast16_t sf_uint_fast16_t
+#define int_fast32_t sf_int_fast32_t
+#define uint_fast32_t sf_uint_fast32_t
 #include "softfloat/platform.h"
 #include "softfloat/internals.h"
 #include "softfloat.h"
index 3d7b400401db1083757c604aee448cb66b18b9ab..f90daa9c54e41b5ef2fac26f32f5342737e86e41 100644 (file)
@@ -101,6 +101,8 @@ for {set i 0} {$i < [llength $pbtype_flags]} {incr i} {
     # 1. Test executable built with dtrace generated header file
     
     foreach runtime [get_runtime_list] {
+       if {$runtime == "dyninst" && $pbtype_mssg != "V3_uprobe"} {
+           continue }
        set test_xtra ""
        if {$runtime != ""} {
            set test_xtra " ($runtime)"
@@ -158,6 +160,8 @@ for {set i 0} {$i < [llength $pbtype_flags]} {incr i} {
     }
     
     foreach runtime [get_runtime_list] {
+       if {$runtime == "dyninst" && $pbtype_mssg != "V3_uprobe"} {
+           continue }
        set test_xtra ""
        if {$runtime != ""} {
            set test_xtra " ($runtime)"
@@ -280,9 +284,7 @@ for {set i 0} {$i < [llength $pbtype_flags]} {incr i} {
            # On ARM these tests are known to fail with timeout for V1
            # and V2 probes.  Skip them altogether to speed execution.
            if {[istarget "arm*-*-*"] \
-                   && ($pbtype_mssg == "V1_uprobe" \
-                           || $pbtype_mssg == "V2_kprobe" \
-                           || $pbtype_mssg == "V2_uprobe")} {
+                   && ($pbtype_mssg == "V1_uprobe" || $pbtype_mssg == "V2_uprobe")} {
                xfail "$test types $test_suffix"
                continue
            }
@@ -306,6 +308,8 @@ for {set i 0} {$i < [llength $pbtype_flags]} {incr i} {
            }
            
            foreach runtime [get_runtime_list] {
+               if {$runtime == "dyninst" && $pbtype_mssg != "V3_uprobe"} {
+                   continue }
                set test_xtra ""
                if {$runtime != ""} {
                    set test_xtra " ($runtime)"
@@ -324,6 +328,7 @@ for {set i 0} {$i < [llength $pbtype_flags]} {incr i} {
                set notok 0
                set fail ""
                set uns_notok 0
+               set float_notok 0
                expect {
                    -timeout 180
                    # i386 unsigned may xfail because of sign extension
@@ -333,6 +338,8 @@ for {set i 0} {$i < [llength $pbtype_flags]} {incr i} {
                        set s $expect_out(1,string);
                        if {[regexp "unsigned" $s] && [istarget "i*86-*-*"]} {
                            incr uns_notok }
+                       if {[regexp "float" $s] || [regexp "double" $s]} {
+                           incr float_notok }
                        incr notok; set fail "$fail $s"; exp_continue }
                    -re {^[^\r]*\r\n} { incr notok; exp_continue }
                    timeout { fail "$test types (timeout) $test_suffix" }
@@ -341,7 +348,15 @@ for {set i 0} {$i < [llength $pbtype_flags]} {incr i} {
                catch {close}; catch {wait}
                
                if { $notok != 0 || $ok == 0} {
-                   if { [lindex $type_xfail $j] || $notok == $uns_notok} {
+                   if { $notok == $float_notok } {
+                       # Ignore float failures for V1, V2, and dyninst
+                       if { $pbtype_mssg != "V3_uprobe" || $runtime == "dyninst" } {
+                           pass "$test types $test_suffix"
+                       } else {
+                           incr fail_count
+                           fail "$test types $fail $test_suffix"
+                       }
+                   } elseif { [lindex $type_xfail $j] || $notok == $uns_notok } {
                        xfail "$test types $fail $test_suffix"
                    } else {
                        incr fail_count
@@ -379,6 +394,8 @@ for {set i 0} {$i < [llength $pbtype_flags]} {incr i} {
     }
     
     foreach runtime [get_runtime_list] {
+       if {$runtime == "dyninst" && $pbtype_mssg != "V3_uprobe"} {
+           continue }
        set test_xtra ""
        if {$runtime != ""} {
            set test_xtra " ($runtime)"
@@ -444,6 +461,8 @@ for {set i 0} {$i < [llength $pbtype_flags]} {incr i} {
     }
     
     foreach runtime [get_runtime_list] {
+       if {$runtime == "dyninst" && $pbtype_mssg != "V3_uprobe"} {
+           continue }
        set test_xtra ""
        if {$runtime != ""} {
            set test_xtra " ($runtime)"
@@ -568,6 +587,8 @@ for {set i 0} {$i < [llength $pbtype_flags]} {incr i} {
 # 7. Test V3 $$parms support
 
 foreach runtime [get_runtime_list] {
+    if {$runtime == "dyninst" && $pbtype_mssg != "V3_uprobe"} {
+       continue }
     set test_xtra ""
     if {$runtime != ""} {
        set test_xtra " ($runtime)"
index 6d99ccdcb539a8a40fd6bc8d136a3ed0c0f0316d..060bc0235d6e8fed5f9cd4051509705272ac707f 100644 (file)
@@ -1,6 +1,7 @@
 #include "sys/sdt.h"
 #include <stdint.h>
 #include <values.h>
+#include <stdio.h>
 
 struct opaque;
 
@@ -48,6 +49,7 @@ main (int argc, char **argv)
   long int * volatile long_int_ptr_volatile_var = &long_int_var;
 
   /* c89 doesn't define __STDC_VERSION. With -pedantic warns about long long. */
+
 #if ! defined NO_LONG_LONG && __SIZEOF_SIZE_T__ == 8
   long long int long_long_int_var = 0x7fffffffffffffffLL;
   const long long int const_long_long_int_var = -0x7fffffffffffffffLL;
@@ -106,6 +108,12 @@ main (int argc, char **argv)
   struct opaque_struct *incomplete_struct_type = 0;
 # endif
 
+  float float_var;
+  double double_var;
+  /* Avoid float_var being treated as .Label(Reg) which is not supported by stap */
+  sscanf("3.14159", "%f", &float_var);
+  double_var = (double)float_var;
+
   /* gnu90 and gnu99 don't support this so for now don't test it
      enum opaque_enum *incomplete_enum_type = 0; */
 
@@ -152,6 +160,10 @@ main (int argc, char **argv)
   STAP_PROBE2(provider,ptr_volatile_long_int_var,ptr_volatile_long_int_var,&long_int_var);
   STAP_PROBE2(provider,long_int_ptr_volatile_var,long_int_ptr_volatile_var,&long_int_var);
 
+  /* float / double */
+  STAP_PROBE1(provider,float_var,float_var);
+  STAP_PROBE1(provider,double_var,double_var);
+
   /* long long */
 #if ! defined NO_LONG_LONG && __SIZEOF_SIZE_T__ == 8
   STAP_PROBE1(provider,long_long_int_var,long_long_int_var);
index 6bb2ecc8e430ae0aecd33520b3598f4d48459653..4e2230114ff6fbf139281c60c172599d37c87a24 100644 (file)
@@ -6,6 +6,18 @@ function check(name, value, expected)
     printf ("sdt_types FAIL: %s (%#x != %#x)\n", name, value, expected)
 }
 
+function check_float(name, value, expected, need_double)
+{
+  if (need_double)
+    value = fp32_to_fp64(value)
+  range = string_to_fp("0.00001")
+  /* Check that value is in the interval [expected - range < x < expected + range] */
+  if (fp_le(fp_sub(expected,range),value) && fp_le(value,fp_add(expected,range)))
+    printf ("sdt_types PASS: %s\n", name)
+  else
+    printf ("sdt_types FAIL: %s (%s != %s)\n", name, fp_to_string(value,8), fp_to_string(expected,8))
+}
+
 function check_string(name, value, expected)
 {
   if (value == expected)
@@ -232,6 +244,18 @@ probe process(@1).mark("long_int_ptr_volatile_var")
 }
 
 
+/********** float / double **********/
+
+probe process(@1).mark("float_var")
+{
+  check_float($$name, $arg1, string_to_fp("3.14159"),1)
+}
+
+probe process(@1).mark("double_var")
+{
+  check_float($$name, $arg1, string_to_fp("3.14159"),0)
+}
+
 /********** long long **********/
 
 probe process(@1).mark("long_long_int_var") ?
This page took 0.086268 seconds and 5 git commands to generate.