Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Bugfixes on x86-64 target
@ 2002-02-26  9:28 Michal Ludvig
  2002-02-26 18:49 ` Andrew Cagney
  2002-03-01  7:00 ` Andrew Cagney
  0 siblings, 2 replies; 10+ messages in thread
From: Michal Ludvig @ 2002-02-26  9:28 UTC (permalink / raw)
  To: gdb-patches

Index: ChangeLog
from  Michal Ludvig  <mludvig@suse.cz>

	* x86-64-tdep.c (value.h): Delete.
	(gdb_assert.h): Include.
	(x86_64_register_convert_to_virtual,
	x86_64_register_convert_to_raw ): Add check which lets only
	floating-point values to be converted.
	(value_push): Delete.
	(x86_64_push_arguments): Order of arguments pushed on stack fixed.
	(i386_gdbarch_init): Number of register_bytes fixed.

Index: x86-64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-tdep.c,v
retrieving revision 1.7
diff -c -3 -p -r1.7 x86-64-tdep.c
*** x86-64-tdep.c	2002/01/20 18:05:51	1.7
--- x86-64-tdep.c	2002/02/26 17:09:07
***************
*** 29,35 ****
  #include "symfile.h"
  #include "x86-64-tdep.h"
  #include "dwarf2cfi.h"
! #include "value.h"


  /* Register numbers of various important registers.  */
--- 29,35 ----
  #include "symfile.h"
  #include "x86-64-tdep.h"
  #include "dwarf2cfi.h"
! #include "gdb_assert.h"


  /* Register numbers of various important registers.  */
*************** static struct type *
*** 84,98 ****
  x86_64_register_virtual_type (int regno)
  {
    if (regno == PC_REGNUM || regno == SP_REGNUM)
!     return lookup_pointer_type (builtin_type_void);
    if (IS_FP_REGNUM (regno))
!     return builtin_type_long_double;
    if (IS_SSE_REGNUM (regno))
      return builtin_type_v4sf;
    if (IS_FPU_CTRL_REGNUM (regno) || regno == MXCSR_REGNUM
        || regno == EFLAGS_REGNUM)
!     return builtin_type_int;
!   return builtin_type_long;
  }

  /* x86_64_register_convertible is true if register N's virtual format is
--- 84,98 ----
  x86_64_register_virtual_type (int regno)
  {
    if (regno == PC_REGNUM || regno == SP_REGNUM)
!     return builtin_type_void_func_ptr;
    if (IS_FP_REGNUM (regno))
!     return builtin_type_i387_ext;
    if (IS_SSE_REGNUM (regno))
      return builtin_type_v4sf;
    if (IS_FPU_CTRL_REGNUM (regno) || regno == MXCSR_REGNUM
        || regno == EFLAGS_REGNUM)
!     return builtin_type_int32;
!   return builtin_type_int64;
  }

  /* x86_64_register_convertible is true if register N's virtual format is
*************** void
*** 114,122 ****
  x86_64_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);
  }

  /* Convert data from virtual format with type TYPE in buffer FROM to
--- 114,138 ----
  x86_64_register_convert_to_virtual (int regnum, struct type *type,
  				    char *from, char *to)
  {
!   char buf[12];
!   DOUBLEST d;
!
!   /* We only support floating-point values.  */
!   if (TYPE_CODE (type) != TYPE_CODE_FLT)
!     {
!       warning ("Cannot convert floating-point register value "
! 	       "to non-floating-point type.");
!       memset (to, 0, TYPE_LENGTH (type));
!       return;
!     }
!
!   /* 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.  */
!   convert_typed_floating (to, type, buf, x86_64_register_virtual_type (regnum));
  }

  /* Convert data from virtual format with type TYPE in buffer FROM to
*************** void
*** 127,135 ****
  x86_64_register_convert_to_raw (struct type *type, int regnum,
  				char *from, char *to)
  {
    memcpy (to, from, FPU_REG_RAW_SIZE);
  }
-

  /* This is the variable that is set with "set disassembly-flavour", and
     its legitimate values.  */
