| 1 |
set test "tls" |
| 2 |
set stap_path $env(SYSTEMTAP_PATH)/stap |
| 3 |
|
| 4 |
# exp_internal 1 |
| 5 |
|
| 6 |
# tls not supported on aarch64: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97344 |
| 7 |
set arch [exec uname -i] |
| 8 |
if {$arch eq "aarch64"} { untested $test; return } |
| 9 |
|
| 10 |
set so_flags "additional_flags=-shared" |
| 11 |
set so_flags "$so_flags additional_flags=-g" |
| 12 |
set so_flags "$so_flags additional_flags=-fPIC" |
| 13 |
set x_flags "additional_flags=-Wl,-rpath,[pwd]" |
| 14 |
set x_flags "$x_flags additional_flags=-g" |
| 15 |
set x_flags "$x_flags additional_flags=-fPIC" |
| 16 |
set x_flags "$x_flags additional_flags=-lpthread" |
| 17 |
|
| 18 |
# static tls variables setup |
| 19 |
|
| 20 |
set so1_sopath "[pwd]/libtls1.so" |
| 21 |
set res0 [target_compile $srcdir/$subdir/tls1_.c $so1_sopath \ |
| 22 |
executable $so_flags ] |
| 23 |
set x1_flags "$x_flags additional_flags=-L[pwd] additional_flags=-ltls1" |
| 24 |
set x1_exepath "[pwd]/tls1.x" |
| 25 |
set res [target_compile $srcdir/$subdir/tls1.c $x1_exepath \ |
| 26 |
executable $x1_flags ] |
| 27 |
if {$res0 != "" || $res != ""} { |
| 28 |
fail "$test compiling tls1" |
| 29 |
return |
| 30 |
} else { |
| 31 |
pass "$test compiling tls1" |
| 32 |
} |
| 33 |
|
| 34 |
# extern tls variables setup |
| 35 |
|
| 36 |
set so2_sopath "[pwd]/libtls2.so" |
| 37 |
set so3_sopath "[pwd]/libtls3.so" |
| 38 |
set so2_flags "$so_flags additional_flags=-DEXTERN_TLS" |
| 39 |
|
| 40 |
set res0 [target_compile $srcdir/$subdir/tls1_.c $so2_sopath \ |
| 41 |
executable $so2_flags ] |
| 42 |
set res1 [target_compile $srcdir/$subdir/tls2_.c $so3_sopath \ |
| 43 |
executable $so2_flags ] |
| 44 |
set x2_flags "$x_flags additional_flags=-L[pwd] additional_flags=-ltls2" |
| 45 |
set x2_flags "$x2_flags additional_flags=-ltls3" |
| 46 |
set x2_flags "$x2_flags additional_flags=-DEXTERN_TLS" |
| 47 |
set x2_exepath "[pwd]/tls2.x" |
| 48 |
set res [target_compile $srcdir/$subdir/tls1.c $x2_exepath \ |
| 49 |
executable $x2_flags ] |
| 50 |
if { $res0 != "" || $res != "" } { |
| 51 |
fail "$test compiling -shared" |
| 52 |
return |
| 53 |
} else { |
| 54 |
pass "$test compiling -shared" |
| 55 |
} |
| 56 |
|
| 57 |
# errno setup |
| 58 |
|
| 59 |
set errno_exepath "[pwd]/tlserrno.x" |
| 60 |
set res [target_compile $srcdir/$subdir/tlserrno.c $errno_exepath \ |
| 61 |
executable $x_flags ] |
| 62 |
if {$res != ""} { |
| 63 |
fail "$test compiling tlserrno" |
| 64 |
return |
| 65 |
} else { |
| 66 |
pass "$test compiling tls1errno" |
| 67 |
} |
| 68 |
set libc_path [exec sh -c "ldd tlserrno.x | grep libc.so | awk '{print \$3}'"] |
| 69 |
|
| 70 |
foreach runtime [get_runtime_list] { |
| 71 |
if {$runtime != ""} { |
| 72 |
set test_type "$test ($runtime)" |
| 73 |
} else { |
| 74 |
set runtime "kernel" |
| 75 |
set test_type $test |
| 76 |
} |
| 77 |
|
| 78 |
set ok 0 |
| 79 |
set nodb 0 |
| 80 |
spawn $stap_path --runtime=$runtime -g -c $x1_exepath $srcdir/$subdir/tls1.stp $so1_sopath IGNORE |
| 81 |
expect { |
| 82 |
-timeout 180 |
| 83 |
-re {WARNING:.*No DWARF information found} { incr nodb } |
| 84 |
-re {In Stap(()| increase_tls): (tls1=0x[23] tls2=0x[34]|tls=99)} { incr ok; exp_continue } |
| 85 |
eof { } |
| 86 |
} |
| 87 |
catch {close}; catch {wait} |
| 88 |
if {$nodb != 0} { |
| 89 |
untested "$test_type (missing debuginfo)" |
| 90 |
return |
| 91 |
} |
| 92 |
if {$ok == 3} { |
| 93 |
pass "$test_type local tls vars" |
| 94 |
} else { |
| 95 |
fail "$test_type local tls vars ($ok/3)" |
| 96 |
} |
| 97 |
|
| 98 |
# extern tls variables |
| 99 |
|
| 100 |
set ok 0 |
| 101 |
spawn $stap_path --runtime=$runtime -g -c $x2_exepath $srcdir/$subdir/tls1.stp $so2_sopath $so3_sopath |
| 102 |
expect { |
| 103 |
-timeout 180 |
| 104 |
-re {In Stap (worker|increase_tls): tls1=0x[23] tls2=0x[34]\r\n} { incr ok; exp_continue } |
| 105 |
eof { } |
| 106 |
} |
| 107 |
catch {close}; catch {wait} |
| 108 |
if {$ok == 4} { |
| 109 |
pass "$test_type ext tls vars" |
| 110 |
} else { |
| 111 |
fail "$test_type ext tls vars ($ok/4)" |
| 112 |
} |
| 113 |
|
| 114 |
# Check errno |
| 115 |
|
| 116 |
set ok 0 |
| 117 |
set nodb 0 |
| 118 |
spawn $stap_path --runtime=$runtime -e "probe process(\"$libc_path\").function(\"*stat*\").return { printf(\"errno=%d %s\\n\", @var(\"[email protected]\"),errno_str(@var(\"[email protected]\"))) }" -c "/usr/bin/ls /file/does/not/exist" |
| 119 |
expect { |
| 120 |
-timeout 180 |
| 121 |
-re {Missing separate debuginfos} { incr nodb } |
| 122 |
-re {errno=2 (ENOENT)} { incr ok; exp_continue } |
| 123 |
eof { } |
| 124 |
} |
| 125 |
catch {close}; catch {wait} |
| 126 |
if {$ok >= 1} { |
| 127 |
pass "$test_type errno" |
| 128 |
} elseif {$nodb > 0} { |
| 129 |
xfail "$test_type errno (no glibc debuginfo)" |
| 130 |
} else { |
| 131 |
fail "$test_type errno ($ok/>=1)" |
| 132 |
} |
| 133 |
|
| 134 |
set ok 0 |
| 135 |
set nodb 0 |
| 136 |
spawn $stap_path --runtime=$runtime -e "probe process(\"$errno_exepath\").function(\"main\").return {println (\"In Stap errno=\",@errno) }" -c "$errno_exepath" |
| 137 |
|
| 138 |
expect { |
| 139 |
-timeout 180 |
| 140 |
-re {Missing separate debuginfos} { incr nodb } |
| 141 |
-re {In Stap errno=2} { incr ok; exp_continue } |
| 142 |
eof { } |
| 143 |
} |
| 144 |
catch {close}; catch {wait} |
| 145 |
if {$ok >= 1} { |
| 146 |
pass "$test_type @errno" |
| 147 |
} elseif {$nodb > 0} { |
| 148 |
xfail "$test_type errno (no glibc debuginfo)" |
| 149 |
} else { |
| 150 |
fail "$test_type @errno ($ok/>=1)" |
| 151 |
} |
| 152 |
} |