From patchwork Mon Oct 7 12:07:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 34840 Received: (qmail 114914 invoked by alias); 7 Oct 2019 12:07:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 114906 invoked by uid 89); 7 Oct 2019 12:07:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=ctf_context_t X-HELO: mail-wm1-f68.google.com Received: from mail-wm1-f68.google.com (HELO mail-wm1-f68.google.com) (209.85.128.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Oct 2019 12:07:28 +0000 Received: by mail-wm1-f68.google.com with SMTP id 3so12061095wmi.3 for ; Mon, 07 Oct 2019 05:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=JqzgP3v8aNsdj/8fmkUyP7EkmQjsawmgEWHpmslbphM=; b=EgicHL32aE2xRfb19bVQHmyA6tnNu/TY8O8g7ZNOVEkwdRWWSc3q/uI3WZjpl0URHy ILKjEDfRMsYBG+GzZqMZgbkfyxV+onutBe+NtOEqBAZcpPnmid4eiCI85hnWKjfs2m+A tgEbefhPal1SZGCe42z8l3VUQFeiP8+hIILJOvKG5iPWGejucU4eabtQXcS0pU7zqicd gm2vHS2OllOrZMQa6vMGcHbPjYAipoTrWeIN1XJW+lcEA4CY8zLIN4lPAh+djfieLM3e WS1E2c+I0+vHz4ycdXscC74iSeVT1enuvd1aD0kvYLk24V+4bUcu4IpG5y6iZb74yXru 1zYw== Return-Path: Received: from localhost (cust64-dsl91-135-5.idnet.net. [91.135.5.64]) by smtp.gmail.com with ESMTPSA id p5sm9494289wmi.4.2019.10.07.05.07.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Oct 2019 05:07:25 -0700 (PDT) Date: Mon, 7 Oct 2019 13:07:24 +0100 From: Andrew Burgess To: Tom de Vries Cc: Weimin Pan , gdb-patches@sourceware.org, Simon Marchi Subject: Re: [PATCH v3] gdb: CTF support Message-ID: <20191007120723.GO4962@embecosm.com> References: <1570143372-27092-1-git-send-email-weimin.pan@oracle.com> <596e6b5b-901b-b1ad-fb9a-3a6631f44547@suse.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <596e6b5b-901b-b1ad-fb9a-3a6631f44547@suse.de> X-Fortune: The meek shall inherit the earth -- they are too weak to refuse. X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes * 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. 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);