--- 143,154 ----
  x86_64_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);
  }

  /* This is the variable that is set with "set disassembly-flavour", and
     its legitimate values.  */
*************** x86_64_frame_init_saved_regs (struct fra
*** 530,555 ****
  #define INT_REGS 6
  #define SSE_REGS 16

- /* Push onto the stack the specified value VALUE.  Pad it correctly for
-    it to be an argument to a function.  */
-
- static CORE_ADDR
- value_push (register CORE_ADDR sp, struct value *arg)
- {
-   register int len = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg));
-   register int container_len = len;
-
-   /* How big is the container we're going to put this value in?  */
-   if (PARM_BOUNDARY)
-     container_len = ((len + PARM_BOUNDARY / TARGET_CHAR_BIT - 1)
- 		     & ~(PARM_BOUNDARY / TARGET_CHAR_BIT - 1));
-
-   sp -= container_len;
-   write_memory (sp, VALUE_CONTENTS_ALL (arg), len);
-
-   return sp;
- }
-
  CORE_ADDR
  x86_64_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
  		       int struct_return, CORE_ADDR struct_addr)
--- 549,554 ----
*************** x86_64_push_arguments (int nargs, struct
*** 565,570 ****
--- 564,574 ----
  						  38, 39, 40, 41,
  						  42, 43, 44, 45,
  						  46, 47, 48, 49};
+   int stack_values_count=0;
+   int *stack_values;
+
+   stack_values = alloca (naregs * sizeof (int));
+
    for (i = 0; i < nargs; i++)
      {
        enum x86_64_reg_class class[MAX_CLASSES];
*************** x86_64_push_arguments (int nargs, struct
*** 574,583 ****

        if (!n ||
  	  !examine_argument (class, n, &needed_intregs, &needed_sseregs)
! 	  || intreg + needed_intregs > INT_REGS
! 	  || ssereg + needed_sseregs > SSE_REGS)
  	{				/* memory class */
! 	  sp = value_push (sp, args[i]);
  	}
        else
  	{
--- 578,587 ----

        if (!n ||
  	  !examine_argument (class, n, &needed_intregs, &needed_sseregs)
! 	  || intreg / 2 + needed_intregs > INT_REGS
! 	  || ssereg / 2 + needed_sseregs > SSE_REGS)
  	{				/* memory class */
! 	  stack_values[stack_values_count++]=i;
  	}
        else
  	{
*************** x86_64_push_arguments (int nargs, struct
*** 616,625 ****
  		  ssereg++;
  		  break;
  		case X86_64_X87_CLASS:
- 		case X86_64_X87UP_CLASS:
  		case X86_64_MEMORY_CLASS:
! 		  sp = value_push (sp, args[i]);
  		  break;
  		default:
  		  internal_error (__FILE__, __LINE__,
  				  "Unexpected argument class");
--- 620,630 ----
  		  ssereg++;
  		  break;
  		case X86_64_X87_CLASS:
  		case X86_64_MEMORY_CLASS:
! 		  stack_values[stack_values_count++]=i;
  		  break;
+ 		case X86_64_X87UP_CLASS:
+ 		  break;
  		default:
  		  internal_error (__FILE__, __LINE__,
  				  "Unexpected argument class");
*************** x86_64_push_arguments (int nargs, struct
*** 629,634 ****
--- 634,650 ----
  	    }
  	}
      }
+   while (--stack_values_count >= 0)
+     {
+       value_ptr arg = args[stack_values[stack_values_count]];
+       int len = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg));
+
+       len += 7;
+       len -= len % 8;
+
+       sp -= len;
+       write_memory (sp, VALUE_CONTENTS_ALL (arg), len);
+     }
    return sp;
  }

