From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 106299 invoked by alias); 5 Nov 2015 10:46:38 -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 106289 invoked by uid 89); 5 Nov 2015 10:46:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 05 Nov 2015 10:46:36 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id A221220A9A for ; Thu, 5 Nov 2015 10:46:35 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA5AkYAZ020951; Thu, 5 Nov 2015 05:46:34 -0500 Message-ID: <563B3389.20502@redhat.com> Date: Thu, 05 Nov 2015 10:46:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Kevin Buettner , gdb-patches@sourceware.org Subject: Re: [PATCH] gdb.dwarf2: Define and use gdb_target_symbol_prefix for symbol prefixes References: <20151029212509.438b5642@pinnacle.lan> <20151029222505.3bb590b9@pinnacle.lan> <56335065.1060100@redhat.com> <20151104233946.51336127@pinnacle.lan> In-Reply-To: <20151104233946.51336127@pinnacle.lan> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-11/txt/msg00178.txt.bz2 On 11/05/2015 06:39 AM, Kevin Buettner wrote: > On Fri, 30 Oct 2015 11:11:33 +0000 > Pedro Alves wrote: > But for a .S file, we need to do something like this (as shown in > gdb.arch/i386-float.S): > > #define CONCAT1(a, b) CONCAT2(a, b) > #define CONCAT2(a, b) a ## b > > #ifdef SYMBOL_PREFIX > # define SYMBOL(str) CONCAT1(SYMBOL_PREFIX, str) > #else > # define SYMBOL(str) str > #endif > > .text > .globl SYMBOL(main) > SYMBOL(main): > > I don't understand the reason for both CONCAT1 and CONCAT2, You need two levels in order to first expand SYMBOL_PREFIX, and then concat the result. Otherwise SYMBOL(main) expands to literally "SYMBOL_PREFIXmain" (minus quotes). > It seems to me that the way to fix this is to make > gdb_target_symbol_prefix_flags return an unquoted prefix. I.e. > it should return: > > additional_flags=-DSYMBOL_PREFIX=_ > > instead of: > > additional_flags=-DSYMBOL_PREFIX="_" Yup. > > Then, within C files, SYMBOL is defined as follows: > > #ifdef SYMBOL_PREFIX > #define SYMBOL(str) #SYMBOL_PREFIX #str > #else > #define SYMBOL(str) #str > #endif > > Note that this is the same as before, except that I added a # to > the front of SYMBOL_PREFIX. It's possible that this won't work - It wont. # can only be used with a macro parameter. > we might end up with "SYMBOL_PREFIX" instead of "_" for the prefix. > If that's the case, then some layering is needed, perhaps something > like this: > > #define STRCAT1(a,b) #a #b > #ifdef SYMBOL_PREFIX > #define SYMBOL(str) STRCAT1(SYMBOL_PREFIX,str) > #else > #define SYMBOL(str) #str > #endif > That still needs double expansion. > I'm willing to make these changes, but I want to first be sure that > I'm not missing an easier fix. IMO, it's clearer to separate the concerns -- concatenation and final stringification. Start with the usual concatenation: #define CONCAT1(a, b) CONCAT2(a, b) #define CONCAT2(a, b) a ## b #ifdef SYMBOL_PREFIX # define SYMBOL1(str) CONCAT1(SYMBOL_PREFIX, str) #else # define SYMBOL1(str) str #endif Then add a stringification layer: #define STR1(s) #s #define STR(s) STR1(s) #define SYMBOL(str) STR(SYMBOL1(str)) This way you have these expansions: SYMBOL1(main) -> _main SYMBOL(main) -> "_main" Thanks, Pedro Alves