From patchwork Tue Jul 4 15:22:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 72086 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D4BF438768A0 for ; Tue, 4 Jul 2023 15:26:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4BF438768A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688484375; bh=gZI4WRPyagAZM+fZLtBD108C6j163ALnav8B4IVh6o0=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=AG/rwS1KcKMJxsc2dbtyk3wHFKGZ7ogwpncn3JzlF4x13WQFqBFiu5hItzNNO1hdd HXGHBg2K7FLFPHP9GAg5iypG4Ai7bqQk+5v0hiSzHN0DiR5zl81cMDdc31tNXDEBxk HTbruBIC9jmF8UVAowin0VizbZLy8dINmHwPRWeg= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 13D133857342 for ; Tue, 4 Jul 2023 15:23:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 13D133857342 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-338-4sgLa7E_O4umc3G_BwHhzQ-1; Tue, 04 Jul 2023 11:23:05 -0400 X-MC-Unique: 4sgLa7E_O4umc3G_BwHhzQ-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fa9a282fffso33382395e9.1 for ; Tue, 04 Jul 2023 08:23:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688484184; x=1691076184; 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=KyXtAlnDgonWNWE7dNhN1Qi3TPpIG0uyRnYX69JkN7qCUprCQvLbo26XIbeUN7bcXX KkOLkzgqe3CQhAXWmBvM4nPB67u/6/FvOUgID6lnow0Dpim4XE8fB9rYNKK444w4e8gu mUpOXlTyInIAiRr2bHfW5H/32ZNrWhps56kCX0R4zBiNyMBmJEcxaWw30dCG/B2L9JLd aVUrjXuSyh7qaTvjr+EO6nZndlXJqT2VrCtKUqvcB1Lw7wqO4ihQmmGAZv2uX6cWdpMV +8X5pWP2Xx/iAoMpN2Wk08ZlKXC8H8I8uq+emYr6ynHmcr5W5SsfcIDJ1w8DVdNo3Al0 vAGA== X-Gm-Message-State: ABy/qLY/Zc6q6TZrzHI5jOS/yCgpPyV0Fg/juKd+WkeVrkOsKWwruFel Mm3PysxCfPEApSotqQSCmV5HuUvSgHZBkIeoH+NkYK+/e2lx+aHMuw1AA0J2TZRt40bihtu+quA 6hyIfZe2eg+QYTcc9hhL2x8/K51GHL7jQBCb4zsE8/rAkUcKbVXoH0nyiKj+aLtiuiZt6TocNAe nuJUJsAg== X-Received: by 2002:a1c:f712:0:b0:3fb:dbd0:a7ea with SMTP id v18-20020a1cf712000000b003fbdbd0a7eamr4525405wmh.37.1688484184372; Tue, 04 Jul 2023 08:23:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlHDuiKbM3wNz1vt03sBX/P6wBG00U9dioLj01AunGg40lF4Fo/s6dXolJW+T5I3t8x4o9KV/Q== X-Received: by 2002:a1c:f712:0:b0:3fb:dbd0:a7ea with SMTP id v18-20020a1cf712000000b003fbdbd0a7eamr4525388wmh.37.1688484184088; Tue, 04 Jul 2023 08:23:04 -0700 (PDT) Received: from localhost (2.72.115.87.dyn.plus.net. [87.115.72.2]) by smtp.gmail.com with ESMTPSA id m25-20020a7bca59000000b003fbca942499sm11429879wml.14.2023.07.04.08.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jul 2023 08:23:03 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Andrew Burgess , tankut.baris.aktemur@intel.com Subject: [PATCHv2 1/8] gdb: catch more errors in gdb.base/foll-vfork.exp Date: Tue, 4 Jul 2023 16:22:51 +0100 Message-Id: <470e7aaaf7e27a36c33083afe412720492a915b1.1688484032.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 X-Spam-Status: No, score=-11.8 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_H4, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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"