Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 1997-2020 Free Software Foundation, Inc. |
c906108c SS |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
c906108c SS |
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. | |
e22f8b7c | 12 | # |
c906108c | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 15 | |
c906108c SS |
16 | # display.exp Test display commands |
17 | # Also do some printing stuff for coverage's sake. | |
18 | # | |
f76495c8 | 19 | standard_testfile |
c906108c | 20 | |
5b362f04 | 21 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile \ |
f76495c8 | 22 | {debug nowarnings}]} { |
b60f0898 | 23 | return -1 |
c906108c | 24 | } |
c906108c | 25 | |
739d0d99 CV |
26 | # Preserve the old timeout, and set a new one that should be |
27 | # sufficient to avoid timing out during this test. | |
28 | set oldtimeout $timeout | |
29 | set timeout [expr "$timeout + 60"] | |
30 | verbose "Timeout is now $timeout seconds" 2 | |
c906108c SS |
31 | |
32 | # use this to debug: | |
33 | #log_user 1 | |
34 | ||
085dd6e6 JM |
35 | # Some coverage stuff |
36 | # | |
e11ac3a3 | 37 | if !$use_gdb_stub { |
1aca8eb7 ND |
38 | gdb_test "kill" ".*The program is not being run.*" |
39 | gdb_test "detach" ".*" | |
40 | gdb_test "run" ".*" | |
41 | ||
42 | gdb_load ${binfile} | |
43 | gdb_test "kill" ".*" "kill again" | |
44 | gdb_test "detach" ".*" "detach again" | |
45 | ||
46 | gdb_exit | |
47 | gdb_start | |
48 | gdb_reinitialize_dir $srcdir/$subdir | |
49 | gdb_load ${binfile} | |
50 | } | |
c906108c SS |
51 | |
52 | # Ok, on to real life | |
53 | # | |
96baa820 | 54 | if ![runto_main] then { |
bc6c7af4 | 55 | fail "could not run to main - other tests will fail." |
96baa820 | 56 | continue |
7a292a7a | 57 | } |
96baa820 | 58 | |
958a4e4c MS |
59 | # Disable hardware watchpoints if necessary. |
60 | if [target_info exists gdb,no_hardware_watchpoints] { | |
35ec993f | 61 | gdb_test_no_output "set can-use-hw-watchpoints 0" "" |
958a4e4c MS |
62 | } |
63 | ||
7cbcbded DJ |
64 | set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] |
65 | gdb_test "break $bp_location1" ".*Breakpoint 2.*" "break do_loops" | |
958a4e4c | 66 | gdb_test "cont" ".*Breakpoint 2, do_loops.*" "get to do_loops" |
c906108c SS |
67 | |
68 | # Create stopping points. | |
69 | # | |
958a4e4c | 70 | gdb_test "watch sum" ".*\[Ww\]atchpoint 3: sum.*" "set watch" |
7cbcbded DJ |
71 | set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] |
72 | gdb_test "break $bp_location2" ".*Breakpoint 4.*" "break loop end" | |
c906108c SS |
73 | |
74 | # Create displays for those points | |
75 | # | |
76 | gdb_test "info disp" ".*There are no auto-display expressions now..*" "inf disp" | |
77 | gdb_test "disp i" ".*1: i = 0.*" "display i" | |
78 | gdb_test "disp/x j" ".*2: /x j = 0x0.*" "display j" | |
2b28d209 | 79 | gdb_test "disp/i &k" ".*3: x/i &k(\r\n| ) $hex:.*" "display &k" |
739d0d99 | 80 | gdb_test "disp/f f" ".*4: /f f = 3.1415*" "display/f f" |
c906108c SS |
81 | gdb_test "disp/s &sum" ".*5: x/s &sum $hex.*sum.:.*" "display/s &sum" |
82 | ||
83 | # Hit the displays | |
84 | # | |
62147a22 PA |
85 | gdb_test "cont" [multi_line \ |
86 | ".*\[Ww\]atchpoint 3: sum.*" \ | |
87 | "\[1-9\]*: i = 0.*" \ | |
88 | "\[1-9\]*: /x j = 0x0" \ | |
89 | "\[1-9\]*: x/i &k.*" \ | |
90 | "\[1-9\]*: /f f = 3.1415" \ | |
91 | "\[1-9\]*: x/s &sum.*" \ | |
92 | ] "first disp" | |
93 | ||
94 | gdb_test "cont" [multi_line \ | |
95 | ".*\[Ww\]atchpoint 3: sum.*" \ | |
96 | "\[1-9\]*: i = 0.*" \ | |
97 | "\[1-9\]*: /x j = 0x0.*" \ | |
98 | "\[1-9\]*: x/i &k.*" \ | |
99 | "\[1-9\]*: /f f = 4.1415" \ | |
100 | "\[1-9\]*: x/s &sum.*" \ | |
101 | ] "second disp" | |
c906108c SS |
102 | |
103 | gdb_test "enab disp 6" ".*No display number 6..*" "catch err" | |
27d3a1a2 MS |
104 | gdb_test_no_output "disab disp 1" "disab disp 1" |
105 | gdb_test_no_output "disab disp 2" "disab disp 2" | |
106 | gdb_test_no_output "enab disp 1" "re-enab" | |
107 | gdb_test_no_output "enab disp 1" "re-enab of enab" | |
108 | gdb_test_no_output "undisp 5" "undisp" | |
62147a22 PA |
109 | gdb_test "info disp" [multi_line \ |
110 | "Auto-display expressions now in effect.*" \ | |
111 | ".*y i" \ | |
112 | ".*n /x j" \ | |
113 | ".*y /1bi &k" \ | |
114 | ".*y /f f" \ | |
11af934b | 115 | ] |
62147a22 PA |
116 | |
117 | gdb_test "cont" [multi_line \ | |
118 | ".*\[Ww\]atch.*" \ | |
119 | ".*i = 0" \ | |
120 | ".*5.1415" \ | |
121 | ] "next hit" | |
c906108c | 122 | |
a76e022a MS |
123 | gdb_test "undisp" \ |
124 | "" \ | |
125 | "undisp all" \ | |
126 | ".*Delete all auto-display expressions.*y or n. $" \ | |
127 | "y" | |
128 | ||
c906108c | 129 | |
9d8fa392 PA |
130 | # Test displaying a variable that is temporarily at a bad address. |
131 | # But if we can examine what's at memory address 0, then we'll also be | |
132 | # able to display it without error. Don't run the test in that case. | |
20c6f1e1 | 133 | set can_read_0 [is_address_zero_readable] |
9d8fa392 PA |
134 | |
135 | if { !$can_read_0 } { | |
136 | gdb_test "disp *p_i" ".*: \\*p_i = 0" | |
137 | gdb_test "p p_i = 0x0" " = \\(int \\*\\) 0x0" | |
138 | gdb_test "display" ".*: \\*p_i = <error: .*>" "display bad address" | |
139 | gdb_test "p p_i = &i" " = \\(int \\*\\) $hex" | |
140 | gdb_test "display" ".*: \\*p_i = 0" "display good address" | |
141 | ||
142 | gdb_test "undisp" \ | |
143 | "" \ | |
144 | "undisp all again" \ | |
145 | ".*Delete all auto-display expressions.*y or n. $" \ | |
146 | "y" | |
147 | } | |
148 | ||
11af934b | 149 | gdb_test "disab 3" ".*.*" |
958a4e4c | 150 | gdb_test "cont" ".*Breakpoint 4.*" "watch off" |
c906108c SS |
151 | |
152 | # Now the printf tests | |
153 | # | |
104c1213 JM |
154 | # The "finish" command may leave us mid-line in the caller on some |
155 | # targets, including but not limited to the m68k, i386 & PA. So we | |
156 | # have to arrange to step until we hit the line with the call to | |
157 | # "do_vars". | |
a76e022a | 158 | gdb_test_multiple "finish" "finish" { |
11cf8741 | 159 | -re ".*do_loops\\(\\);.*$gdb_prompt $" { |
104c1213 JM |
160 | send_gdb "step\n" |
161 | exp_continue | |
162 | } | |
163 | -re ".*do_vars.*$gdb_prompt $" { | |
164 | pass "finish" | |
165 | } | |
104c1213 JM |
166 | } |
167 | ||
7cbcbded DJ |
168 | gdb_test "step" ".*do_vars.*.*i = 9.*" |
169 | set bp_location3 [gdb_get_line_number "set breakpoint 3 here"] | |
170 | gdb_test "tbreak $bp_location3" ".*breakpoint 5 a.*" "tbreak in do_vars" | |
171 | gdb_test "cont" ".*do_vars.*$bp_location3.*$bp_location3.*" | |
c906108c SS |
172 | |
173 | # Beat on printf a bit | |
174 | # | |
a0b3c4fd JM |
175 | gdb_test "printf" ".*Argument required.*" |
176 | gdb_test "printf %d" ".*Bad format string, missing.*" | |
177 | gdb_test "printf \"%d" ".*Bad format string, non-terminated.*" | |
178 | gdb_test "printf \"%d%d\",i" ".*Wrong number of arguments.*" | |
96baa820 | 179 | gdb_test "printf \"\\\\!\\a\\f\\r\\t\\v\\b\\n\"" ".*!.*" |
27d3a1a2 | 180 | gdb_test_no_output "printf \"\"" "re-set term" |
a0b3c4fd JM |
181 | gdb_test "printf \"\\w\"" ".*Unrecognized escape character.*" |
182 | gdb_test "printf \"%d\" j" ".*Invalid argument syntax.*" | |
2025a643 DJ |
183 | gdb_test "printf \"%p\\n\", 0" "\\(nil\\)" |
184 | gdb_test "printf \"%p\\n\", 1" "0x1" | |
c906108c | 185 | |
958a4e4c | 186 | # play with "print", too |
c906108c | 187 | # |
6fbe845e | 188 | gdb_test "print/k j" ".*Undefined output format.*" |
a6bac58e TT |
189 | gdb_test "print/d j" " = 0\[\\r\\n\]+" "debug test output 1" |
190 | gdb_test "print/r j" " = 0\[\\r\\n\]+" "debug test output 1a" | |
191 | gdb_test "print/x j" " = 0x0\[\\r\\n\]+" "debug test output 2" | |
192 | gdb_test "print/r j" " = 0x0\[\\r\\n\]+" "debug test output 2a" | |
193 | gdb_test "print j" " = 0\[\\r\\n\]+" "debug test output 3" | |
a0b3c4fd | 194 | |
085dd6e6 | 195 | # x/0 j doesn't produce any output and terminates PA64 process when testing |
3ca22649 SM |
196 | gdb_test_no_output "x/0 j" |
197 | ||
11af934b | 198 | gdb_test "print/0 j" ".*Item count other than 1 is meaningless.*" |
ea37ba09 | 199 | gdb_test "print/s sum" " = 1000" "ignored s" |
958a4e4c MS |
200 | gdb_test "print/i sum" ".*Format letter.*is meaningless.*.*" "no i" |
201 | gdb_test "print/a &sum" ".*= $hex.*<sum>.*" | |
104c1213 JM |
202 | # If the constant below is larger than the length of main, then |
203 | # this test will (incorrectly) fail. So use a small number. | |
958a4e4c MS |
204 | gdb_test "print/a main+4" ".*= $hex.*<.*>.*" |
205 | gdb_test "print/a \$pc" ".*= $hex.*<do_vars+.*>.*" | |
206 | gdb_test "print/a &&j" ".*A .* error in expression.*" | |
c906108c SS |
207 | |
208 | # Done! | |
209 | # | |
210 | gdb_exit | |
739d0d99 CV |
211 | |
212 | # Restore the preserved old timeout value. | |
213 | set timeout $oldtimeout | |
214 | verbose "Timeout is now $timeout seconds" 2 | |
215 | ||
c906108c | 216 | return 0 |