This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: [RFC] Use only dwarf_vma types in dwarf code (was RE: [RFC patch]: Adjust the use of 'long' type in dwarf2.h header)


2011/2/25 Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>:
> ?This patch RFC is follow up of the
> thread concerning problems with the act that
> readelf defines BFD64 under other conditions
> than dwarf.c leading to potential problems.
>
> ?The idea is to completely remove bfd_vma and dwarf_signed_vma
> from dwarf.h and dwarf.c sources.
>
> ?The patch is pretty mechanical, but there are several
> points that probably needs discussion:
>
> ?1) This basically makes use of 8-byte for dwarf_vma and dwarf_signed_vma
> for almost all modern machines/compilers.
> ?It could still impact performance for system where int64
> computation is slow, I have no idea if this can really be a problem or not.
>
> 2) I also tried to remove (long) and (unsigned long) types
> whenever they seemed to me to be used for something that could
> be a target address or offset and replaced it by a dwarf_{signed_}vma type.
> (This is also related to the Mingw64 target issue for
> which 'long' is 4-byte whereas 'void *' is 8-byte).
> But I might not have caught all occurrences and might have
> misunderstood some other cases.
> ?An example is the address field of the Machine_State_Registers,
> I don't know if this relates really to a target address...
>
> ?Another important point is that I have no machine
> that can run the testsuite on my patch, so that it might very well
> introduce regression that I am unaware of.
>
> ?Anyhow, I will be pleased to get comments
> on this patch.
>
>
> Pierre Muller
> GDB pascal language maintainer

> Index: binutils/dwarf.c
> ===================================================================
> RCS file: /cvs/src/src/binutils/dwarf.c,v
> retrieving revision 1.84
> diff -u -p -r1.84 dwarf.c
> --- binutils/dwarf.c ? ?23 Feb 2011 08:52:33 -0000 ? ? ?1.84
> +++ binutils/dwarf.c ? ?25 Feb 2011 10:12:30 -0000
> @@ -106,6 +106,7 @@ static void
> ?print_dwarf_vma (dwarf_vma val, unsigned byte_size)
> ?{
> ? static char buff[18];
> + ?int offset;
>
> ? /* Printf does not have a way of specifiying a maximum field width for an
> ? ? ?integer value, so we print the full value into a buffer and then
> select
> @@ -120,11 +121,29 @@ print_dwarf_vma (dwarf_vma val, unsigned
> ? snprintf (buff, sizeof (buff), "%16.16lx ", val);
> ?#endif
>
> - ?fputs (buff + (byte_size == 4 ? 8 : 0), stdout);
> + ?if (byte_size == 0)
> + ? ?offset = 0;
> + ?else
> + ? ?if (byte_size > 0 && byte_size <=8)

Whitespace issue. should be ... && byte_size <= 8)

> + ? ? ?offset = 16 - 2 * byte_size;
> + ? ?else
> + ? ? ?error("Wrong size in print_dwarf_vma");
> +
> + ?fputs (buff + offset, stdout);
> ?}
>
> +#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
> +#ifndef __MSVCRT__
Please don't use here __MSVCRT__, instead use
#if !defined (__MSVCRT__) && !defined (__MINGW32__)

As __MSVCRT__ is just declared by VC, and __MINGW32__ for gcc. IMHO
__MINGW32__ should be the only guard necessary here, as VC neither
defines __STDC_VERSION__ > 199901L and it doesn't defines __GNUC__,
too.

> +#define ?DWARF_VMA_FMT "ll"
> +#else
> +#define ?DWARF_VMA_FMT "I64"
> +#endif
> +#else
> +#define ?DWARF_VMA_FMT "l"
> +#endif
> +

> -bfd_vma
> +static char *
> +dwarf_svmatoa (const char *fmtch, dwarf_signed_vma value)

Why you are using here dwarf_svmatoa? It should be dwarf_vmatoa
As the formatter is specified here as argument and in dwarf_vmatoa the
formatter-buffer is constructed, I see no point in adding a signed
variant.

This is just a first glance, and well, I can't approve this patch. But
in general I appreachiate your modification.

Regards,
Kai


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