From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108157 invoked by alias); 27 Jun 2018 02:59:37 -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 108145 invoked by uid 89); 27 Jun 2018 02:59:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=fence, Anyway X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.146.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Jun 2018 02:59:35 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway33.websitewelcome.com (Postfix) with ESMTP id AD829BD3BD for ; Tue, 26 Jun 2018 21:59:32 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id Y0fsf46uXbXuJY0g0fFh2d; Tue, 26 Jun 2018 21:59:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=CTxaKMmtLcs1kwiqfo1EVVAn7QaAa3D2xqhRyhCjoZw=; b=MltbpN/urO4KjmIG6AqZe/NMlZ 9i3aYmnh2y+sIYyIG8D7zFWqo7eBlf1vGhKhGU2Pf1NX8/qEmaHzCsjpvQp0WSg3tM32Z7vW+8F1Y VEuOfIBpchqTd9T1A9FgV1Bpm; Received: from 75-166-79-120.hlrn.qwest.net ([75.166.79.120]:47330 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fY0fr-002oyN-Ae; Tue, 26 Jun 2018 21:59:15 -0500 From: Tom Tromey To: Sergio Durigan Junior Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [RFA 0/2] Support ptype/o in Rust References: <20180623202227.17259-1-tom@tromey.com> <87woup9ifk.fsf@redhat.com> Date: Wed, 27 Jun 2018 02:59:00 -0000 In-Reply-To: <87woup9ifk.fsf@redhat.com> (Sergio Durigan Junior's message of "Sat, 23 Jun 2018 19:44:47 -0400") Message-ID: <87bmbxrl31.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2018-06/txt/msg00632.txt.bz2 >>>>> "Sergio" == Sergio Durigan Junior writes: Sergio> Even though it's a bit uglier than your solution, IMO it's easier to Sergio> understand and correlate the sizes with their respective structs. Sergio> Compare this to: Sergio> (gdb) ptype /o struct c Sergio> /* offset | size */ type = struct c { Sergio> /* 0 | 12 */ struct a { Sergio> /* 0 | 4 */ int a1; Sergio> /* 4 | 1 */ char a2; Sergio> /* XXX 3-byte hole */ Sergio> /* 8 | 4 */ int a3; Sergio> /* total size (bytes): 12 */ Sergio> } c1; Sergio> /* 12 | 20 */ struct b { Sergio> /* 12 | 12 */ struct a { Sergio> /* 12 | 4 */ int a1; Sergio> /* 16 | 1 */ char a2; Sergio> /* XXX 3-byte hole */ Sergio> /* 20 | 4 */ int a3; Sergio> /* total size (bytes): 12 */ Sergio> } b1; Sergio> /* 24 | 4 */ int b2; Sergio> /* 28 | 1 */ char b3; Sergio> /* XXX 3-byte padding */ Sergio> /* total size (bytes): 20 */ Sergio> } c2; Sergio> /* 32 | 1 */ char c3; Sergio> /* XXX 3-byte hole */ Sergio> /* 36 | 4 */ int c4; Sergio> /* total size (bytes): 40 */ Sergio> } My idea was to line up the total size with the "}" so it would instead appear as: (gdb) ptype /o struct c /* offset | size */ type = struct c { /* 0 | 12 */ struct a { /* 0 | 4 */ int a1; /* 4 | 1 */ char a2; /* XXX 3-byte hole */ /* 8 | 4 */ int a3; /* total size: 12 */ } c1; /* 12 | 20 */ struct b { /* 12 | 12 */ struct a { /* 12 | 4 */ int a1; /* 16 | 1 */ char a2; /* XXX 3-byte hole */ /* 20 | 4 */ int a3; /* total size: 12 */ } b1; /* 24 | 4 */ int b2; /* 28 | 1 */ char b3; /* XXX 3-byte padding */ /* total size: 20 */ } c2; /* 32 | 1 */ char c3; /* XXX 3-byte hole */ /* 36 | 4 */ int c4; /* total size: 40 */ } But yeah, maybe that's a bit harder to read than the status quo. Sergio> Anyway, TBH I don't have a strong opinion here. If you want to indent Sergio> the outermost fields by 4 spaces, I won't oppose. I'm on the fence. It works ok now; it just made some of the code a little uglier. Tom