*************** i386_gdbarch_init (struct gdbarch_info i
*** 844,850 ****
    /* Total amount of space needed to store our copies of the machine's register
       (SIZEOF_GREGS + SIZEOF_FPU_REGS + SIZEOF_FPU_CTRL_REGS + SIZEOF_SSE_REGS) */
    set_gdbarch_register_bytes (gdbarch,
! 			      (18 * 8) + (8 * 10) + (8 * 4) + (8 * 16 + 4));
    set_gdbarch_register_virtual_size (gdbarch, generic_register_virtual_size);
    set_gdbarch_max_register_virtual_size (gdbarch, 16);

--- 860,866 ----
    /* Total amount of space needed to store our copies of the machine's register
       (SIZEOF_GREGS + SIZEOF_FPU_REGS + SIZEOF_FPU_CTRL_REGS + SIZEOF_SSE_REGS) */
    set_gdbarch_register_bytes (gdbarch,
! 			      (18 * 8) + (8 * 10) + (8 * 4) + (16 * 16 + 4));
    set_gdbarch_register_virtual_size (gdbarch, generic_register_virtual_size);
    set_gdbarch_max_register_virtual_size (gdbarch, 16)

Michal Ludvig
-- 
* SuSE CR, s.r.o     * mludvig@suse.cz
* +420 2 9654 5373   * http://www.suse.cz


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

* Re: [RFA] Bugfixes on x86-64 target
  2002-02-26  9:28 [RFA] Bugfixes on x86-64 target Michal Ludvig
@ 2002-02-26 18:49 ` Andrew Cagney
  2002-03-01  7:00 ` Andrew Cagney
  1 sibling, 0 replies; 10+ messages in thread
From: Andrew Cagney @ 2002-02-26 18:49 UTC (permalink / raw)
  To: Michal Ludvig; +Cc: gdb-patches

> Index: ChangeLog
> from  Michal Ludvig  <mludvig@suse.cz>
> 
> * x86-64-tdep.c (value.h): Delete.
> 	(gdb_assert.h): Include.
> 	(x86_64_register_convert_to_virtual,
> 	x86_64_register_convert_to_raw ): Add check which lets only
> 	floating-point values to be converted.
> 	(value_push): Delete.
> 	(x86_64_push_arguments): Order of arguments pushed on stack fixed.
> 	(i386_gdbarch_init): Number of register_bytes fixed.
> 
Nice!  I've checked it in (I've also re-indented the file as a separate 
commit).

Andrew




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

* Re: [RFA] Bugfixes on x86-64 target
  2002-02-26  9:28 [RFA] Bugfixes on x86-64 target Michal Ludvig
  2002-02-26 18:49 ` Andrew Cagney
@ 2002-03-01  7:00 ` Andrew Cagney
  2002-03-04  3:07   ` Michal Ludvig
  1 sibling, 1 reply; 10+ messages in thread
From: Andrew Cagney @ 2002-03-01  7:00 UTC (permalink / raw)
  To: Michal Ludvig; +Cc: gdb-patches

Michal,
Can I suggest adding your self to the maintainers file as an obvious fix 
(don't forget to post the patch).

You may also want to tweak x86-64 as it uses value_ptr which no longer 
exists.

> +       value_ptr arg = args[stack_values[stack_values_count]];

ARI spotted it :-)

enjoy,
Andrew




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

* Re: [RFA] Bugfixes on x86-64 target
  2002-03-01  7:00 ` Andrew Cagney
@ 2002-03-04  3:07   ` Michal Ludvig
  2002-03-04 18:27     ` Andrew Cagney
  0 siblings, 1 reply; 10+ messages in thread
From: Michal Ludvig @ 2002-03-04  3:07 UTC (permalink / raw)
  To: gdb-patches

