| 1 |
set test "at_var" |
| 2 |
set testpath "$srcdir/$subdir" |
| 3 |
|
| 4 |
# Test that $var and @var("var") work identically for parameters, variables, |
| 5 |
# for uprobes and kprobes with members, arrays, taking the address and also |
| 6 |
# plays nice when used in combination with @cast and @entry. |
| 7 |
set result_string1 {$argc: 1 |
| 8 |
@var("argc"): 1 |
| 9 |
user_string($argv[0]): ./at_var |
| 10 |
user_string(@var("argv")[0]): ./at_var |
| 11 |
$foo->bar: 42 |
| 12 |
@var("foo")->bar: 42 |
| 13 |
} |
| 14 |
|
| 15 |
set result_string2 {$times$$: {.tv_sec=1, .tv_nsec=2000} |
| 16 |
$times[1]$$: {.tv_sec=3, .tv_nsec=4000} |
| 17 |
@var("times")$$: {.tv_sec=1, .tv_nsec=2000} |
| 18 |
@var("times")[1]$$: {.tv_sec=3, .tv_nsec=4000} |
| 19 |
} |
| 20 |
|
| 21 |
set result_string3 {user_int(&$foo->bar): 40 |
| 22 |
user_int(&@var("foo")->bar): 40 |
| 23 |
&@cast($foo->bar, "struct foo")->bar: 42 |
| 24 |
$foo->bar == @entry($foo->bar): true} |
| 25 |
|
| 26 |
# s390x machines can't do $utimes$$, since all syscall args are |
| 27 |
# longs. So, we won't test the $utimes$$ stuff. |
| 28 |
if {[istarget s390x-*-*]} { |
| 29 |
set ::result_string "${result_string1}${result_string3}" |
| 30 |
} else { |
| 31 |
set ::result_string "${result_string1}${result_string2}${result_string3}" |
| 32 |
} |
| 33 |
|
| 34 |
# Only run on make installcheck and uprobes present. |
| 35 |
if {! [installtest_p]} { untested "$test"; return } |
| 36 |
if {! [uretprobes_p]} { untested "$test"; return } |
| 37 |
|
| 38 |
set res [target_compile ${testpath}/${test}.c ${test} executable "additional_flags=-O2 additional_flags=-g"] |
| 39 |
if { $res != "" } { |
| 40 |
verbose "target_compile failed: $res" 2 |
| 41 |
fail "${test}: unable to compile ${test}.c" |
| 42 |
} else { |
| 43 |
stap_run3 $test $srcdir/$subdir/$test.stp -c ./${test} -w |
| 44 |
} |
| 45 |
|
| 46 |
# Test for target program compiled without optimization |
| 47 |
set test_name "${test} (non-optimized)" |
| 48 |
set res [target_compile ${testpath}/${test}.c ${test} executable "additional_flags=-g"] |
| 49 |
if { $res != "" } { |
| 50 |
verbose "target_compile failed: $res" 2 |
| 51 |
fail "${test_name}: unable to compile ${test}.c" |
| 52 |
} else { |
| 53 |
stap_run3 $test_name $srcdir/$subdir/$test.stp -c ./${test} -w |
| 54 |
} |
| 55 |
|
| 56 |
# Cleanup |
| 57 |
if { $verbose == 0 } { catch { exec rm -f $test } } |