This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v3] gdb: CTF support
On 07-10-19 11:33, Tom de Vries wrote:
> 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.
I was curious if I could detect this at build time, and indeed after
building with -fuse-ld=gold -Wl,--detect-odr-violations, I get:
....
$ grep -i 'odr violation' build/MAKELOG
/usr/bin/ld.gold: warning: while linking gdb: symbol
'field_info::field_info()' defined in multiple places (possible ODR
violation):
/usr/bin/ld.gold: warning: while linking gdb: symbol
'field_info::field_info()' defined in multiple places (possible ODR
violation):
/usr/bin/ld.gold: warning: while linking gdb: symbol
'field_info::~field_info()' defined in multiple places (possible ODR
violation):
/usr/bin/ld.gold: warning: while linking gdb: symbol
'field_info::~field_info()' defined in multiple places (possible ODR
violation):
...
Thanks,
- Tom