blob: 00fc832d324de84c97ddb852e0700e9664c2475a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# Tests whether we can put statement probes on all lines of a function,
# even without debuginfo around (in guru mode currently). PR10454.
set test "uprobe_stmt_num"
# Only run on make installcheck and uprobes present.
if {! [installtest_p]} { untested "$test"; return }
if {! [uprobes_p]} { untested "$test"; return }
set testpath "$srcdir/$subdir"
set testsrc "$testpath/$test.c"
set testexe "[pwd]/$test"
# We want debug info and no optimization (every line counts).
set testflags "additional_flags=-g additional_flags=-O0"
set teststp "$testpath/$test.stp"
set res [target_compile $testsrc $testexe executable $testflags]
if { $res != "" } {
verbose "target_compile failed: $res" 2
fail "unable to compile $testsrc"
return
}
set cmd [concat stap -c $testexe $teststp]
send_log "cmd: $cmd\n"
catch {eval exec $cmd} output
send_log "cmd output: $output\n"
# There should be at least 6 lines probes
# Function entry, 4 actual source lines and function exit.
set output_lines [split $output "\n"]
set lines [llength $output_lines]
if { $lines >= 6 } {
pass "$test-run-one"
} else {
fail "$test-run-one ($lines)"
}
# Expect the same output for next runs
set ::result_string $output
# Sanity check, just run again...
stap_run3 $test-run-two $testpath/$test.stp -c $testexe
# create a script based on the given statements,
# probe all of them individually.
set fp [open $test-run-statements.stp "w"]
foreach line $output_lines {
puts $fp "probe process(\"uprobe_stmt_num\").statement($line)"
puts $fp "{"
puts $fp " printf(\"0x%x\\n\", uaddr());"
puts $fp "}"
}
close $fp
stap_run3 $test-run-statements $test-run-statements.stp -c $testexe
# Now strip away the line info and try again (with -g).
set strip_cmd [list "objcopy" "-R" ".debug_line"]
lappend strip_cmd "$testexe"
send_log "Executing: $strip_cmd\n"
eval exec $strip_cmd
stap_run3 $test-run-statements-nolines -w -g $test-run-statements.stp -c $testexe
# XXX Last test still fails. PR10454.
return
# Now strip away all debuginfo. Since the script doesn't need any it
# should still work.
set strip_cmd [list "strip" "-g"]
lappend strip_cmd "$testexe"
send_log "Executing: $strip_cmd\n"
eval exec $strip_cmd
stap_run3 $test-run-statements-nodebuginfo -w -g $test-run-statements.stp -c $testexe
# cleanup
eval exec rm $testexe $test-run-statements.stp
|