This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

The DWARF2 debugging section size is different in different machine


Hello,

The DWARF2 debugging information of an executable is
different when i build a testcase with toolchain on
i386 and x86_64 machine. 

main()
{
..

  {
     const unsigned long int bad = 0xbaddeed00baddeed;
   

   ...
  }
..
}

When compiled with -O2 on i386 the compiler generates
this code

        .ascii "bad\0"   # DW_AT_name
        .byte   0x1      # DW_AT_decl_file
        .2byte  0x3f8    # DW_AT_decl_line
        .8byte  0x1bd0   # DW_AT_type
        .byte   0x8      # DW_AT_const_value
        .4byte  0x0      # long long constant
        .4byte  0xbaddeed
        .byte   0x0      # end of children of DIE
0x1b62
        .byte   0x0      # end of children of DIE
0x1b45


where when compiled on x86_64 the compiler generates
this code

        .ascii "bad\0"   # DW_AT_name
        .byte   0x1      # DW_AT_decl_file
        .2byte  0x3f8    # DW_AT_decl_line
        .8byte  0x1977   # DW_AT_type
        .byte   0x10     # DW_AT_const_value
        .8byte  0x0      # long long constant
        .8byte  0xbaddeed00baddeed
        .byte   0x0      # end of children of DIE
0x1b62
        .byte   0x0      # end of children of DIE
0x1b45

The above result is generated by configuring the
toolchain with mips64-linux target triplet.

And compiled the testcase with -mips64 -mabi=64 -O2

Here is the patch which generates to solve this
problem.

Please let me know it is okay to apply.

Thanks
Chandra


2005-01-11  Chandrakala Chavva <cchavva@yahoo.com>
                                                      
                                              
        * dwarf2out.c (dw_long_long_struct): Change
struct elements to "unsigned
        long long".
        (add_AT_long_long): Likewise.
        (print_die): Change "%lu" to "%llu".
        (size_of_die): Use HOST_BITS_PER_LONGLONG to
calculation the size of
        dw_val_class_long_long.
        (output_die): Likewise.

Index: dwarf2out.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.566
diff -p -r1.566 dwarf2out.c
*** dwarf2out.c 6 Jan 2005 14:49:31 -0000       1.566
--- dwarf2out.c 12 Jan 2005 01:39:17 -0000
*************** enum dw_val_class
*** 2520,2527 ****
                                                      
                                              
  typedef struct dw_long_long_struct GTY(())
  {
!   unsigned long hi;
!   unsigned long low;
  }
  dw_long_long_const;
                                                      
                                              
--- 2520,2527 ----
                                                      
                                              
  typedef struct dw_long_long_struct GTY(())
  {
!   unsigned long long hi;
!   unsigned long long low;
  }
  dw_long_long_const;
                                                      
                                              
