From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 129282 invoked by alias); 7 Oct 2019 16:08:06 -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 129274 invoked by uid 89); 7 Oct 2019 16:08:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Oct 2019 16:08:04 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x97Fx3MG156424; Mon, 7 Oct 2019 16:07:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=HS4mMKvxJuiC7Evg/dK2uLcqO/oTplEjHjHz6pqIAO0=; b=ZjkffHtSXZ6FoVsr3kXY940kDvRj2WsbfHUuN0weVBjhxt2cTFVaiJ7wAQp9hmXNaxmb dLLpabmP87f072xaWhECtMwHxLKAUlvPKDhTU97S9JoeEe+urC6MAY0FWvpol0AyG+2g Q3KmyX2t2QR8S0yQ8sQT38qePz/Wwpnke3Ldg9NGA5q9CbZ0vg/qr/0MCFooWh0zhJwJ 0+aJ4688Oz3EjUO+aq/nogi/cHMU3ky4OLwC/aDUfhePKDnJXMb2wTuFQv1N8c9jWwcp o4wMIV1XKO1SXWu6d4xueh+jLBNMesdmEalLq0u1cNwv6Z2y2YssC3oW4fPo1pWxA6rI mA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2vek4q7srh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 07 Oct 2019 16:07:54 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x97FwUlR170094; Mon, 7 Oct 2019 16:05:53 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 2vf4n9hw1v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 07 Oct 2019 16:05:53 +0000 Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x97G5qPv016888; Mon, 7 Oct 2019 16:05:52 GMT Received: from [172.27.35.125] (/108.88.88.153) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 07 Oct 2019 09:05:51 -0700 Subject: Re: [PATCH v3] gdb: CTF support To: Andrew Burgess , Tom de Vries Cc: gdb-patches@sourceware.org, Simon Marchi References: <1570143372-27092-1-git-send-email-weimin.pan@oracle.com> <596e6b5b-901b-b1ad-fb9a-3a6631f44547@suse.de> <20191007120723.GO4962@embecosm.com> From: Wei-min Pan Message-ID: <66ec0403-849a-476a-38fe-edc80b0eb1af@oracle.com> Date: Mon, 07 Oct 2019 16:08:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20191007120723.GO4962@embecosm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2019-10/txt/msg00191.txt.bz2 On 10/7/2019 5:07 AM, Andrew Burgess wrote: > * Tom de Vries [2019-10-07 11:33:12 +0200]: > >> On 04-10-19 00:56, Weimin Pan wrote: >>> +/* The routines that read and process fields/members of a C struct, union, >>> + or enumeration, pass lists of data member fields in an instance of a >>> + field_info structure. It is derived from dwarf2read.c. */ >>> + >>> +struct nextfield >>> +{ >>> + struct field field {}; >>> +}; >>> + >>> +struct field_info >> Hi, >> >> not only is field_info derived from dwarf2read.c, it uses the same name >> for the type. This is a C++ One-Definition-Rule violation, which causes >> most of the test-suite to start failing for me. >> >> What happens is that here: >> ... >> if (die->child != NULL && ! die_is_declaration (die, cu)) >> { >> struct field_info fi; >> std::vector template_args; >> ... >> the constructor for field_info is called, but it calls the constructor >> for field_info defined in ctfread.c rather than dwarf2read.c. > Tom, > > Thanks for tracking this down. I had just run into the same issue. > I've pushed the patch below which I believe fixes this issue. > > Weimin, > > Hopefully you're happy with this fix, I guess if you'd rather see an > alternative solution then feel free to propose one. Hi Andrew, Your fix looks good. Thank you for taking care of it. Weimin > > Thanks, > Andrew > > --- > > From b2caee6aaa78106d7ae3c46dda3a84a325e43a1d Mon Sep 17 00:00:00 2001 > From: Andrew Burgess > Date: Mon, 7 Oct 2019 12:34:51 +0100 > Subject: [PATCH] gdb: Rename structures within ctfread.c > > Commit: > > commit 30d1f0184953478d14641c495261afd06ebfabac > Date: Mon Oct 7 00:46:52 2019 +0000 > > gdb: CTF support > > Introduces some structures with names that are already in use within > GBB, this violates C++'s one-definition rule. Specifically the > structures 'nextfield' and 'field_info' are now defined in > dwarf2read.c and ctfread.c. > > This commit renames the new structures (in ctfread.c), adding a 'ctf_' > prefix. Maybe we should consider renaming the DWARF versions too in > the future to avoid accidental conflicts. > > gdb/ChangeLog: > > * ctfread.c (struct nextfield): Renamed to ... > (struct ctf_nextfield): ... this. > (struct field_info): Renamed to ... > (strut ctf_field_info): ... this. > (attach_fields_to_type): Update for renamed structures. > (ctf_add_member_cb): Likewise. > (ctf_add_enum_member_cb): Likewise. > (process_struct_members): Likewise. > (process_enum_type): Likewise. > --- > gdb/ChangeLog | 12 ++++++++++++ > gdb/ctfread.c | 28 ++++++++++++++-------------- > 2 files changed, 26 insertions(+), 14 deletions(-) > > diff --git a/gdb/ctfread.c b/gdb/ctfread.c > index 3e3bd89d5f1..44ccff62ae3 100644 > --- a/gdb/ctfread.c > +++ b/gdb/ctfread.c > @@ -98,17 +98,17 @@ typedef struct ctf_context > > /* The routines that read and process fields/members of a C struct, union, > or enumeration, pass lists of data member fields in an instance of a > - field_info structure. It is derived from dwarf2read.c. */ > + ctf_field_info structure. It is derived from dwarf2read.c. */ > > -struct nextfield > +struct ctf_nextfield > { > struct field field {}; > }; > > -struct field_info > +struct ctf_field_info > { > /* List of data member fields. */ > - std::vector fields; > + std::vector fields; > > /* Context. */ > ctf_context_t *cur_context; > @@ -269,7 +269,7 @@ set_symbol_address (struct objfile *of, struct symbol *sym, const char *name) > /* Create the vector of fields, and attach it to TYPE. */ > > static void > -attach_fields_to_type (struct field_info *fip, struct type *type) > +attach_fields_to_type (struct ctf_field_info *fip, struct type *type) > { > int nfields = fip->fields.size (); > > @@ -284,7 +284,7 @@ attach_fields_to_type (struct field_info *fip, struct type *type) > /* Copy the saved-up fields into the field vector. */ > for (int i = 0; i < nfields; ++i) > { > - struct nextfield &field = fip->fields[i]; > + struct ctf_nextfield &field = fip->fields[i]; > TYPE_FIELD (type, i) = field.field; > } > } > @@ -314,7 +314,7 @@ ctf_init_float_type (struct objfile *objfile, > > /* Callback to add member NAME to a struct/union type. TID is the type > of struct/union member, OFFSET is the offset of member in bits, > - and ARG contains the field_info. */ > + and ARG contains the ctf_field_info. */ > > static int > ctf_add_member_cb (const char *name, > @@ -322,9 +322,9 @@ ctf_add_member_cb (const char *name, > unsigned long offset, > void *arg) > { > - struct field_info *fip = (struct field_info *) arg; > + struct ctf_field_info *fip = (struct ctf_field_info *) arg; > ctf_context_t *ccp = fip->cur_context; > - struct nextfield new_field; > + struct ctf_nextfield new_field; > struct field *fp; > struct type *t; > uint32_t kind; > @@ -358,13 +358,13 @@ ctf_add_member_cb (const char *name, > } > > /* Callback to add member NAME of EVAL to an enumeration type. > - ARG contains the field_info. */ > + ARG contains the ctf_field_info. */ > > static int > ctf_add_enum_member_cb (const char *name, int enum_value, void *arg) > { > - struct field_info *fip = (struct field_info *) arg; > - struct nextfield new_field; > + struct ctf_field_info *fip = (struct ctf_field_info *) arg; > + struct ctf_nextfield new_field; > struct field *fp; > ctf_context_t *ccp = fip->cur_context; > > @@ -587,7 +587,7 @@ process_struct_members (ctf_context_t *ccp, > ctf_id_t tid, > struct type *type) > { > - struct field_info fi; > + struct ctf_field_info fi; > > fi.cur_context = ccp; > if (ctf_member_iter (ccp->fp, tid, ctf_add_member_cb, &fi) == CTF_ERR) > @@ -665,7 +665,7 @@ static void > process_enum_type (ctf_context_t *ccp, ctf_id_t tid) > { > struct type *type; > - struct field_info fi; > + struct ctf_field_info fi; > > type = read_enum_type (ccp, tid); >