Andrew Cagney wrote:
> Michal,
> Can I suggest adding your self to the maintainers file as an obvious fix 
> (don't forget to post the patch).

Index: ChangeLog
from  Michal Ludvig  <mludvig@suse.cz>
         * MAINTAINERS (x86-64): Add myself.

Index: MAINTAINERS
===================================================================
RCS file: /cvs/src/src/gdb/MAINTAINERS,v
retrieving revision 1.154
diff -c -3 -p -r1.154 MAINTAINERS
*** MAINTAINERS 2002/03/01 03:30:59     1.154
--- MAINTAINERS 2002/03/04 10:54:48
*************** maintainer works with the native maintai
*** 171,177 ****
         w65             Deleted.

         x86-64          (--target=x86_64-linux-gnu broken)
!                       Maintenance only

         xstormy16       --target=xstormy16-elf ,-Werror
                         Corinna Vinschen        vinschen@redhat.com
--- 171,177 ----
         w65             Deleted.

         x86-64          (--target=x86_64-linux-gnu broken)
!                       Michal Ludvig           mludvig@suse.cz

         xstormy16       --target=xstormy16-elf ,-Werror
                         Corinna Vinschen        vinschen@redhat.com


> You may also want to tweak x86-64 as it uses value_ptr which no longer 
> exists.
>> +       value_ptr arg = args[stack_values[stack_values_count]];
> ARI spotted it :-)

This was fixed in the second (corrected) posting of my patch. 
Unfortunately you've commited the broken one :-(
Anyway, patch follows...

Index: ChangeLog
from Michal Ludvig <mludvig@suse.cz>

       * x86-64-tdep.c (x86_64_push_arguments): Fixed typo naregs->nregs,
       changed value_ptr -> struct value *

Index: x86-64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-tdep.c,v
retrieving revision 1.9
diff -c -3 -p -r1.9 x86-64-tdep.c
*** x86-64-tdep.c       2002/02/27 02:55:13     1.9
--- x86-64-tdep.c       2002/03/04 10:54:49
*************** x86_64_push_arguments (int nargs, struct
*** 569,575 ****
     };
     int stack_values_count = 0;
     int *stack_values;
!   stack_values = alloca (naregs * sizeof (int));
     for (i = 0; i < nargs; i++)
       {
         enum x86_64_reg_class class[MAX_CLASSES];
--- 569,575 ----
     };
     int stack_values_count = 0;
     int *stack_values;
!   stack_values = alloca (nargs * sizeof (int));
     for (i = 0; i < nargs; i++)
       {
         enum x86_64_reg_class class[MAX_CLASSES];
*************** x86_64_push_arguments (int nargs, struct
*** 639,645 ****
       }
     while (--stack_values_count >= 0)
       {
!       value_ptr arg = args[stack_values[stack_values_count]];
         int len = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg));
         len += 7;
         len -= len % 8;
--- 639,645 ----
       }
     while (--stack_values_count >= 0)
       {
!       struct value *arg = args[stack_values[stack_values_count]];
         int len = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg));
         len += 7;
         len -= len % 8;


Both patches are commited as obvious fixes.

Michal Ludvig
-- 
* SuSE CR, s.r.o     * mludvig@suse.cz
* +420 2 9654 5373   * http://www.suse.cz


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

* Re: [RFA] Bugfixes on x86-64 target
  2002-03-04  3:07   ` Michal Ludvig
@ 2002-03-04 18:27     ` Andrew Cagney
  2002-03-05  4:51       ` Michal Ludvig
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Cagney @ 2002-03-04 18:27 UTC (permalink / raw)
  To: Michal Ludvig; +Cc: gdb-patches

> Andrew Cagney wrote:
> Michal,
> Can I suggest adding your self to the maintainers file as an obvious fix (don't forget to post the patch).

Oops, sorry.  I was thinking of write-after-approval.

Andrew


> 
> Index: ChangeLog
> from  Michal Ludvig  <mludvig@suse.cz>
>         * MAINTAINERS (x86-64): Add myself.
> 
> Index: MAINTAINERS
> ===================================================================
> RCS file: /cvs/src/src/gdb/MAINTAINERS,v
> retrieving revision 1.154
> diff -c -3 -p -r1.154 MAINTAINERS
> *** MAINTAINERS 2002/03/01 03:30:59     1.154
> --- MAINTAINERS 2002/03/04 10:54:48
> *************** maintainer works with the native maintai
> *** 171,177 ****
>         w65             Deleted.
> 
>         x86-64          (--target=x86_64-linux-gnu broken)
> !                       Maintenance only
> 
>         xstormy16       --target=xstormy16-elf ,-Werror
>                         Corinna Vinschen        vinschen@redhat.com
> --- 171,177 ----
>         w65             Deleted.
> 
>         x86-64          (--target=x86_64-linux-gnu broken)
> !                       Michal Ludvig           mludvig@suse.cz
> 
>         xstormy16       --target=xstormy16-elf ,-Werror
>                         Corinna Vinschen        vinschen@redhat.com
> 



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

* Re: [RFA] Bugfixes on x86-64 target
  2002-03-04 18:27     ` Andrew Cagney