*************** static void add_AT_int (dw_die_ref,
enum
*** 3792,3799 ****
  static inline HOST_WIDE_INT AT_int (dw_attr_ref);
  static void add_AT_unsigned (dw_die_ref, enum
dwarf_attribute, unsigned HOST_WIDE_INT);
  static inline unsigned HOST_WIDE_INT AT_unsigned
(dw_attr_ref);
! static void add_AT_long_long (dw_die_ref, enum
dwarf_attribute, unsigned long,
!                             unsigned long);
  static inline void add_AT_vec (dw_die_ref, enum
dwarf_attribute, unsigned int,
                               unsigned int, unsigned
char *);
  static hashval_t debug_str_do_hash (const void *);
--- 3792,3799 ----
  static inline HOST_WIDE_INT AT_int (dw_attr_ref);
  static void add_AT_unsigned (dw_die_ref, enum
dwarf_attribute, unsigned HOST_WIDE_INT);
  static inline unsigned HOST_WIDE_INT AT_unsigned
(dw_attr_ref);
! static void add_AT_long_long (dw_die_ref, enum
dwarf_attribute, unsigned long long,
!                             unsigned long long);
  static inline void add_AT_vec (dw_die_ref, enum
dwarf_attribute, unsigned int,
                               unsigned int, unsigned
char *);
  static hashval_t debug_str_do_hash (const void *);
*************** AT_unsigned (dw_attr_ref a)
*** 4754,4760 ****
   
  static inline void
  add_AT_long_long (dw_die_ref die, enum
dwarf_attribute attr_kind,
!                 long unsigned int val_hi, long
unsigned int val_low)
  {
    dw_attr_ref attr = ggc_alloc (sizeof
(dw_attr_node));
   
--- 4754,4760 ----
   
  static inline void
  add_AT_long_long (dw_die_ref die, enum
dwarf_attribute attr_kind,
!                 long long unsigned int val_hi, long
long unsigned int val_low)
  {
    dw_attr_ref attr = ggc_alloc (sizeof
(dw_attr_node));
   
*************** print_die (dw_die_ref die, FILE
*outfile
*** 5551,5557 ****
          fprintf (outfile,
HOST_WIDE_INT_PRINT_UNSIGNED, AT_unsigned (a));
          break;
        case dw_val_class_long_long:
!         fprintf (outfile, "constant (%lu,%lu)",
                   a->dw_attr_val.v.val_long_long.hi,
                  
a->dw_attr_val.v.val_long_long.low);
          break;
--- 5551,5557 ----
          fprintf (outfile,
HOST_WIDE_INT_PRINT_UNSIGNED, AT_unsigned (a));
          break;
        case dw_val_class_long_long:
!         fprintf (outfile, "constant (%llu,%llu)",
                   a->dw_attr_val.v.val_long_long.hi,
                  
a->dw_attr_val.v.val_long_long.low);
          break;
*************** size_of_die (dw_die_ref die)
*** 6441,6447 ****
          size += constant_size (AT_unsigned (a));
          break;
        case dw_val_class_long_long:
!         size += 1 +
2*HOST_BITS_PER_LONG/HOST_BITS_PER_CHAR; /* block */
          break;
        case dw_val_class_vec:
          size += 1 + (a->dw_attr_val.v.val_vec.length
--- 6441,6447 ----
          size += constant_size (AT_unsigned (a));
          break;
        case dw_val_class_long_long:
!         size += 1 +
2*HOST_BITS_PER_LONGLONG/HOST_BITS_PER_CHAR; /* block
*/
          break;
        case dw_val_class_vec:
          size += 1 + (a->dw_attr_val.v.val_vec.length
*************** output_die (dw_die_ref die)
*** 6888,6894 ****
            unsigned HOST_WIDE_INT first, second;
   
            dw2_asm_output_data (1,
!                                2 *
HOST_BITS_PER_LONG / HOST_BITS_PER_CHAR,
                                 "%s", name);
   
            if (WORDS_BIG_ENDIAN)
--- 6888,6894 ----
            unsigned HOST_WIDE_INT first, second;
   
            dw2_asm_output_data (1,
!                                2 *
HOST_BITS_PER_LONGLONG / HOST_BITS_PER_CHAR,
                                 "%s", name);
   
            if (WORDS_BIG_ENDIAN)
*************** output_die (dw_die_ref die)
*** 6902,6910 ****
                second =
a->dw_attr_val.v.val_long_long.hi;
              }
   
!           dw2_asm_output_data (HOST_BITS_PER_LONG /
HOST_BITS_PER_CHAR,
                                 first, "long long
constant");
!           dw2_asm_output_data (HOST_BITS_PER_LONG /
HOST_BITS_PER_CHAR,
                                 second, NULL);
          }
          break;
--- 6902,6910 ----
                second =
a->dw_attr_val.v.val_long_long.hi;
              }
   
!           dw2_asm_output_data
(HOST_BITS_PER_LONGLONG / HOST_BITS_PER_CHAR,
                                 first, "long long
constant");
!           dw2_asm_output_data
(HOST_BITS_PER_LONGLONG / HOST_BITS_PER_CHAR,
                                 second, NULL);
          }
          break;


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail


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