public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Kai Tietz <ktietz70@googlemail.com>
To: Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>
Cc: "H.J. Lu" <hjl.tools@gmail.com>, Binutils <binutils@sourceware.org>
Subject: Re: [RFC] Use only dwarf_vma types in dwarf code (was RE: [RFC patch]: Adjust the use of 'long' type in dwarf2.h header)
Date: Fri, 25 Feb 2011 12:23:00 -0000	[thread overview]
Message-ID: <AANLkTik9=KVF+gX9yR-=EtnHDnnOmWG2wGaKqbDXn9Os@mail.gmail.com> (raw)
In-Reply-To: <5095785081977025060@unknownmsgid>

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

  parent reply	other threads:[~2011-02-25 12:23 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-17 14:21 [RFC patch]: Adjust the use of 'long' type in dwarf2.h header Kai Tietz
2011-02-17 18:59 ` Kai Tietz
2011-02-17 19:03   ` Jakub Jelinek
2011-02-17 19:07     ` Kai Tietz
2011-02-17 19:17       ` Jakub Jelinek
2011-02-18  9:50         ` Kai Tietz
2011-02-21 12:37           ` NightStrike
2011-02-21 13:10 ` Pierre Muller
     [not found] ` <-8460070221060995487@unknownmsgid>
2011-02-21 13:27   ` Kai Tietz
2011-02-21 13:46     ` Pierre Muller
     [not found]     ` <-6930711422310680743@unknownmsgid>
2011-02-21 14:30       ` Kai Tietz
2011-02-21 15:25         ` Kai Tietz
2011-02-21 15:43           ` Mark Kettenis
2011-02-21 15:53             ` Kai Tietz
2011-02-22 15:21           ` Nick Clifton
2011-02-23  8:59             ` Kai Tietz
2011-02-23 15:12               ` Pierre Muller
     [not found]               ` <-2339605939192327273@unknownmsgid>
2011-02-23 17:42                 ` Kai Tietz
2011-02-23 21:55                   ` Pierre Muller
     [not found]                   ` <-3886800211494155692@unknownmsgid>
2011-02-23 22:51                     ` H.J. Lu
2011-02-24 11:33                       ` Pierre Muller
     [not found]                       ` <1561346207520594884@unknownmsgid>
2011-02-24 13:50                         ` H.J. Lu
2011-02-25 10:40                           ` [RFC] Use only dwarf_vma types in dwarf code (was RE: [RFC patch]: Adjust the use of 'long' type in dwarf2.h header) Pierre Muller
     [not found]                           ` <5095785081977025060@unknownmsgid>
2011-02-25 12:23                             ` Kai Tietz [this message]
2011-02-25 13:31                               ` Pierre Muller
2011-02-25 13:35                               ` [RFC-v2] Use only dwarf_vma types in dwarf code Pierre Muller
2011-03-25 15:16                                 ` Nick Clifton
2011-03-25 15:48                                   ` [RFA] Supplemtal patch for use " Pierre Muller
2011-03-25 18:04                                     ` Nick Clifton
2011-03-25 21:44                                       ` Pierre Muller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTik9=KVF+gX9yR-=EtnHDnnOmWG2wGaKqbDXn9Os@mail.gmail.com' \
    --to=ktietz70@googlemail.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    --cc=pierre.muller@ics-cnrs.unistra.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).