| 1 |
set test "sdt_varname" |
| 2 |
set testpath "$srcdir/$subdir" |
| 3 |
|
| 4 |
if {![installtest_p]} { |
| 5 |
untested "$test" |
| 6 |
return |
| 7 |
} |
| 8 |
if {![uprobes_p]} { |
| 9 |
untested "$test" |
| 10 |
return |
| 11 |
} |
| 12 |
|
| 13 |
# In this testcase, we verify that stap can parse SDT operands of the type |
| 14 |
# [off+]varname[+off][(reg)]. These occur when the operands refer to STB_GLOBAL |
| 15 |
# or STB_LOCAL objects. |
| 16 |
|
| 17 |
set sopath "lib$test.so" |
| 18 |
set exepath "$test" |
| 19 |
|
| 20 |
proc test_cleanup {} { |
| 21 |
global sopath exepath |
| 22 |
if {[file exists "$sopath"]} { file delete "$sopath" } |
| 23 |
if {[file exists "$exepath"]} { file delete "$exepath" } |
| 24 |
} |
| 25 |
|
| 26 |
set failed 0 |
| 27 |
|
| 28 |
# Compile the shared lib |
| 29 |
set libflags [sdt_includes] |
| 30 |
set libflags "$libflags additional_flags=-shared" |
| 31 |
set libflags "$libflags additional_flags=-fPIC" |
| 32 |
set libflags "$libflags additional_flags=-DSDT_VARNAME_LIB" |
| 33 |
set libflags "$libflags additional_flags=-DSTAP_SDT_ARG_CONSTRAINT=m" |
| 34 |
set res [target_compile $testpath/$test.c $sopath executable $libflags] |
| 35 |
if { $res == "" } { |
| 36 |
pass "$test library compile" |
| 37 |
} else { |
| 38 |
fail "$test library compile: $res" |
| 39 |
test_cleanup |
| 40 |
return |
| 41 |
} |
| 42 |
|
| 43 |
# Compile the executable |
| 44 |
set exeflags [sdt_includes] |
| 45 |
set exeflags "$exeflags additional_flags=-l$test" |
| 46 |
set exeflags "$exeflags additional_flags=-Wl,-rpath,[pwd]" |
| 47 |
set exeflags "$exeflags additional_flags=-L." |
| 48 |
set exeflags "$exeflags additional_flags=-DSDT_VARNAME_MAIN" |
| 49 |
set exeflags "$exeflags additional_flags=-DSTAP_SDT_ARG_CONSTRAINT=m" |
| 50 |
set res [target_compile $testpath/$test.c $exepath executable $exeflags] |
| 51 |
if { $res == "" } { |
| 52 |
pass "$test exe compile" |
| 53 |
} else { |
| 54 |
fail "$test exe compile: $res" |
| 55 |
test_cleanup |
| 56 |
return |
| 57 |
} |
| 58 |
|
| 59 |
# Test it |
| 60 |
set ::result_string {main globalvar = 1 |
| 61 |
main main_globalvar = 2 |
| 62 |
main localvar = 3 |
| 63 |
main localstruct.bar = 4 |
| 64 |
main localstruct.zoo = 5 |
| 65 |
main localstruct.poo = 6 |
| 66 |
lib globalvar = 1 |
| 67 |
lib lib_globalvar = 7 |
| 68 |
lib localvar = 8 |
| 69 |
lib localstruct.bar = 9 |
| 70 |
lib localstruct.zoo = 10 |
| 71 |
lib localstruct.poo = 11} |
| 72 |
|
| 73 |
stap_run2 $testpath/$test.stp $exepath $sopath -c "./$exepath" |
| 74 |
test_cleanup |