From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13448 invoked by alias); 24 Oct 2012 17:24:00 -0000 Received: (qmail 13400 invoked by uid 22791); 24 Oct 2012 17:23:56 -0000 X-SWARE-Spam-Status: No, hits=-3.0 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RCVD_IN_HOSTKARMA_NO,RP_MATCHES_RCVD,TW_EG X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 24 Oct 2012 17:23:46 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 42A9C1C7999; Wed, 24 Oct 2012 13:23:46 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id dinx-bcCoD2y; Wed, 24 Oct 2012 13:23:46 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 28FB61C7A05; Wed, 24 Oct 2012 13:23:46 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id D0DC0C88A1; Wed, 24 Oct 2012 13:23:43 -0400 (EDT) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: kettenis@gnu.org, Joel Brobecker Subject: [RFA 1/2] Revert "amd64-windows: memory args passed by pointer during function calls." Date: Wed, 24 Oct 2012 17:24:00 -0000 Message-Id: <1351099417-18960-2-git-send-email-brobecker@adacore.com> In-Reply-To: <1351099417-18960-1-git-send-email-brobecker@adacore.com> References: <1351099417-18960-1-git-send-email-brobecker@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-10/txt/msg00468.txt.bz2 A more correct implementation of parameters passed by pointer will follow. gdb/ChangeLog: Revert the following change: * i386-tdep.h (gdbarch_tdep): Add field memory_args_by_pointer. * amd64-tdep.c (amd64_push_arguments): Add handling of architectures where tdep->memory_args_by_pointer is non-zero. * amd64-windows-tdep.c (amd64_windows_init_abi): Set tdep->memory_args_by_pointer to 1. Tested on both amd64-windows and amd64-linux. OK to commit? Thanks, -- Joel --- gdb/amd64-tdep.c | 40 ++++++---------------------------------- gdb/amd64-windows-tdep.c | 1 - gdb/i386-tdep.h | 9 --------- 3 files changed, 6 insertions(+), 44 deletions(-) diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index a4172fc..c6ee493 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -749,8 +749,7 @@ static CORE_ADDR amd64_push_arguments (struct regcache *regcache, int nargs, struct value **args, CORE_ADDR sp, int struct_return) { - struct gdbarch *gdbarch = get_regcache_arch (regcache); - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); + struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache)); int *integer_regs = tdep->call_dummy_integer_regs; int num_integer_regs = tdep->call_dummy_num_integer_regs; @@ -763,11 +762,6 @@ amd64_push_arguments (struct regcache *regcache, int nargs, AMD64_XMM0_REGNUM + 6, AMD64_XMM0_REGNUM + 7, }; struct value **stack_args = alloca (nargs * sizeof (struct value *)); - /* An array that mirrors the stack_args array. For all arguments - that are passed by MEMORY, if that argument's address also needs - to be stored in a register, the ARG_ADDR_REGNO array will contain - that register number (or a negative value otherwise). */ - int *arg_addr_regno = alloca (nargs * sizeof (int)); int num_stack_args = 0; int num_elements = 0; int element = 0; @@ -811,19 +805,7 @@ amd64_push_arguments (struct regcache *regcache, int nargs, { /* The argument will be passed on the stack. */ num_elements += ((len + 7) / 8); - stack_args[num_stack_args] = args[i]; - /* If this is an AMD64_MEMORY argument whose address must also - be passed in one of the integer registers, reserve that - register and associate this value to that register so that - we can store the argument address as soon as we know it. */ - if (class[0] == AMD64_MEMORY - && tdep->memory_args_by_pointer - && integer_reg < tdep->call_dummy_num_integer_regs) - arg_addr_regno[num_stack_args] = - tdep->call_dummy_integer_regs[integer_reg++]; - else - arg_addr_regno[num_stack_args] = -1; - num_stack_args++; + stack_args[num_stack_args++] = args[i]; } else { @@ -878,20 +860,10 @@ amd64_push_arguments (struct regcache *regcache, int nargs, { struct type *type = value_type (stack_args[i]); const gdb_byte *valbuf = value_contents (stack_args[i]); - CORE_ADDR arg_addr = sp + element * 8; - - write_memory (arg_addr, valbuf, TYPE_LENGTH (type)); - if (arg_addr_regno[i] >= 0) - { - /* We also need to store the address of that argument in - the given register. */ - gdb_byte buf[8]; - enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - - store_unsigned_integer (buf, 8, byte_order, arg_addr); - regcache_cooked_write (regcache, arg_addr_regno[i], buf); - } - element += ((TYPE_LENGTH (type) + 7) / 8); + int len = TYPE_LENGTH (type); + + write_memory (sp + element * 8, valbuf, len); + element += ((len + 7) / 8); } /* The psABI says that "For calls that may call functions that use diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index 142e141..3e8a830 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -213,7 +213,6 @@ amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) ARRAY_SIZE (amd64_windows_dummy_call_integer_regs); tdep->call_dummy_integer_regs = amd64_windows_dummy_call_integer_regs; tdep->classify = amd64_windows_classify; - tdep->memory_args_by_pointer = 1; tdep->integer_param_regs_saved_in_caller_frame = 1; set_gdbarch_return_value (gdbarch, amd64_windows_return_value); set_gdbarch_skip_main_prologue (gdbarch, amd64_skip_main_prologue); diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h index 5f233f5..01b0936 100644 --- a/gdb/i386-tdep.h +++ b/gdb/i386-tdep.h @@ -85,15 +85,6 @@ struct gdbarch_tdep and store the result in CLASS. */ void (*classify) (struct type *type, enum amd64_reg_class class[2]); - /* Used on amd64 only. Non-zero if the first few MEMORY arguments - should be passed by pointer. - - More precisely, MEMORY arguments are passed through the stack. - But certain architectures require that their address be passed - by register as well, if there are still some integer registers - available for argument passing. */ - int memory_args_by_pointer; - /* Used on amd64 only. If non-zero, then the callers of a function are expected to reserve -- 1.7.9.5