From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 0C927385B507 for ; Sat, 25 Feb 2023 03:32:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0C927385B507 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 31P3WqYx028959 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 24 Feb 2023 22:32:56 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 31P3WqYx028959 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1677295977; bh=9AvJqRpdXyUdz4ZQ+VOTPOuyjcvXMfAvh9mMqFlXfuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t+AU9KypqONmouqiIVa0eL8OUuZt9hiD5BRo9XI2xfFLCKVyVOMmzWz8Y7k+5A38U z2I6ZeMFdV7v+JDI+UeAsYknF/2GhomgCBfVDWi1uqiRXxrYShZwaA7GPRme4qWGse iU1/HwQkI/eRf8sycIlzY1/30DDWP3ug7dh+ywZM= Received: from simark.localdomain (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id F27D81E221; Fri, 24 Feb 2023 22:32:51 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi , Tom Tromey Subject: [PATCH v2 09/10] gdb: make-target-delegates.py: add Entry type Date: Fri, 24 Feb 2023 22:30:46 -0500 Message-Id: <20230225033047.373899-10-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230225033047.373899-1-simon.marchi@polymtl.ca> References: <20230225033047.373899-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Sat, 25 Feb 2023 03:32:52 +0000 X-Spam-Status: No, score=-3189.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,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 the Entry type and use it in the `entries` map, rather than using an ad-hoc str -> str map that comes from the re.match. This will make it easier to make typing work in a subsequent patch, but it also helps readers know what attributes exist for entries, which is not clear currently. Change-Id: I5b58dee1ed7ae85987b99bd417e641ede718624c Reviewed-By: Tom Tromey --- gdb/make-target-delegates.py | 52 +++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/gdb/make-target-delegates.py b/gdb/make-target-delegates.py index 2df84cd458c6..aa0919e51b13 100755 --- a/gdb/make-target-delegates.py +++ b/gdb/make-target-delegates.py @@ -92,6 +92,16 @@ ARGTYPES = re.compile( TARGET_DEBUG_PRINTER = r"\s*TARGET_DEBUG_PRINTER\s*\((?P[^)]*)\)\s*" +class Entry: + def __init__( + self, argtypes: list[str], return_type: str, style: str, default_arg: str + ): + self.argtypes = argtypes + self.return_type = return_type + self.style = style + self.default_arg = default_arg + + def scan_target_h(): found_trigger = False all_the_text = "" @@ -295,10 +305,9 @@ def print_class(f, class_name, delegators, entries): print("", file=f) for name in delegators: - return_type = entries[name]["return_type"] - argtypes = entries[name]["argtypes"] print(" ", file=f, end="") - write_declaration(f, name, return_type, argtypes) + entry = entries[name] + write_declaration(f, name, entry.return_type, entry.argtypes) print("};\n", file=f) @@ -313,11 +322,14 @@ for current_line in scan_target_h(): if not m: continue data = m.groupdict() - data["argtypes"] = parse_argtypes(data["args"]) - data["return_type"] = data["return_type"].strip() - entries[data["name"]] = data + name = data["name"] + argtypes = parse_argtypes(data["args"]) + return_type = data["return_type"].strip() + style = data["style"] + default_arg = data["default_arg"] + entries[name] = Entry(argtypes, return_type, style, default_arg) - delegators.append(data["name"]) + delegators.append(name) with open("target-delegates.c", "w") as f: print( @@ -330,11 +342,21 @@ with open("target-delegates.c", "w") as f: print_class(f, "debug_target", delegators, entries) for name in delegators: - tdefault = entries[name]["default_arg"] - return_type = entries[name]["return_type"] - style = entries[name]["style"] - argtypes = entries[name]["argtypes"] - - write_delegator(f, name, return_type, argtypes) - write_tdefault(f, tdefault, style, name, return_type, argtypes) - write_debugmethod(f, tdefault, name, return_type, argtypes) + entry = entries[name] + + write_delegator(f, name, entry.return_type, entry.argtypes) + write_tdefault( + f, + entry.default_arg, + entry.style, + name, + entry.return_type, + entry.argtypes, + ) + write_debugmethod( + f, + entry.default_arg, + name, + entry.return_type, + entry.argtypes, + ) -- 2.39.2