Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Michael Snyder <msnyder@redhat.com>
To: Mark Kettenis <kettenis@wins.uva.nl>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PATCH] Fix i386 FPU register conversion code
Date: Sat, 28 Jul 2001 12:49:00 -0000	[thread overview]
Message-ID: <3B6316FC.7D86@redhat.com> (raw)
In-Reply-To: <200107281649.f6SGn6w19068@delius.kettenis.local>

Mark Kettenis wrote:
> 
> Fixing the debug register number mapping scheme uncovered a bug in
> i386-tdep.c:i386_register_convert_to_virtual().  Fixed with the
> attached patch.
> 
> Mark

Isn't "gdb_assert" rather strong for this use?
Seems like simply returning without doing anything
would be sufficient in case we were called with an
integer register or what-not.  Calling gdb_assert
will result in the user being asked if he would like
GDB to abort and dump core (I think...)


> 
> Index: ChangeLog
> from  Mark Kettenis  <kettenis@gnu.org>
> 
>         * i386-tdep.c: Include "gdb_assert.h"
>         (i386_register_convert_to_virtual): Fix such that it can handle
>         conversion to any floating-point type.  Assert that we are dealing
>         with a floating-point first.
>         (i386_register_convert_to_raw): Assert that TYPE is a
>         floating-point type with length 12.
> 
> Index: i386-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/i386-tdep.c,v
> retrieving revision 1.34
> diff -u -p -r1.34 i386-tdep.c
> --- i386-tdep.c 2001/07/15 20:10:02 1.34
> +++ i386-tdep.c 2001/07/28 16:45:41
> @@ -33,6 +33,8 @@
>  #include "arch-utils.h"
>  #include "regcache.h"
> 
> +#include "gdb_assert.h"
> +
>  /* i386_register_byte[i] is the offset into the register file of the
>     start of register number i.  We initialize this from
>     i386_register_raw_size.  */
> @@ -972,27 +974,39 @@ i386_register_convertible (int regnum)
>  }
> 
>  /* Convert data from raw format for register REGNUM in buffer FROM to
> -   virtual format with type TYPE in buffer TO.  In principle both
> -   formats are identical except that the virtual format has two extra
> -   bytes appended that aren't used.  We set these to zero.  */
> +   virtual format with type TYPE in buffer TO.  */
> 
>  void
>  i386_register_convert_to_virtual (int regnum, struct type *type,
>                                   char *from, char *to)
>  {
> -  /* Copy straight over, but take care of the padding.  */
> -  memcpy (to, from, FPU_REG_RAW_SIZE);
> -  memset (to + FPU_REG_RAW_SIZE, 0, TYPE_LENGTH (type) - FPU_REG_RAW_SIZE);
> +  char buf[12];
> +  DOUBLEST d;
> +
> +  /* We only support floating-point values.  */
> +  gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT);
> +
> +  /* First add the necessary padding.  */
> +  memcpy (buf, from, FPU_REG_RAW_SIZE);
> +  memset (buf + FPU_REG_RAW_SIZE, 0, sizeof buf - FPU_REG_RAW_SIZE);
> +
> +  /* Convert to TYPE.  This should be a no-op, if TYPE is equivalent
> +     to the extended floating-point format used by the FPU.  */
> +  d = extract_floating (buf, sizeof buf);
> +  store_floating (to, TYPE_LENGTH (type), d);
>  }
> 
>  /* Convert data from virtual format with type TYPE in buffer FROM to
> -   raw format for register REGNUM in buffer TO.  Simply omit the two
> -   unused bytes.  */
> +   raw format for register REGNUM in buffer TO.  */
> 
>  void
>  i386_register_convert_to_raw (struct type *type, int regnum,
>                               char *from, char *to)
>  {
> +  gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLT
> +             && TYPE_LENGTH (type) == 12);
> +
> +  /* Simply omit the two unused bytes.  */
>    memcpy (to, from, FPU_REG_RAW_SIZE);
>  }
>


  reply	other threads:[~2001-07-28 12:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-28  9:49 Mark Kettenis
2001-07-28 12:49 ` Michael Snyder [this message]
2001-07-28 13:53   ` Mark Kettenis
2001-07-30 10:35     ` Michael Snyder
     [not found]     ` <3B633A59.6030009@cygnus.com>
2001-07-30 10:36       ` Michael Snyder
2001-07-30 14:42         ` Mark Kettenis

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=3B6316FC.7D86@redhat.com \
    --to=msnyder@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=kettenis@wins.uva.nl \
    /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