From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4023 invoked by alias); 26 Jun 2017 10:25:41 -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 122183 invoked by uid 89); 26 Jun 2017 10:25:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham 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; Mon, 26 Jun 2017 10:25:29 +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 A937880F6D for ; Mon, 26 Jun 2017 10:25:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A937880F6D Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A937880F6D 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 D187180F65; Mon, 26 Jun 2017 10:25:27 +0000 (UTC) Subject: Re: [PATCH] Record/output access specifiers for class typedefs To: Keith Seitz , gdb-patches@sourceware.org References: <1498416734-14498-1-git-send-email-keiths@redhat.com> From: Pedro Alves Message-ID: <984a26ce-e09a-0b11-4d7e-e8c5adf79173@redhat.com> Date: Mon, 26 Jun 2017 10:25: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: <1498416734-14498-1-git-send-email-keiths@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-06/txt/msg00694.txt.bz2 On 06/25/2017 07:52 PM, Keith Seitz wrote: > We do not currently record/output accessibility for typedefs defined > in a class: > > (gdb) list > 71 struct typedef_struct { > 72 public: > 73 typedef int public_int; > 74 public_int a; > 75 protected: > 76 typedef int protected_int; > 77 protected_int b; > 78 private: > 79 typedef int private_int; > 80 private_int c; > 81 protected: > 82 typedef float protected_float; > 83 protected_float d; > 84 private: > 85 typedef float private_float; > 86 private_float e; > 87 public: > 88 typedef float public_float; > 89 public_float f; > 90 }; > (gdb) ptype typedef_struct > type = struct typedef_struct { > public: > public_int a; > protected: > public_int b; > private: > public_int c; > protected: > protected_float d; > private: > protected_float e; > public: > protected_float f; > > typedef int public_int; > typedef int protected_int; > typedef int private_int; > typedef float protected_float; > typedef float private_float; > typedef float public_float; > } > > This patch modifies the DWARF reader to record accessibility when reading > in typedef DIEs. As general principle, please also show in the commit log what output looks like after the patch. On 06/25/2017 07:52 PM, Keith Seitz wrote: > + /* Save accessibility. */ > + struct attribute *attr = dwarf2_attr (die, DW_AT_accessibility, cu); > + enum dwarf_access_attribute accessibility; > + > + if (attr != NULL) > + accessibility = (enum dwarf_access_attribute) DW_UNSND (attr); > + else > + accessibility = dwarf2_default_access_attribute (die, cu); > + switch (accessibility) > + { > + case DW_ACCESS_public: > + fp->is_public = 1; > + break; > + case DW_ACCESS_private: > + fp->is_private = 1; > + break; > + case DW_ACCESS_protected: > + fp->is_protected = 1; > + break; > + default: > + gdb_assert_not_reached ("unexpected accessibility attribute"); Please don't add assertions that can trigger with invalid/broken DWARF. Call complaint instead. > + if (TYPE_TYPEDEF_FIELD_PROTECTED (type, i)) > + { > + if (section_type != s_protected) > + { > + section_type = s_protected; > + fprintfi_filtered (level + 2, stream, > + "protected:\n"); > + } > + } > + else if (TYPE_TYPEDEF_FIELD_PRIVATE (type, i)) > + { > + if (section_type != s_private) > + { > + section_type = s_private; > + fprintfi_filtered (level + 2, stream, > + "private:\n"); > + } > + } > + else > + { > + gdb_assert (TYPE_TYPEDEF_FIELD_PUBLIC (type, i)); Won't this assertion fail with debug formats other than DWARF? E.g., stabs? > + if (section_type != s_public) > + { > + section_type = s_public; > + fprintfi_filtered (level + 2, stream, > + "public:\n"); > + } > + } > + > --- a/gdb/gdbtypes.h > +++ b/gdb/gdbtypes.h > @@ -884,6 +884,18 @@ struct typedef_field > /* * Type this typedef named NAME represents. */ > > struct type *type; > + > + /* * True if this field was declared public, false otherwise. */ > + unsigned int is_public : 1; > + > + /* * True if this field was declared protected, false otherwise. */ > + unsigned int is_protected : 1; > + > + /* * True if this field was declared private, false otherwise. */ > + unsigned int is_private : 1; > + > + /* * Unused. */ > + unsigned int dummy : 13; Is this really 13 bits? Looks to me 29 bits on 32-bit archs (and due to padding, really 61 bits on 64-bit archs)? > }; For completeness, do you have a sense of whether this is a struct that might have a significant impact on gdb's memory consumption? Did you try measuring it with some large program, say, Firefox, with -readnow ? Thanks, Pedro Alves