2 # Copyright
(C
) 2020 Free Software Foundation
, Inc.
4 # This
program is free software
; you can redistribute it and
/or modify
5 # under the terms of the GNU General Public License as published by
6 # the Free Software Foundation
; either version
3 of the License
, or
7 #
(at your option
) any later version.
9 # DejaGnu is distributed in the hope that it will be useful
, but
10 # WITHOUT
ANY WARRANTY
; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License
for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with DejaGnu
; if not
, write to the Free Software Foundation
,
16 # Inc.
, 51 Franklin Street
- Fifth Floor
, Boston
, MA
02110-1301, USA.
18 # load_base_board_description
"gdbserver-support"
23 # No multilib flags needed by default.
24 process_multilib_options
""
26 set_board_info compiler
[find_gcc
]
28 # When testing GCC in tree
, the libgloss linker scripts files aren
't
29 # usually in a known location, so we have to find them in the sysroot.
30 # FIXME: this may change in the near future, but for now it works.
31 set compiler "[find_gcc]"
32 set ret [local_exec "$compiler --print-sysroot" "" "" $timeout]
33 if { [lindex $ret 0] == 0 } {
34 set sysroot "[lindex $ret 1]"
35 # Strip the CR or LF off the end of the line as returned by GCC
36 regsub -all "\[\n\r\]+" $sysroot "" sysroot
38 # set library path environment variable for qemu
39 set env(QEMU_LD_PREFIX) $sysroot
41 # Define ld_library_path variable to workaround asan and go testsuites
43 set ld_library_path ""
45 # In the beginning, only linker scripts were used to produce a fully
46 # linked executable. Then a better solution of having GCC spec file
47 # "patches" worked much better. None of the ARM/AARCH64 target
48 # use linker scripts, some targets support both, some just the
50 set ldscripts [ glob -nocomplain $sysroot/usr/lib/*.ld ]
51 if { [string length $ldscripts] == 0 } {
52 warning "No linker scripts found."
54 set specfiles [ glob -nocomplain $sysroot/usr/lib/*.specs ]
55 if { [string length $specfiles] == 0 } {
56 warning "No spec files found."
58 # FIXME: For now, both ldscripts and specfiles are ignored, and a
59 # single value is used tor testing.
60 foreach spec $specfiles {
61 verbose "Found spec file $spec"
65 # The basic set of flags needed to build "hello world" for this
66 # board. This board uses libgloss and newlib.
67 case "$target_triplet" in {
70 set spec "elf-rdimon.specs"
80 set spec "elf-rdimon.specs"
82 { "aarch64be-*-elf" } {
83 set qemu "qemu-aarch64_be"
84 set spec "rdimon.specs"
87 set qemu "qemu-aarch64"
90 { "aarch64*-*elf*" } {
91 # There's multiple spec files
, but rdimon is the
92 # one usually used
for testing.
93 set qemu
"qemu-aarch64"
94 set spec
"rdimon.specs"
96 # FIXME
: These following qemu variants are just what QEMU
97 # supports
, the pattern to match
for the target needs to be
103 set qemu
"qemu-microblaze"
104 set spec
"elf-gloss-linux.specs"
106 { "microblazeel-*" } {
107 set qemu
"qemu-microblazeel"
108 set spec
"elf-gloss-linux.specs"
114 set qemu
"qemu-mips64"
117 set qemu
"qemu-mips64el"
120 set qemu
"qemu-mipsel"
123 set qemu
"qemu-mipsn32"
126 set qemu
"qemu-mipsn32el"
132 set qemu
"qemu-ppc64"
135 set qemu
"qemu-ppc64abi32"
138 set qemu
"qemu-ppc64le"
141 set qemu
"qemu-riscv32"
144 set qemu
"qemu-riscv64"
151 set qemu
"qemu-sh4eb"
154 set qemu
"qemu-sparc"
156 { "sparc32plus-*" } {
157 set qemu
"qemu-sparc32plus"
160 set qemu
"qemu-sparc64"
163 puts
"No target hardware for $target_triplet"
167 #
2345 is the default port used
for the remote debugging protocol
169 # QEMU uses the standard renmote debugging protocol as used by gdbserver.
170 set_board_info gdb_protocol
"remote"
171 # localhost is the default host used
for the remote debugging protocol
172 set_board_info sockethost
"localhost"
173 set_board_info gdb
,socketport $port
174 set_board_info target_sim_options
"-g $port"
175 set_board_info gdb_server_prog $qemu
176 set_board_info specfile $spec
177 set_board_info needs_status_wrapper
1
178 #set_board_info protocol standard
179 push_config target qemu
181 # Path to the gdbserver executable
, if required.
182 set_board_info gdb_server_prog
"/usr/bin/gdbserver"
184 # This gdbserver can only run a process once per session.
185 set_board_info gdb
,do_reload_on_run
1
186 set_board_info exit_is_reliable
1
188 #
Set this
if the board does not support passing arguments to the
190 set_board_info noargs
0
192 set_board_info cflags
"[libgloss_include_flags]"
193 set_board_info ldflags
"[libgloss_link_flags] [newlib_link_flags] -specs=$spec -static"
196 set_board_info rsh_prog
/usr
/bin
/ssh
197 set_board_info rcp_prog
/usr
/bin
/scp
199 proc qemu_load
{ dest prog
args } {
202 set ret
[local_exec
"$qemu $prog" "" "" $timeout]
204 if { [array size ret
] == 0 } {
212 # Start QEMU with the executable
214 proc qemu_download
{ dest prog
args } {
217 # qemu is already running with our executable.
221 #
Load executable into GDB
223 proc gdb_load
{ args } {
232 if [gdb_file_cmd $
args] then { return -1 }
235 if { $
args == "{}"} {
236 puts
"No executable passed to GDB!"
238 # Only the remote protocol is used with the QEMU
's gdbserver support
239 send_gdb "target extended-remote :2345\n"
241 -re ".*$gdb_prompt $" {
243 send_user "Connected to QEMU target\n"
246 -re "Remote debugging using .*$gdb_prompt $" {
247 verbose "Set target to remote for QEMU"
251 perror "Timed out trying to connect to QEMU target."
255 # send_gdb "continue\n"
260 -re ".*$gdb_prompt $" {
262 send_user "Loaded $args into GDB\n"
267 -re "$gdb_prompt $" {
269 perror "GDB couldn't
load.
"
274 perror
"Timed out trying to load $args."
283 proc runto_main
{ } {
287 send_gdb
"continue\n"
289 -re
".*$gdb_prompt $" {
291 send_user
"Continuing QEMU target\n"
296 perror
"Timed out trying to connect to QEMU target."
302 #
return [runto main no
-message
]