summaryrefslogtreecommitdiffstats
path: root/testsuite/systemtap.context/backtrace.tcl
blob: 8d63604def0676b8f9dfca4887b3eed06c09f207 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
set m1 0
set m2 0
set m3 0
set m4 0
set m5 0
set m6 0

spawn stap backtrace.stp
#exp_internal 1
expect {
    -timeout 240
    "Systemtap probe: begin\r\n" {
	pass "backtrace of begin probe"
	exec echo 0 > /proc/stap_test_cmd
	exp_continue
    }
    -re {^backtrace from module\(\"systemtap_test_module2\"\)\.function\(\"yyy_func3@[^\r\n]+\r\n} {
	incr m1
	expect {
	    -timeout 5
	    -re {^ 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]\r\n} {
		if {$m1 == 1} {incr m1}
		exp_continue
	    }
	    -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} {
		if {$m1 == 2} {incr m1}
		exp_continue
	    }
	    -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} {
		if {$m1 == 3} {incr m1}
	    }
	}
	exp_continue
    }
    -re {.*---\r\nthe call stack is 0x[a-f0-9]+ [^\r\n]+\r\n} {
	incr m2
	expect {
	    -timeout 5
	    -re {.*---\r\n 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]\r\n} {
		if {$m2 == 1} {incr m2}
		exp_continue
	    }
	    -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} {
		if {$m2 == 2} {incr m2}
		exp_continue
	    }
	    -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} {
		if {$m2 == 3} {incr m2}
	    }
	}
	exp_continue
    }
    -re {.*backtrace from module\(\"systemtap_test_module2\"\)\.function\(\"yyy_func4@[^\r\n]+\r\n} {
	incr m3
	expect {
	    -timeout 5
            -re {^Returning from: 0x[a-f0-9]+ : yyy_func4[^\[]+\[systemtap_test_module2\]\r\n} {
		if {$m3 == 1} {incr m3}
		exp_continue
            }
            -re {^Returning to  : 0x[a-f0-9]+ : yyy_func3[^\[]+\[systemtap_test_module2\]\r\n} {
		if {$m3 == 2} {incr m3}
		exp_continue
            }
	    -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} {
		if {$m3 == 3} {incr m3}
		exp_continue
	    }
	    -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} {
		if {$m3 == 4} {incr m3}
	    }
	}
	exp_continue
    }
    -re {.*---\r\nthe return stack is 0x[a-f0-9]+ [^\r\n]+\r\n} {
	incr m4
	expect {
	    -timeout 5
	    -re {.*0x[a-f0-9]+ : kretprobe_trampoline_holder[^\[]+\[\]\r\n} {
		if {$m4 == 1} {incr m4}
		exp_continue
	    }
	    -re {^ 0x[a-f0-9]+ : yyy_func2[^\[]+\[systemtap_test_module2\]\r\n} {
		if {$m4 == 2} {incr m4}
		exp_continue
	    }
	    -re {^ 0x[a-f0-9]+ : yyy_func1[^\[]+\[systemtap_test_module2\]\r\n} {
		if {$m4 == 3} {incr m4}
	    }
	}
	exp_continue
    }
    -re {.*backtrace from timer.profile:\r\n} {
	incr m5
	expect {
	    -timeout 5
	    -re {^ 0x[a-f0-9]+ : [^\r\n]+\r\n 0x[a-f0-9]+ : [^\r\n]+\r\n} {
		if {$m5 == 1} {incr m5}
	    }
	}
	exp_continue
    }
    -re {.*---\r\nthe profile stack is 0x[a-f0-9]+ [^\r\n]+\r\n} {
	incr m6
	expect {
	    -timeout 5
	    -re {.*---\r\n 0x[a-f0-9]+ : [^\r\n]+\r\n 0x[a-f0-9]+ : [^\r\n]+\r\n} {
		if {$m6 == 1} {incr m6}
	    }
	}
    }
   eof {fail "backtrace of yyy_func3, yyy_func4.return and timer.profile. unexpected EOF" }
}
send "\003"
if {$m1 == 4} {
    pass "backtrace of yyy_func3"
} else {
    fail "backtrace of yyy_func3 ($m1)"
}
if {$m2 == 4} {
    pass "print_stack of yyy_func3"
} else {
    fail "print_stack of yyy_func3 ($m2)"
}
if {$m3 == 5} {
    pass "backtrace of yyy_func4.return"
} else {
    fail "backtrace of yyy_func4.return ($m3)"
}
if {$m4 == 4} {
    pass "print_stack of yyy_func4.return"
} else {
    fail "print_stack of yyy_func4.return ($m4)"
}
if {$m5 == 2} {
    pass "backtrace of timer.profile"
} else {
    fail "backtrace of timer.profile ($m5)"
}
if {$m6 == 2} {
    pass "print_stack of timer.profile"
} else {
    fail "print_stack of timer.profile ($m6)"
}

close
wait