This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] gdb.dwarf2: Define and use gdb_target_symbol_prefix for symbol prefixes


On 11/05/2015 10:46 AM, Pedro Alves wrote:
>> > I'm willing to make these changes, but I want to first be sure that
>> > I'm not missing an easier fix.

BTW, an alternative to the below would be to have two tcl procedures,
one for asm, and another for C/C++/etc, like
gdb_target_symbol_prefix_flags_asm / gdb_target_symbol_prefix_flags.
The C version would just call the asm version and add the double
quotes.

Thanks,
Pedro Alves

> 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"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]