@ 2002-03-05  4:51       ` Michal Ludvig
  2002-03-05  6:55         ` Andrew Cagney
  0 siblings, 1 reply; 10+ messages in thread
From: Michal Ludvig @ 2002-03-05  4:51 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Cagney

 > x86-64          (--target=x86_64-linux-gnu broken)
 >                 Michal Ludvig           mludvig@suse.cz

Andrew Cagney wrote:
>> Andrew Cagney wrote:
>> Can I suggest adding your self to the maintainers file as an obvious 
>> fix (don't forget to post the patch).
> Oops, sorry.  I was thinking of write-after-approval.

Is it wrong? Can I remove the "broken" word? The target is not
broken when compiled natively.

Michal Ludvig


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

* Re: [RFA] Bugfixes on x86-64 target
  2002-03-05  4:51       ` Michal Ludvig
@ 2002-03-05  6:55         ` Andrew Cagney
  2002-03-05  8:27           ` Michal Ludvig
  0 siblings, 1 reply; 10+ messages in thread
From: Andrew Cagney @ 2002-03-05  6:55 UTC (permalink / raw)
  To: Michal Ludvig; +Cc: gdb-patches

>> x86-64          (--target=x86_64-linux-gnu broken)
>>                 Michal Ludvig           mludvig@suse.cz
> 
>> Andrew Cagney wrote:
>>> Andrew Cagney wrote:
>>> Can I suggest adding your self to the maintainers file as an obvious fix (don't forget to post the patch).
> 
>> Oops, sorry.  I was thinking of write-after-approval.
> Is it wrong? Can I remove the "broken" word? The target is not
> broken when compiled natively.

Sorry which, maintainer or broken?

With respect to maintenance, I wrote something that could be interpreted 
in several different ways.  I'm very sorry for this misunderstanding. 
You contributed a (correct?) patch, had an assignment on hand and hence 
ment the criteria for write-after-approval.

A target should always be buildable as a cross.  The other native-only 
target is HP/UX and that is also considered broken.

Andrew



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

* Re: [RFA] Bugfixes on x86-64 target
  2002-03-05  6:55         ` Andrew Cagney
@ 2002-03-05  8:27           ` Michal Ludvig
  2002-03-05 11:14             ` Andrew Cagney
  0 siblings, 1 reply; 10+ messages in thread
From: Michal Ludvig @ 2002-03-05  8:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Andrew Cagney

Andrew Cagney wrote:
> With respect to maintenance, I wrote something that could be interpreted 
> in several different ways.  I'm very sorry for this misunderstanding. 
> You contributed a (correct?) patch, had an assignment on hand and hence 
> ment the criteria for write-after-approval.

I'm confused a little now... ;-))
Perhaps this one is correct???

Index: MAINTAINERS
===================================================================
RCS file: /cvs/src/src/gdb/MAINTAINERS,v
retrieving revision 1.156
diff -c -3 -p -r1.156 MAINTAINERS
*** MAINTAINERS 2002/03/04 12:25:39     1.156
--- MAINTAINERS 2002/03/05 16:22:38
*************** maintainer works with the native maintai
*** 171,177 ****
         w65             Deleted.

         x86-64          (--target=x86_64-linux-gnu, broken)
!                       Michal Ludvig           mludvig@suse.cz

         xstormy16       --target=xstormy16-elf ,-Werror
                         Corinna Vinschen        vinschen@redhat.com
--- 171,177 ----
         w65             Deleted.

         x86-64          (--target=x86_64-linux-gnu, broken)
!                       Maintenance only

         xstormy16       --target=xstormy16-elf ,-Werror
                         Corinna Vinschen        vinschen@redhat.com
*************** Jason Thorpe 
thorpej@wasabisystems.c
*** 392,397 ****
--- 392,398 ----
   Tom Tromey                                    tromey@redhat.com
   Corinna Vinschen                              vinschen@redhat.com
   Keith Walker                                  keith.walker@arm.com
+ Michal Ludvig                                 mludvig@suse.cz



Michal Ludvig
-- 
* SuSE CR, s.r.o     * mludvig@suse.cz
* +420 2 9654 5373   * http://www.suse.cz


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

* Re: [RFA] Bugfixes on x86-64 target
  2002-03-05  8:27           ` Michal Ludvig
@ 2002-03-05 11:14             ` Andrew Cagney
  0 siblings, 0 replies; 10+ messages in thread
From: Andrew Cagney @ 2002-03-05 11:14 UTC (permalink / raw)
  To: Michal Ludvig; +Cc: gdb-patches

> *************** Jason Thorpe thorpej@wasabisystems.c
> *** 392,397 ****
> --- 392,398 ----
>   Tom Tromey                                    tromey@redhat.com
>   Corinna Vinschen                              vinschen@redhat.com
>   Keith Walker                                  keith.walker@arm.com
> + Michal Ludvig                                 mludvig@suse.cz
> 
Yes, I'm really sorry for causing this confusion.  Separtly, note the 
clause:

> All maintainers can test and thence approve non-trivial changes to
> ``maintenance only'' targets submitted by recognized developers.

Andreas Schwab is such a maintainer.

Andrew



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

* [RFA] Bugfixes on x86-64 target
@ 2002-02-26  9:50 Michal Ludvig
  0 siblings, 0 replies; 10+ messages in thread
From: Michal Ludvig @ 2002-02-26  9:50 UTC (permalink / raw)
  To: gdb-patches

Sorry for the last one. It was an old version which didn't compile. Now
the correct patch:

Index: ChangeLog
from  Michal Ludvig  <mludvig@suse.cz>

	* x86-64-tdep.c (value.h): Delete.
	(gdb_assert.h): Include.
	(x86_64_register_convert_to_virtual,
	x86_64_register_convert_to_raw ): Add check which lets only
	floating-point values to be converted.
	(value_push): Delete.
	(x86_64_push_arguments): Order of arguments pushed on stack fixed.
	(i386_gdbarch_init): Number of register_bytes fixed.

Index: x86-64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/x86-64-tdep.c,v
retrieving revision 1.7
diff -c -3 -p -r1.7 x86-64-tdep.c
*** x86-64-tdep.c	2002/01/20 18:05:51	1.7
--- x86-64-tdep.c	2002/02/26 17:09:07
***************
*** 29,35 ****
  #include "symfile.h"
  #include "x86-64-tdep.h"
  #include "dwarf2cfi.h"
! #include "value.h"


  /* Register numbers of various important registers.  */
--- 29,35 ----
  #include "symfile.h"
  #include "x86-64-tdep.h"
  #include "dwarf2cfi.h"
! #include "gdb_assert.h"


  /* Register numbers of various important registers.  */
*************** static struct type *
*** 84,98 ****
  x86_64_register_virtual_type (int regno)
  {
    if (regno == PC_REGNUM || regno == SP_REGNUM)
!     return lookup_pointer_type (builtin_type_void);
    if (IS_FP_REGNUM (regno))
!     return builtin_type_long_double;
    if (IS_SSE_REGNUM (regno))
      return builtin_type_v4sf;
    if (IS_FPU_CTRL_REGNUM (regno) || regno == MXCSR_REGNUM
        || regno == EFLAGS_REGNUM)
!     return builtin_type_int;
!   return builtin_type_long;
  }

  /* x86_64_register_convertible is true if register N's virtual format is
--- 84,98 ----
  x86_64_register_virtual_type (int regno)
  {
    if (regno == PC_REGNUM || regno == SP_REGNUM)
!     return builtin_type_void_func_ptr;
    if (IS_FP_REGNUM (regno))
!     return builtin_type_i387_ext;
    if (IS_SSE_REGNUM (regno))
      return builtin_type_v4sf;
    if (IS_FPU_CTRL_REGNUM (regno) || regno == MXCSR_REGNUM
        || regno == EFLAGS_REGNUM)
!     return builtin_type_int32;
!   return builtin_type_int64;
  }

  /* x86_64_register_convertible is true if register N's virtual format is
*************** void
*** 114,122 ****
  x86_64_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);
  }

  /* Convert data from virtual format with type TYPE in buffer FROM to
--- 114,138 ----
  x86_64_register_convert_to_virtual (int regnum, struct type *type,
  				    char *from, char *to)
  {
!   char buf[12];
!   DOUBLEST d;
!
!   /* We only support floating-point values.  */
!   if (TYPE_CODE (type) != TYPE_CODE_FLT)
!     {
!       warning ("Cannot convert floating-point register value "
! 	       "to non-floating-point type.");
!       memset (to, 0, TYPE_LENGTH (type));
!       return;
!     }
!
!   /* 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.  */
!   convert_typed_floating (to, type, buf, x86_64_register_virtual_type (regnum));
  }

  /* Convert data from virtual format with type TYPE in buffer FROM to
*************** void
*** 127,135 ****
  x86_64_register_convert_to_raw (struct type *type, int regnum,
  				char *from, char *to)
  {
    memcpy (to, from, FPU_REG_RAW_SIZE);
  }
-

  /* This is the variable that is set with "set disassembly-flavour", and
     its legitimate values.  */
