Commit | Line | Data |
---|---|---|
3cada740 PA |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | # | |
88b9d363 | 3 | # Copyright 2018-2022 Free Software Foundation, Inc. |
3cada740 PA |
4 | # |
5 | # This program is free software; you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation; either version 3 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | ||
18 | # Test backward compatibility with older GDBservers which did not | |
19 | # include ";thread:NNN" in T stop replies when debugging | |
20 | # single-threaded programs, even though they'd list the main thread in | |
21 | # response to qfThreadInfo/qsThreadInfo. See PR remote/22597. | |
22 | ||
23 | load_lib gdbserver-support.exp | |
24 | ||
25 | if { [skip_gdbserver_tests] } { | |
26 | verbose "skipping gdbserver tests" | |
27 | return -1 | |
28 | } | |
29 | ||
30 | standard_testfile | |
7b0ff8a2 | 31 | if { [build_executable "failed to prepare" $testfile $srcfile] == -1 } { |
3cada740 PA |
32 | return -1 |
33 | } | |
34 | ||
24ed6739 | 35 | # Run the tests with different features of GDBserver disabled. |
e139a727 | 36 | proc run_test { disable_feature target_nonstop } { |
8dc558a0 | 37 | global binfile gdb_prompt decimal GDBFLAGS |
3cada740 | 38 | |
8dc558a0 SM |
39 | save_vars { GDBFLAGS } { |
40 | # If GDB and GDBserver are both running locally, set the sysroot to avoid | |
41 | # reading files via the remote protocol. | |
42 | if { ![is_remote host] && ![is_remote target] } { | |
43 | set GDBFLAGS "$GDBFLAGS -ex \"set sysroot\"" | |
44 | } | |
45 | ||
46 | clean_restart ${binfile} | |
47 | } | |
3cada740 | 48 | |
24ed6739 AB |
49 | # Make sure we're disconnected, in case we're testing with an |
50 | # extended-remote board, therefore already connected. | |
51 | gdb_test "disconnect" ".*" | |
3cada740 | 52 | |
e139a727 TBA |
53 | set packet_arg "" |
54 | if { $disable_feature != "" } { | |
55 | set packet_arg "--disable-packet=${disable_feature}" | |
56 | } | |
57 | set res [gdbserver_start $packet_arg $binfile] | |
24ed6739 AB |
58 | set gdbserver_protocol [lindex $res 0] |
59 | set gdbserver_gdbport [lindex $res 1] | |
3cada740 | 60 | |
24ed6739 AB |
61 | # Disable XML-based thread listing, and multi-process extensions. |
62 | gdb_test_no_output "set remote threads-packet off" | |
63 | gdb_test_no_output "set remote multiprocess-feature-packet off" | |
64 | ||
e139a727 TBA |
65 | # Set target-nonstop mode. |
66 | gdb_test_no_output "maint set target-non-stop ${target_nonstop}" | |
67 | ||
24ed6739 AB |
68 | set res [gdb_target_cmd $gdbserver_protocol $gdbserver_gdbport] |
69 | if ![gdb_assert {$res == 0} "connect"] { | |
70 | return | |
3cada740 | 71 | } |
24ed6739 AB |
72 | |
73 | # There should be only one thread listed. | |
74 | set test "info threads" | |
75 | gdb_test_multiple $test $test { | |
76 | -re "2 Thread.*$gdb_prompt $" { | |
77 | fail $test | |
78 | } | |
79 | -re "has terminated.*$gdb_prompt $" { | |
80 | fail $test | |
81 | } | |
82 | -re "\\\* 1\[\t \]*Thread\[^\r\n\]*\r\n$gdb_prompt $" { | |
83 | pass $test | |
84 | } | |
3cada740 | 85 | } |
3cada740 | 86 | |
24ed6739 | 87 | gdb_breakpoint "main" |
3cada740 | 88 | |
24ed6739 AB |
89 | # Bad GDB behaved like this: |
90 | # (gdb) c | |
91 | # Cannot execute this command without a live selected thread. | |
92 | # (gdb) | |
93 | gdb_test "c" "Breakpoint $decimal, main.*" "continue to main" | |
e139a727 TBA |
94 | |
95 | # Continue until exit. The server sends a 'W' with no PID. | |
96 | # Bad GDB gave an error like below when target is nonstop: | |
97 | # (gdb) c | |
98 | # Continuing. | |
99 | # No process or thread specified in stop reply: W00 | |
100 | gdb_continue_to_end "" continue 1 | |
24ed6739 AB |
101 | } |
102 | ||
103 | # Disable different features within gdbserver: | |
104 | # | |
105 | # Tthread: Start GDBserver, with ";thread:NNN" in T stop replies disabled, | |
106 | # emulating old gdbservers when debugging single-threaded programs. | |
107 | # | |
108 | # T: Start GDBserver with the entire 'T' stop reply packet disabled, | |
109 | # GDBserver will instead send the 'S' stop reply. | |
e139a727 TBA |
110 | foreach_with_prefix to_disable { "" Tthread T } { |
111 | foreach_with_prefix t_nonstop { off on } { | |
112 | run_test $to_disable $t_nonstop | |
113 | } | |
24ed6739 | 114 | } |
64d38fdd JM |
115 | |
116 | # Regression for PR gdb/26819: Cover the case when GDBserver does not report | |
117 | # any threads (i.e. the remote target has no concept of threads). | |
118 | # | |
119 | # Scenario 1: Disable 'T' and 'qfThreadInfo' packets | |
120 | # Scenario 2: Disable all threading packets | |
121 | foreach_with_prefix to_disable { "T,qfThreadInfo" "threads" } { | |
122 | # Non-stop mode not applicable - off. | |
123 | run_test $to_disable off | |
124 | } |