From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9256 invoked by alias); 20 Sep 2010 10:15:42 -0000 Received: (qmail 9245 invoked by uid 22791); 20 Sep 2010 10:15:41 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp.nokia.com (HELO mgw-mx03.nokia.com) (192.100.122.230) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Sep 2010 10:15:35 +0000 Received: from esebh106.NOE.Nokia.com (esebh106.ntc.nokia.com [172.21.138.213]) by mgw-mx03.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o8KAFQX1029224 for ; Mon, 20 Sep 2010 13:15:31 +0300 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by esebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 20 Sep 2010 13:14:29 +0300 Received: from mgw-da02.ext.nokia.com ([147.243.128.26]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 20 Sep 2010 13:14:28 +0300 Received: from gar.localnet (berwst16747.europe.nokia.com [172.25.167.47]) by mgw-da02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o8KAEQDe032491 for ; Mon, 20 Sep 2010 13:14:27 +0300 From: =?utf-8?q?Andr=C3=A9_P=C3=B6nitz?= To: gdb-patches@sourceware.org Subject: Re: [PATCH] [RFC] python: gdb.Type: strip typedefs past pointers too Date: Mon, 20 Sep 2010 13:14:00 -0000 User-Agent: KMail/1.13.2 (Linux/2.6.32-21-generic; KDE/4.4.2; i686; ; ) References: <1284753356.21566.10.camel@localhost.localdomain> In-Reply-To: <1284753356.21566.10.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <201009201214.21314.andre.poenitz@nokia.com> X-Nokia-AV: Clean X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-09/txt/msg00340.txt.bz2 On Friday 17 September 2010 21:55:56 ext Paul Bolle wrote: > 0) gdb.Type.strip_typedefs() stops stripping types if it encounters a > type that is a pointer to a typedef: > > (gdb) ptype wchar_t > type = long int > (gdb) ptype wchar_t * > type = long int * Funny. What platform and gdb version is that? I seem to get 'wchar_t *' here with 6.3, 6.8. 7.0, 7.1, and fairly recent git. >&"ptype wchar_t\n" >~"type = wchar_t\n" >^done >&"ptype wchar_t*\n" >~"type = wchar_t *\n" > (gdb) python print gdb.lookup_type("wchar_t").strip_typedefs() > long int > (gdb) python print gdb.lookup_type("wchar_t").pointer().strip_typedefs() > wchar_t * [This is also in my opinion correct and expected behaviour.] > 1) I drafted a patch (pasted below this message) that works around this > limitation: > > (gdb) ptype wchar_t > type = long int > (gdb) ptype wchar_t * > type = long int * > (gdb) python print gdb.lookup_type("wchar_t").strip_typedefs() > long int > (gdb) python print gdb.lookup_type("wchar_t").pointer().strip_typedefs() > long int * If you need the functionality you can provide it using a few lines of Python by checking for type.code == gdb.TYPE_CODE_PTR and recurse if needed. Andre'