--- 143,154 ----
  x86_64_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);
  }

  /* This is the variable that is set with "set disassembly-flavour", and
     its legitimate values.  */
*************** x86_64_frame_init_saved_regs (struct fra
*** 530,555 ****
  #define INT_REGS 6
  #define SSE_REGS 16

- /* Push onto the stack the specified value VALUE.  Pad it correctly for
-    it to be an argument to a function.  */
-
- static CORE_ADDR
- value_push (register CORE_ADDR sp, struct value *arg)
- {
-   register int len = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg));
-   register int container_len = len;
-
-   /* How big is the container we're going to put this value in?  */
-   if (PARM_BOUNDARY)
-     container_len = ((len + PARM_BOUNDARY / TARGET_CHAR_BIT - 1)
- 		     & ~(PARM_BOUNDARY / TARGET_CHAR_BIT - 1));
-
-   sp -= container_len;
-   write_memory (sp, VALUE_CONTENTS_ALL (arg), len);
-
-   return sp;
- }
-
  CORE_ADDR
  x86_64_push_arguments (int nargs, struct value **args, CORE_ADDR sp,
  		       int struct_return, CORE_ADDR struct_addr)
--- 549,554 ----
*************** x86_64_push_arguments (int nargs, struct
*** 565,570 ****
--- 564,574 ----
  						  38, 39, 40, 41,
  						  42, 43, 44, 45,
  						  46, 47, 48, 49};
