From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id JXZwKg5JkGoRiAYAWB0awg (envelope-from ) for ; Thu, 27 Aug 2026 10:26:22 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ja6DQn6r; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 304101E0A3; Thu, 27 Aug 2026 10:26:22 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,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 39F721E033 for ; Thu, 27 Aug 2026 10:26:20 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4A0104BA798B for ; Thu, 27 Aug 2026 14:26:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4A0104BA798B Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ja6DQn6r Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 035864BA2E2D for ; Thu, 27 Aug 2026 14:25:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 035864BA2E2D Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 035864BA2E2D Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787840754; cv=none; b=EQPwHO3WJi4Nppq9UVBZiFIXf87uF5igsulfNrPbUeW0yQ6Piw0nVtSW0mCfYAY8sSWipMVlgjtlAoLboulbZ2neEMj5sdCIKNeusb9WJxiNQ15SFtbpCe2Goi14LOvF2XuFj5MbuMvO9e3Qq6FnDtEuPUiftOqjlyRWvW+Y8DQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787840754; c=relaxed/simple; bh=nkpwLb5b0SYAWx8oMPrxW1OHDK4UfRWh4J7PDXyPn6E=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=daJSzCO67DK1AG0TqIBK4vQnHX27p2rCUjyFDqK1+8oK36dYydXc7b/wJWrEAYnC1PIvVgt8D8ftDeSQZpQagBphg8MvhAFDD4sYNOaIXAk5ytx1LAOs5zx6MReHMgoruiFYHDTZQZxzaN80mAQxPrSOqUiHKD1AbIL5OvEHe/U= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Ja6DQn6r DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 035864BA2E2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1787840753; h=from:from:reply-to:subject:subject: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=TnnQulgN1WbvYW3NRvrj0vtD8SiQcdysBx8NGnAzfCg=; b=Ja6DQn6re4IU24MhODKA/t3THU+veQePnpRX2TnopsD5ra3IiV9OZsRZzTD/Ttf47MCBhY lJkNTzjHSl491VTlLBaRquQG/IPHPUxy1BmsiUTlBJVrn5Ey3A8milfUvrKRCV/NQz5IEl WduLMwvVsxf1PDg4QAN1bwPjPBFqSbc= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-345-d91ADDsRN4qSPXGQNzekEQ-1; Thu, 27 Aug 2026 10:25:51 -0400 X-MC-Unique: d91ADDsRN4qSPXGQNzekEQ-1 X-Mimecast-MFC-AGG-ID: d91ADDsRN4qSPXGQNzekEQ_1787840751 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-85c370a5eaaso13075757b3.1 for ; Thu, 27 Aug 2026 07:25:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787840751; x=1788445551; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TnnQulgN1WbvYW3NRvrj0vtD8SiQcdysBx8NGnAzfCg=; b=acPojCqOOvgWeUBAh4B3x1U35C7zoA2yH2uXmimalEYQRLB1BSUiPaseGr9SRfs+Mu gcpS9WmNfC6vhnFRlXzuthbTd/a99pdBl7lJZ22vM3q3oGwo32KfPPK/mdFO45DiwzlG Iej0Jj8MRBBRxE3FhjrikTEKwkazQTJ3/BubZV3Oi/vrOOjnLmd7rUVd2kr/fEXM5Fcs /YRFMQw7//9kIGwDbvwxagmKUij+XmqQuicklaXFMtnhPFrlaRNL9RMb3BLza76K90Cn byL3Co4vS6DAKQmgzIixkmW3lcBA4L9Ot48z1sUbKKS4FPmu1gwLIO4zYfps7CNVmStL +Kpw== X-Gm-Message-State: AFuF++kJg9TY7fX0s5/eTqyIY7B94tIBrX8wfp8rDB6bQ+0T/jw3wfzN IVh2lcvuaqtv8h2sdyh5gVrG+1JINhmyIlSTTzG9XhDlgfY1YKu2IkVHhcvunoHQJyznlRgPlud sVDO3UdPw3vRIb+6P0DVrDd1sYk9Wd91NPwSPTmAZJ/AmdFbdCt8e3CRnL9Babeiq+y8UDMnEkf arnCktUNgrpbtmdY+wx1C40a0jMIiTA/938WNtBTluMF4+Q2J1 X-Gm-Gg: AR+sD10AinngfWmp59I0a2UIB2xaoIZ9QWZMUKbKToa2KHroQim4tXuJ/qVFGd4op4L rVY4+dPeTYfnnYccWYf4qqbZfslZI6u1cWOSiVJKYgz2oZagFwpRoZdkmUV3ZDxVjkniziDHrTx 9zcTZjCda/JmpuAjoWJOjOJguOSebPeX9YNFiOi8a1Pg8TMQvmz226UQW3CIz7I38o9VUBosueL WmJP3HSJ4PI9OJwqjQlpJ0s3YmIvBhU5vdGbBHUS1Dkr3OkPcZa5xPnuD6+88ZukCF7tF26wUuE /0TmnsKsgvVXED+ZAtpZ1LYkaaApZl/rArBVXLvUrPmEIp90h8EFCo8FY9lNGDZSAyVpcYXUC8S smvNhoKz4GrdMvlN2gpmCJaaeU6wxvECBuDfmTIAPkxjnlr/saA== X-Received: by 2002:a05:690e:120d:b0:667:82d6:eb47 with SMTP id 956f58d0204a3-66e1185c136mr2906933d50.17.1787840751159; Thu, 27 Aug 2026 07:25:51 -0700 (PDT) X-Received: by 2002:a05:690e:120d:b0:667:82d6:eb47 with SMTP id 956f58d0204a3-66e1185c136mr2906874d50.17.1787840750415; Thu, 27 Aug 2026 07:25:50 -0700 (PDT) Received: from ?IPV6:2804:14d:8084:993e:22e8:4ed1:527a:55c0? ([2804:14d:8084:993e:22e8:4ed1:527a:55c0]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-66d24722290sm3056327d50.10.2026.08.27.07.25.49 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Aug 2026 07:25:49 -0700 (PDT) Message-ID: Date: Thu, 27 Aug 2026 11:25:43 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/testsuite] Document return behavior in gdb_test_multiple To: gdb-patches@sourceware.org References: <20260822093058.3818336-1-tdevries@suse.de> From: Guinevere Larsen In-Reply-To: <20260822093058.3818336-1-tdevries@suse.de> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: KJXjJTZ-BIlg_UqLTMHL2ypejwyzek_Vu9NMbkymvkI_1787840751 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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/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. -- 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