Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@cygnus.com>
To: gdb-patches@sources.redhat.com
Cc: jimb@sourceware.cygnus.com, ezannoni@sourceware.cygnus.com
Subject: Re: gdb patch for 64-bit enum values on 64-bit hosts (ia64-linux)
Date: Wed, 05 Sep 2001 00:16:00 -0000	[thread overview]
Message-ID: <3947FEC7.2BAC@cygnus.com> (raw)
In-Reply-To: <200006090053.RAA14301@ada.cygnus.com.cygnus.com>

Hi Jim, 

Jim Blandy, our Dwarf maintainer, is occupied right now.
I think your change looks good -- I only worry that we have
no guarantee that even a long will be 64-bits.  I suppose a
long is more likely to be correct than an int...

Elena, this is your call.

				Michael

Jim Wilson wrote:
> 
> This fixes two bugs in the handling of 64-bit values on 64-bit LP64 hosts.
> We need to use long instead of int in several places, so that we don't
> accidentally truncate values to 32-bits when longs are 64-bits.
> 
> The specific problems fixed are unsigned 64-bit enum values, and signed 64-bit
> enum values.
> 
> This testcase is extracted from emacs.
> 
> enum gdb_lisp_params
> {
>   gdb_data_seg_bits = 0x8000000000000000UL,
> };
> 
> main()
> {
>   printf ("0x%lx\n", gdb_data_seg_bits);
> }
> 
> Without this patch, "print (long) gdb_data_seg_bits" gives 0.
> 
> #include <limits.h>
> 
> enum foo
> {
>   bar = LONG_MIN
> };
> 
> main()
> {
>   printf ("0x%lx\n", bar);
> }
> 
> Without this patch, "print (long) bar" gives 0.
> 
> In order for these testcases to work, you also need the gcc patches I checked
> in today, as gcc also got it wrong until today.
> 
> This was tested on ia64-linux with make check in the gdb directory.
> 
> 2000-06-08  James E. Wilson  <wilson@bletchleypark.cygnus.com>
> 
>         * dwarf2read.c (struct attribute): Change unsnd and snd field types
>         to long.
>         (read_8_bytes): Change return type to long.
>         (read_unsigned_leb128): Change return type to long.  Change type of
>         local result to long.  Cast argument of left shift to long.
>         (read_signed_leb128): Likewise.
> 
> *** orig-devo/gdb/dwarf2read.c  Fri Jun  2 14:22:37 2000
> --- devo/gdb/dwarf2read.c       Thu Jun  8 15:37:41 2000
> *************** struct attribute
> *** 227,234 ****
>         {
>         char *str;
>         struct dwarf_block *blk;
> !       unsigned int unsnd;
> !       int snd;
>         CORE_ADDR addr;
>         }
>       u;
> --- 227,234 ----
>         {
>         char *str;
>         struct dwarf_block *blk;
> !       unsigned long unsnd;
> !       long int snd;
>         CORE_ADDR addr;
>         }
>       u;
> *************** static unsigned int read_2_bytes (bfd *,
> *** 591,597 ****
> 
>   static unsigned int read_4_bytes (bfd *, char *);
> 
> ! static unsigned int read_8_bytes (bfd *, char *);
> 
>   static CORE_ADDR read_address (bfd *, char *);
> 
> --- 591,597 ----
> 
>   static unsigned int read_4_bytes (bfd *, char *);
> 
> ! static unsigned long read_8_bytes (bfd *, char *);
> 
>   static CORE_ADDR read_address (bfd *, char *);
> 
> *************** static char *read_n_bytes (bfd *, char *
> *** 599,607 ****
> 
>   static char *read_string (bfd *, char *, unsigned int *);
> 
> ! static unsigned int read_unsigned_leb128 (bfd *, char *, unsigned int *);
> 
> ! static int read_signed_leb128 (bfd *, char *, unsigned int *);
> 
>   static void set_cu_language (unsigned int);
> 
> --- 599,607 ----
> 
>   static char *read_string (bfd *, char *, unsigned int *);
> 
> ! static unsigned long read_unsigned_leb128 (bfd *, char *, unsigned int *);
> 
> ! static long read_signed_leb128 (bfd *, char *, unsigned int *);
> 
>   static void set_cu_language (unsigned int);
> 
> *************** read_4_signed_bytes (abfd, buf)
> *** 3446,3452 ****
>     return bfd_get_signed_32 (abfd, (bfd_byte *) buf);
>   }
> 
> ! static unsigned int
>   read_8_bytes (abfd, buf)
>        bfd *abfd;
>        char *buf;
> --- 3446,3452 ----
>     return bfd_get_signed_32 (abfd, (bfd_byte *) buf);
>   }
> 
> ! static unsigned long
>   read_8_bytes (abfd, buf)
>        bfd *abfd;
>        char *buf;
> *************** read_string (abfd, buf, bytes_read_ptr)
> *** 3543,3555 ****
>   #endif
>   }
> 
> ! static unsigned int
>   read_unsigned_leb128 (abfd, buf, bytes_read_ptr)
>        bfd *abfd;
>        char *buf;
>        unsigned int *bytes_read_ptr;
>   {
> !   unsigned int result, num_read;
>     int i, shift;
>     unsigned char byte;
> 
> --- 3543,3556 ----
>   #endif
>   }
> 
> ! static unsigned long
>   read_unsigned_leb128 (abfd, buf, bytes_read_ptr)
>        bfd *abfd;
>        char *buf;
>        unsigned int *bytes_read_ptr;
>   {
> !   unsigned long result;
> !   unsigned int num_read;
>     int i, shift;
>     unsigned char byte;
> 
> *************** read_unsigned_leb128 (abfd, buf, bytes_r
> *** 3562,3568 ****
>         byte = bfd_get_8 (abfd, (bfd_byte *) buf);
>         buf++;
>         num_read++;
> !       result |= ((byte & 127) << shift);
>         if ((byte & 128) == 0)
>         {
>           break;
> --- 3563,3569 ----
>         byte = bfd_get_8 (abfd, (bfd_byte *) buf);
>         buf++;
>         num_read++;
> !       result |= ((unsigned long)(byte & 127) << shift);
>         if ((byte & 128) == 0)
>         {
>           break;
> *************** read_unsigned_leb128 (abfd, buf, bytes_r
> *** 3573,3585 ****
>     return result;
>   }
> 
> ! static int
>   read_signed_leb128 (abfd, buf, bytes_read_ptr)
>        bfd *abfd;
>        char *buf;
>        unsigned int *bytes_read_ptr;
>   {
> !   int result;
>     int i, shift, size, num_read;
>     unsigned char byte;
> 
> --- 3574,3586 ----
>     return result;
>   }
> 
> ! static long
>   read_signed_leb128 (abfd, buf, bytes_read_ptr)
>        bfd *abfd;
>        char *buf;
>        unsigned int *bytes_read_ptr;
>   {
> !   long result;
>     int i, shift, size, num_read;
>     unsigned char byte;
> 
> *************** read_signed_leb128 (abfd, buf, bytes_rea
> *** 3593,3599 ****
>         byte = bfd_get_8 (abfd, (bfd_byte *) buf);
>         buf++;
>         num_read++;
> !       result |= ((byte & 127) << shift);
>         shift += 7;
>         if ((byte & 128) == 0)
>         {
> --- 3594,3600 ----
>         byte = bfd_get_8 (abfd, (bfd_byte *) buf);
>         buf++;
>         num_read++;
> !       result |= ((long)(byte & 127) << shift);
>         shift += 7;
>         if ((byte & 128) == 0)
>         {


  parent reply	other threads:[~2001-09-05  0:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200006090053.RAA14301@ada.cygnus.com.cygnus.com>
     [not found] ` <14664.971.753679.67153@kwikemart.cygnus.com>
2000-06-14 17:52   ` Michael Snyder
2000-06-15 20:05     ` Elena Zannoni
2000-06-19 16:41     ` James Wilson
     [not found] ` <npk8frhmkp.fsf@zwingli.cygnus.com>
2001-09-05  0:16   ` Michael Snyder
2001-09-05  0:16 ` Michael Snyder [this message]
     [not found] <200006200213.TAA22932@wilson.cygnus.com>
     [not found] ` <395013E2.D78A2EE2@cygnus.com>
2000-06-20 20:39   ` Michael Snyder
     [not found] <200006200106.SAA22809@wilson.cygnus.com>
2000-06-19 19:03 ` Andrew Cagney

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=3947FEC7.2BAC@cygnus.com \
    --to=msnyder@cygnus.com \
    --cc=ezannoni@sourceware.cygnus.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=jimb@sourceware.cygnus.com \
    /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