From patchwork Tue Oct 3 17:18:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 1842765 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=KebqDoEG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S0PhM0rbBz1yng for ; Wed, 4 Oct 2023 04:19:47 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EED2E3865C21 for ; Tue, 3 Oct 2023 17:19:41 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id E3F493858408 for ; Tue, 3 Oct 2023 17:19:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E3F493858408 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-3528bc102adso4209605ab.2 for ; Tue, 03 Oct 2023 10:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1696353541; x=1696958341; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=boOmGV/6TjOLuBhywtJCzQe4ZAPokQuL6+bf0WcCb/k=; b=KebqDoEGIrtPHaeZEpTJGlhBmR0dR2iwpCh4PukpO8PgVaA7QyQFGBgNMl0J5rqbkq Mb40GkjQ8KL+f1VJtoE3uElg7Q2CYd286lA3IbpGyZoAWn9gifmhp6cLqxUgSbz/sRMe QqrROcYS6O3bpo63yoMRxiLty5titUVu26RbhmQbBmB29DC9NlTojGnzAlLdxHC6DYHc gYFkS12j52ploEAH28I6SNnMQmSJ0Amu8QN3FluqU6YeABmzbXSBWnG/URM80+tZQsHf +/V0NSAtlPAQulHPiNIjaPy4gyqx6+7NxhAdUVT1xeYrx3AXHJ0erZ4tDAFG23Q8YrDx s0qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696353541; x=1696958341; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=boOmGV/6TjOLuBhywtJCzQe4ZAPokQuL6+bf0WcCb/k=; b=X1GN8pN5vyBlAdD09LzYIk7zbA8OQJPJ517Ji0uTIjzVLWiT5qhxc9hQZJYiECJQpv ugpejgd2dg7a9UZwok8BucNIvzxOXmqLN0cAvtmhIKQv1pzQ6gcT+TBp62dEpLgAnaFT K2Cg7nhhGSFKMr+gX1N+Q7m0yq2eMOL/uszGJCeVC1rdWDKAsqpW2x66gP1R3IKXIe0U DJRzm/kGUoPn47wsjeub4vqzdP1la80uVcv5Lgm5JbRgShSD7NyiKqA4zzKBstxIb+rr gkBHAWXMDSYWkrtGiryAeYxxsfd4LuDtLqPf8qU5Cs+tbPbokilU1MzQ8jvJqZ62r1D9 zwxw== X-Gm-Message-State: AOJu0YyCwIHhQPMXsPW5Q9MrHM6F8lQpN4jkgn9jn8lWcpFQhoRGSRKb yOfWFPygVrYpVz0otVkPveyjeJKyMjj7twISfHvtmA== X-Google-Smtp-Source: AGHT+IE0s+w++o/bHkjL8oiWTPK7F0GqJMc1Bl3xQa8BK7lkM40FzT19LpFpPD7J6mbdW0fS5y4dzw== X-Received: by 2002:a05:6e02:12e3:b0:350:f442:9a4d with SMTP id l3-20020a056e0212e300b00350f4429a4dmr86082iln.28.1696353541187; Tue, 03 Oct 2023 10:19:01 -0700 (PDT) Received: from localhost.localdomain (71-211-130-31.hlrn.qwest.net. [71.211.130.31]) by smtp.gmail.com with ESMTPSA id p7-20020a92c607000000b0035134215863sm480967ilm.55.2023.10.03.10.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 10:19:00 -0700 (PDT) From: Tom Tromey To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Tom Tromey Subject: [PATCH 1/2] libstdc++: Define _versioned_namespace in xmethods.py Date: Tue, 3 Oct 2023 11:18:50 -0600 Message-Id: <20231003171851.1161340-2-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231003171851.1161340-1-tromey@adacore.com> References: <20231003171851.1161340-1-tromey@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org flake8 pointed out that is_specialization_of in xmethods.py looks at a global that wasn't added to the file. This patch correct the oversight. libstdc++-v3/ChangeLog: * python/libstdcxx/v6/xmethods.py (_versioned_namespace): Define. --- libstdc++-v3/python/libstdcxx/v6/xmethods.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py b/libstdc++-v3/python/libstdcxx/v6/xmethods.py index 844c8a2105a..8ccf57c4d6b 100644 --- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py +++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py @@ -28,6 +28,8 @@ def get_bool_type(): def get_std_size_type(): return gdb.lookup_type('std::size_t') +_versioned_namespace = '__8::' + def is_specialization_of(x, template_name): """ Test whether a type is a specialization of the named class template. From patchwork Tue Oct 3 17:18:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 1842766 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=BHzHOXWx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S0PhY5yQNz1yng for ; Wed, 4 Oct 2023 04:19:57 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B43943882107 for ; Tue, 3 Oct 2023 17:19:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by sourceware.org (Postfix) with ESMTPS id B98653858409 for ; Tue, 3 Oct 2023 17:19:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B98653858409 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-79fa425855cso41731339f.2 for ; Tue, 03 Oct 2023 10:19:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1696353542; x=1696958342; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZQutYBjZrMl0t1Pwc1HW6mT51dOnPqEHrafNvCrf/HU=; b=BHzHOXWxe5ODFqNM02IEqUD59t3V/zchc/+cB15C1DcQHsXF+qfMH29L87jI1gwAbJ 7zAtriqCE/MZRo3SfJuWzIf72W/tyg9/tm1ejFC05CtBAacekMdhVcLkFEbyXSRCtM8P IeaQ/QVs1ER48S5/saxq7oN8+uPtCt9oR/cT3Ot1tB4Dbi5STz74Qw5ooo1Kettb5ddm 6f1klpSmRHpcGff7orwWz5bXherQcMxjIVZH2+c24u6/uclaAA1gVbn4eBzOyxbGUsq/ AqBgmDuuaNJL5vgGOsoyWpHo/wKvuKs+pD7GwiXs6/bkklBjcpaX/oUyc9AAq2+SZndK nBdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696353542; x=1696958342; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZQutYBjZrMl0t1Pwc1HW6mT51dOnPqEHrafNvCrf/HU=; b=Fq8R6tSwxHhDf86zFnRnw3GjTTlN7W0XA+QC8StDAaA6aKYgFbngF7oxF/ibCS2MN4 GWV/LzdLPvoiCmkQD/POAIxDVJ0SlKiRmwmb8ieiR+Taa9a51WdmhZISoQipgn+9ZDYW urWdgTBR6VS/4RYs6bJqDshhVDVUtcIyzejvkGzPXqlBJzLMR1ZJACeloW5dP+benvln wNLFdBptkWmzZ8YyIG2iBpNBkgdC68KfNEXEh7wn547TraLnzzfEh0VS/db9hubHteFB RELEP6pspg168ws24wxzoT9K5xTcbTW5b52esOC8bDqoxYx3IEmt+DQfuZu6YBXy3gqA ZQEg== X-Gm-Message-State: AOJu0YxmaB9zBZHnx8Tdju1tTK6zhQvOGCvhpE7N2uaLtSTFZ5ycbUgg 8fZOXWJ4Li/Ozl7gbaxCu4sHQAZgMqpfxOLDXFVcrg== X-Google-Smtp-Source: AGHT+IH9ugIMzaG/178tD4IQXWsx2dQy7aOOBjIQj4jH9Mbz/DDALq6StKiTrKW8gpU8eTOUh5cHug== X-Received: by 2002:a05:6e02:2189:b0:34f:35e8:5098 with SMTP id j9-20020a056e02218900b0034f35e85098mr88678ila.20.1696353541940; Tue, 03 Oct 2023 10:19:01 -0700 (PDT) Received: from localhost.localdomain (71-211-130-31.hlrn.qwest.net. [71.211.130.31]) by smtp.gmail.com with ESMTPSA id p7-20020a92c607000000b0035134215863sm480967ilm.55.2023.10.03.10.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 10:19:01 -0700 (PDT) From: Tom Tromey To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Tom Tromey Subject: [PATCH 2/2] libstdc++: _versioned_namespace is always non-None Date: Tue, 3 Oct 2023 11:18:51 -0600 Message-Id: <20231003171851.1161340-3-tromey@adacore.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231003171851.1161340-1-tromey@adacore.com> References: <20231003171851.1161340-1-tromey@adacore.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Some code in the pretty-printers seems to assume that the _versioned_namespace global might be None (or the empty string). However, doesn't occur, as the variable is never reassigned. libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py: Assume that _versioned_namespace is non-None. * python/libstdcxx/v6/xmethods.py (is_specialization_of): Assume that _versioned_namespace is non-None. --- libstdc++-v3/python/libstdcxx/v6/printers.py | 15 ++++++--------- libstdc++-v3/python/libstdcxx/v6/xmethods.py | 3 +-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 23efbd171ec..e370551cbe1 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -139,7 +139,7 @@ def lookup_templ_spec(templ, *args): except gdb.error as e: # Type not found, try again in versioned namespace. global _versioned_namespace - if _versioned_namespace and _versioned_namespace not in templ: + if _versioned_namespace not in templ: t = t.replace('::', '::' + _versioned_namespace, 1) try: return gdb.lookup_type(t) @@ -211,16 +211,13 @@ def is_specialization_of(x, template_name): global _versioned_namespace if isinstance(x, gdb.Type): x = x.tag - if _versioned_namespace: - template_name = '(%s)?%s' % (_versioned_namespace, template_name) + template_name = '(%s)?%s' % (_versioned_namespace, template_name) return re.match('^std::%s<.*>$' % template_name, x) is not None def strip_versioned_namespace(typename): global _versioned_namespace - if _versioned_namespace: - return typename.replace(_versioned_namespace, '') - return typename + return typename.replace(_versioned_namespace, '') def strip_inline_namespaces(type_str): @@ -2355,7 +2352,7 @@ class Printer(object): # Add a name using _GLIBCXX_BEGIN_NAMESPACE_VERSION. def add_version(self, base, name, function): self.add(base + name, function) - if _versioned_namespace and '__cxx11' not in base: + if '__cxx11' not in base: vbase = re.sub('^(std|__gnu_cxx)::', r'\g<0>%s' % _versioned_namespace, base) self.add(vbase + name, function) @@ -2527,7 +2524,7 @@ def add_one_template_type_printer(obj, name, defargs): printer = TemplateTypePrinter('std::__debug::' + name, defargs) gdb.types.register_type_printer(obj, printer) - if _versioned_namespace and '__cxx11' not in name: + if '__cxx11' not in name: # Add second type printer for same type in versioned namespace: ns = 'std::' + _versioned_namespace # PR 86112 Cannot use dict comprehension here: @@ -2628,7 +2625,7 @@ class FilteringTypePrinter(object): def add_one_type_printer(obj, template, name, targ1=None): printer = FilteringTypePrinter('std::' + template, 'std::' + name, targ1) gdb.types.register_type_printer(obj, printer) - if _versioned_namespace and '__cxx11' not in template: + if '__cxx11' not in template: ns = 'std::' + _versioned_namespace printer = FilteringTypePrinter(ns + template, ns + name, targ1) gdb.types.register_type_printer(obj, printer) diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py b/libstdc++-v3/python/libstdcxx/v6/xmethods.py index 8ccf57c4d6b..42e60eb57b1 100644 --- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py +++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py @@ -39,8 +39,7 @@ def is_specialization_of(x, template_name): """ if isinstance(x, gdb.Type): x = x.tag - if _versioned_namespace: - template_name = '(%s)?%s' % (_versioned_namespace, template_name) + template_name = '(%s)?%s' % (_versioned_namespace, template_name) return re.match(r'^std::(__\d::)?%s<.*>$' % template_name, x) is not None class LibStdCxxXMethod(gdb.xmethod.XMethod):