From patchwork Mon Jun 12 18:11:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 20972 Received: (qmail 57288 invoked by alias); 12 Jun 2017 18:11:28 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 57267 invoked by uid 89); 12 Jun 2017 18:11:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f172.google.com Received: from mail-wr0-f172.google.com (HELO mail-wr0-f172.google.com) (209.85.128.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 12 Jun 2017 18:11:24 +0000 Received: by mail-wr0-f172.google.com with SMTP id g76so105108852wrd.1 for ; Mon, 12 Jun 2017 11:11:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=S47kUl+bPSU88xx2NweL6gnkwZfWMomo9TuNm+MtTS0=; b=TakMAemyjXBgtUbzKWUMtZgdtIHtGfVZ9Cigo1O58i02XXKws0QlLG9B4/R03e8snn CAdAhoFtj4c7VpC1sbcSy13xJKJjwz+PIjY4V+ztsuxYZ61FjaRQ4Nvo+AckVRvFS5zm OvYAxPkAIXlZBU1n0chTs8Wrnv0ODS85VpaOzog8Um8n3MC7f4pMwZf7Lf+Ib93BWorT v8l+xmuq5ws0BRQIDjUgnNzJk1iXSle4lXZJoZnbtDuU2ZFXEJVNCB3VwEKH7J6nZHr8 xi0PxRnMlj7I+RmXWQLWie3NHPZ/DyrOsPapBT45od8IWDWrmFgw2EqYHodF9QNihc46 Tr3g== X-Gm-Message-State: AKS2vOyWQSlNX6Qt+JnB4k0ji9Dw5Mnt9nYriJ/xEAYnuATz88gdclm7 V9kAhxz2Xwdf0m3o X-Received: by 10.223.167.15 with SMTP id c15mr159661wrd.79.1497291085145; Mon, 12 Jun 2017 11:11:25 -0700 (PDT) Received: from [192.168.0.102] ([37.189.166.198]) by smtp.gmail.com with ESMTPSA id z184sm15678637wmz.0.2017.06.12.11.11.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 11:11:23 -0700 (PDT) Subject: Re: [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (4/4) To: Alan Hayward References: <3C00280E-37C9-4C0A-9DA6-F3B9DB1A6E8F@arm.com> <86y3v7uf9j.fsf@gmail.com> <0150DDF9-6204-4F4F-99E9-D757C1DBD512@arm.com> <434A7317-C19A-4B53-8CB1-C7B4ACEC7D17@arm.com> Cc: "Maciej W. Rozycki" , Yao Qi , "gdb-patches@sourceware.org" , nd From: Pedro Alves Message-ID: <8271d989-3f06-3efd-4193-c16b35f5573a@redhat.com> Date: Mon, 12 Jun 2017 19:11:19 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: On 06/12/2017 10:09 AM, Alan Hayward wrote: > I’d be happy with this patch. I like how the define refers just to the usage > of the register. Great. > With the two minor changes below, it passes all my tests. Whoops, looks like I posted a slightly outdated patch. Sorry about that. > Name of the define is MAX_MIPS_ABI_REGSIZE, not MAX_MIPS_ABI_REGISTER_SIZE. Indeed. > This line needs changing from valbuf to ref_valbuf. *nod* On 06/12/2017 03:29 PM, Maciej W. Rozycki wrote: > LGTM; fairly mechanical. Thanks! > Great, thanks. I've pushed this in now. From b3464d0316235899d9facf81896d7a427d5cd6d0 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 12 Jun 2017 19:04:52 +0100 Subject: [PATCH] mips-tdep.c: Remove MAX_REGISTER_SIZE usage mips_eabi_push_dummy_call is storing the address of a struct in a buffer that must have the same of the configured/set ABI register size. Add a define for the maximum ABI size and use it to size the local buffer. Also rename the 'regsize' local to 'abi_regsize' for clarity. Tested that --enable-targets=all still builds. gdb/ChangeLog: 2017-06-12 Pedro Alves Alan Hayward * mips-tdep.c (MAX_MIPS_ABI_REGSIZE): New. (mips_eabi_push_dummy_call): Rename local 'regsize' to 'abi_regsize'. Rename local array 'valbuf' to 'ref_valbuf', and use MAX_MIPS_ABI_REGSIZE instead of MAX_REGISTER_SIZE to size it. Assert that abi_regsize bytes fit in 'ref_valbuf'. --- gdb/ChangeLog | 9 +++++++++ gdb/mips-tdep.c | 40 +++++++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 82f972a..0298a15 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,4 +1,13 @@ 2017-06-12 Pedro Alves + Alan Hayward + + * mips-tdep.c (MAX_MIPS_ABI_REGSIZE): New. + (mips_eabi_push_dummy_call): Rename local 'regsize' to + 'abi_regsize'. Rename local array 'valbuf' to 'ref_valbuf', and + use MAX_MIPS_ABI_REGSIZE instead of MAX_REGISTER_SIZE to size it. + Assert that abi_regsize bytes fit in 'ref_valbuf'. + +2017-06-12 Pedro Alves * dwarf2read.c (mapped_symtab::data): Now a vector of symtab_index_entry instead of vector of diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 82f91ba..dcd9ef2 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -271,6 +271,9 @@ mips_isa_regsize (struct gdbarch *gdbarch) / gdbarch_bfd_arch_info (gdbarch)->bits_per_byte); } +/* Max saved register size. */ +#define MAX_MIPS_ABI_REGSIZE 8 + /* Return the currently configured (or set) saved register size. */ unsigned int @@ -4476,7 +4479,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int stack_offset = 0; enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); CORE_ADDR func_addr = find_function_addr (function, NULL); - int regsize = mips_abi_regsize (gdbarch); + int abi_regsize = mips_abi_regsize (gdbarch); /* For shared libraries, "t9" needs to point at the function address. */ @@ -4499,7 +4502,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, than necessary for EABI, because the first few arguments are passed in registers, but that's OK. */ for (argnum = 0; argnum < nargs; argnum++) - len += align_up (TYPE_LENGTH (value_type (args[argnum])), regsize); + len += align_up (TYPE_LENGTH (value_type (args[argnum])), abi_regsize); sp -= align_up (len, 16); if (mips_debug) @@ -4528,7 +4531,9 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, for (argnum = 0; argnum < nargs; argnum++) { const gdb_byte *val; - gdb_byte valbuf[MAX_REGISTER_SIZE]; + /* This holds the address of structures that are passed by + reference. */ + gdb_byte ref_valbuf[MAX_MIPS_ABI_REGSIZE]; struct value *arg = args[argnum]; struct type *arg_type = check_typedef (value_type (arg)); int len = TYPE_LENGTH (arg_type); @@ -4541,14 +4546,15 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* The EABI passes structures that do not fit in a register by reference. */ - if (len > regsize + if (len > abi_regsize && (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)) { - store_unsigned_integer (valbuf, regsize, byte_order, + gdb_assert (abi_regsize <= ARRAY_SIZE (ref_valbuf)); + store_unsigned_integer (ref_valbuf, abi_regsize, byte_order, value_address (arg)); typecode = TYPE_CODE_PTR; - len = regsize; - val = valbuf; + len = abi_regsize; + val = ref_valbuf; if (mips_debug) fprintf_unfiltered (gdb_stdlog, " push"); } @@ -4560,7 +4566,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, up before the check to see if there are any FP registers left. Non MIPS_EABI targets also pass the FP in the integer registers so also round up normal registers. */ - if (regsize < 8 && fp_register_arg_p (gdbarch, typecode, arg_type)) + if (abi_regsize < 8 && fp_register_arg_p (gdbarch, typecode, arg_type)) { if ((float_argreg & 1)) float_argreg++; @@ -4626,12 +4632,12 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Copy the argument to general registers or the stack in register-sized pieces. Large arguments are split between registers and stack. */ - /* Note: structs whose size is not a multiple of regsize + /* Note: structs whose size is not a multiple of abi_regsize are treated specially: Irix cc passes them in registers where gcc sometimes puts them on the stack. For maximum compatibility, we will put them in both places. */ - int odd_sized_struct = (len > regsize && len % regsize != 0); + int odd_sized_struct = (len > abi_regsize && len % abi_regsize != 0); /* Note: Floating-point values that didn't fit into an FP register are only written to memory. */ @@ -4639,7 +4645,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, { /* Remember if the argument was written to the stack. */ int stack_used_p = 0; - int partial_len = (len < regsize ? len : regsize); + int partial_len = (len < abi_regsize ? len : abi_regsize); if (mips_debug) fprintf_unfiltered (gdb_stdlog, " -- partial=%d", @@ -4657,15 +4663,15 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, stack_used_p = 1; if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) { - if (regsize == 8 + if (abi_regsize == 8 && (typecode == TYPE_CODE_INT || typecode == TYPE_CODE_PTR || typecode == TYPE_CODE_FLT) && len <= 4) - longword_offset = regsize - len; + longword_offset = abi_regsize - len; else if ((typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION) - && TYPE_LENGTH (arg_type) < regsize) - longword_offset = regsize - len; + && TYPE_LENGTH (arg_type) < abi_regsize) + longword_offset = abi_regsize - len; } if (mips_debug) @@ -4706,7 +4712,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, if (mips_debug) fprintf_filtered (gdb_stdlog, " - reg=%d val=%s", argreg, - phex (regval, regsize)); + phex (regval, abi_regsize)); regcache_cooked_write_signed (regcache, argreg, regval); argreg++; } @@ -4721,7 +4727,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function, only needs to be adjusted when it has been used. */ if (stack_used_p) - stack_offset += align_up (partial_len, regsize); + stack_offset += align_up (partial_len, abi_regsize); } } if (mips_debug)