]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright 1999-2024 Free Software Foundation, Inc. |
6fdebc3d 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 | # Test that annotations support doesn't leave GDB's terminal settings | |
17 | # into effect when we run a foreground command. | |
18 | ||
6fdebc3d PA |
19 | standard_testfile |
20 | ||
21 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug] == -1} { | |
22 | return -1 | |
23 | } | |
24 | ||
740feeaa SM |
25 | # Because runto_main doesn't know how to handle the prompt with annotations, |
26 | # run to main before we set the annotation level. | |
65a33d75 | 27 | if {![runto_main]} { |
e70a7231 | 28 | return 1 |
740feeaa | 29 | } |
6fdebc3d PA |
30 | |
31 | # NOTE: this prompt is OK only when the annotation level is > 1 | |
32 | # NOTE: When this prompt is in use the gdb_test procedure cannot be | |
33 | # used because it assumes that the last char after the gdb_prompt is a | |
34 | # white space. This is not true with this annotated prompt. So we | |
35 | # must use the gdb_annota_test replacement below, or | |
36 | # gdb_test_multiple. | |
37 | ||
38 | set old_gdb_prompt $gdb_prompt | |
39 | set gdb_prompt "\r\n\032\032pre-prompt\r\n$gdb_prompt \r\n\032\032prompt\r\n" | |
40 | ||
41 | # Like gdb_test, but cope with the annotation prompt. | |
42 | proc gdb_annota_test {command pattern message} { | |
43 | global gdb_prompt | |
44 | ||
45 | gdb_test_multiple $command $message { | |
46 | -re "$pattern$gdb_prompt$" { | |
47 | pass "$message" | |
48 | } | |
49 | -re "$gdb_prompt$" { | |
50 | fail "$message" | |
51 | } | |
52 | } | |
53 | } | |
54 | ||
55 | # Set the annotation level to 2. | |
6fdebc3d PA |
56 | gdb_annota_test "set annotate 2" ".*" "annotation set at level 2" |
57 | ||
6fdebc3d PA |
58 | set test "delete breakpoints" |
59 | gdb_test_multiple "delete" $test { | |
4a4fd10d | 60 | -re "Delete all breakpoints, watchpoints, tracepoints, and catchpoints. .y or n." { |
6fdebc3d PA |
61 | send_gdb "y\n" |
62 | exp_continue | |
63 | } | |
64 | -re "$gdb_prompt$" { | |
65 | pass $test | |
66 | } | |
67 | } | |
68 | ||
69 | # Set the target running, and then type something. GDB used to have a | |
70 | # bug where it'd be accepting input even though the target was | |
71 | # supposedly resumed in the foreground. This ultimately resulted in | |
72 | # readline aborting. | |
73 | ||
74 | set linenum [gdb_get_line_number "set break here"] | |
75 | ||
76 | gdb_annota_test "break $linenum" \ | |
77 | "Breakpoint .*$srcfile, line .*" \ | |
78 | "break after sleep" | |
79 | ||
80 | # Continue, and wait a bit to make sure the inferior really starts | |
81 | # running. Wait less than much the program sleeps, which is 5 | |
82 | # seconds, though. | |
83 | set saw_continuing 0 | |
84 | set test "continue" | |
85 | gdb_test_multiple $test $test { | |
86 | -timeout 2 | |
87 | -re "Continuing\\." { | |
88 | set saw_continuing 1 | |
89 | exp_continue | |
90 | } | |
91 | timeout { | |
92 | gdb_assert $saw_continuing $test | |
93 | } | |
94 | } | |
95 | ||
96 | # Type something. | |
97 | send_gdb "print 1\n" | |
98 | ||
99 | # Poor buggy GDB would crash before the breakpoint was hit. | |
100 | set test "breakpoint hit" | |
101 | gdb_test_multiple "" $test { | |
102 | -re "stopped\r\n$gdb_prompt" { | |
103 | pass $test | |
104 | } | |
105 | } | |
106 | ||
107 | set test "print command result" | |
108 | gdb_test_multiple "" $test { | |
109 | -re "\r\n1\r\n\r\n\032\032value-history-end\r\n$gdb_prompt" { | |
110 | pass $test | |
111 | } | |
112 | } | |
113 | ||
114 | # Restore the original prompt for the rest of the testsuite. | |
115 | ||
116 | set gdb_prompt $old_gdb_prompt |