Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfc] conditional 128-bit long double
  2004-03-19  0:09 [rfc] conditional 128-bit long double Richard Henderson
@ 2004-03-07  8:07 ` Richard Henderson
  2004-03-07 20:19 ` Andrew Cagney
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2004-03-07  8:07 UTC (permalink / raw)
  To: gdb-patches

I'm somewhere in the middle of transitioning alpha-linux to a 128-bit
long double type.  I have two interests: one, not crashing when trying
to print such a value.  Two, doing approximately the right thing for
folks on either side of the transition.

Drow seemed to think that the following might be close, and that does
in fact seem to be true.  Note the small inconsistency wrt sizeof here:

	long double x = 1;
	main() { return 0; }

	[dorothy:~] gcc -g z.c -mlong-double-64 -o a.out
	[dorothy:~] gcc -g z.c -mlong-double-128 -o b.out
	[dorothy:~] gdb ./a.out
	(gdb) p x
	$1 = 1
	(gdb) ptype x
	type = long double
	(gdb) p sizeof(x)
	$2 = 8
	(gdb) p sizeof(long double)
	$3 = 16
	(gdb) q
	[dorothy:~] gdb ./b.out
	(gdb) p x
	$1 = 1
	(gdb) ptype x
	type = long double
	(gdb) p sizeof(x)
	$2 = 16
	(gdb) q

The only thing that would be better is if gdb could look up long double
in the debug info:

 From a.out:
 <1><a5a>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : long double    
     DW_AT_byte_size   : 8      
     DW_AT_encoding    : 4      (float)

 From b.out:
 <1><a5a>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : long double    
     DW_AT_byte_size   : 16     
     DW_AT_encoding    : 4      (float)

but I have no idea if one could even think doing such a thing in gdb.
I expect to *never* have to handle applications with mismatched types,
as I'm planning to bump the libc version number before this is over.

Thoughts?


r~


	* alpha-tdep.c (alpha_gdbarch_init): Set for 128-bit long double.

Index: alpha-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-tdep.c,v
retrieving revision 1.127
diff -c -p -d -r1.127 alpha-tdep.c
*** alpha-tdep.c	16 Feb 2004 21:49:21 -0000	1.127
--- alpha-tdep.c	7 Mar 2004 07:55:42 -0000
***************
*** 1,6 ****
  /* Target-dependent code for the ALPHA architecture, for GDB, the GNU Debugger.
!    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
!    Free Software Foundation, Inc.
  
     This file is part of GDB.
  
--- 1,6 ----
  /* Target-dependent code for the ALPHA architecture, for GDB, the GNU Debugger.
!    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
!    2004 Free Software Foundation, Inc.
  
     This file is part of GDB.
  
*************** alpha_gdbarch_init (struct gdbarch_info 
*** 1498,1507 ****
    set_gdbarch_int_bit (gdbarch, 32);
    set_gdbarch_long_bit (gdbarch, 64);
    set_gdbarch_long_long_bit (gdbarch, 64);
    set_gdbarch_float_bit (gdbarch, 32);
    set_gdbarch_double_bit (gdbarch, 64);
!   set_gdbarch_long_double_bit (gdbarch, 64);
!   set_gdbarch_ptr_bit (gdbarch, 64);
  
    /* Register info */
    set_gdbarch_num_regs (gdbarch, ALPHA_NUM_REGS);
--- 1498,1514 ----
    set_gdbarch_int_bit (gdbarch, 32);
    set_gdbarch_long_bit (gdbarch, 64);
    set_gdbarch_long_long_bit (gdbarch, 64);
+   set_gdbarch_ptr_bit (gdbarch, 64);
    set_gdbarch_float_bit (gdbarch, 32);
    set_gdbarch_double_bit (gdbarch, 64);
