From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95649 invoked by alias); 12 Dec 2017 17:04:43 -0000 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 Received: (qmail 95460 invoked by uid 89); 12 Dec 2017 17:04:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Dec 2017 17:04:41 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6C389C00D880; Tue, 12 Dec 2017 17:04:40 +0000 (UTC) Received: from localhost (unused-10-15-17-193.yyz.redhat.com [10.15.17.193]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E5A7470A0E; Tue, 12 Dec 2017 17:04:39 +0000 (UTC) From: Sergio Durigan Junior To: John Baldwin Cc: Simon Marchi , Pedro Alves , Simon Marchi , GDB Patches , Tom Tromey , Eli Zaretskii Subject: Re: [PATCH v2] Implement pahole-like 'ptype /o' option References: <20171121160709.23248-1-sergiodj@redhat.com> <20171128212137.15655-1-sergiodj@redhat.com> <87o9n5drbn.fsf@redhat.com> <99286acb-ce9f-42f0-41c3-ef10e03171ff@ericsson.com> <87tvwxc6t9.fsf@redhat.com> <964bae42-6e60-4e9d-048c-ef570c1d3a5b@redhat.com> <87fu8gdgl8.fsf@redhat.com> <0d314798-6e0d-f7a9-ace8-3cb43bda9947@redhat.com> <87shcg94hp.fsf@redhat.com> <750e0e54f663f81c1f7bf7207bc1e814@polymtl.ca> Date: Tue, 12 Dec 2017 17:04:00 -0000 In-Reply-To: (John Baldwin's message of "Tue, 12 Dec 2017 10:50:09 -0500") Message-ID: <87h8svyj14.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2017-12/txt/msg00280.txt.bz2 On Tuesday, December 12 2017, John Baldwin wrote: > On 12/11/17 8:25 PM, Simon Marchi wrote: >> On 2017-12-11 19:51, Pedro Alves wrote: >>>>> So from that angle, I see value in not printing the offsets >>>>> of union members. >>>> >>>> Since it's still not clear whether the offsets should be printed or >>>> not >>>> in this case, and I am not a global maintainer, I adjusted the code to >>>> print them and will post the patch as a reply to the v4 e-mail. This >>>> way you can decide which version is best. >>> >>> Fun, just when I agreed with not printing the offsets... :-P :-) >> >> Damn, sorry for starting you guys on that track! I just wanted to know >> if it was intentional or not, I am fine with either. > > The only reason I would find the offset usable is to know the offset of > a structure member inside of a union. E.g.: > > struct foo { > int x; > union { > struct { > int y; > int z; > }; > int a; > }; > }; > > I think it is useful to know the offset of 'foo.z' within the overall > structure. You'll have that: (gdb) ptype /o struct foo /* offset | size */ struct foo { /* 0 | 4 */ int x; /* 4 | 8 */ union { /* 8 */ struct { /* 4 | 4 */ int y; /* 8 | 4 */ int z; } /* total size: 8 bytes */; /* 4 */ int a; } /* total size: 8 bytes */; } /* total size: 12 bytes */ -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/