]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.threads/stepi-random-signal.exp
Update Copyright year range in all files maintained by GDB.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.threads / stepi-random-signal.exp
CommitLineData
ecd75fc8 1# Copyright 2013-2014 Free Software Foundation, Inc.
776f04fa
PA
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16standard_testfile
17set executable ${testfile}
18
19if { [gdb_compile_pthreads \
20 "${srcdir}/${subdir}/${srcfile}" \
21 "${binfile}" \
22 executable {debug}] != "" } {
23 untested "Couldn't compile test program."
24 return -1
25}
26
27clean_restart $executable
28
29# Start the second thread.
30if ![runto start] {
31 return -1
32}
33
34# Go back to the main thread, and leave it in the loop, where we're
35# reasonably sure we don't have 'conditional jmp $pc'-like
36# instructions. We wouldn't be able to detect whether a stepi makes
37# progress over those.
38gdb_test_no_output "set scheduler-locking on"
39gdb_test "thread 1" "Switching to .*"
40gdb_breakpoint $srcfile:[gdb_get_line_number "set break 2 here"]
41gdb_continue_to_breakpoint "loop" ".* set break 2 here .*"
42
43# Now back to thread 2, and let it queue a signal in thread 1.
44gdb_test "thread 2" "Switching to .*"
45gdb_breakpoint $srcfile:[gdb_get_line_number "set break here"]
46gdb_continue_to_breakpoint "after pthread_kill" ".* set break here .*"
47
48# We're now ready to stepi thread 1. It should immediately dequeue
49# the signal.
50gdb_test "thread 1" "Switching to .*" "thread 1 again"
51
52# No longer need these.
53delete_breakpoints
54
55# Turn on infrun debugging, so we can tell whether the signal is
56# really dequeued and that GDB sees it.
57gdb_test_no_output "set debug infrun 1"
58
59# Helper to extract the current PC. PREFIX is used to make each call
60# have its own unique test name.
61
62proc get_pc { prefix } {
63 with_test_prefix "$prefix" {
64 return [get_hexadecimal_valueof "\$pc" ""]
65 }
66}
67
68set prev_addr [get_pc "before stepi"]
69if {$prev_addr == ""} {
70 return
71}
72
73# True if we saw the infrun path we want to test be exercised.
74set seen 0
75
76set test "stepi"
77if {[gdb_test_multiple "stepi" "$test" {
78 -re "infrun: random signal" {
79 set seen 1
80 exp_continue
81 }
82 -re "$gdb_prompt $" {
83 }
84}] != 0} {
85 return
86}
87
88if {$seen} {
89 pass "$test"
90} else {
91 fail "$test (no random signal)"
92}
93
94set addr [get_pc "after stepi"]
95if {$addr == ""} {
96 return
97}
98
99set test "stepi interfered by signal makes progress"
100if {$addr == $prev_addr} {
101 fail "$test"
102} else {
103 pass "$test"
104}