From patchwork Wed Jan 25 20:06:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 63688 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 DF1CA3858005 for ; Wed, 25 Jan 2023 20:07:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DF1CA3858005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674677238; bh=GeW3XmS96K9+VKgXVYQZlPqjWVcv3gFGjV5Ng9WWS9o=; 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=my9/VQp1JWrtEcOQ5rsa0mdBLS1Ns2DDfUHZtNSIVvZh2bvX9FmBuu/KO/XcZAaIU 83bC5MhD2HwuKOShcLNQg1D3HEygzf2BWqOpy7jC0hdtVyniPsjkYIRhpYVrFspIv9 mUreYnuVkjLiQp1B7PWnVHej2o3Nl4SPOiJfGYIA= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 2AEE83858D38 for ; Wed, 25 Jan 2023 20:06:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2AEE83858D38 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 471311FEAB; Wed, 25 Jan 2023 20:06:27 +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 2E2651339E; Wed, 25 Jan 2023 20:06:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IMAuCsOL0WPmeAAAMHmgww (envelope-from ); Wed, 25 Jan 2023 20:06:27 +0000 To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFC 2/3] [gdb/contrib] Add refactor_require.py Date: Wed, 25 Jan 2023 21:06:25 +0100 Message-Id: <20230125200626.29340-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230125200626.29340-1-tdevries@suse.de> References: <20230125200626.29340-1-tdevries@suse.de> 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, KAM_SHORT, 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" Add refactoring script refactor_require.py, to be used with refactor.py. --- gdb/contrib/refactor_require.py | 53 +++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 gdb/contrib/refactor_require.py diff --git a/gdb/contrib/refactor_require.py b/gdb/contrib/refactor_require.py new file mode 100644 index 00000000000..e8ac96643cf --- /dev/null +++ b/gdb/contrib/refactor_require.py @@ -0,0 +1,53 @@ +#! /usr/bin/env python3 + +# Copyright (C) 2022 Free Software Foundation, Inc. +# +# This file is part of GDB. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import re + +dirs = ["gdb/testsuite"] +avoid_dir = None +exts = [".exp"] + +pattern_lines = [ + "(else)?" + re.escape ("if { ![istarget x86_64-*-* ] || ![is_lp64_target] } {"), + r"\s+verbose.*", + r"\s+return", + "\}" +] +pattern = "\n".join(pattern_lines) + +def repl(matchobj): + global have_match + have_match = True + + if matchobj.group(1) == "else": + repl_lines = [ + r"else {", + r" require is_x86_64_m64_target", + r"}" + ] + else: + repl_lines = [ + r"require is_x86_64_m64_target" + ] + repl= "\n".join(repl_lines) + + return repl + +def transform(data): + return re.sub(pattern, repl, data)