Add bfloat16 support for AVX512 register view.
[deliverable/binutils-gdb.git] / gdb / testsuite / lib / selftest-support.exp
1 # Copyright 2003-2020 Free Software Foundation, Inc.
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 # Find a pathname to a file that we would execute if the shell was asked
17 # to run $arg using the current PATH.
18
19 proc find_gdb { arg } {
20
21 # If the arg directly specifies an existing executable file, then
22 # simply use it.
23
24 if [file executable $arg] then {
25 return $arg
26 }
27
28 set result [which $arg]
29 if [string match "/" [ string range $result 0 0 ]] then {
30 return $result
31 }
32
33 # If everything fails, just return the unqualified pathname as default
34 # and hope for best.
35
36 return $arg
37 }
38
39 # A helper proc that sets up for self-testing.
40 # EXECUTABLE is the gdb to use.
41 # FUNCTION is the function to break in, either captured_main
42 # or captured_command_loop.
43
44 proc selftest_setup { executable function } {
45 global gdb_prompt
46 global timeout
47 global INTERNAL_GDBFLAGS
48
49 # load yourself into the debugger
50 # This can take a relatively long time, particularly for testing where
51 # the executable is being accessed over a network, or where gdb does not
52 # support partial symbols for a particular target and has to load the
53 # entire symbol table. Set the timeout to 10 minutes, which should be
54 # adequate for most environments (it *has* timed out with 5 min on a
55 # SPARCstation SLC under moderate load, so this isn't unreasonable).
56 # After gdb is started, set the timeout to 30 seconds for the duration
57 # of this test, and then back to the original value.
58
59 set oldtimeout $timeout
60 set timeout 600
61 verbose "Timeout is now $timeout seconds" 2
62
63 global gdb_file_cmd_debug_info
64 set gdb_file_cmd_debug_info "unset"
65
66 set result [gdb_load $executable]
67 set timeout $oldtimeout
68 verbose "Timeout is now $timeout seconds" 2
69
70 if { $result != 0 } then {
71 return -1
72 }
73
74 if { $gdb_file_cmd_debug_info != "debug" } then {
75 untested "no debug information, skipping testcase."
76 return -1
77 }
78
79 # Set a breakpoint at main. Allow more than one location, as
80 # workaround for PR26096 - "gdb sets breakpoint at cold clone".
81 gdb_test "break $function" \
82 "Breakpoint.*at.* (file.*, line|locations).*" \
83 "breakpoint in $function"
84
85 # run yourself
86 # It may take a very long time for the inferior gdb to start (lynx),
87 # so we bump it back up for the duration of this command.
88 set timeout 600
89
90 set description "run until breakpoint at $function"
91 gdb_test_multiple "run $INTERNAL_GDBFLAGS" "$description" {
92 -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(.*\\).* at .*main.c:.*$gdb_prompt $" {
93 pass "$description"
94 }
95 -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(.*\\).*$gdb_prompt $" {
96 xfail "$description (line numbers scrambled?)"
97 }
98 -re "vfork: No more processes.*$gdb_prompt $" {
99 fail "$description (out of virtual memory)"
100 set timeout $oldtimeout
101 verbose "Timeout is now $timeout seconds" 2
102 return -1
103 }
104 -re ".*$gdb_prompt $" {
105 fail "$description"
106 set timeout $oldtimeout
107 verbose "Timeout is now $timeout seconds" 2
108 return -1
109 }
110 }
111
112 set timeout $oldtimeout
113 verbose "Timeout is now $timeout seconds" 2
114
115 return 0
116 }
117
118 # A simple way to run some self-tests.
119
120 proc do_self_tests {function body} {
121 global GDB tool
122
123 # Are we testing with a remote board? In that case, the target
124 # won't have access to the GDB's auxilliary data files
125 # (data-directory, etc.). It's simpler to just skip.
126 if [is_remote target] {
127 return
128 }
129
130 # ... or seemingly testing with a cross debugger? Likely GDB
131 # wouldn't be able to debug itself then...
132 if ![isnative] {
133 return
134 }
135
136 # ... or with a stub-like server? I.e., gdbserver + "target
137 # remote"? In that case we won't be able to pass command line
138 # arguments to GDB, and selftest_setup wants to do exactly that.
139 if [use_gdb_stub] {
140 return
141 }
142
143 # Run the test with self. Copy the file executable file in case
144 # this OS doesn't like to edit its own text space.
145
146 set GDB_FULLPATH [find_gdb $GDB]
147
148 if {[is_remote host]} {
149 set xgdb x$tool
150 } else {
151 set xgdb [standard_output_file x$tool]
152 }
153
154 # Remove any old copy lying around.
155 remote_file host delete $xgdb
156
157 gdb_start
158 set file [remote_download host $GDB_FULLPATH $xgdb]
159
160 set result [selftest_setup $file $function]
161 if {$result == 0} then {
162 set result [uplevel $body]
163 }
164
165 gdb_exit
166 catch "remote_file host delete $file"
167
168 if {$result < 0} then {
169 warning "Couldn't test self"
170 }
171 }
This page took 0.0325 seconds and 4 git commands to generate.