From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35124 invoked by alias); 7 Oct 2019 09:44:40 -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 35110 invoked by uid 89); 7 Oct 2019 09:44:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-13.0 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Oct 2019 09:44:38 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 61634B1A4; Mon, 7 Oct 2019 09:44:36 +0000 (UTC) Subject: Re: [PATCH v3] gdb: CTF support From: Tom de Vries To: Weimin Pan , gdb-patches@sourceware.org, Simon Marchi References: <1570143372-27092-1-git-send-email-weimin.pan@oracle.com> <596e6b5b-901b-b1ad-fb9a-3a6631f44547@suse.de> Openpgp: preference=signencrypt Message-ID: Date: Mon, 07 Oct 2019 09:44:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <596e6b5b-901b-b1ad-fb9a-3a6631f44547@suse.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-10/txt/msg00182.txt.bz2 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 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