From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 3ILwLxtOmGp0Kx8AWB0awg (envelope-from ) for ; Wed, 02 Sep 2026 12:26:03 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=AbC5MENW; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=sXF2kATF; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=PR44Jdzm; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=BNL76Gp2; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AA2FE1E033; Wed, 02 Sep 2026 12:26:03 -0400 (EDT) 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 autolearn=ham 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 B28221E033 for ; Wed, 02 Sep 2026 12:26:02 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F49B4BA9004 for ; Wed, 2 Sep 2026 16:26:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2F49B4BA9004 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=AbC5MENW; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=sXF2kATF; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=PR44Jdzm; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=BNL76Gp2 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 06CE14BA2E2C for ; Wed, 2 Sep 2026 16:25:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 06CE14BA2E2C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 06CE14BA2E2C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788366336; cv=none; b=Ky67HV2QbjdmJJD00mbIpx+2pB2Povk2mIzHmm1wVkbHe6JzfZKOaPQgDmibh2AxJ5kKZuNa6RZTw3Lo0kCX3evXnNmwUciIK31UtSRWlJObYO5FafkjxfPkUJMrCAw4PS7OjyTpsb56A3ikyJ6q388FpRV+6Hn17d7QGu0cPj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788366336; c=relaxed/simple; bh=rJGyJO0htfVlaIwhCLhGkN0jftYDmbpJV1wG/pTzuNQ=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=haB2WYuGMUDvhe0ogcnr9fooee+5NF0X32JqgEtjN7IvCrgiwmyE6LqQ+KIUqv3uuRSe9ZExKhfF14NZQaNxQhcIkjWJOO1TGeJewgVFuY6K3M4AAncBNJkwROJ4DYdaSIQ6fCnePPWP1fNpIsu5fcXS9rEjRUN8aXauDLeKyh4= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=AbC5MENW; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=sXF2kATF; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=PR44Jdzm; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=BNL76Gp2 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 06CE14BA2E2C Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3CD851F7B8; Wed, 2 Sep 2026 16:25:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1788366330; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ChELFOFxXtp2k/Wr78LzBkuT+allAOPnozGMB/Douho=; b=AbC5MENW/iE4xrruZZ61mkwB9wsc+IOoJBqPgBGSaH4hsSDh2PDTg9/uyaPmCFHUTA0tAL BNu+MqYdKwlxm/MYeS6e3WpM1B40AUJ6h4czMweJywObxUPkSOQruQddffc2GlOMu8IDr0 8xfLC38QoFw59qve6p10qAkFMJyGwhE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1788366330; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ChELFOFxXtp2k/Wr78LzBkuT+allAOPnozGMB/Douho=; b=sXF2kATFIPLbRR8Qt3IlH9vva/gRg45fq9jZ4KZIrw1PLvNaj6ruAf8828gxZg2gGlV2qB fWBvkIV9cT8OjQAw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=PR44Jdzm; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=BNL76Gp2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1788366326; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ChELFOFxXtp2k/Wr78LzBkuT+allAOPnozGMB/Douho=; b=PR44JdzmAkhULLrhczq/1BhnwqJq71NhwL1EZcDI5Xef0sgWMl8rQSzCRDOKhqjo4wyrNs SFH0qgQXiF5lu21fGuaVdvDYH00Za74MxpCFwlDe+Ym8rre6I6g4xLMnFUWMU3O/O6s8Ls TLLAff5awY4MjJfbXVMJTj8DHVQjI8M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1788366326; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ChELFOFxXtp2k/Wr78LzBkuT+allAOPnozGMB/Douho=; b=BNL76Gp2qS7LgpP4x7c4Az8Wecuy8cvUhQRs8iwTHGOwc6vgZ7f1cLjelonTPXSqKFp8tU SAnglzCF0p2DNFAw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id DE33613736; Wed, 2 Sep 2026 16:25:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ZK3GNPVNmGofDgAAD6G6ig (envelope-from ); Wed, 02 Sep 2026 16:25:25 +0000 Message-ID: <9ffde902-857e-4244-a2f3-7343e34b5604@suse.de> Date: Wed, 2 Sep 2026 18:25:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/testsuite] Document return behavior in gdb_test_multiple To: Guinevere Larsen , gdb-patches@sourceware.org References: <20260822093058.3818336-1-tdevries@suse.de> Content-Language: en-US From: Tom de Vries In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 3CD851F7B8 X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:mid,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] 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 On 8/27/26 4:25 PM, Guinevere Larsen wrote: > > On 8/22/26 6:30 AM, Tom de Vries wrote: >> There are a few places in gdb_test_multiple where "return -1" is used. >> >> The first two simply cause proc gdb_test_multiple to return -1. >> >> The other two are in implicit clauses dealing with eof.  Showing the >> first: >> ... >>      append code { >>     ... >>     eof { >>         perror "GDB process no longer exists" >>         set wait_status [wait -i $gdb_spawn_id] >>         verbose -log "GDB process exited with wait status $wait_status" >>         if { $message != "" } { >>         fail "$message" >>         } >>         # This does not return from gdb_test_multiple, but from the proc >>         # above it. >>         return -1 >>     } >> ... >> >> The result of this is not that gdb_test_multiple returns -1.  Instead, >> its >> caller does.  This is defined behavior, focused mainly on handling >> break and >> continue in such a way that it has effect on the caller in code like >> this [1]: >> ... >> for {set i 1} {$i <= 10} {incr i} { >>      gdb_test_multiple "print $i" "" { >>          -re -wrap " = 5" {break} >>     -re -wrap ""     {} >>      } >> } >> ... >> and return is simply treated the same way. >> >> The next question is why only for eof we use "return -1" instead of >> "set result -1". >> >> It could be argued that this facilitates a style: >> ... >> gdb_test_multiple "" "" {} >> gdb_test_multiple "" "" {} >> ... >> where at command 2 we can assume that gdb is still running, without >> having to >> check for the result of command 1. >> >> But if that were the intention, it would make sense that gdb_test >> would have >> the same behavior, and it doesn't. >> >> For now, document the behavior at the eof returns in proc >> gdb_test_multiple >> and add two tests in a pre-existing test-case checking current behavior. >> >> [1] https://sourceware.org/pipermail/gdb-patches/2011- >> November/086792.html >> --- > > Hi! Thanks for working on this! I love documentation patches. > > I ran the new test and it works, so I think this is fine, but I think > there should be a bit more, especially since the new test shows this as > expected behavior. > > I think there should be a note in the pre-function comment, perhaps > around the "return value" section, mentioning that the gdb_test_multiple > may make the proc calling it return early, and explaining the situation. > That will make it easier to debug if this ever gets in the way. > Hi Guinevere, thanks for the review. Good point, I've added a comment. I also noticed that the test that I added doesn't work with remote host, so I've disabled that. Pushed with those changes. Thanks, - Tom > -- > Cheers, > Guinevere Larsen > it/its > she/her (deprecated) > >>   gdb/testsuite/gdb.testsuite/gdb-test.exp | 43 ++++++++++++++++++++++++ >>   gdb/testsuite/lib/gdb.exp                |  7 ++++ >>   2 files changed, 50 insertions(+) >> >> diff --git a/gdb/testsuite/gdb.testsuite/gdb-test.exp b/gdb/testsuite/ >> gdb.testsuite/gdb-test.exp >> index dab65f21bdb..8ae5325b5e6 100644 >> --- a/gdb/testsuite/gdb.testsuite/gdb-test.exp >> +++ b/gdb/testsuite/gdb.testsuite/gdb-test.exp >> @@ -49,6 +49,49 @@ with_test_prefix "cmd with trailing control code" { >>       } >>   } >> +proc quit {proc} { >> +    with_override perror nop { >> +    with_override fail nop { >> +        if {$proc == "gdb_test_multiple"} { >> +        set res [gdb_test_multiple "quit" "" {}] >> +        # Not reached. >> +        } elseif {$proc == "gdb_test"} { >> +        set res [gdb_test "quit"] >> +        # Reached. >> +        } >> +        return [expr {100 + $res}] >> +    } >> +    } >> +    # Not reached. >> +    return 200 >> +} >> + >> +with_test_prefix "eof handling" { >> +    set res 300 >> +    try { >> +    set res [quit gdb_test_multiple] >> +    } on return {result} { >> +    } finally { >> +    # Proc gdb_test_multiple does "return -1" on eof, which makes its >> +    # caller return.  Check that behavior. >> +    gdb_assert {$res == -1} "gdb_test_multiple" >> +    } >> + >> +    clean_restart >> + >> +    set res 300 >> +    try { >> +    set res [quit gdb_test] >> +    } on return {result} { >> +    } finally { >> +    # Proc gdb_test_multiple does "return -1" on eof, which makes its >> caller >> +    # return, which is gdb_test.  Check that behavior. >> +    gdb_assert {$res == 99} "gdb_test" >> +    } >> + >> +    clean_restart >> +} >> + >>   # Change the prompt. >>   set prompt "(GDB) " >>   set prompt_re "\\(GDB\\) $" >> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp >> index 1a6438f36a5..15ec71cb542 100644 >> --- a/gdb/testsuite/lib/gdb.exp >> +++ b/gdb/testsuite/lib/gdb.exp >> @@ -1522,6 +1522,8 @@ proc gdb_test_multiple { command message args } { >>           if { $message != "" } { >>           fail "$message" >>           } >> +        # This does not return from gdb_test_multiple, but from the proc >> +        # above it. >>           return -1 >>       } >>       } >> @@ -1542,6 +1544,8 @@ proc gdb_test_multiple { command message args } { >>           if { $message != "" } { >>           fail "$message" >>           } >> +        # This does not return from gdb_test_multiple, but from the proc >> +        # above it. >>           return -1 >>       } >>       full_buffer { >> @@ -12417,6 +12421,9 @@ proc unprintable_to_octal { input_string } { >>       return $result >>   } >> +# Ignore args and don't do anything.  Can be used with proc >> with_override. >> +proc nop {args} {} >> + >>   require {tcl_version_at_least 8 6 2} >>   # Always load compatibility stuff. >> >> base-commit: 7c1f6faaf3bcd28a37d5f5a9737f6c1dcd0f13ef >