From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32893 invoked by alias); 14 Dec 2017 14:19:47 -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 32883 invoked by uid 89); 14 Dec 2017 14:19:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=BAYES_00,KAM_ASCII_DIVIDERS,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=xxx 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; Thu, 14 Dec 2017 14:19:40 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A3AAC4903D; Thu, 14 Dec 2017 14:19:39 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3FE27D949; Thu, 14 Dec 2017 14:19:27 +0000 (UTC) Subject: Re: [PATCH v6 2/2] Implement pahole-like 'ptype /o' option To: Sergio Durigan Junior , GDB Patches References: <20171121160709.23248-1-sergiodj@redhat.com> <20171214024816.29629-1-sergiodj@redhat.com> <20171214024816.29629-3-sergiodj@redhat.com> Cc: Tom Tromey , Eli Zaretskii , Simon Marchi , Keith Seitz From: Pedro Alves Message-ID: <1db3626e-95b3-45b2-2e2e-dc27e97dda16@redhat.com> Date: Thu, 14 Dec 2017 14:19:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20171214024816.29629-3-sergiodj@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-12/txt/msg00344.txt.bz2 Something broke in v5 -> v6 in the offset and hole computation. I'm seeing this: v6: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (top-gdb) ptype/o minimal_symbol /* offset | size */ type = struct minimal_symbol { /* 0 | 32 */ struct general_symbol_info { /* 0 | 8 */ const char *name; /* 8 | 8 */ union { /* 8 */ LONGEST ivalue; /* 8 */ const block *block; /* 8 */ const gdb_byte *bytes; /* 8 */ CORE_ADDR address; /* 8 */ const common_block *common_block; /* 8 */ symbol *chain; /* total size (bytes): 8 */ } value; /* 24 | 8 */ union { /* 8 */ obstack *obstack; /* 8 */ const char *demangled_name; /* total size (bytes): 8 */ } language_specific; /* 48:27 | 4 */ language language : 5; /* 48:26 | 4 */ unsigned int ada_mangled : 1; /* XXX 2-bit hole */ /* XXX 1-byte hole */ /* 50 | 2 */ short section; /* total size (bytes): 32 */ } mginfo; /* 56 | 8 */ unsigned long size; /* 64 | 8 */ const char *filename; /* 72:28 | 4 */ minimal_symbol_type type : 4; /* 72:27 | 4 */ unsigned int created_by_gdb : 1; /* 72:26 | 4 */ unsigned int target_flag_1 : 1; /* 72:25 | 4 */ unsigned int target_flag_2 : 1; /* 72:24 | 4 */ unsigned int has_size : 1; /* XXX 7-byte hole */ /* 80 | 8 */ minimal_symbol *hash_next; /* 88 | 8 */ minimal_symbol *demangled_hash_next; /* total size (bytes): 72 */ } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This says that "language_specific" is at 24, with size 8 => next byte is at 32. "language" is at 48. How come no "XXX hole" is printed? Similarly in the "8 + 8 -> 24" jump. It turns out the byte offsets are wrong. Here's the actual byte offset for language_specific is: (top-gdb) p /d &((minimal_symbol *) 0) ->mginfo.language_specific $1 = 16 while v6 says 24. v5 seemed to get it right. Here's what it would show: (top-gdb) ptype /o minimal_symbol /* offset | size */ type = struct minimal_symbol { /* 0 | 32 */ struct general_symbol_info { /* 0 | 8 */ const char *name; /* 8 | 8 */ union { /* 8 */ LONGEST ivalue; /* 8 */ const block *block; /* 8 */ const gdb_byte *bytes; /* 8 */ CORE_ADDR address; /* 8 */ const common_block *common_block; /* 8 */ symbol *chain; } /* total size: 8 bytes */ value; /* 16 | 8 */ union { /* 8 */ obstack *obstack; /* 8 */ const char *demangled_name; } /* total size: 8 bytes */ language_specific; /* 24:27 | 4 */ language language : 5; /* 24:26 | 4 */ unsigned int ada_mangled : 1; /* XXX 2-bit hole */ /* XXX 1-byte hole */ /* 26 | 2 */ short section; } /* total size: 32 bytes */ mginfo; /* 32 | 8 */ unsigned long size; /* 40 | 8 */ const char *filename; /* 48:28 | 4 */ minimal_symbol_type type : 4; /* 48:27 | 4 */ unsigned int created_by_gdb : 1; /* 48:26 | 4 */ unsigned int target_flag_1 : 1; /* 48:25 | 4 */ unsigned int target_flag_2 : 1; /* 48:24 | 4 */ unsigned int has_size : 1; /* XXX 7-byte hole */ /* 56 | 8 */ minimal_symbol *hash_next; /* 64 | 8 */ minimal_symbol *demangled_hash_next; } /* total size: 72 bytes */ (top-gdb) Surprised this wasn't caught by the testcases. I do like the new output format a lot better. Thanks much for implementing the suggestions! Pedro Alves