From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 92426 invoked by alias); 29 Jun 2017 15:48:50 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 92277 invoked by uid 89); 29 Jun 2017 15:48:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.2 spammy=phil X-HELO: mail-wm0-f49.google.com Received: from mail-wm0-f49.google.com (HELO mail-wm0-f49.google.com) (74.125.82.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 29 Jun 2017 15:48:41 +0000 Received: by mail-wm0-f49.google.com with SMTP id b184so19274103wme.1 for ; Thu, 29 Jun 2017 08:48:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=qG7tInvSk7Spppg4xvRMXK4kGC3Gg4cMKcNpWbro20I=; b=BL3Amdy+lI83JXIQYRhS3bQp5e8NKXviewn5IMLvnMRxYNyurzqdECf92C0VRoQfXl 02MZQGxchujv7B81y6JDOtPmMfyR6X6AQysfVeEIJkdELbmA/QG4XmvQ5naeOgvQSdKF QHD45P4Vf85hb9uwNoNNfMTTgBzI6BWBjsDCOgxS2XkfVMd2KzWwsu1RrTT3rj2yF3Ru 8Ut7UJ55A1YvbXG1VoaVoE4TwZ0FPPXXm90HHswFA1bhDUuw1zj47+IXKVHod8nmX3x5 6BXVdpN2nRpFNrOrmjhOdIsrk4qrUcPgd1xZa4Qq3IJ5s90UMN86np8+yoEseWP5aFEz SDCg== X-Gm-Message-State: AKS2vOzgmzoQwJZVL5aReqHYwLMlErp8cP2nC7tnGeFNb37Gj+F7qWjo c7wCl89H1Cgp+eZM X-Received: by 10.28.138.21 with SMTP id m21mr2345919wmd.99.1498751319087; Thu, 29 Jun 2017 08:48:39 -0700 (PDT) Received: from ?IPv6:2a02:c7f:ae15:7800:4685:ff:fe66:9f4? ([2a02:c7f:ae15:7800:4685:ff:fe66:9f4]) by smtp.gmail.com with ESMTPSA id 69sm1830662wmm.33.2017.06.29.08.48.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 08:48:31 -0700 (PDT) Subject: Re: [RFC PATCH 0/3] Pretty-printing for errno To: Zack Weinberg , libc-alpha@sourceware.org, gdb@sourceware.org Cc: joseph@codesourcery.com, fweimer@redhat.com, tom@tromey.com, siddhesh@gotplt.org References: <20170622224456.1358-1-zackw@panix.com> From: Phil Muldoon Message-ID: Date: Thu, 29 Jun 2017 15:48:00 -0000 MIME-Version: 1.0 In-Reply-To: <20170622224456.1358-1-zackw@panix.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00041.txt.bz2 On 22/06/17 23:44, Zack Weinberg wrote: > I say 'attempts' because it only _almost_ works, but the remaining > problems appear to be GDB bugs. The most important of these is that > if error_t is a typedef name for int, > > (gdb) p (error_t) 1 > > will _not_ invoke the pretty-printer for error_t. Bizarrely, the same > pretty-printer _does_ get invoked when you print an _array_ of error_t > quantities. Zack, I found some time to look at this and I wanted to make sure this is (or is not) a GDB bug. I cooked up a really simple testcase: typedef int test_i; int main () { test_i i = 1; return 0; } ptype shows i as type int. whatis shows i as type test_i. (gdb) ptype i type = int (gdb) whatis i type = test_i Both are correct as ptype always unrolls types. I looked at the pretty printer registration and lookup mechanics in GDB and looked at the value and type coming into the lookup function. I wanted to make sure the type is not being unrolled before being searched through the printers. It is not. In printers.py in the class RegexpCollectionPrettyPrinter and invoked through the __call__ function we see the typename as so (this is just output from a temporary print statement): ('typename: ', 'test_i') So the printer registered against a typedef type should get called. But similar to your experience, I get this for a value cast on the command line: (gdb) p (test_i) 1 $1 = ('typename: ', 'int') Which again is odd. I thought it might have something to do with temporary values (i.e. 1 exists for a moment, but is not in the inferior). So I tried: (gdb) p (test_i) i $2 = ('typename: ', 'int') Which is most puzzling. In summary, typedefs are accounted for normal and non-casting operations in pretty printing (i.e. print i). The typedef error_t should trigger the error_t pretty printer as registered. The situation for casting operations on the command line reverting to an unrolled type is puzzling to me and hopefully somebody can explain why this is so. I'll hack on this for a little bit and see if there are other things I can find. Cheers Phil