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 6D86E3858C00 for ; Thu, 23 Feb 2023 19:06:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6D86E3858C00 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=1677179218; 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: in-reply-to:in-reply-to:references:references; bh=1SLDqjmKaQIb+FhVNoDsf6VG6+9RXh1SZUzpnq2C76U=; b=b5/kLX7EGSYTxEMYftCiM0wXaf37wbNhrJpeiIFrboNHgZett1N9jxUyW+sBTQesGwisTv zkFRw3mlNF52DVXUpVQQ3xYG+kqdxG2j6N8J/hW2/ZXZbl0tCvPknit50XHZqp4dKLlW6T zP248H3rsqkyVnXWFCduEGl+Nb+a9Kw= 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_128_GCM_SHA256) id us-mta-658-AMFxaaTnMjS3_rD2UC-kCg-1; Thu, 23 Feb 2023 14:06:57 -0500 X-MC-Unique: AMFxaaTnMjS3_rD2UC-kCg-1 Received: by mail-wm1-f69.google.com with SMTP id l23-20020a7bc457000000b003e206cbce8dso5407358wmi.7 for ; Thu, 23 Feb 2023 11:06:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1SLDqjmKaQIb+FhVNoDsf6VG6+9RXh1SZUzpnq2C76U=; b=0bN8apJMq7R8dABsKGLKYubRubXczmZzrFr7PEmzTXJ25UhH70D0mlWuXVUtJ4yZWX IzvwHqSV6x9s4nayofbDJ/YRbdumvqNz2Mj6u4jOfpLzBWKeTWdBauZTE5eolHpi/tW/ K5zxnechpFlg1+1ZN4X3FFbrIYyaji7hkghEGUAbQWbIxcL7P42mGgZzYn55BVQJ35tw sLRjyuNR8jpsIrIyFcHOK36m6jNPOfduO2HKZyJDYxyMN+JPZmBFSTVcthm9waMqjBys 6rGw5A1ZJKuG9Ii8zAzXaMDDt6Y7VRcOJx/IuTxux0t6bawzddqU9wRDC8fJ7kSx00QK B0mg== X-Gm-Message-State: AO0yUKXEaM2mZthMswEVm4CyQkS2yrYHwwVQ+eGYy6sCuc98S9JkY0fV gFOWn+cNdPQ6bXPSMlc+x2HbzIVI8iq5vrIQMaOmE/v2purU047/+6jI6Pu8M2o4MAFK3lr7rCx knYIibSvoa5aE8aX4vP2MeCeHcneATPhoATPtl22StjO4VgozP/Y2a7O5nq3Aouf5/E6bZnIGCJ hKzGo= X-Received: by 2002:a05:600c:4f4e:b0:3e2:d3:b2b6 with SMTP id m14-20020a05600c4f4e00b003e200d3b2b6mr12062230wmq.14.1677179215733; Thu, 23 Feb 2023 11:06:55 -0800 (PST) X-Google-Smtp-Source: AK7set+AVVOcajkaCCVzpqi+PFpNYnQkJtg9eOIBCCxGeER/rwyYBFKBVuOq/VRjIe9Rlln8o5mS7Q== X-Received: by 2002:a05:600c:4f4e:b0:3e2:d3:b2b6 with SMTP id m14-20020a05600c4f4e00b003e200d3b2b6mr12062214wmq.14.1677179215453; Thu, 23 Feb 2023 11:06:55 -0800 (PST) Received: from localhost (92.40.184.125.threembb.co.uk. [92.40.184.125]) by smtp.gmail.com with ESMTPSA id m4-20020a05600c40c400b003db06224953sm182886wmh.41.2023.02.23.11.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 11:06:55 -0800 (PST) From: Andrew Burgess To: Bruno Larsen via Gdb-patches , gdb-patches@sourceware.org Cc: Bruno Larsen Subject: Re: [PATCH] gdb/testsuite: add regression test for per-objfile typeprinters In-Reply-To: <20230223131333.3743376-1-blarsen@redhat.com> References: <20230223131333.3743376-1-blarsen@redhat.com> Date: Thu, 23 Feb 2023 19:06:52 +0000 Message-ID: <87o7pkjj5f.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: Bruno Larsen via Gdb-patches writes: > 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. LGTM. Reviewed-By: Andrew Burgess Thanks, Andrew > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=17136 > --- > 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()) > -- > 2.39.1