From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1674677187; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GeW3XmS96K9+VKgXVYQZlPqjWVcv3gFGjV5Ng9WWS9o=; b=ifWoh1eNn8x9gAXp+4aNdCZT82u8nEiI5CcxHLOiMFWZl5aAhpkp8j8CXGHnceESCI9Vhe KFO8z07t2y5rDvEJ5Zmlg0TziAN3aPswUcHFpBc6v1ytFYkFiS1yRvTaL0nFN3J6KZ2RDd VzrraVu5oSHT9tQUPsmq8ghUw0U0KbQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1674677187; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GeW3XmS96K9+VKgXVYQZlPqjWVcv3gFGjV5Ng9WWS9o=; b=WWw+w19M39mC3+X1taMCtODuPCgaiZrAzQkDUMN6hp+XU+5jYTyPU97FyjC2NXyu0dokzg /As7ti5UnCkXyiDQ== 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 From: Tom de Vries 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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) -- 2.35.3