From patchwork Fri Nov 11 14:31:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 60418 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 8FF073858C2B for ; Fri, 11 Nov 2022 14:31:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8FF073858C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668177091; bh=FG7cWVJ713s9wGLj4antUDAtNPX3KqIO506a1m5vD+I=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Ig81uiRoHYQ4CVPqRuCpyx3KgSNKIbUnk51aZatY5wNnAqIHWRaCytV2fuzoje9pD fG0XWYmI3Z2bnexVMWfsYrZeLXhZ60d0b1Gwww1oc0BH6Sk3UJhHrSXBAkGHtfE/6a JbM+Fq8KhLR8L4NpU2ooZe/bR04rNvMU8MgCjDyk= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 96C443858D1E for ; Fri, 11 Nov 2022 14:31:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 96C443858D1E Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9F091201DD for ; Fri, 11 Nov 2022 14:31:01 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8954E13357 for ; Fri, 11 Nov 2022 14:31:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 7udUIKVcbmMBEgAAMHmgww (envelope-from ) for ; Fri, 11 Nov 2022 14:31:01 +0000 To: gdb-patches@sourceware.org Subject: [pushed] [gdb/testsuite] Better error checking in has_hw_wp_support Date: Fri, 11 Nov 2022 15:31:01 +0100 Message-Id: <20221111143101.22310-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP 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: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" With gdb 12.1, on powerpc64le I ran into ERRORs related to has_hw_wp_support usage, which was already fixed on trunk by commits: - 13f72372413 ("gdb/testsuite: fix gdb.base/break-idempotent.exp on ppc"), and - 01a32ee0b8c ("PowerPC, fix gdb.base/watchpoint.exp on Power 9") While looking into these ERRORs and the commits that fix them, it occurred to me that while the commits fix the root cause, the failure mode is not great. The test-cases expect a running instance of gdb upon return, which is not there, so there's an long stream of ERRORs generated as a result. Fix this at the start of has_hw_wp_support, by (instead of accomodating a running gdb instance by calling gdb_exit), checking whether it's called without a running gdb instance, and erroring out otherwise. This way, there's just one error. I also noticed that in case we do an early exit due to !runto_main, we don't clean up, so copy the missing cleanups (gdb_exit and $obj file deletion) from the regular exit. Tested on x86_64-linux, using has_hw_wp_support for x86_64 in skip_hw_watchpoint_tests. --- gdb/testsuite/lib/gdb.exp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) base-commit: 70b9d05b26e861524d70ee90dcd28cfd77032ddd diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 3e0a46445ca..d70b6410441 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -9045,9 +9045,15 @@ gdb_caching_proc has_hw_wp_support { # support for HW watchpoints. global srcdir subdir gdb_prompt inferior_exited_re - set compile_flags {debug nowarnings quiet} set me "has_hw_wp_support" + global gdb_spawn_id + if { [info exists gdb_spawn_id] } { + error "$me called with running gdb instance" + } + + set compile_flags {debug nowarnings quiet} + # Compile a test program to test if HW watchpoints are supported set src { int main (void) { @@ -9063,12 +9069,14 @@ gdb_caching_proc has_hw_wp_support { return 0 } - gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load "$obj" if ![runto_main] { + gdb_exit + remote_file build delete $obj + set has_hw_wp_support 0 return $has_hw_wp_support }