summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testsuite/systemtap.base/sdt_types.c168
-rw-r--r--testsuite/systemtap.base/sdt_types.stp371
-rw-r--r--testsuite/systemtap.base/static_uprobes.exp47
3 files changed, 561 insertions, 25 deletions
diff --git a/testsuite/systemtap.base/sdt_types.c b/testsuite/systemtap.base/sdt_types.c
new file mode 100644
index 00000000..2e04ec7e
--- /dev/null
+++ b/testsuite/systemtap.base/sdt_types.c
@@ -0,0 +1,168 @@
+#include "sdt.h" /* Really <sys/sdt.h>, but pick current source version. */
+#include <stdint.h>
+#include <values.h>
+
+int
+main (int argc, char **argv)
+{
+ char char_var = '~';
+ STAP_PROBE1(provider,char_var,char_var);
+ const char const_char_var = '!';
+ STAP_PROBE1(provider,const_char_var,const_char_var);
+ volatile char volatile_char_var = '!';
+ STAP_PROBE1(provider,volatile_char_var,volatile_char_var);
+ char *ptr_char_var = &char_var;
+ STAP_PROBE2(provider,ptr_char_var,ptr_char_var,&char_var);
+ const char *ptr_const_char_var = &char_var;
+ STAP_PROBE2(provider,ptr_const_char_var,ptr_const_char_var,&char_var);
+ char * const char_ptr_const_var = &char_var;
+ STAP_PROBE2(provider,char_ptr_const_var,char_ptr_const_var,&char_var);
+ volatile char *ptr_volatile_char_var = &char_var;
+ STAP_PROBE2(provider,ptr_volatile_char_var,ptr_volatile_char_var,&char_var);
+ char * volatile char_ptr_volatile_var = &char_var;
+ STAP_PROBE2(provider,char_ptr_volatile_var,char_ptr_volatile_var,&char_var);
+ short int short_int_var = 32767;
+ STAP_PROBE1(provider,short_int_var,short_int_var);
+ const short int const_short_int_var = -32767;
+ STAP_PROBE1(provider,const_short_int_var,const_short_int_var);
+ volatile short int volatile_short_int_var = -32767;
+ STAP_PROBE1(provider,volatile_short_int_var,volatile_short_int_var);
+ short int *ptr_short_int_var = &short_int_var;
+ STAP_PROBE2(provider,ptr_short_int_var,ptr_short_int_var,&short_int_var);
+ const short int *ptr_const_short_int_var = &short_int_var;
+ STAP_PROBE2(provider,ptr_const_short_int_var,ptr_const_short_int_var,&short_int_var);
+ short int * const short_int_ptr_const_var = &short_int_var;
+ STAP_PROBE2(provider,short_int_ptr_const_var,short_int_ptr_const_var,&short_int_var);
+ volatile short int *ptr_volatile_short_int_var = &short_int_var;
+ STAP_PROBE2(provider,ptr_volatile_short_int_var,ptr_volatile_short_int_var,&short_int_var);
+ short int * volatile short_int_ptr_volatile_var = &short_int_var;
+ STAP_PROBE2(provider,short_int_ptr_volatile_var,short_int_ptr_volatile_var,&short_int_var);
+ int int_var = 65536;
+ STAP_PROBE1(provider,int_var,int_var);
+ const int const_int_var = -65536;
+ STAP_PROBE1(provider,const_int_var,const_int_var);
+ volatile int volatile_int_var = -65536;
+ STAP_PROBE1(provider,volatile_int_var,volatile_int_var);
+ int *ptr_int_var = &int_var;
+ STAP_PROBE2(provider,ptr_int_var,ptr_int_var,&int_var);
+ const int *ptr_const_int_var = &int_var;
+ STAP_PROBE2(provider,ptr_const_int_var,ptr_const_int_var,&int_var);
+ int * const int_ptr_const_var = &int_var;
+ STAP_PROBE2(provider,int_ptr_const_var,int_ptr_const_var,&int_var);
+ volatile int *ptr_volatile_int_var = &int_var;
+ STAP_PROBE2(provider,ptr_volatile_int_var,ptr_volatile_int_var,&int_var);
+ int * volatile int_ptr_volatile_var = &int_var;
+ STAP_PROBE2(provider,int_ptr_volatile_var,int_ptr_volatile_var,&int_var);
+ long int long_int_var = 65536;
+ STAP_PROBE1(provider,long_int_var,long_int_var);
+ const long int const_long_int_var = -65536;
+ STAP_PROBE1(provider,const_long_int_var,const_long_int_var);
+ volatile long int volatile_long_int_var = -65536;
+ STAP_PROBE1(provider,volatile_long_int_var,volatile_long_int_var);
+ long int *ptr_long_int_var = &long_int_var;
+ STAP_PROBE2(provider,ptr_long_int_var,ptr_long_int_var,&long_int_var);
+ const long int *ptr_const_long_int_var = &long_int_var;
+ STAP_PROBE2(provider,ptr_const_long_int_var,ptr_const_long_int_var,&long_int_var);
+ long int * const long_int_ptr_const_var = &long_int_var;
+ STAP_PROBE2(provider,long_int_ptr_const_var,long_int_ptr_const_var,&long_int_var);
+ volatile long int *ptr_volatile_long_int_var = &long_int_var;
+ STAP_PROBE2(provider,ptr_volatile_long_int_var,ptr_volatile_long_int_var,&long_int_var);
+ long int * volatile long_int_ptr_volatile_var = &long_int_var;
+ STAP_PROBE2(provider,long_int_ptr_volatile_var,long_int_ptr_volatile_var,&long_int_var);
+ long long int long_long_int_var = 65536;
+ STAP_PROBE1(provider,long_long_int_var,long_long_int_var);
+ const long long int const_long_long_int_var = -65536;
+ STAP_PROBE1(provider,const_long_long_int_var,const_long_long_int_var);
+ volatile long long int volatile_long_long_int_var = -65536;
+ STAP_PROBE1(provider,volatile_long_long_int_var,volatile_long_long_int_var);
+ long long int *ptr_long_long_int_var = &long_long_int_var;
+ STAP_PROBE2(provider,ptr_long_long_int_var,ptr_long_long_int_var,&long_long_int_var);
+ const long long int *ptr_const_long_long_int_var = &long_long_int_var;
+ STAP_PROBE2(provider,ptr_const_long_long_int_var,ptr_const_long_long_int_var,&long_long_int_var);
+ long long int * const long_long_int_ptr_const_var = &long_long_int_var;
+ STAP_PROBE2(provider,long_long_int_ptr_const_var,long_long_int_ptr_const_var,&long_long_int_var);
+ volatile long long int *ptr_volatile_long_long_int_var = &long_long_int_var;
+ STAP_PROBE2(provider,ptr_volatile_long_long_int_var,ptr_volatile_long_long_int_var,&long_long_int_var);
+ long long int * volatile long_long_int_ptr_volatile_var = &long_long_int_var;
+ STAP_PROBE2(provider,long_long_int_ptr_volatile_var,long_long_int_ptr_volatile_var,&long_long_int_var);
+
+ char arr_char [2] = "!~";
+ STAP_PROBE1(provider,arr_char,&arr_char);
+ struct {
+ int int_var;
+ } arr_struct [2] = {{
+ .int_var=1,
+ },{
+ .int_var=2,
+ }};
+ STAP_PROBE1(provider,arr_struct,&arr_struct);
+ struct {
+ unsigned int bit1_0:1;
+ unsigned int bit1_1:1;
+ char char_2;
+ unsigned int bit1_6:1;
+ unsigned int bit1_7:1;
+ char char_8;
+ unsigned int bit1_9:1;
+ unsigned int bit1_10:1;
+ } bitfields_small_var = {
+ .bit1_0=1,
+ .bit1_1=0,
+ .char_2='a',
+ .bit1_6=1,
+ .bit1_7=0,
+ .char_8='z',
+ .bit1_9=1,
+ .bit1_10=0,
+ };
+ STAP_PROBE8(provider,bitfields_small_var,
+ (int)bitfields_small_var.bit1_0,
+ (int)bitfields_small_var.bit1_1,
+ bitfields_small_var.char_2,
+ (int)bitfields_small_var.bit1_6,
+ (int)bitfields_small_var.bit1_7,
+ bitfields_small_var.char_8,
+ (int)bitfields_small_var.bit1_9,
+ (int)bitfields_small_var.bit1_10);
+ struct {
+ unsigned char char_0;
+ int bit1_4:1;
+ unsigned int bit1_5:1;
+ int bit2_6:2;
+ unsigned int bit2_8:2;
+ int bit3_10:3;
+ unsigned int bit3_13:3;
+ int bit9_16:9;
+ unsigned int bit9_25:9;
+ char char_34;
+ } bitfields_bit_var = {
+ .char_0='A',
+ .bit1_4=-1,
+ .bit1_5=1,
+ .bit2_6=1,
+ .bit2_8=3,
+ .bit3_10=3,
+ .bit3_13=7,
+ .bit9_16=255,
+ .bit9_25=511,
+ .char_34='Z',
+ };
+ STAP_PROBE10(provider,bitfields_bit_var,bitfields_bit_var.char_0,
+ (int)bitfields_bit_var.bit1_4,
+ (int)bitfields_bit_var.bit1_5,
+ (int)bitfields_bit_var.bit2_6,
+ (int)bitfields_bit_var.bit2_8,
+ (int)bitfields_bit_var.bit3_10,
+ (int)bitfields_bit_var.bit3_13,
+ (int)bitfields_bit_var.bit9_16,
+ (int)bitfields_bit_var.bit9_25,
+ bitfields_bit_var.char_34);
+ enum {
+ red = 0,
+ green = 1,
+ blue = 2
+ } primary_colors_var = green;
+ STAP_PROBE1(provider,primary_colors_var,primary_colors_var);
+ return 0;
+}
+
diff --git a/testsuite/systemtap.base/sdt_types.stp b/testsuite/systemtap.base/sdt_types.stp
new file mode 100644
index 00000000..654b0d18
--- /dev/null
+++ b/testsuite/systemtap.base/sdt_types.stp
@@ -0,0 +1,371 @@
+probe process(@1).mark("char_var") {
+ if ($arg1 != 126)
+ printf("FAIL: char_var\n")
+ else
+ printf("PASS: char_var\n")
+}
+
+probe process(@1).mark("const_char_var") {
+ if ($arg1 != 33)
+ printf("FAIL: const_char_var\n")
+ else
+ printf("PASS: const_char_var\n")
+}
+
+probe process(@1).mark("volatile_char_var") {
+ if ($arg1 != 33)
+ printf("FAIL: volatile_char_var\n")
+ else
+ printf("PASS: volatile_char_var\n")
+}
+
+probe process(@1).mark("ptr_char_var") {
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_char_var\n")
+ else
+ printf("PASS: ptr_char_var\n")
+}
+
+probe process(@1).mark("ptr_const_char_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_const_char_var\n")
+ else
+ printf("PASS: ptr_const_char_var\n")
+}
+
+probe process(@1).mark("char_ptr_const_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: char_ptr_const_var\n")
+ else
+ printf("PASS: char_ptr_const_var\n")
+}
+
+probe process(@1).mark("ptr_volatile_char_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_volatile_char_var\n")
+ else
+ printf("PASS: ptr_volatile_char_var\n")
+}
+
+probe process(@1).mark("char_ptr_volatile_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: char_ptr_volatile_var\n")
+ else
+ printf("PASS: char_ptr_volatile_var\n")
+}
+
+probe process(@1).mark("short_int_var")
+{
+ if ($arg1 != 32767)
+ printf("FAIL: short_int_var\n")
+ else
+ printf("PASS: short_int_var\n")
+}
+
+probe process(@1).mark("const_short_int_var")
+{
+ if ($arg1 != -32767)
+ printf("FAIL: const_short_int_var\n")
+ else
+ printf("PASS: const_short_int_var\n")
+}
+
+probe process(@1).mark("volatile_short_int_var")
+{
+ if ($arg1 != -32767)
+ printf("FAIL: volatile_short_int_var\n")
+ else
+ printf("PASS: volatile_short_int_var\n")
+}
+
+probe process(@1).mark("ptr_short_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_short_int_var\n")
+ else
+ printf("PASS: ptr_short_int_var\n")
+}
+
+probe process(@1).mark("ptr_const_short_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_const_short_int_var\n")
+ else
+ printf("PASS: ptr_const_short_int_var\n")
+}
+
+probe process(@1).mark("short_int_ptr_const_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: short_int_ptr_const_var\n")
+ else
+ printf("PASS: short_int_ptr_const_var\n")
+}
+
+probe process(@1).mark("ptr_volatile_short_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_volatile_short_int_var\n")
+ else
+ printf("PASS: ptr_volatile_short_int_var\n")
+}
+
+probe process(@1).mark("short_int_ptr_volatile_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: short_int_ptr_volatile_var\n")
+ else
+ printf("PASS: short_int_ptr_volatile_var\n")
+}
+
+probe process(@1).mark("int_var")
+{
+ if ($arg1 != 65536)
+ printf("FAIL: int_var")
+ else
+ printf("PASS: int_var")
+}
+
+probe process(@1).mark("const_int_var")
+{
+ if ($arg1 != -65536)
+ printf("FAIL: const_int_var\n")
+ else
+ printf("PASS: const_int_var\n")
+}
+
+probe process(@1).mark("volatile_int_var")
+{
+ if ($arg1 != -65536)
+ printf("FAIL: volatile_int_var\n")
+ else
+ printf("PASS: volatile_int_var\n")
+}
+
+probe process(@1).mark("ptr_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_const_int_var\n")
+ else
+ printf("PASS: ptr_const_int_var\n")
+}
+
+probe process(@1).mark("ptr_const_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_const_int_var\n")
+ else
+ printf("PASS: ptr_const_int_var\n")
+}
+
+probe process(@1).mark("int_ptr_const_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: int_ptr_const_var\n")
+ else
+ printf("PASS: int_ptr_const_var\n")
+}
+
+probe process(@1).mark("ptr_volatile_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_volatile_int_var\n")
+ else
+ printf("PASS: ptr_volatile_int_var\n")
+}
+
+probe process(@1).mark("int_ptr_volatile_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: int_ptr_volatile_var\n")
+ else
+ printf("PASS: int_ptr_volatile_var\n")
+}
+
+probe process(@1).mark("long_int_var")
+{
+ if ($arg1 != 65536)
+ printf("FAIL: long_int_var\n")
+ else
+ printf("PASS: long_int_var\n")
+}
+
+probe process(@1).mark("const_long_int_var")
+{
+ if ($arg1 != -65536)
+ printf("FAIL: const_long_int_var\n")
+ else
+ printf("PASS: const_long_int_var\n")
+}
+
+probe process(@1).mark("volatile_long_int_var")
+{
+ if ($arg1 != -65536)
+ printf("FAIL: volatile_long_int_var\n")
+ else
+ printf("PASS: volatile_long_int_var\n")
+}
+
+probe process(@1).mark("ptr_long_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_long_int_var\n")
+ else
+ printf("PASS: ptr_long_int_var\n")
+}
+
+probe process(@1).mark("ptr_const_long_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_const_long_int_var\n")
+ else
+ printf("PASS: ptr_const_long_int_var\n")
+}
+
+probe process(@1).mark("long_int_ptr_const_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: long_int_ptr_const_var\n")
+ else
+ printf("PASS: long_int_ptr_const_var\n")
+}
+
+probe process(@1).mark("ptr_volatile_long_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_volatile_long_int_var\n")
+ else
+ printf("PASS: ptr_volatile_long_int_var\n")
+}
+
+probe process(@1).mark("long_int_ptr_volatile_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: long_int_ptr_volatile_var\n")
+ else
+ printf("PASS: long_int_ptr_volatile_var\n")
+}
+
+probe process(@1).mark("long_long_int_var")
+{
+ if ($arg1 != 65536)
+ printf("FAIL: long_long_int_var\n")
+ else
+ printf("PASS: long_long_int_var\n")
+}
+
+probe process(@1).mark("const_long_long_int_var")
+{
+ if ($arg1 != -65536)
+ printf("FAIL: const_long_long_int_var\n")
+ else
+ printf("PASS: const_long_long_int_var\n")
+}
+
+probe process(@1).mark("volatile_long_long_int_var")
+{
+ if ($arg1 != -65536)
+ printf("FAIL: volatile_long_long_int_var\n")
+ else
+ printf("PASS: volatile_long_long_int_var\n")
+}
+
+probe process(@1).mark("ptr_long_long_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_long_long_int_var\n")
+ else
+ printf("PASS: ptr_long_long_int_var\n")
+}
+
+probe process(@1).mark("ptr_const_long_long_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_const_long_long_int_var\n")
+ else
+ printf("PASS: ptr_const_long_long_int_var\n")
+}
+
+probe process(@1).mark("long_long_int_ptr_const_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: long_long_int_ptr_const_var\n")
+ else
+ printf("PASS: long_long_int_ptr_const_var\n")
+}
+
+probe process(@1).mark("ptr_volatile_long_long_int_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: ptr_volatile_long_long_int_var\n")
+ else
+ printf("PASS: ptr_volatile_long_long_int_var\n")
+}
+
+probe process(@1).mark("long_long_int_ptr_volatile_var")
+{
+ if ($arg1 != $arg2)
+ printf("FAIL: long_long_int_ptr_volatile_var\n")
+ else
+ printf("PASS: long_long_int_ptr_volatile_var\n")
+}
+
+probe process(@1).mark("arr_char")
+{
+ arr_char = user_string ($arg1);
+ if (arr_char != "!~")
+ printf("FAIL: arr_char_var\n")
+ else
+ printf("PASS: arr_char_var\n")
+}
+
+probe process(@1).mark("arr_struct")
+{
+ arr_struct_int_var = user_int ($arg1)
+ if (arr_struct_int_var != 1)
+ printf("FAIL: arr_struct_var\n")
+ else
+ printf("PASS: arr_struct_var\n")
+}
+
+probe process(@1).mark("bitfields_small_var")
+{
+ if ($arg1 != 1 || $arg2 != 0 || $arg3 != 97 || $arg4 != 1
+ || $arg5 != 0 || $arg6 != 122 || $arg7 != 1 || $arg8 != 0)
+ printf("FAIL: bitfields_small_var\n")
+
+}
+
+probe process(@1).mark("bitfields_bit_var")
+{
+ if ($arg1 != 65 || $arg2 != -1 || $arg3 != 1 || $arg4 != 1
+ || $arg5 != 3 || $arg6 != 3 || $arg7 != 7 || $arg8 != 255
+ || $arg9 != 511 || $arg10 != 90)
+ printf("FAIL: bitfields_bit_var\n")
+ else
+ printf("PASS: bitfields_bit_var\n")
+}
+
+
+probe process(@1).mark("primary_colors_var")
+{
+ if ($arg1 != 1)
+ printf("FAIL: primary_colors_var\n")
+ else
+ printf("PASS: primary_colors_var\n")
+}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/testsuite/systemtap.base/static_uprobes.exp b/testsuite/systemtap.base/static_uprobes.exp
index e407440e..620d5576 100644
--- a/testsuite/systemtap.base/static_uprobes.exp
+++ b/testsuite/systemtap.base/static_uprobes.exp
@@ -118,17 +118,6 @@ if { $res != "" } {
pass "$test compiling C -g"
}
-set sup_flags "$sup_flags additional_flags=-x additional_flags=c++"
-set res [target_compile $sup_srcpath $supcplus_exepath executable $sup_flags]
-if { $res != "" } {
- verbose "target_compile failed: $res" 2
- fail "$test compiling C++ -g"
- catch {exec rm -f $sup_srcpath $sup_exepath $sup_hpath $sup_stppath}
- return
-} else {
- pass "$test compiling C++ -g"
-}
-
if {![installtest_p]} {untested $test; return}
# Try to find utrace_attach symbol in /proc/kallsyms
@@ -162,29 +151,37 @@ wait
if {$ok == 5} { pass "$test C" } { fail "$test C ($ok)" }
-set ok 0
+set sup_flags "$sup_flags additional_flags=-O0"
+set res [target_compile $srcdir/$subdir/sdt_types.c sdt_types.x executable $sup_flags]
+if { $res != "" } {
+ verbose "target_compile failed: $res" 2
+ fail "$test compiling -g"
+ return
+} else {
+ pass "$test compiling -g"
+}
-# Test setting a probe without .probes using only dwarf label info
-verbose -log "objcopy -R .probes $supcplus_exepath $sup_exepath"
-spawn objcopy -R .probes $supcplus_exepath $sup_exepath
-verbose -log "spawn stap -c $sup_exepath $sup_stppath"
-spawn stap -c $sup_exepath $sup_stppath
+set ok 0
+set fail "types"
+verbose -log "spawn stap -c ./sdt_types.x $srcdir/$subdir/sdt_types.stp ./sdt_types.x"
+spawn stap -c ./sdt_types.x $srcdir/$subdir/sdt_types.stp ./sdt_types.x
expect {
-timeout 180
- -re {In test_probe_2 probe 0x2} { incr ok; exp_continue }
- -re {In test_probe_0 probe 0x3} { incr ok; exp_continue }
- -re {In test_probe_3 probe 0x3 0x[0-9a-f][0-9a-f]} { incr ok; exp_continue }
- -re {In test_probe_4 dtrace probe 0x4} { incr ok; exp_continue }
- timeout { fail "$test C++ (timeout)" }
+ -re {FAIL: [a-z_]+var} { regexp " .*$" $expect_out(0,string) s;
+ incr ok; set fail "$fail $s"; exp_continue }
+ timeout { fail "$test C (timeout)" }
eof { }
}
wait
-# 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 { $ok != 0 } {
+ fail $fail
+} else {
+ pass types
+}
if { $verbose == 0 } {
-catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_dpath $sup_hpath $sup_stppath}
+catch {exec rm -f $sup_srcpath $sup_exepath $supcplus_exepath $sup_dpath $sup_hpath $sup_stppath sdt_types.x}
}