From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 103731 invoked by alias); 12 Dec 2017 01:59:08 -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 103325 invoked by uid 89); 12 Dec 2017 01:59:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1800, life X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Dec 2017 01:59:05 +0000 Received: from [10.0.0.11] (192-222-251-162.qc.cable.ebox.net [192.222.251.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 2D4D91E4C4; Mon, 11 Dec 2017 20:59:00 -0500 (EST) Subject: Re: [PATCH v4 2/2] Implement pahole-like 'ptype /o' option To: Sergio Durigan Junior , GDB Patches Cc: Tom Tromey , Eli Zaretskii , Simon Marchi , Pedro Alves , =?UTF-8?B?QW5kcsOpIFDDtm5pdHo=?= , Keith Seitz References: <20171121160709.23248-1-sergiodj@redhat.com> <20171211234345.27351-1-sergiodj@redhat.com> <20171211234345.27351-3-sergiodj@redhat.com> From: Simon Marchi Message-ID: Date: Tue, 12 Dec 2017 01:59:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171211234345.27351-3-sergiodj@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-12/txt/msg00268.txt.bz2 On 2017-12-11 06:43 PM, Sergio Durigan Junior wrote: > This commit implements the pahole-like '/o' option for 'ptype', which > prints the offsets and sizes of struct fields, reporting whenever > there is a hole found. > > The output is heavily based on pahole(1), with a few modifications > here and there to adjust it to our reality. Here's an example: > > (gdb) ptype /o stap_probe > /* offset | size */ > struct stap_probe { > /* 0 | 40 */ struct probe { > /* 0 | 8 */ const probe_ops *pops; > /* 8 | 8 */ gdbarch *arch; > /* 16 | 8 */ const char *name; > /* 24 | 8 */ const char *provider; > /* 32 | 8 */ CORE_ADDR address; > } /* total size: 40 bytes */ p; > /* 40 | 8 */ CORE_ADDR sem_addr; > /* 48:31 | 4 */ unsigned int args_parsed : 1; > /* XXX 7-bit hole */ > /* XXX 7-byte hole */ > /* 56 | 8 */ union { > /* 8 */ const char *text; > /* 8 */ VEC_stap_probe_arg_s *vec; > } /* total size: 8 bytes */ args_u; > } /* total size: 64 bytes */ > > A big part of this patch handles the formatting logic of 'ptype', > which is a bit messy. I tried to be not very invasive, but I had to > do some cleanups here and there to make life easier. > > This patch is the start of a long-term work I'll do to flush the local > patches we carry for Fedora GDB. In this specific case, I'm aiming at > upstreaming the feature implemented by the 'pahole.py' script that is > shipped with Fedora GDB: > > > > This has been regression-tested on the BuildBot. There's a new > testcase for it, along with an update to the documentation. I also > thought it was worth mentioning this feature in the NEWS file. That patch LGTM as-is, as well as with the union offsets :) Simon