1 # Copyright (C) 2014-2015 Free Software Foundation, Inc.
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.
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.
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/>.
16 # On decr_pc_after_break targets, GDB used to adjust the PC
17 # incorrectly if a background single-step stopped somewhere where
18 # PC-$decr_pc had a breakpoint, and the thread was not the current
21 # ADDR1 nop <-- breakpoint here
24 # IOW, say thread A is stepping ADDR2's line in the background (an
25 # infinite loop), and the user switches focus to thread B. GDB's
26 # adjust_pc_after_break logic would confuse the single-step stop of
27 # thread A for a hit of the breakpoint at ADDR1, and thus adjust
28 # thread A's PC to point at ADDR1 when it should not: the thread had
29 # been single-stepped, not continued.
33 if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] == -1} {
37 clean_restart $binfile
43 # Make sure it's GDB's decr_pc logic that's being tested, not the
45 gdb_test_no_output "set range-stepping off"
49 gdb_breakpoint [gdb_get_line_number "set breakpoint here"]
50 gdb_continue_to_breakpoint "run to nop breakpoint"
51 gdb_test "info threads" "\\\* 2 .* 1.*" "info threads shows all threads"
53 gdb_test "next" "while.*" "next over nop"
55 gdb_test_no_output "next&" "next& over inf loop"
57 set test "switch to main thread"
58 gdb_test_multiple "thread 1" $test {
59 -re "Cannot execute this command while the target is running.*$gdb_prompt $" {
62 # With remote targets, we can't send any other remote packet
63 # until the target stops. Switching thread wants to ask the
64 # remote side whether the thread is alive.
67 -re "Switching to thread 1.*\\(running\\)\r\n$gdb_prompt " {
68 # Prefer to match the prompt without an anchor. If there's a
69 # bug and output comes after the prompt immediately, it's
70 # faster to handle that in the following test, instead of
71 # waiting for a timeout here.
76 # Wait a bit. Use gdb_expect instead of sleep so that any (bad) GDB
77 # output is visible in the log.
80 set test "no output while stepping"
81 gdb_test_multiple "" $test {
87 # If we see any output, it's a failure. On the original bug,
88 # this would be a breakpoint hit.