+   int stack_values_count=0;
+   int *stack_values;
+
+   stack_values = alloca (nargs * sizeof (int));
+
    for (i = 0; i < nargs; i++)
      {
        enum x86_64_reg_class class[MAX_CLASSES];
*************** x86_64_push_arguments (int nargs, struct
*** 574,583 ****

        if (!n ||
  	  !examine_argument (class, n, &needed_intregs, &needed_sseregs)
! 	  || intreg + needed_intregs > INT_REGS
! 	  || ssereg + needed_sseregs > SSE_REGS)
  	{				/* memory class */
! 	  sp = value_push (sp, args[i]);
  	}
        else
  	{
--- 578,587 ----

        if (!n ||
  	  !examine_argument (class, n, &needed_intregs, &needed_sseregs)
! 	  || intreg / 2 + needed_intregs > INT_REGS
! 	  || ssereg / 2 + needed_sseregs > SSE_REGS)
  	{				/* memory class */
! 	  stack_values[stack_values_count++]=i;
  	}
        else
  	{
*************** x86_64_push_arguments (int nargs, struct
*** 616,625 ****
  		  ssereg++;
  		  break;
  		case X86_64_X87_CLASS:
- 		case X86_64_X87UP_CLASS:
  		case X86_64_MEMORY_CLASS:
! 		  sp = value_push (sp, args[i]);
  		  break;
  		default:
  		  internal_error (__FILE__, __LINE__,
  				  "Unexpected argument class");
--- 620,630 ----
  		  ssereg++;
  		  break;
  		case X86_64_X87_CLASS:
  		case X86_64_MEMORY_CLASS:
! 		  stack_values[stack_values_count++]=i;
  		  break;
+ 		case X86_64_X87UP_CLASS:
+ 		  break;
  		default:
  		  internal_error (__FILE__, __LINE__,
  				  "Unexpected argument class");
*************** x86_64_push_arguments (int nargs, struct
*** 629,634 ****
--- 634,650 ----
  	    }
  	}
      }
+   while (--stack_values_count >= 0)
+     {
+       struct value *arg = args[stack_values[stack_values_count]];
+       int len = TYPE_LENGTH (VALUE_ENCLOSING_TYPE (arg));
+
+       len += 7;
+       len -= len % 8;
+
+       sp -= len;
+       write_memory (sp, VALUE_CONTENTS_ALL (arg), len);
+     }
    return sp;
  }

*************** i386_gdbarch_init (struct gdbarch_info i
*** 844,850 ****
    /* Total amount of space needed to store our copies of the machine's register
       (SIZEOF_GREGS + SIZEOF_FPU_REGS + SIZEOF_FPU_CTRL_REGS + SIZEOF_SSE_REGS) */
    set_gdbarch_register_bytes (gdbarch,
! 			      (18 * 8) + (8 * 10) + (8 * 4) + (8 * 16 + 4));
    set_gdbarch_register_virtual_size (gdbarch, generic_register_virtual_size);
    set_gdbarch_max_register_virtual_size (gdbarch, 16);

--- 860,866 ----
    /* Total amount of space needed to store our copies of the machine's register
       (SIZEOF_GREGS + SIZEOF_FPU_REGS + SIZEOF_FPU_CTRL_REGS + SIZEOF_SSE_REGS) */
    set_gdbarch_register_bytes (gdbarch,
! 			      (18 * 8) + (8 * 10) + (8 * 4) + (16 * 16 + 4));
    set_gdbarch_register_virtual_size (gdbarch, generic_register_virtual_size);
    set_gdbarch_max_register_virtual_size (gdbarch, 16)


Michal Ludvig
-- 
* SuSE CR, s.r.o     * mludvig@suse.cz
* +420 2 9654 5373   * http://www.suse.cz


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

end of thread, other threads:[~2002-03-05 19:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-26  9:28 [RFA] Bugfixes on x86-64 target Michal Ludvig
2002-02-26 18:49 ` Andrew Cagney
2002-03-01  7:00 ` Andrew Cagney
2002-03-04  3:07   ` Michal Ludvig
2002-03-04 18:27     ` Andrew Cagney
2002-03-05  4:51       ` Michal Ludvig
2002-03-05  6:55         ` Andrew Cagney
2002-03-05  8:27           ` Michal Ludvig
2002-03-05 11:14             ` Andrew Cagney
2002-02-26  9:50 Michal Ludvig

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