From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28332 invoked by alias); 26 Feb 2002 17:28:41 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 28250 invoked from network); 26 Feb 2002 17:28:38 -0000 Received: from unknown (HELO kerberos.suse.cz) (195.47.106.10) by sources.redhat.com with SMTP; 26 Feb 2002 17:28:38 -0000 Received: from chimera.suse.cz (chimera.suse.cz [10.20.0.2]) by kerberos.suse.cz (SuSE SMTP server) with ESMTP id B1CFA59D35B for ; Tue, 26 Feb 2002 18:28:37 +0100 (CET) Received: from chimera.suse.cz (chimera.suse.cz [10.20.0.2]) by chimera.suse.cz (8.11.0/8.11.0/SuSE Linux 8.11.0-0.4) with ESMTP id g1QHSbR21904 for ; Tue, 26 Feb 2002 18:28:37 +0100 Date: Tue, 26 Feb 2002 09:28:00 -0000 From: Michal Ludvig To: Subject: [RFA] Bugfixes on x86-64 target Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2002-02/txt/msg00702.txt.bz2 Index: ChangeLog from Michal Ludvig * 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