! 
!   /* Try to cope with -mlong-double-128.  When using dwarf2, we hope this
!      does the right thing by virtue of the fact that we only get a size
!      from the debug info and infer the type from that.  We'll have small
!      inconsistencies in random places, but that seems better than crashing
!      when the gcc option is enabled.  */
!   set_gdbarch_long_double_bit (gdbarch, 128);
!   set_gdbarch_long_double_format (gdbarch, &floatformat_ia64_quad_little);
  
    /* Register info */
    set_gdbarch_num_regs (gdbarch, ALPHA_NUM_REGS);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [rfc] conditional 128-bit long double
  2004-03-19  0:09 [rfc] conditional 128-bit long double Richard Henderson
  2004-03-07  8:07 ` Richard Henderson
@ 2004-03-07 20:19 ` Andrew Cagney
  2004-03-19  0:09   ` Andrew Cagney
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2004-03-07 20:19 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gdb-patches

> The only thing that would be better is if gdb could look up long double
> in the debug info:

GDB needs to come up in a sane state without debug info - stripped 
executable or even:

$ gdb
(gdb) print (long double) 1 * 2

so you can't rely on debug info.

> but I have no idea if one could even think doing such a thing in gdb.
> I expect to *never* have to handle applications with mismatched types,
> as I'm planning to bump the libc version number before this is over.

Won't you also want to brand the executable and object file?  Without 
that it will be too wasy to link the wrong object file into the wrong 
executable.

GDB handles ABI variants with OSABI sniffers that key off the brand.

Andrew



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [rfc] conditional 128-bit long double
@ 2004-03-19  0:09 Richard Henderson
  2004-03-07  8:07 ` Richard Henderson
  2004-03-07 20:19 ` Andrew Cagney
  0 siblings, 2 replies; 4+ messages in thread
From: Richard Henderson @ 2004-03-19  0:09 UTC (permalink / raw)
  To: gdb-patches

I'm somewhere in the middle of transitioning alpha-linux to a 128-bit
long double type.  I have two interests: one, not crashing when trying
to print such a value.  Two, doing approximately the right thing for
folks on either side of the transition.

Drow seemed to think that the following might be close, and that does
in fact seem to be true.  Note the small inconsistency wrt sizeof here:

	long double x = 1;
	main() { return 0; }

	[dorothy:~] gcc -g z.c -mlong-double-64 -o a.out
	[dorothy:~] gcc -g z.c -mlong-double-128 -o b.out
	[dorothy:~] gdb ./a.out
	(gdb) p x
	$1 = 1
	(gdb) ptype x
	type = long double
	(gdb) p sizeof(x)
	$2 = 8
	(gdb) p sizeof(long double)
	$3 = 16
	(gdb) q
	[dorothy:~] gdb ./b.out
	(gdb) p x
	$1 = 1
	(gdb) ptype x
	type = long double
	(gdb) p sizeof(x)
	$2 = 16
	(gdb) q

The only thing that would be better is if gdb could look up long double
in the debug info:

 From a.out:
 <1><a5a>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : long double    
     DW_AT_byte_size   : 8      
     DW_AT_encoding    : 4      (float)

 From b.out:
 <1><a5a>: Abbrev Number: 3 (DW_TAG_base_type)
     DW_AT_name        : long double    
     DW_AT_byte_size   : 16     
     DW_AT_encoding    : 4      (float)

but I have no idea if one could even think doing such a thing in gdb.
I expect to *never* have to handle applications with mismatched types,
as I'm planning to bump the libc version number before this is over.

Thoughts?


r~


	* alpha-tdep.c (alpha_gdbarch_init): Set for 128-bit long double.

Index: alpha-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/alpha-tdep.c,v
retrieving revision 1.127
diff -c -p -d -r1.127 alpha-tdep.c
*** alpha-tdep.c	16 Feb 2004 21:49:21 -0000	1.127
--- alpha-tdep.c	7 Mar 2004 07:55:42 -0000
***************
*** 1,6 ****
  /* Target-dependent code for the ALPHA architecture, for GDB, the GNU Debugger.
!    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
!    Free Software Foundation, Inc.
  
     This file is part of GDB.
  
--- 1,6 ----
  /* Target-dependent code for the ALPHA architecture, for GDB, the GNU Debugger.
!    Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
!    2004 Free Software Foundation, Inc.
  
     This file is part of GDB.
  
*************** alpha_gdbarch_init (struct gdbarch_info 
*** 1498,1507 ****
    set_gdbarch_int_bit (gdbarch, 32);
    set_gdbarch_long_bit (gdbarch, 64);
    set_gdbarch_long_long_bit (gdbarch, 64);
    set_gdbarch_float_bit (gdbarch, 32);
    set_gdbarch_double_bit (gdbarch, 64);
!   set_gdbarch_long_double_bit (gdbarch, 64);
!   set_gdbarch_ptr_bit (gdbarch, 64);
  
    /* Register info */
    set_gdbarch_num_regs (gdbarch, ALPHA_NUM_REGS);
--- 1498,1514 ----
    set_gdbarch_int_bit (gdbarch, 32);
    set_gdbarch_long_bit (gdbarch, 64);
    set_gdbarch_long_long_bit (gdbarch, 64);
+   set_gdbarch_ptr_bit (gdbarch, 64);
    set_gdbarch_float_bit (gdbarch, 32);
    set_gdbarch_double_bit (gdbarch, 64);
! 
!   /* Try to cope with -mlong-double-128.  When using dwarf2, we hope this
!      does the right thing by virtue of the fact that we only get a size
!      from the debug info and infer the type from that.  We'll have small
!      inconsistencies in random places, but that seems better than crashing
!      when the gcc option is enabled.  */
!   set_gdbarch_long_double_bit (gdbarch, 128);
!   set_gdbarch_long_double_format (gdbarch, &floatformat_ia64_quad_little);
  
    /* Register info */
    set_gdbarch_num_regs (gdbarch, ALPHA_NUM_REGS);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [rfc] conditional 128-bit long double
  2004-03-07 20:19 ` Andrew Cagney
@ 2004-03-19  0:09   ` Andrew Cagney
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Cagney @ 2004-03-19  0:09 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gdb-patches

> The only thing that would be better is if gdb could look up long double
> in the debug info:

GDB needs to come up in a sane state without debug info - stripped 
executable or even:

$ gdb
(gdb) print (long double) 1 * 2

so you can't rely on debug info.

> but I have no idea if one could even think doing such a thing in gdb.
> I expect to *never* have to handle applications with mismatched types,
> as I'm planning to bump the libc version number before this is over.

Won't you also want to brand the executable and object file?  Without 
that it will be too wasy to link the wrong object file into the wrong 
executable.

GDB handles ABI variants with OSABI sniffers that key off the brand.

Andrew



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-03-07 20:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-19  0:09 [rfc] conditional 128-bit long double Richard Henderson
2004-03-07  8:07 ` Richard Henderson
2004-03-07 20:19 ` Andrew Cagney
2004-03-19  0:09   ` Andrew Cagney

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