From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 32E113858D37 for ; Thu, 22 Jun 2023 13:17:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 32E113858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687439857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gZI4WRPyagAZM+fZLtBD108C6j163ALnav8B4IVh6o0=; b=BgV3oEVaQzbvPyU+DdsqRZljIxA+hDeLAH/35phBZ28fKzoiablHG2dV0OP0jc2XbY3t02 nPzGIWafeezYZflNweri9luYfIlhMc32SICDXCG/qn2oUWZS6FoqjeWSDaV/hxJdWiXLVC ojRqmpBCG2HGJEaaY9s5rut01YJlya0= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-456-XsD1shYOO_S6q9K1pTu7ZA-1; Thu, 22 Jun 2023 09:17:36 -0400 X-MC-Unique: XsD1shYOO_S6q9K1pTu7ZA-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3127a76c56bso1507268f8f.1 for ; Thu, 22 Jun 2023 06:17:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687439855; x=1690031855; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gZI4WRPyagAZM+fZLtBD108C6j163ALnav8B4IVh6o0=; b=Z08Zrl3R15IwqXzDLLE0OcGgZGf5oIn+X/tLsBV0nQPMb2WtbftdGsdL1XMzsne6+5 R3AO5yCTVZ030ld9tngpbiTrs+tVk9XizSlgGumV8yNI2PH5Z/BkCSORgqGOPqAVHHeD 5MAo54VZ0yuyU2svVfi5zQkM927glhUv5I9ajZucMmaubjhWcoQKzp5arDXC19v9Z4Po yxdklUYVgpEB+34H1qUeUN9Dx0ZXhvFBohe0u7O2kZ/qhy2L0ZxaFqMivChjrsAkbStT IO3tH5K0WADElC++S2HTOUqRmKdA7xV46A0mKN2S6ClmjI4r4EBc4hEUZ9b80rjl6I33 0R1A== X-Gm-Message-State: AC+VfDzKLb/THfPoGtLe4rBLEaaAPJ/PloiDlkgzJmAoGAFzpVyhkuwn FPy+O/0EoVtvFY1KQze8xuu3hjdOJTf0qOyNRCE8P3OAMXO6IFwJpnEdQB3QoIq2aEIPvMOlinF IPYQZy/jQNPc5zg9VMlUbr9/vv0rcf0Uevp8kmOocG/yiCj52yIOmDbXA6BnqUqoLHWMj11rINz lXeUP6+w== X-Received: by 2002:a05:6000:1203:b0:2f6:c5bd:ba13 with SMTP id e3-20020a056000120300b002f6c5bdba13mr12540102wrx.42.1687439854970; Thu, 22 Jun 2023 06:17:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5B3iECqao0LK1yzTiY1J4xKbU/kGq4v1Rd0ckmxv96MViIbbPWKc72BB++ZwvcXpzzZZKJWg== X-Received: by 2002:a05:6000:1203:b0:2f6:c5bd:ba13 with SMTP id e3-20020a056000120300b002f6c5bdba13mr12540087wrx.42.1687439854619; Thu, 22 Jun 2023 06:17:34 -0700 (PDT) Received: from localhost (2.72.115.87.dyn.plus.net. [87.115.72.2]) by smtp.gmail.com with ESMTPSA id e17-20020a5d5011000000b002c70ce264bfsm7070198wrt.76.2023.06.22.06.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 06:17:34 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 1/8] gdb: catch more errors in gdb.base/foll-vfork.exp Date: Thu, 22 Jun 2023 14:17:21 +0100 Message-Id: <0d5a0339aa86c54311c258a1127f753b957068c2.1687438786.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: For *reasons* I was looking at gdb.base/foll-vfork.exp. This test script has a proc 'setup_gdb' that could (potentially) fail. The setup_gdb proc is called from many places and I, initially, didn't think that we were checking if setup_gdb had failed or not. My confusion was because I didn't understand what this tcl construct did: return -code return this will actually act as a return in the context of a proc's caller, effectively returning two levels of the call stack. Neat (I guess). So it turns out my worries were misplaced, everywhere setup_gdb is called, if setup_gdb fails then we will (magically) return. However, I did spot one place where we managed to confuse ourselves with our cleverness. In check_vfork_catchpoints, this proc is called to check that GDB is able to catch vforks or not. This proc is called early in the test script, and the intention is that, should this proc fail, we'll mark the whole test script as unsupported and then move onto the next test script. However, check_vfork_catchpoints also uses setup_gdb, and so, if that call to setup_gdb fails we'll end up returning immediately from check_vfork_catchpoints, and then continue with the test of _this_ test script, which is not correct. To fix this I see two choices, one is remove the use of 'return -code return' from setup_gdb, however, this would require every use of setup_gdb to then be placed inside: if { ![setup_gdb] } { return } Or, I can wrap the one call to setup_gdb in check_vfork_catchpoints and check its return code. I chose the second option as this is the smaller code change. There should be no change in what is tested after this commit. --- gdb/testsuite/gdb.base/foll-vfork.exp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.base/foll-vfork.exp b/gdb/testsuite/gdb.base/foll-vfork.exp index 313afa06324..bdceff0f5de 100644 --- a/gdb/testsuite/gdb.base/foll-vfork.exp +++ b/gdb/testsuite/gdb.base/foll-vfork.exp @@ -70,9 +70,15 @@ proc setup_gdb {} { proc check_vfork_catchpoints {} { global gdb_prompt - global has_vfork_catchpoints - setup_gdb + # Because setup_gdb uses 'return -code return' which would return to + # our caller we need to wrap this call, spot when setup_gdb failed + # (with return code 2), and then issue our own 'return -code return'. + set code [catch {setup_gdb} string] + if { $code == 2 } { + unsupported "vfork catchpoints" + return -code return + } # Verify that the system supports "catch vfork". gdb_test "catch vfork" "Catchpoint \[0-9\]* \\(vfork\\)" "insert first vfork catchpoint" -- 2.25.4