]>
Commit | Line | Data |
---|---|---|
4a94e368 | 1 | # Copyright (C) 2014-2022 Free Software Foundation, Inc. |
0703599a 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 | ||
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 | |
19 | # thread, like: | |
20 | # | |
21 | # ADDR1 nop <-- breakpoint here | |
22 | # ADDR2 jmp PC | |
23 | # | |
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. | |
30 | ||
31 | standard_testfile | |
32 | ||
33 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] == -1} { | |
34 | return -1 | |
35 | } | |
36 | ||
0703599a PA |
37 | if ![runto_main] { |
38 | continue | |
39 | } | |
40 | ||
41 | # Make sure it's GDB's decr_pc logic that's being tested, not the | |
42 | # target's. | |
43 | gdb_test_no_output "set range-stepping off" | |
44 | ||
45 | delete_breakpoints | |
46 | ||
47 | gdb_breakpoint [gdb_get_line_number "set breakpoint here"] | |
48 | gdb_continue_to_breakpoint "run to nop breakpoint" | |
b05b1202 | 49 | gdb_test "info threads" " 1 .*\\\* 2 .*" "info threads shows all threads" |
0703599a PA |
50 | |
51 | gdb_test "next" "while.*" "next over nop" | |
52 | ||
53 | gdb_test_no_output "next&" "next& over inf loop" | |
54 | ||
55 | set test "switch to main thread" | |
56 | gdb_test_multiple "thread 1" $test { | |
57 | -re "Cannot execute this command while the target is running.*$gdb_prompt $" { | |
58 | unsupported $test | |
59 | ||
60 | # With remote targets, we can't send any other remote packet | |
61 | # until the target stops. Switching thread wants to ask the | |
62 | # remote side whether the thread is alive. | |
63 | return | |
64 | } | |
65 | -re "Switching to thread 1.*\\(running\\)\r\n$gdb_prompt " { | |
66 | # Prefer to match the prompt without an anchor. If there's a | |
67 | # bug and output comes after the prompt immediately, it's | |
68 | # faster to handle that in the following test, instead of | |
69 | # waiting for a timeout here. | |
70 | pass $test | |
71 | } | |
72 | } | |
73 | ||
74 | # Wait a bit. Use gdb_expect instead of sleep so that any (bad) GDB | |
75 | # output is visible in the log. | |
76 | gdb_expect 4 {} | |
77 | ||
78 | set test "no output while stepping" | |
79 | gdb_test_multiple "" $test { | |
80 | -timeout 1 | |
81 | timeout { | |
82 | pass $test | |
83 | } | |
84 | -re "." { | |
85 | # If we see any output, it's a failure. On the original bug, | |
86 | # this would be a breakpoint hit. | |
87 | fail $test | |
88 | } | |
89 | } |