From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kRpLAGvS/mphtx8AWB0awg (envelope-from ) for ; Thu, 19 Nov 2026 05:41:47 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=vrany.io header.i=@vrany.io header.a=rsa-sha256 header.s=protonmail header.b=E9Z/vBv6; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id F1A171E0BC; Thu, 19 Nov 2026 05:41:46 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C887A1E087 for ; Thu, 19 Nov 2026 05:41:45 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D2ED74BA2E38 for ; Thu, 19 Nov 2026 10:41:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D2ED74BA2E38 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=vrany.io header.i=@vrany.io header.a=rsa-sha256 header.s=protonmail header.b=E9Z/vBv6 Received: from mail-4320.protonmail.ch (mail-4320.protonmail.ch [185.70.43.20]) by sourceware.org (Postfix) with ESMTPS id 5EC084BA2E0B for ; Thu, 19 Nov 2026 10:41:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5EC084BA2E0B Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=vrany.io Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrany.io ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5EC084BA2E0B Authentication-Results: sourceware.org; arc=none smtp.remote-ip=185.70.43.20 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795084870; cv=none; b=qUAjmjjv99uCv+dQLt20AHiB0qpwh3iAneZvSsvhvaHs/Cosz3yEdly2zhHZLnFTvddhCi0q3/i1Iz39uxKI4dtmG5qq73H5Ug6neG/qQ6Tlh8kY+wi9F+O8Vmc2ZuWdxXhhftyy85Uo3zqehMHjpax6Y8r4d9iDiJ/pUHkkFcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795084870; c=relaxed/simple; bh=cFq+8yLrF2smvJTG6hx9n3u5gOA6vriPFQFhwFTUihA=; h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version; b=IByGHrRRgTVNwMgKM/ww74eU1oM659QiZzPqIOp9uoGVtaqMx2S9CVRVdbMuIKStPWjl/okzWCwQll6PVBQ46fe2JjpjFi6aQANEMAVbudi7N7rRkGOWpMGrf5jkMLfZdyF9RN9PCjCXV7qQNGvE+gwWmXUcyGZvdmdM/zQ4sHU= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=vrany.io header.i=@vrany.io header.a=rsa-sha256 header.s=protonmail header.b=E9Z/vBv6 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5EC084BA2E0B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrany.io; s=protonmail; t=1795084863; x=1795344063; bh=cFq+8yLrF2smvJTG6hx9n3u5gOA6vriPFQFhwFTUihA=; h=Date:To:From:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=E9Z/vBv69/dRBIvUzJ3nMgcl/vivfOowk/SRmnG0Fpw3MmpgvUkDENoKVs7zxAqnl xQsKIQfq3g9MnCJ/Ju8T0zSMBmvZNcSdn1Rz8z7DchSWSvHYClfFt2+A4n+minBXNS +hQi4dOUf7wfL9od3vKq9Aym1dNGqr8MeCflJQ8ndA+EJR48M9UEklRcVlRMJqcsFo 0WB2J0a8RgxZ9WTmsjqCW/Yb28PqX7wePOTCBwye35xS0qtOKI0d6QmFAjjozcohGk GhimZ+NEo+1awiHRPU5hyoJMBEeqYwHG+OZtPXVxZFwKPY25a8bqg1GgQAWgXGPc1i tTBqgnzIqGnLQ== Date: Thu, 19 Nov 2026 10:41:01 +0000 To: simark@simark.ca, gdb-patches@sourceware.org From: Jan Vrany Subject: [PING] Re: [PATCH v3] gdb/testsuite: add support for running tests using QEMU Message-ID: <5b67fb5f9a484b22eaf3a6f64bcbbf0da9d26360.camel@vrany.io> In-Reply-To: <20261110232643.2945321-1-jan@vrany.io> References: <20261110232643.2945321-1-jan@vrany.io> Feedback-ID: 40767693:user:proton X-Pm-Message-ID: 75d3313358de600568315a966d9a84b19da99207 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Polite ping, thanks! Jan On Tue, 2026-11-10 at 23:29 +0000, Jan Vrany wrote: > Below is a v3 of patch adding support for running tests using QEMU. >=20 > The v1 submission is here: >=20 > =C2=A0=C2=A0 https://inbox.sourceware.org/gdb-patches/20261026100153.1789= 950-1-jan@vrany.io/ >=20 > The v2 submission is here: >=20 > =C2=A0=C2=A0 https://inbox.sourceware.org/gdb-patches/20261027135827.3868= 769-1-jan@vrany.io/ >=20 > Changes in v3: >=20 > =C2=A0=C2=A0 * This version *does not* use unix sockets. I tried but quic= kly run > =C2=A0=C2=A0=C2=A0=C2=A0 into a issues with limited path length and socke= t cleanups so > =C2=A0=C2=A0=C2=A0=C2=A0 I left it for later. >=20 > =C2=A0=C2=A0 * Updated the comment in qemu-user.exp and added example wit= h QEMU_FLAGS. >=20 > =C2=A0=C2=A0 * Fixed a number of TCL coding issues pointed out by Simon >=20 > =C2=A0=C2=A0 * If given --target is not yet supported by qemu-user board,= do not > =C2=A0=C2=A0=C2=A0=C2=A0 make it hard error as long as both QEMU and CROS= S are supported > =C2=A0=C2=A0=C2=A0=C2=A0 (if both are provided, --target value is effecti= vely ignored). >=20 > =C2=A0=C2=A0 * Extracted qemu cleanup code to new function - qemu_reap - = and use it. > =C2=A0=C2=A0=C2=A0=C2=A0 Since I decided to use it also in case QEMU term= inates immediately, > =C2=A0=C2=A0=C2=A0=C2=A0 I dropped the warning about failing to close QEM= U (since in that case, > =C2=A0=C2=A0=C2=A0=C2=A0 channel would be already closed). >=20 > =C2=A0=C2=A0 * Drop handling of CFLAGS_FOR_TARGET environment (when I tri= ed, I did not > =C2=A0=C2=A0=C2=A0=C2=A0 realize I had to put it into RUNTESTFLAGS in ord= e to make it work without > =C2=A0=C2=A0=C2=A0=C2=A0 extra code). >=20 > =C2=A0=C2=A0 * Use get_portnum instead of generating port randomly. >=20 > =C2=A0=C2=A0 * Consistently prefix all log messages / warnings with "qemu= -user:" to > =C2=A0=C2=A0=C2=A0=C2=A0 ease debugging. >=20 > > I noticed that GDB reads the target libraries through the remote > > protocol.=C2=A0 Since the sysroot is on disk, we could point GDB to it,= which > > would make it faster. > >=20 > > I added: > >=20 > > =C2=A0 set sysroot /home/smarchi/x-tools/armv7-rpi2-linux-gnueabihf/arm= v7-rpi2-linux-gnueabihf/sysroot > >=20 > > in my GDBFLAGS, and the time to run gdb.base/break.exp went from 209s t= o > > 50s. > >=20 > > Maybe we can have the board accept a SYSROOT variable, which it could > > use to: > >=20 > > =C2=A01. pass `-L $SYSROOT` to qemu > > =C2=A02. add `set sysroot $SYSROOT` to GDBFLAGS > >=20 > > If SYSROOT is not set, then we can query qemu for its default: > >=20 > > =C2=A0 $ qemu-aarch64 -h | grep ^QEMU_LD_PREFIX > > =C2=A0 QEMU_LD_PREFIX=C2=A0 =3D /usr/gnemul/qemu-aarch64 > >=20 > > And then we can pass that as a sysroot to GDB.=C2=A0 It doesn't have to= be in > > the first version, I can work on that as an optimization after the boar= d > > is merged. >=20 > That's a good idea. We can check QEMU_FLAGS and QEMU_LD_PREFIX rather tha= n > introducing yet another variable. But I'll leave it for later. >=20 > > ... > >=20 > > > + > > > + verbose -log "Spawning qemu: $cmd" > > > + > > > + if {[catch { eval $cmd } err ]} { > >=20 > > I could imagine all sorts of problems due to eval, like if inferior_arg= s > > contains some special characters that have a meaning in tcl.=C2=A0 I wo= uld > > write it directly here, even if that means duplication with the logging > > message. > >=20 > > =C2=A0 spawn -noecho $qemu {*}$qemu_flags -g $portnum $file {*}$inferio= r_args > >=20 >=20 > I changed that to do exactly the above but this requires splitting QEMU_F= LAGS > according to shell quoting/escaping rules. As I could not find a TCL func= tion > for that (like Python's shlex.split()) so in v3 I merely split it by spac= es. >=20 > Thanks! > Jan >=20 > -- 8< -- > gdb/testsuite: add support for running tests using QEMU >=20 > While debugging failing RISC-V tests, I found myself once again in a > situation where running tests easily using QEMU usermode emulation > would be useful. Since this is something that resurfaces every now and > then [1], I decided to have another stab at it. >=20 > This commit adds a new "board" file - qemu-user.exp - that allows running > tests using QEMU usermode emulation. The main goal is to make it easier > to test changes on multiple different architectures. However using QEMU > to run tests is no substitute for running tests on real hardware (or > in a VM). See limitations below. >=20 > The implementation based on simavr.exp and on an earlier patch by > Zeck S [2] and somewhat simplified. Unlike previous attempts, test > programs are no compiled statically by default in order to support > broader set of testcases. A static compilation can be forced by setting > CFLAGS_FOR_TARGET=3D-static. It also supports more targets (new targets > should be easy to add). >=20 > Not all test that pass on real hardware pass when run under usermode > QEMU. Some failures stem from limitations of QEMU's GDB stub - it does > not support non-stop mode, multiple threads, hardware watchpoints. In > some other cases GDB crashes, perhaps due to a bug in either GDB or QEMU. > I have made no attempt to investigate these failures in detail. >=20 > Running all tests in gdb.base on x86_64 Linux using qemu-aarch64 I got: >=20 > =C2=A0=C2=A0=C2=A0 # of unexpected core files 1 > =C2=A0=C2=A0=C2=A0 # of expected passes 66182 > =C2=A0=C2=A0=C2=A0 # of unexpected failures 558 > =C2=A0=C2=A0=C2=A0 # of expected failures 20 > =C2=A0=C2=A0=C2=A0 # of known failures 29 > =C2=A0=C2=A0=C2=A0 # of untested testcases 14 > =C2=A0=C2=A0=C2=A0 # of unresolved testcases 4 > =C2=A0=C2=A0=C2=A0 # of unsupported tests 146 > =C2=A0=C2=A0=C2=A0 # of paths in test names 7 > =C2=A0=C2=A0=C2=A0 # of duplicate test names 3 >=20 > Running same set of tests using qemu-x86_64 I got: >=20 > =C2=A0=C2=A0=C2=A0 # of unexpected core files 1 > =C2=A0=C2=A0=C2=A0 # of expected passes 64988 > =C2=A0=C2=A0=C2=A0 # of unexpected failures 2527 > =C2=A0=C2=A0=C2=A0 # of expected failures 20 > =C2=A0=C2=A0=C2=A0 # of known failures 29 > =C2=A0=C2=A0=C2=A0 # of untested testcases 8 > =C2=A0=C2=A0=C2=A0 # of unresolved testcases 5 > =C2=A0=C2=A0=C2=A0 # of unsupported tests 174 > =C2=A0=C2=A0=C2=A0 # of paths in test names 7 > =C2=A0=C2=A0=C2=A0 # of duplicate test names 5 >=20 > [1]: https://inbox.sourceware.org/gdb/938d2b5574b94d9584b758eee3c0c064@ti= .com/ > [2]: https://inbox.sourceware.org/gdb-patches/20231204024634.419445-3-zec= k654321@gmail.com/ >=20 > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D33590 > --- > =C2=A0gdb/testsuite/boards/qemu-user.exp | 244 ++++++++++++++++++++++++++= +++ > =C2=A01 file changed, 244 insertions(+) > =C2=A0create mode 100644 gdb/testsuite/boards/qemu-user.exp >=20 > diff --git a/gdb/testsuite/boards/qemu-user.exp b/gdb/testsuite/boards/qe= mu-user.exp > new file mode 100644 > index 00000000000..0206d6e9d40 > --- /dev/null > +++ b/gdb/testsuite/boards/qemu-user.exp > @@ -0,0 +1,244 @@ > +# Copyright 2026 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=C2=A0 See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program.=C2=A0 If not, see . > + > +# This file is a dejagnu "board file" and is used to run the testsuite > +# using QEMU's usermode emulation.=C2=A0 Use --target to specify desired= target. > +# > +# To use a specific QEMU, pass custom options to QEMU, specify the targe= t > +# toolchain to use, set environment variable QEMU, QEMU_FLAGS, CROSS (se= e > +# examples below). > +# > +# Note that to execute dynamically linked programs with qemu-user, a min= imal > +# sysroot is required.=C2=A0 It contains the target system's dynamic lin= ker and the > +# shared libraries needed by the program.=C2=A0 If it is not located at = the default > +# path, either set QEMU_LD_PREFIX to the sysroot path or set QEMU_FLAGS = to > +# "-L /path/to/sysroot". > +# > +# To avoid the need for minimal sysroot altogether, force static compila= tion > +# by setting CFLAGS_FOR_TARGET to "-static" (see example below).=C2= =A0 Note however > +# that some tests need dynamic linking (for example, gdb.base/solib-vani= sh.exp) > +# > +# Example usage: > +# > +#=C2=A0=C2=A0=C2=A0=C2=A0 make check RUNTESTFLAGS=3D'--target=3Driscv64-= unknown-linux-gnu --target_board=3Dqemu-user' > +# > +#=C2=A0=C2=A0=C2=A0=C2=A0 make check QEMU=3Dqemu-aarch64 QEMU_FLAGS=3D'-= L /usr/aarch64-linux-gnu' \ > +#=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 CROSS=3Daarch64-linux-gnu- \ > +#=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 RUNTESTFLAGS=3D'--target=3Da= arch64-linux-gnu --target_board=3Dqemu-user' > +# > +#=C2=A0=C2=A0=C2=A0=C2=A0 make check CROSS=3D/opt/gcc-8-armhf/bin/arm-li= nux-gnueabihf- \ > +#=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 RUNTESTFLAGS=3D'--target=3Da= rm-unknown-linux-gnueabihf --target_board=3Dqemu-user' > +# > +#=C2=A0=C2=A0=C2=A0=C2=A0 make check \ > +#=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 RUNTESTFLAGS=3D'CFLAGS_FOR_T= ARGET=3D-static --target=3Daarch64-unknown-linux-gnu --target_board=3Dqemu-= user' > +# > + > +# Load this for "gdb_target_cmd_ext" > +load_lib gdbserver-support.exp > + > +# > +# Setup > +# > +set qemu "" > +set qemu_flags {} > +set cross "" > + > +# Provide sensible defaults based on TARGET_TRIPLET (--target option). > +# Add more if needed. > +switch -glob $target_triplet { > +=C2=A0=C2=A0=C2=A0 "x86_64-*-linux-gnu" { > + set qemu "qemu-x86_64" > + set cross "x86_64-linux-gnu-" > +=C2=A0=C2=A0=C2=A0 } > +=C2=A0=C2=A0=C2=A0 "riscv64-*-linux-gnu" { > + set qemu "qemu-riscv64" > + set cross "riscv64-linux-gnu-" > +=C2=A0=C2=A0=C2=A0 } > +=C2=A0=C2=A0=C2=A0 "aarch64-*-linux-gnu" { > + set qemu "qemu-aarch64" > + set cross "aarch64-linux-gnu-" > +=C2=A0=C2=A0=C2=A0 } > +=C2=A0=C2=A0=C2=A0 "arm-*-linux-gnueabihf" { > + set qemu "qemu-arm" > + set cross "arm-linux-gnueabihf-" > +=C2=A0=C2=A0=C2=A0 } > +=C2=A0=C2=A0=C2=A0 "powerpc-*-linux-gnu" { > + set qemu "qemu-ppc" > + set cross "powerpc-linux-gnu-" > +=C2=A0=C2=A0=C2=A0 } > +=C2=A0=C2=A0=C2=A0 "powerpc64le-*-linux-gnu" { > + set qemu "qemu-ppc64le" > + set cross "powerpc64le-linux-gnu-" > +=C2=A0=C2=A0=C2=A0 } > +=C2=A0=C2=A0=C2=A0 default { > + if { ![info exist ::env(QEMU)] || ![info exists ::env(CROSS)] } { > + =C2=A0=C2=A0=C2=A0 error "No defaults for target $target_triplet - you = may want to specify QEMU and CROSS variables." > + } > +=C2=A0=C2=A0=C2=A0 } > +} > + > +# > +# Allow user to specify QEMU binary and/or custom options by setting > +# QEMU and/or QEMU_FLAGS environment variables. > +# > +if [info exists ::env(QEMU)] { > +=C2=A0=C2=A0=C2=A0 set qemu $::env(QEMU) > +} > +if [info exists ::env(QEMU_FLAGS)] { > +=C2=A0=C2=A0=C2=A0 # Here we split QEMU_FLAGS to a list of arguments.= =C2=A0 We use a simplistic > +=C2=A0=C2=A0=C2=A0 # method by splitting by space - so shell-style quoti= ng and escaping is > +=C2=A0=C2=A0=C2=A0 # not supported. > +=C2=A0=C2=A0=C2=A0 set qemu_flags [regexp -all -inline {\S+} $::env(QEMU= _FLAGS)] > +} > + > +# > +# Allow user to specify target toolchain by setting CROSS environment va= riable > +# > +if [info exists ::env(CROSS)] { > +=C2=A0=C2=A0=C2=A0 set cross $::env(CROSS) > +} > + > +set qemu_spawn_id "" > + > +set_board_info compiler "${cross}gcc" > +set_board_info c++compiler "${cross}g++" > + > +set_board_info use_gdb_stub 1 > +set_board_info gdb_protocol "remote" > +set_board_info gdb,do_reload_on_run 1 > +set_board_info gdb,nofileio 1 > +set_board_info exit_is_reliable 1 > +# QEMU does not support HW watchpoints > +set_board_info gdb,no_hardware_watchpoints 1 > + > + > + > +# Helper function to reap previously spawn QEMU.=C2=A0 Calling this func= tion > +# if no QEMU is running is no-op. > + > +proc qemu_reap { } { > +=C2=A0=C2=A0=C2=A0 global qemu_spawn_id > + > +=C2=A0=C2=A0=C2=A0 if { $qemu_spawn_id !=3D "" } { > + verbose -log "qemu-user: closing previous spawn id $qemu_spawn_id" > + catch { close -i $qemu_spawn_id } > + > + # Some tests get QEMU/its gdb stub into a state where the process > + # doesn't want to die.=C2=A0 Use -nowait to tell TCL to wait in backgro= und > + # instead of blocking. > + wait -nowait -i $qemu_spawn_id > + set qemu_spawn_id "" > + unset ::inferior_spawn_id > +=C2=A0=C2=A0=C2=A0 } > +} > + > +# Helper function to run QEMU.=C2=A0 Returns the port number on which QE= MU > +# stub listens or 0 on failure. > + > +proc qemu_spawn { file inferior_args } { > +=C2=A0=C2=A0=C2=A0 global qemu_spawn_id > +=C2=A0=C2=A0=C2=A0 global qemu > +=C2=A0=C2=A0=C2=A0 global qemu_flags > + > +=C2=A0=C2=A0=C2=A0 # Close any previous QEMU instance. > +=C2=A0=C2=A0=C2=A0 qemu_reap > + > +=C2=A0=C2=A0=C2=A0 # Run QEMU. > +=C2=A0=C2=A0=C2=A0 while 1 { > + set portnum [get_portnum] > + set qemu_args [list {*}$qemu_flags -g $portnum $file {*}$inferior_args] > + > + if {[catch { spawn $qemu {*}$qemu_args } err ]} { > + =C2=A0=C2=A0=C2=A0 verbose -log "qemu-user: failed to spawn QEMU: $err" > + =C2=A0=C2=A0=C2=A0 return 0 > + } > + set qemu_spawn_id $spawn_id > + > + # QEMU stub doesn't do inferior I/O through GDB.=C2=A0 But we can > + # talk to the program using QEMU's tty instead. > + global inferior_spawn_id > + set inferior_spawn_id $spawn_id > + > + expect { > + =C2=A0=C2=A0=C2=A0 -i $qemu_spawn_id > + =C2=A0=C2=A0=C2=A0 -timeout 1 > + =C2=A0=C2=A0=C2=A0 -re ".*Address already in use.*" { > + # Port already in use.=C2=A0 Cleanup and retry. > + verbose -log "qemu-user: port $portnum is already in use." > + > + qemu_reap > + continue > + =C2=A0=C2=A0=C2=A0 } > + =C2=A0=C2=A0=C2=A0 eof { > + verbose -log "qemu-user: QEMU terminated prematurely." > + > + qemu_reap > + return 0 > + =C2=A0=C2=A0=C2=A0 } > + > + } > + > + verbose -log "qemu-user: spawned with spawn id $qemu_spawn_id, pid [exp= _pid $qemu_spawn_id], stub listening at $portnum" > + break > +=C2=A0=C2=A0=C2=A0 } > + > +=C2=A0=C2=A0=C2=A0 return $portnum > +} > + > + > + > +# gdb_reload -- load a file into the target. > + > +proc gdb_reload { {inferior_args {}} } { > +=C2=A0=C2=A0=C2=A0 global last_loaded_file > +=C2=A0=C2=A0=C2=A0 set portnum [qemu_spawn $last_loaded_file $inferior_a= rgs] > + > +=C2=A0=C2=A0=C2=A0 if { $portnum =3D=3D 0 } { > + return 1 > +=C2=A0=C2=A0=C2=A0 } > + > +=C2=A0=C2=A0=C2=A0 set res [gdb_target_cmd_ext "remote" ":$portnum"] > + > +=C2=A0=C2=A0=C2=A0 if { $res =3D=3D 2 } { > + unsupported "qemu-user: cannot connect to QEMU stub (likely because QEM= U does not support non-stop mode)." > + # QEMU does not support non-stop mode.=C2=A0 Exit here to avoid subsequ= ent > + # failures / timeouts. > + qemu_reap > + exit 0 > +=C2=A0=C2=A0=C2=A0 } > +=C2=A0=C2=A0=C2=A0 if { $res !=3D 0 } { > + qemu_reap > + return 1 > +=C2=A0=C2=A0=C2=A0 } > +=C2=A0=C2=A0=C2=A0 return 0 > +} > + > +proc mi_gdb_target_load { } { > +=C2=A0=C2=A0=C2=A0 global last_loaded_file > +=C2=A0=C2=A0=C2=A0 set portnum [qemu_spawn $last_loaded_file ""] > + > +=C2=A0=C2=A0=C2=A0 if { $portnum =3D=3D 0 } { > + return -1 > +=C2=A0=C2=A0=C2=A0 } > + > +=C2=A0=C2=A0=C2=A0 if {[mi_gdb_target_cmd "remote" ":$portnum"] !=3D 0} = { > + qemu_reap > + return -1 > +=C2=A0=C2=A0=C2=A0 } > + > +=C2=A0=C2=A0=C2=A0 return 0 > +} > + > +set GDBFLAGS "${GDBFLAGS} -iex \"set auto-connect-native-target off\""