| 1 |
set test "stmt_inlines" |
| 2 |
if {![uprobes_p]} { untested "$test"; return } |
| 3 |
|
| 4 |
# This test verifies that probing a statement in a function inlined multiple |
| 5 |
# times will place a probe at all instances. |
| 6 |
|
| 7 |
# Earlier GCC versions do not output the required debuginfo for this test |
| 8 |
# (there is no DIE for access to the context variable $i in the inlined foo |
| 9 |
# DIEs). Not sure exactly which GCC version fixes this, but this should work |
| 10 |
# starting from at least GCC 4.4.0. |
| 11 |
if {[strverscmp $GCC_Version 4.4] < 0} { |
| 12 |
verbose -log "skipping $test.exp: GCC too old ($GCC_Version vs. 4.4)" |
| 13 |
untested $test |
| 14 |
return |
| 15 |
} |
| 16 |
|
| 17 |
proc cleanup_test {} { |
| 18 |
global test |
| 19 |
if {[file exists "$test"]} { |
| 20 |
file delete "$test" |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
catch {exec gcc -g -o $test $srcdir/$subdir/$test.c} err |
| 25 |
if {$err == "" && [file exists $test]} { |
| 26 |
pass "$test (compiled)" |
| 27 |
} else { |
| 28 |
fail "$test (compilation error)" |
| 29 |
cleanup_test |
| 30 |
return |
| 31 |
} |
| 32 |
|
| 33 |
# Check that the statement and var show up in -L |
| 34 |
|
| 35 |
eval spawn stap -L process("./$test").statement("foo@$test.c:6") |
| 36 |
set failed 1 |
| 37 |
expect { |
| 38 |
-timeout 30 |
| 39 |
-re {^process\("[^\"]+"\)\.statement\("foo@[^\:]+\:6"\) \$i:int\r\n$} { |
| 40 |
set failed 0 |
| 41 |
} |
| 42 |
timeout { kill -INT -[exp_pid] 2 } |
| 43 |
eof {} |
| 44 |
} |
| 45 |
catch {close}; catch {wait} |
| 46 |
|
| 47 |
if {!$failed} { |
| 48 |
pass "$test (listing)" |
| 49 |
} else { |
| 50 |
fail "$test (listing error)" |
| 51 |
cleanup_test |
| 52 |
return |
| 53 |
} |
| 54 |
|
| 55 |
# Now check that probing actually triggers the inlined statement twice |
| 56 |
|
| 57 |
if {![installtest_p]} { |
| 58 |
untested "$test (runtime)" |
| 59 |
cleanup_test |
| 60 |
return |
| 61 |
} |
| 62 |
|
| 63 |
set script " \ |
| 64 |
probe process(\"./$test\").statement(\"foo@$test.c:6\") { \ |
| 65 |
printf(\"before printf with i=%d\\n\", \$i) \ |
| 66 |
} \ |
| 67 |
" |
| 68 |
|
| 69 |
eval spawn stap -e {$script} -c "./$test" |
| 70 |
set n 0 |
| 71 |
expect { |
| 72 |
-timeout 60 |
| 73 |
"printf 1" { incr n; exp_continue } |
| 74 |
"printf 2" { incr n; exp_continue } |
| 75 |
"before printf with i=1" { incr n; exp_continue } |
| 76 |
"before printf with i=2" { incr n; exp_continue } |
| 77 |
timeout { kill -INT -[exp_pid] 2 } |
| 78 |
eof {} |
| 79 |
} |
| 80 |
catch {close}; catch {wait} |
| 81 |
|
| 82 |
if {$n == 4} { |
| 83 |
pass "$test (probing)" |
| 84 |
} else { |
| 85 |
fail "$test (probing error, expected 4, got $n)" |
| 86 |
cleanup_test |
| 87 |
return |
| 88 |
} |
| 89 |
|
| 90 |
cleanup_test |
| 91 |
|