From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 9B60C3858D39 for ; Mon, 13 Mar 2023 08:56:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9B60C3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678697774; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qj+PnWAIB7a3uI4Op5u5knI+5QzVqZgX+086WoUkDLU=; b=L0VnS8AN1LpU7P8o9Wz97u56Sdm1ohkTQJtxpbKZwFLasnPz1W9EMwK58ZRv3sGc9St0q8 EjOIwUPwWk/f78Dk5OXIHLQ2eQ1ImzHWvUfWpvv83tVmU2R5+BHZNqMam0+75kzBzA7oQf VAAoFBkcFNimSxubO9pfY736lnPSTr8= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-IbvOo2qwMh-NSfMaZHZgSQ-1; Mon, 13 Mar 2023 04:56:13 -0400 X-MC-Unique: IbvOo2qwMh-NSfMaZHZgSQ-1 Received: by mail-wm1-f69.google.com with SMTP id az7-20020a05600c600700b003ed25435106so528417wmb.2 for ; Mon, 13 Mar 2023 01:56:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678697772; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qj+PnWAIB7a3uI4Op5u5knI+5QzVqZgX+086WoUkDLU=; b=09O82o7QYVaC7uS7U/T9HnUjouORfO9I5qsSGa24CvWvxpNQ62WR7q9A8FyBLX6XYT EjH4fxmf7VWcNhoBwLiDjHsqwwY8UCWF5dWGfLisjGfCL0zlr+kfpzrJF+b3rdn2/nmx Z41lfNLnjpfL4wSJ63KAJEecLhwfmG/YQjF27o5C2Ync30iqg4IaY9l6Rvz/CGXbJKLp zVGj70yDuc7M4Ax2rD+MaypNVJQlLrR6fN+M+FoHa41RklaT/Tey+SNw6FWFhCsLBwUW AIKVLGc12bnJwOUwceI3ZChgV0L93vkkjommavpaTYwXB2D4+2FplQKepcbWjUxa50Sq ggFA== X-Gm-Message-State: AO0yUKVufUAjWyiev5MXbkvywWqEmho4LnFhfRRP5u7Fo6O5huGJxxIE e6qnYbwDydDB3H5I/Y9wKHgqPSjhSj2YWWIeHSbzFbq+zTjtD8cWAgsAdr7RRIfoJE16WhkUVPL N+Xg6e50AdK3XBo4U5TEMwasSrZekA20WbThJsrvgo5gYm30Cg2oaGjvAZWmMWU7EFPa02Qc/z1 r4sMeU X-Received: by 2002:a05:600c:198e:b0:3eb:3998:8c05 with SMTP id t14-20020a05600c198e00b003eb39988c05mr8019373wmq.6.1678697771177; Mon, 13 Mar 2023 01:56:11 -0700 (PDT) X-Google-Smtp-Source: AK7set88vtgdggFWBAWRp6tCizgcFWPlo3MJfni0Ig98DJVJAFUaEtaup+BG+N4KhBN2Pc5JbPiLIg== X-Received: by 2002:a05:600c:198e:b0:3eb:3998:8c05 with SMTP id t14-20020a05600c198e00b003eb39988c05mr8019248wmq.6.1678697767451; Mon, 13 Mar 2023 01:56:07 -0700 (PDT) Received: from [192.168.0.45] (ip-94-112-225-44.bb.vodafone.cz. [94.112.225.44]) by smtp.gmail.com with ESMTPSA id q20-20020a1cf314000000b003ebfc075eaasm8334794wmq.16.2023.03.13.01.56.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Mar 2023 01:56:06 -0700 (PDT) Message-ID: <845a1956-af20-bbd2-67a8-821ae7c44553@redhat.com> Date: Mon, 13 Mar 2023 09:56:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: [PING][PATCH v2] gdb/testsuite: add regression test for per-objfile typeprinters To: gdb-patches@sourceware.org Cc: jkratochvil@azul.com, pedro@palves.com, Andrew Burgess , Bruno Larsen References: <20230227111201.4092957-1-blarsen@redhat.com> From: Bruno Larsen In-Reply-To: <20230227111201.4092957-1-blarsen@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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: Ping! The only thing that changed from v1 to v2 was adding the Co-Authored-By tag On 27/02/2023 12:12, Bruno Larsen wrote: > PR python/17136 reported an unhandled exception when using typeprinters > only valid on some objfiles, rather than being a global typeprinter. The > fix was accepted without a regression test, and we've been carrying one > out-of-tree for a while but I think it's worth upstreaming. The code > itself was developed by Jan Kratochvil. > > Co-Authored-By: Jan Kratochvil > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17136 > Reviewed-By: Andrew Burgess > --- > gdb/testsuite/gdb.python/py-typeprint.cc | 6 ++++++ > gdb/testsuite/gdb.python/py-typeprint.exp | 4 ++++ > gdb/testsuite/gdb.python/py-typeprint.py | 25 ++++++++++++++++++++--- > 3 files changed, 32 insertions(+), 3 deletions(-) > > diff --git a/gdb/testsuite/gdb.python/py-typeprint.cc b/gdb/testsuite/gdb.python/py-typeprint.cc > index ccd2ed02db1..3f274a73498 100644 > --- a/gdb/testsuite/gdb.python/py-typeprint.cc > +++ b/gdb/testsuite/gdb.python/py-typeprint.cc > @@ -31,6 +31,12 @@ templ s; > > basic_string bs; > > +class Other > +{ > +}; > + > +Other ovar; > + > int main() > { > return 0; > diff --git a/gdb/testsuite/gdb.python/py-typeprint.exp b/gdb/testsuite/gdb.python/py-typeprint.exp > index 40f7e53847f..778583b9eff 100644 > --- a/gdb/testsuite/gdb.python/py-typeprint.exp > +++ b/gdb/testsuite/gdb.python/py-typeprint.exp > @@ -48,3 +48,7 @@ gdb_test_no_output "enable type-printer string" > gdb_test "whatis bs" "string" "whatis with enabled printer" > > gdb_test "whatis s" "templ" > + > +gdb_test "info type-printers" "Type printers for \[^\r\n\]*/py-typeprint:\r\n *other\r\n.*" \ > + "info type-printers for other" > +gdb_test "whatis ovar" "type = Another" > diff --git a/gdb/testsuite/gdb.python/py-typeprint.py b/gdb/testsuite/gdb.python/py-typeprint.py > index b5ba243889b..aac42a1a99a 100644 > --- a/gdb/testsuite/gdb.python/py-typeprint.py > +++ b/gdb/testsuite/gdb.python/py-typeprint.py > @@ -15,8 +15,7 @@ > > import gdb > > - > -class Recognizer(object): > +class StringRecognizer(object): > def __init__(self): > self.enabled = True > > @@ -32,7 +31,27 @@ class StringTypePrinter(object): > self.enabled = True > > def instantiate(self): > - return Recognizer() > + return StringRecognizer() > > > gdb.type_printers.append(StringTypePrinter()) > + > +class OtherRecognizer(object): > + def __init__(self): > + self.enabled = True > + > + def recognize(self, type_obj): > + if type_obj.tag == 'Other': > + return 'Another' > + return None > + > +class OtherTypePrinter(object): > + def __init__(self): > + self.name = 'other' > + self.enabled = True > + > + def instantiate(self): > + return OtherRecognizer() > + > +import gdb.types > +gdb.types.register_type_printer(gdb.objfiles()[0], OtherTypePrinter()) -- Cheers, Bruno