]> sourceware.org Git - systemtap.git/commitdiff
Define static user probe point using asm instead of c.
authorStan Cox <scox@redhat.com>
Fri, 20 Mar 2009 20:30:19 +0000 (16:30 -0400)
committerStan Cox <scox@redhat.com>
Fri, 20 Mar 2009 20:30:19 +0000 (16:30 -0400)
* includes/sys/sdt.h (STAP_PROBE_DATA): New.  Define the probe point
using asm instead of c.
(STAP_PROBEN): Use it.
* testsuite/systemtap.base/sdt.exp: Continue if a compile fails.
* testsuite/systemtap.base/static_uprobes.exp: Don't test setting
probe without .probes section.

includes/sys/sdt.h
testsuite/systemtap.base/sdt.exp
testsuite/systemtap.base/static_uprobes.exp

index d6c901923f616dfadd4475f55905eba43fa25b64..5b92eeb3a91d8c31d0b4f164d3f5c5ba73ae1ac4 100644 (file)
 #include <string.h>
 #include <sys/types.h>
 
-#if _LP64
-#define STAP_PROBE_STRUCT_ARG(arg)             \
-  __uint64_t arg
-#else
-#define STAP_PROBE_STRUCT_ARG(arg)             \
-  long arg __attribute__ ((aligned(8)))                 
-#endif
-
-#define STAP_SENTINEL 0x31425250
-
-#define STAP_PROBE_STRUCT(probe,argc)  \
-struct _probe_ ## probe                                \
-{                                              \
-  int probe_type;                              \
-  STAP_PROBE_STRUCT_ARG        (probe_name);           \
-  STAP_PROBE_STRUCT_ARG        (probe_arg);            \
-};                                             \
-static char probe ## _ ## probe_name []        \
-       __attribute__ ((section (".probes")))   \
-       = #probe;                               \
-__extension__ static volatile struct _probe_ ## probe _probe_ ## probe __attribute__ ((section (".probes"))) = {STAP_SENTINEL,(size_t)& probe ## _ ## probe_name[0],argc};
-
-/* The goto _probe_ prevents the label from "drifting" */
-#define STAP_LABEL_REF(probe, label)                               \
-  if (__builtin_expect(_probe_ ## probe.probe_type < 0, 0)) \
-    goto label;
+#define STAP_PROBE_DATA_(probe,label) \
+  __asm__ volatile (".section .probes\n" \
+                   "\t.align 4\n"   \
+                   label "_name:\n\t.asciz " #probe "\n" \
+                   "\t.align 4\n" \
+                   "\t.int 0x31425250\n" \
+                   "\t.align 8\n" \
+                   "\t.quad " label "_name\n" \
+                   "\t.quad " label "\n" \
+                   "\t.previous\n")
+
+#define STAP_PROBE_DATA(probe,label)                                   \
+  STAP_PROBE_DATA_(#probe,label)
 
 /* These baroque macros are used to create a unique label */
 #define STAP_CONCAT(a,b) a ## b
+#define STAP_CONCATSTR(a,b) #a #b
 #define STAP_LABEL_PREFIX(p) _stapprobe1_ ## p
 /* __COUNTER__ is not present in gcc 4.1 */
 #if __GNUC__ == 4 && __GNUC_MINOR__ >= 3
@@ -49,88 +37,80 @@ __extension__ static volatile struct _probe_ ## probe _probe_ ## probe __attribu
 #else
 #define STAP_COUNTER  STAP_CONCAT(__,LINE__)
 #endif
-#define STAP_LABEL(a,b) STAP_CONCAT(a,b) 
+#define STAP_LABEL(a,b) STAP_CONCATSTR(a,b) 
 
 #define STAP_PROBE_(probe,label)               \
 do { \
-  STAP_PROBE_STRUCT(probe,(size_t)&& label) \
-  STAP_LABEL_REF(probe,label);             \
-label: \
-  __asm__ volatile ("nop");        \
+  STAP_PROBE_DATA(probe,label);                    \
+  __asm__ volatile (label ":\n" \
+                   "\tnop");   \
  } while (0)
 
-#define STAP_PROBE1_(probe,label,parm1)                \
+#define STAP_PROBE1_(probe,label,parm1)        \
 do { \
-  STAP_PROBE_STRUCT(probe,(size_t)&& label) \
   volatile __typeof__((parm1)) arg1  __attribute__ ((unused)) = parm1; \
-label: \
-  __asm__ volatile ("nop /* %0 */" :: "X"( arg1)); \
STAP_LABEL_REF(probe,label);              \
+  STAP_PROBE_DATA(probe,label);                                        \
+  __asm__ volatile (label ":\n" \
                  "\tnop /* %0 */" :: "X"(arg1));     \
  } while (0)
 
 #define STAP_PROBE2_(probe,label,parm1,parm2)  \
 do { \
-  STAP_PROBE_STRUCT(probe,(size_t)&& label) \
   volatile __typeof__((parm1)) arg1  __attribute__ ((unused)) = parm1; \
   volatile __typeof__((parm2)) arg2  __attribute__ ((unused)) = parm2; \
-label: \
-  __asm__ volatile ("nop /* %0 %1 */" :: "X"(arg1), "X"(arg2)); \
-  STAP_LABEL_REF(probe,label);             \
+  STAP_PROBE_DATA(probe,label);                                        \
+  __asm__ volatile (label ":\n"                                                \
+                   "\tnop /* %0 %1 */" :: "X"(arg1), "X"(arg2));       \
 } while (0)
 
 #define STAP_PROBE3_(probe,label,parm1,parm2,parm3)    \
 do { \
-  STAP_PROBE_STRUCT(probe,(size_t)&& label) \
   volatile __typeof__((parm1)) arg1  __attribute__ ((unused)) = parm1;     \
   volatile __typeof__((parm2)) arg2  __attribute__ ((unused)) = parm2; \
   volatile __typeof__((parm3)) arg3  __attribute__ ((unused)) = parm3; \
-label:                                    \
-  __asm__ volatile ("nop /* %0 %1 %2 */" :: "X"(arg1), "X"(arg2), "X"(arg3)); \
-  STAP_LABEL_REF(probe,label);             \
+  STAP_PROBE_DATA(probe,label);                                           \
+  __asm__ volatile (label ":\n"                                                \
+                   "\tnop /* %0 %1 %2 */" :: "X"(arg1), "X"(arg2), "X"(arg3)); \
 } while (0)
 
 #define STAP_PROBE4_(probe,label,parm1,parm2,parm3,parm4)      \
 do { \
-  STAP_PROBE_STRUCT(probe,(size_t)&& label)    \
   volatile __typeof__((parm1)) arg1  __attribute__ ((unused)) = parm1; \
   volatile __typeof__((parm2)) arg2  __attribute__ ((unused)) = parm2; \
   volatile __typeof__((parm3)) arg3  __attribute__ ((unused)) = parm3; \
   volatile __typeof__((parm4)) arg4  __attribute__ ((unused)) = parm4; \
-label:                         \
-  __asm__ volatile ("nop /* %0 %1 %2 %3 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4)); \
-  STAP_LABEL_REF(probe,label);             \
+  STAP_PROBE_DATA(probe,label);                                       \
+  __asm__ volatile (label ":\n"                                                \
+                   "\tnop /* %0 %1 %2 %3 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4)); \
 } while (0)
 
 #define STAP_PROBE5_(probe,label,parm1,parm2,parm3,parm4,parm5)        \
 do  { \
-  STAP_PROBE_STRUCT(probe,(size_t)&& label) \
   volatile __typeof__((parm1)) arg1  __attribute__ ((unused)) = parm1; \
   volatile __typeof__((parm2)) arg2  __attribute__ ((unused)) = parm2; \
   volatile __typeof__((parm3)) arg3  __attribute__ ((unused)) = parm3; \
   volatile __typeof__((parm4)) arg4  __attribute__ ((unused)) = parm4; \
   volatile __typeof__((parm5)) arg5  __attribute__ ((unused)) = parm5; \
-label:                         \
-  __asm__ volatile ("nop /* %0 %1 %2 %3 %4 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5)); \
-  STAP_LABEL_REF(probe,label);             \
+  STAP_PROBE_DATA(probe,label);                                       \
+  __asm__ volatile (label ":\n"                                                \
+                   "\tnop /* %0 %1 %2 %3 %4 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5)); \
 } while (0)
 
 #define STAP_PROBE6_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6)  \
 do { \
-  STAP_PROBE_STRUCT(probe,(size_t)&& label) \
   volatile __typeof__((parm1)) arg1  __attribute__ ((unused)) = parm1; \
   volatile __typeof__((parm2)) arg2  __attribute__ ((unused)) = parm2; \
   volatile __typeof__((parm3)) arg3  __attribute__ ((unused)) = parm3; \
   volatile __typeof__((parm4)) arg4  __attribute__ ((unused)) = parm4; \
   volatile __typeof__((parm5)) arg5  __attribute__ ((unused)) = parm5; \
   volatile __typeof__((parm6)) arg6  __attribute__ ((unused)) = parm6; \
-label:                         \
-  __asm__ volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6)); \
-  STAP_LABEL_REF(probe,label);             \
+  STAP_PROBE_DATA(probe,label);                                       \
+  __asm__ volatile (label ":\n"                                                \
+                   "\tnop /* %0 %1 %2 %3 %4 %5 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6)); \
 } while (0)
 
-#define STAP_PROBE7_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7)    \
+#define STAP_PROBE7_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7) \
 do  { \
-  STAP_PROBE_STRUCT(probe,(size_t)&& label) \
   volatile __typeof__((parm1)) arg1  __attribute__ ((unused)) = parm1; \
   volatile __typeof__((parm2)) arg2  __attribute__ ((unused)) = parm2; \
   volatile __typeof__((parm3)) arg3  __attribute__ ((unused)) = parm3; \
@@ -138,14 +118,13 @@ do  { \
   volatile __typeof__((parm5)) arg5  __attribute__ ((unused)) = parm5; \
   volatile __typeof__((parm6)) arg6  __attribute__ ((unused)) = parm6; \
   volatile __typeof__((parm7)) arg7  __attribute__ ((unused)) = parm7; \
-label:                         \
-  __asm__ volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7)); \
-  STAP_LABEL_REF(probe,label);             \
+  STAP_PROBE_DATA(probe,label);                                       \
+  __asm__ volatile (label ":\n"                                                \
+                   "\tnop /* %0 %1 %2 %3 %4 %5 %6 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7)); \
 } while (0)
 
 #define STAP_PROBE8_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8) \
 do { \
-  STAP_PROBE_STRUCT(probe,(size_t)&& label) \
   volatile __typeof__((parm1)) arg1  __attribute__ ((unused)) = parm1; \
   volatile __typeof__((parm2)) arg2  __attribute__ ((unused)) = parm2; \
   volatile __typeof__((parm3)) arg3  __attribute__ ((unused)) = parm3; \
@@ -154,14 +133,13 @@ do { \
   volatile __typeof__((parm6)) arg6  __attribute__ ((unused)) = parm6; \
   volatile __typeof__((parm7)) arg7  __attribute__ ((unused)) = parm7; \
   volatile __typeof__((parm8)) arg8  __attribute__ ((unused)) = parm8; \
-label:                         \
-  __asm__ volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8)); \
-  STAP_LABEL_REF(probe,label);             \
+  STAP_PROBE_DATA(probe,label);                                       \
+  __asm__ volatile (label ":\n"                                                \
+                   "\tnop /* %0 %1 %2 %3 %4 %5 %6 %7 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8)); \
 } while (0)
 
 #define STAP_PROBE9_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9) \
 do { \
-  STAP_PROBE_STRUCT(probe,(size_t)&& label) \
   volatile __typeof__((parm1)) arg1  __attribute__ ((unused)) = parm1; \
   volatile __typeof__((parm2)) arg2  __attribute__ ((unused)) = parm2; \
   volatile __typeof__((parm3)) arg3  __attribute__ ((unused)) = parm3; \
@@ -171,14 +149,13 @@ do { \
   volatile __typeof__((parm7)) arg7  __attribute__ ((unused)) = parm7; \
   volatile __typeof__((parm8)) arg8  __attribute__ ((unused)) = parm8; \
   volatile __typeof__((parm9)) arg9  __attribute__ ((unused)) = parm9; \
-label:                         \
-  __asm__ volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8), "X"(arg9)); \
-  STAP_LABEL_REF(probe,label);             \
+  STAP_PROBE_DATA(probe,label);                                       \
+  __asm__ volatile (label ":\n"                                                \
+                   "\tnop /* %0 %1 %2 %3 %4 %5 %6 %7 %8 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8), "X"(arg9)); \
 } while (0)
 
 #define STAP_PROBE10_(probe,label,parm1,parm2,parm3,parm4,parm5,parm6,parm7,parm8,parm9,parm10) \
 do { \
-  STAP_PROBE_STRUCT(probe,(size_t)&& label) \
   volatile __typeof__((parm1)) arg1  __attribute__ ((unused)) = parm1; \
   volatile __typeof__((parm2)) arg2  __attribute__ ((unused)) = parm2; \
   volatile __typeof__((parm3)) arg3  __attribute__ ((unused)) = parm3; \
@@ -189,9 +166,9 @@ do { \
   volatile __typeof__((parm8)) arg8  __attribute__ ((unused)) = parm8; \
   volatile __typeof__((parm9)) arg9  __attribute__ ((unused)) = parm9; \
   volatile __typeof__((parm10)) arg10  __attribute__ ((unused)) = parm10; \
-label:                         \
-  __asm__ volatile ("nop" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8), "X"(arg9), "X"(arg10)); \
-  STAP_LABEL_REF(probe,label);             \
+  STAP_PROBE_DATA(probe,label);                                       \
+  __asm__ volatile (label ":\n"                                                \
+                   "\tnop /* %0 %1 %2 %3 %4 %5 %6 %7 %8 %9 */" :: "X"(arg1), "X"(arg2), "X"(arg3), "X"(arg4), "X"(arg5), "X"(arg6), "X"(arg7), "X"(arg8), "X"(arg9), "X"(arg10)); \
 } while (0)
 
 #define STAP_PROBE(provider,probe)     \
index 21b948102501d69c1ce79c3faf1668febe817405..a398d7951d0c7ce84f422ba285f223d8e0273ef4 100644 (file)
@@ -27,7 +27,8 @@ set res [target_compile $srcdir/$subdir/$test.c $test.prog executable "$test_fla
 if { $res != "" } {
     verbose "target_compile failed: $res" 2
     fail "compiling $test.c $extra_flag"
-    return
+    untested "$test $extra_flag"
+    continue
 } else {
     pass "compiling $test.c $extra_flag"
 }
@@ -49,7 +50,8 @@ set res [target_compile $srcdir/$subdir/$test.c $test.prog executable "$test_fla
 if { $res != "" } {
     verbose "target_compile failed: $res" 2
     fail "compiling $test.c c++ $extra_flag"
-    return
+    untested "$test $extra_flag"
+    continue
 } else {
     pass "compiling $test.c c++ $extra_flag"
 }
index b4214436b508ce0efa53bb91699357d536823a09..e407440e8333f898802ea284172a6df9178ad15a 100644 (file)
@@ -103,7 +103,11 @@ if {[installtest_p]} {
     set sdtdir $srcdir/../includes
 }
 
-set sup_flags "additional_flags=-I$sdtdir additional_flags=-g additional_flags=-O additional_flags=-I."
+set sup_flags "additional_flags=-I$srcdir/../includes/sys"
+set sup_flags "$sup_flags additional_flags=-I$sdtdir"
+set sup_flags "$sup_flags additional_flags=-g"
+set sup_flags "$sup_flags  additional_flags=-O"
+set sup_flags "$sup_flags  additional_flags=-I."
 set res [target_compile $sup_srcpath $sup_exepath executable $sup_flags]
 if { $res != "" } {
     verbose "target_compile failed: $res" 2
@@ -177,6 +181,10 @@ expect {
 
 wait
 
-if {$ok == 5} { pass "$test C++" } { fail "$test C++ ($ok)" }
+# we now generate the probes via asm so there is no label debug info
+if {$ok == 5} { pass "$test C++" } { xfail "$test C++ ($ok)" }
 
+if { $verbose == 0 } {
 catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_dpath $sup_hpath $sup_stppath}
+}
+
This page took 0.041507 seconds and 5 git commands to generate.