[Patch, AArch64, ILP32] 5/5 Improve the debugging experience with the generated file

David Daney ddaney.cavm@gmail.com
Fri Jun 21 18:52:00 GMT 2013


On 06/21/2013 11:08 AM, Yufeng Zhang wrote:
> Hi,
>
> This patch adds a #line directive at the beginning of the generated file
> (elf32-aarch64.c and elf64-aarch64.c) so that the generated debug
> information points to the template file instead.
>
> OK for the trunk?
>
> Thanks,
> Yufeng
>
>
> bfd/
>
>      * Makefile.am (elf32-aarch64.c): Add a #line cpp directive at the
>      beginning of the generated file.
>      (elf64-aarch64.c): Likewise.
>      * Makefile.in: Re-generated.
>
> 05-gen-hash-line-directive.patch
>
>
> diff --git a/bfd/Makefile.am b/bfd/Makefile.am
> index 19b3710..0e69d12 100644
> --- a/bfd/Makefile.am
> +++ b/bfd/Makefile.am
> @@ -917,12 +917,14 @@ elf64-target.h : elfxx-target.h
>
>   elf32-aarch64.c : elfnn-aarch64.c
>   	rm -f elf32-aarch64.c
> -	sed -e s/NN/32/g < $(srcdir)/elfnn-aarch64.c > elf32-aarch64.new
> +	echo "#line 1 \"$(srcdir)/elfnn-aarch64.c\"" > elf32-aarch64.new
> +	sed -e s/NN/32/g < $(srcdir)/elfnn-aarch64.c >> elf32-aarch64.new
>   	mv -f elf32-aarch64.new elf32-aarch64.c
>
>   elf64-aarch64.c : elfnn-aarch64.c
>   	rm -f elf64-aarch64.c
> -	sed -e s/NN/64/g < $(srcdir)/elfnn-aarch64.c > elf64-aarch64.new
> +	echo "#line 1 \"$(srcdir)/elfnn-aarch64.c\"" > elf64-aarch64.new
> +	sed -e s/NN/64/g < $(srcdir)/elfnn-aarch64.c >> elf64-aarch64.new
>   	mv -f elf64-aarch64.new elf64-aarch64.c
>
>   elf32-ia64.c : elfnn-ia64.c

I really hate this pattern of running the file through sed and 
synthesizing the #line.

I know this was built up out of several of the other patches, but I am 
commenting on it here.

Can you instead move the duplicated code to a file to be included 
twice, parameterizing it with one or more preprocessor macros?

I.E.:

.
.
.
#define AARCH64_ABI 32
#include "elfnn-arch64.c"
#undef AARCH64_ABI
#define AARCH64_ABI 64
#include "elfnn-arch64.c"
.
.
.


Thanks,
David Daney



More information about the Binutils mailing list