Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Andrew Burgess <andrew.burgess@embecosm.com>,
	       Tom de Vries <tdevries@suse.de>
Cc: Weimin Pan <weimin.pan@oracle.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH v3] gdb: CTF support
Date: Mon, 07 Oct 2019 14:58:00 -0000	[thread overview]
Message-ID: <89a5ee6d-e9c7-5b6f-22b8-edb3ec50f369@polymtl.ca> (raw)
In-Reply-To: <20191007120723.GO4962@embecosm.com>

On 2019-10-07 8:07 a.m., Andrew Burgess wrote:
> * Tom de Vries <tdevries@suse.de> [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<struct symbol *> 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 <andrew.burgess@embecosm.com>
> 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.

Thanks guys for catching this.  Just in case you didn't already know,
another way to avoid these problems (if we apply it everywhere) is to
define everything that is local to a source file in an anonymous
namespace.  I don't really have the habit of doing it at the moment,
but maybe I should start to do it consistently.

Simon


  reply	other threads:[~2019-10-07 14:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-03 22:58 Weimin Pan
2019-10-04  1:11 ` Simon Marchi
2019-10-04 21:29   ` Weimin Pan
2019-10-07  9:33 ` Tom de Vries
2019-10-07  9:44   ` Tom de Vries
2019-10-07 12:07   ` Andrew Burgess
2019-10-07 14:58     ` Simon Marchi [this message]
2019-10-07 16:08     ` Wei-min Pan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=89a5ee6d-e9c7-5b6f-22b8-edb3ec50f369@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tdevries@suse.de \
    --cc=weimin.pan@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox