This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] Bugfixes in x86-64 target
- From: Jiri Smid <smid at suse dot cz>
- To: gdb-patches at sources dot redhat dot com
- Date: 20 Dec 2001 10:02:10 +0100
- Subject: [RFA] Bugfixes in x86-64 target
Index: ChangeLog
from Jiri Smid <smid@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 whitch caouse that
only floating-point values are 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.5
diff -c -3 -p -r1.5 x86-64-tdep.c
*** x86-64-tdep.c 2001/12/11 22:16:48 1.5
--- x86-64-tdep.c 2001/12/20 07:38:55
***************
*** 29,37 ****
#include "symfile.h"
#include "x86-64-tdep.h"
#include "dwarf2cfi.h"
! #include "value.h"
-
/* Register numbers of various important registers. */
#define RAX_REGNUM 0
#define RDX_REGNUM 1
--- 29,36 ----
#include "symfile.h"
#include "x86-64-tdep.h"
#include "dwarf2cfi.h"
! #include "gdb_assert.h"
/* Register numbers of various important registers. */
#define RAX_REGNUM 0
#define RDX_REGNUM 1
*************** 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
--- 113,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. */
! 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
*************** void
*** 127,132 ****
--- 143,152 ----
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);
}
*************** 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)
--- 550,555 ----
*************** x86_64_push_arguments (int nargs, struct
*** 565,570 ****
--- 565,573 ----
38, 39, 40, 41,
42, 43, 44, 45,
46, 47, 48, 49};
+ int stack_values[nargs];
+ int stack_values_count=0;
+
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
{
--- 577,586 ----
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");
--- 619,629 ----
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 ****
--- 633,649 ----
}
}
}
+ 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
*** 850,856 ****
/* 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);
--- 865,871 ----
/* 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);
--
Jiri Smid
---------------------------------------------------------------------
SuSE CR, s.r.o. e-mail: smid@suse.cz
Drahobejlova 27 tel:+420 2 96542 373
190 00 Praha 9 fax:+420 2 96542 374
Ceska republika http://www.suse.cz