Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH 3/3] [gdb/testsuite] Fix gdb.base/quit-live.exp for remote host
Date: Wed, 7 Oct 2026 12:28:47 +0200	[thread overview]
Message-ID: <e0b1bbc2-f8e9-4bd7-a650-54f4cfe96a5b@suse.de> (raw)
In-Reply-To: <20260919084237.1045724-4-tdevries@suse.de>

On 9/19/26 10:42 AM, Tom de Vries wrote:
> I ran into trouble running test-case gdb.base/quit-live.exp using a remote
> host configuration:
> - host board local-remote-host
> - target board remote-gdbserver-on-localhost.
> 
> The test-case uses kill to send a signal to gdb_spawn_id, but with remote host
> the gdb_spawn_id points to an ssh session, not gdb.
> 
> Detect this more clearly by factoring out a proc kill_gdb (and
> remote_kill_spawn_id and remote_kill_spawn_id_p), and erroring out for remote
> host/target.
> 
> Then fix this by skipping the relevant tests using remote_kill_spawn_id_p.

I've pushed this.

Thanks,
- Tom

> ---
>   gdb/testsuite/gdb.base/quit-live.exp | 13 ++++++++++---
>   gdb/testsuite/lib/gdb.exp            | 29 ++++++++++++++++++++++++++++
>   2 files changed, 39 insertions(+), 3 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.base/quit-live.exp b/gdb/testsuite/gdb.base/quit-live.exp
> index 8dae4fe2aca..8e1b4a428c7 100644
> --- a/gdb/testsuite/gdb.base/quit-live.exp
> +++ b/gdb/testsuite/gdb.base/quit-live.exp
> @@ -43,8 +43,7 @@ if {[build_executable "failed to build" $testfile $srcfile debug]} {
>   # Send signal SIG to GDB, and expect GDB to exit.
>   
>   proc test_quit_with_sig {sig} {
> -    set gdb_pid [exp_pid -i [board_info host fileid]]
> -    remote_exec host "kill -$sig ${gdb_pid}"
> +    kill_gdb $sig
>   
>       set test "quit with SIG$sig"
>       # If GDB mishandles the signal and doesn't exit, this should FAIL
> @@ -176,7 +175,15 @@ foreach_with_prefix appear_how {"run" "attach" "attach-nofile"} {
>       }
>   
>       foreach_with_prefix extra_inferior {0 1} {
> -	foreach_with_prefix quit_how {"quit" "sigterm" "sighup"} {
> +	set qhs {}
> +	lappend qhs "quit"
> +	foreach sig {"sigterm" "sighup"} {
> +	    if {[remote_kill_spawn_id_p host $sig]} {
> +		lappend qhs $sig
> +	    }
> +	}
> +
> +	foreach_with_prefix quit_how $qhs {
>   	    quit_with_live_inferior $appear_how $extra_inferior $quit_how
>   	}
>       }
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 7bdc5dad0a7..b249425528d 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -12473,6 +12473,35 @@ proc unprintable_to_octal { input_string } {
>   # Ignore args and don't do anything.  Can be used with proc with_override.
>   proc nop {args} {}
>   
> +# Return 1 if SIG can be delivered to a spawn_id on board.
> +proc remote_kill_spawn_id_p { board sig } {
> +    if {$board == "host" || $board == "target"} {
> +	if {[isremote $board]} {
> +	    # For remote host/target, the spawn_id holds the pid of the ssh
> +	    # session, so we'd end up sending signals to ssh instead.
> +	    return 0
> +	}
> +    }
> +
> +    return 1
> +}
> +
> +# Send SIG to PID on BOARD.
> +proc remote_kill_spawn_id { board spawn_id sig } {
> +    set pid [exp_pid -i $spawn_id]
> +
> +    if {![remote_kill_spawn_id_p $board $sig]} {
> +	error "Can't send signal $sig to $pid on remote $board"
> +    }
> +
> +    return [remote_exec $board "kill -$sig $pid"]
> +}
> +
> +# Send SIG to GDB.
> +proc kill_gdb { sig } {
> +    return [remote_kill_spawn_id host $::gdb_spawn_id $sig]
> +}
> +
>   require {tcl_version_at_least 8 6 2}
>   
>   # Always load compatibility stuff.


      reply	other threads:[~2026-10-07 10:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19  8:42 [PATCH 0/3] " Tom de Vries
2026-09-19  8:42 ` [PATCH 1/3] [gdb/testsuite] Add gdb_exit_cleanup Tom de Vries
2026-09-27  8:52   ` Andrew Burgess
2026-09-19  8:42 ` [PATCH 2/3] [gdb/testsuite] Use gdb_exit_cleanup a bit more Tom de Vries
2026-09-27  8:52   ` Andrew Burgess
2026-09-28  8:59     ` Tom de Vries
2026-09-19  8:42 ` [PATCH 3/3] [gdb/testsuite] Fix gdb.base/quit-live.exp for remote host Tom de Vries
2026-10-07 10:28   ` Tom de Vries [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e0b1bbc2-f8e9-4bd7-a650-54f4cfe96a5b@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox