From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFC 2/3] [gdb/contrib] Add refactor_require.py
Date: Wed, 25 Jan 2023 21:06:25 +0100 [thread overview]
Message-ID: <20230125200626.29340-3-tdevries@suse.de> (raw)
In-Reply-To: <20230125200626.29340-1-tdevries@suse.de>
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 <http://www.gnu.org/licenses/>.
+
+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
next prev parent reply other threads:[~2023-01-25 20:06 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-25 20:06 [RFC 0/3] [gdb/testsuite] Introduce is_x86_64_m64_target Tom de Vries
2023-01-25 20:06 ` [RFC 1/3] [gdb/contrib] Add refactor.py Tom de Vries
2023-01-25 20:06 ` Tom de Vries [this message]
2023-01-25 20:06 ` [RFC 3/3] [gdb/testsuite] Add and use is_x86_64_m64_target Tom de Vries
2023-01-25 21:25 ` Tom Tromey
2023-01-26 9:17 ` [pushed] " Tom de Vries
2023-01-26 15:48 ` Tom de Vries
2023-01-26 16:10 ` Tom Tromey
2023-01-26 16:36 ` Tom de Vries
2023-01-26 16:38 ` Pedro Alves
2023-01-26 17:08 ` Tom de Vries
2023-01-26 18:25 ` Tom Tromey
2023-01-26 18:34 ` Pedro Alves
2023-01-25 21:26 ` [RFC 0/3] [gdb/testsuite] Introduce is_x86_64_m64_target Tom Tromey
2023-01-26 9:30 ` Tom de Vries
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230125200626.29340-3-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).