This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB 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]

[patch] Fix prob from print/f *(short*)&oct


Hello,

When removing IEEE_FLOAT I didn't realise that print_floating() needed 
to handle types other than TYPE_CODE_FLT.  The attached patch restores 
the old behavour - when the type isn't a FLT, let it be converted to 
doublest.  It also adds a few more comments.

I've checked it in.

Thanks to Peter Schauer for pointing this out.

sigh,
Andrew
2002-02-03  Andrew Cagney  <ac131313@redhat.com>

	* valprint.c (print_floating): Allow non TYPE_CODE_FLT types.
	Restore behavour broken by 2002-01-20 Andrew Cagney
	<ac131313@redhat.com> IEEE_FLOAT removal.

Index: valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/valprint.c,v
retrieving revision 1.21
diff -p -r1.21 valprint.c
*** valprint.c	2002/01/20 18:05:51	1.21
--- valprint.c	2002/02/04 02:15:15
*************** longest_to_int (LONGEST arg)
*** 540,557 ****
    return (rtnval);
  }
  
! /* Print a floating point value of type TYPE, pointed to in GDB by
!    VALADDR, on STREAM.  */
  
  void
  print_floating (char *valaddr, struct type *type, struct ui_file *stream)
  {
    DOUBLEST doub;
    int inv;
!   const struct floatformat *fmt = floatformat_from_type (type);
    unsigned len = TYPE_LENGTH (type);
  
!   if (floatformat_is_nan (fmt, valaddr))
      {
        if (floatformat_is_negative (fmt, valaddr))
  	fprintf_filtered (stream, "-");
--- 540,560 ----
    return (rtnval);
  }
  
! /* Print a floating point value of type TYPE (not always a
!    TYPE_CODE_FLT), pointed to in GDB by VALADDR, on STREAM.  */
  
  void
  print_floating (char *valaddr, struct type *type, struct ui_file *stream)
  {
    DOUBLEST doub;
    int inv;
!   const struct floatformat *fmt = NULL;
    unsigned len = TYPE_LENGTH (type);
  
!   /* If it is a floating-point, check for obvious problems.  */
!   if (TYPE_CODE (type) == TYPE_CODE_FLT)
!     fmt = floatformat_from_type (type);
!   if (fmt != NULL && floatformat_is_nan (fmt, valaddr))
      {
        if (floatformat_is_negative (fmt, valaddr))
  	fprintf_filtered (stream, "-");
*************** print_floating (char *valaddr, struct ty
*** 563,574 ****
        return;
      }
  
!   /* FIXME: cagney/2002-01-15: The simpler extract_typed_floating()
!      routine could be used here only that routine has no way of
!      indicating that the floating point it extracted was invalid (As
!      indicated by INVALID_FLOAT).  Instead, this code here could call
!      something like floating_invalid() to check for an invalid
!      floating point.  */
  
    doub = unpack_double (type, valaddr, &inv);
    if (inv)
--- 566,579 ----
        return;
      }
  
!   /* NOTE: cagney/2002-01-15: The TYPE passed into print_floating()
!      isn't necessarily a TYPE_CODE_FLT.  Consequently, unpack_double
!      needs to be used as that takes care of any necessary type
!      conversions.  Such conversions are of course direct to DOUBLEST
!      and disregard any possible target floating point limitations.
!      For instance, a u64 would be converted and displayed exactly on a
!      host with 80 bit DOUBLEST but with loss of information on a host
!      with 64 bit DOUBLEST.  */
  
    doub = unpack_double (type, valaddr, &inv);
    if (inv)
*************** print_floating (char *valaddr, struct ty
*** 580,588 ****
    /* FIXME: kettenis/2001-01-20: The following code makes too much
       assumptions about the host and target floating point format.  */
  
!   /* FIXME: cagney/2002-01-15: The floatformat pointed to by FMT
!      should contain all the information needed to print the
!      floating-point value without host dependencies.  */
  
    if (len < sizeof (double))
        fprintf_filtered (stream, "%.9g", (double) doub);
--- 585,594 ----
    /* FIXME: kettenis/2001-01-20: The following code makes too much
       assumptions about the host and target floating point format.  */
  
!   /* NOTE: cagney/2002-02-03: Since the TYPE of what was passed in may
!      not necessarially be a TYPE_CODE_FLT, the below ignores that and
!      instead uses the type's length to determine the precision of the
!      floating-point value being printed.  */
  
    if (len < sizeof (double))
        fprintf_filtered (stream, "%.9g", (double) doub);

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