Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
  • [parent not found: <npk8frhmkp.fsf@zwingli.cygnus.com>]
  • * Re: gdb patch for 64-bit enum values on 64-bit hosts (ia64-linux)
           [not found] <200006090053.RAA14301@ada.cygnus.com.cygnus.com>
           [not found] ` <14664.971.753679.67153@kwikemart.cygnus.com>
           [not found] ` <npk8frhmkp.fsf@zwingli.cygnus.com>
    @ 2001-09-05  0:16 ` Michael Snyder
      2 siblings, 0 replies; 7+ messages in thread
    From: Michael Snyder @ 2001-09-05  0:16 UTC (permalink / raw)
      To: gdb-patches; +Cc: jimb, ezannoni
    
    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)
    >         {
    
    
    ^ permalink raw reply	[flat|nested] 7+ messages in thread
  • [parent not found: <200006200213.TAA22932@wilson.cygnus.com>]
    [parent not found: <200006200106.SAA22809@wilson.cygnus.com>]

    end of thread, other threads:[~2001-09-05  0:16 UTC | newest]
    
    Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
    -- links below jump to the message on this page --
         [not found] <200006090053.RAA14301@ada.cygnus.com.cygnus.com>
         [not found] ` <14664.971.753679.67153@kwikemart.cygnus.com>
    2000-06-14 17:52   ` gdb patch for 64-bit enum values on 64-bit hosts (ia64-linux) 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
         [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
    

    This is a public inbox, see mirroring instructions
    for how to clone and mirror all data and code used for this inbox