Debian Codegraph @

testsuite/systemtap.context/uprobe_uaddr.exp

raw
1 # Tests uaddr in function call and return probes. For a call probe we
2 # expect the address to be in the function; for a return probe it
3 # should be in the function's caller.
4
5 set test "uprobe_uaddr"
6
7 # Only run on make installcheck and uprobes present.
8 if {! [installtest_p]} { untested "$test"; return }
9 if {! [uretprobes_p]} { untested "$test"; return }
10
11 set testpath "$srcdir/$subdir"
12 set testsrc "$testpath/uprobe_stmt_num.c"
13 set testexe "[pwd]/$test"
14
15 # We want debug info and no optimization (every line counts).
16 set testflags "additional_flags=-g additional_flags=-O0"
17 set teststp "$testpath/$test.stp"
18
19 set res [target_compile $testsrc $testexe executable $testflags]
20 if { $res != "" } {
21 verbose "target_compile failed: $res" 2
22 fail "unable to compile $testsrc"
23 return
24 }
25
26 set cmd [concat stap -c $testexe $teststp]
27 send_log "cmd: $cmd\n"
28 catch {eval exec $cmd} output
29 send_log "cmd output:\n $output\n"
30
31 # Only save the address lines.
32 set output_lines {}
33 foreach line [split $output "\n"] {
34 if {[regexp {0x[0-9]+} $line]} {
35 lappend output_lines "$line"
36 }
37 }
38
39 set lines [llength $output_lines]
40 if { $lines == 6 } {
41 pass "$test"
42 } else {
43 fail "$test ($lines)"
44 }
45
46 set result_funcs [list "main+*" "func+*" "func2+*" "func+*" "main+*"]
47 set lnr 0
48 foreach expected $result_funcs output $output_lines {
49 if {$expected != ""} {
50 if [string match $expected $output] {
51 pass "$test match line $lnr $expected"
52 } else {
53 fail "$test match line $lnr $expected $output"
54 }
55 incr lnr;
56 } else {
57 break;
58 }
59 }
60
61 if [string match "main *" [lindex $output_lines 5]] {
62 fail "$test return from main"
63 } else {
64 pass "$test return from main"
65 }