From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 8tUqKJ6nMWJZIwAAWB0awg (envelope-from ) for ; Wed, 16 Mar 2022 05:02:22 -0400 Received: by simark.ca (Postfix, from userid 112) id 942021F3CC; Wed, 16 Mar 2022 05:02:22 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, NICE_REPLY_A,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 4E3621EA69 for ; Wed, 16 Mar 2022 05:02:21 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC8FB388212B for ; Wed, 16 Mar 2022 09:02:20 +0000 (GMT) Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id CFE70384781A for ; Wed, 16 Mar 2022 09:01:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CFE70384781A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from [10.130.0.193] (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9DxzxNHpzFiHCMKAA--.7373S3; Wed, 16 Mar 2022 17:00:56 +0800 (CST) Subject: Re: [PATCH] gdb: mips: Fix the handling of complex type of function return value To: Lancelot SIX References: <1647406106-25723-1-git-send-email-tangyouling@loongson.cn> <20220316084248.m5m2et3njtngeoge@Plymouth> From: Youling Tang Message-ID: Date: Wed, 16 Mar 2022 17:00:55 +0800 User-Agent: Mozilla/5.0 (X11; Linux mips64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20220316084248.m5m2et3njtngeoge@Plymouth> X-CM-TRANSID: AQAAf9DxzxNHpzFiHCMKAA--.7373S3 X-Coremail-Antispam: 1UD129KBjvJXoW7Zr18CrWUKFWrXFWxAry5urg_yoW5Jr4rp3 yayr47CFWFq3WxAFWIvw45Xr4fCw47Gr1UGrWS9rZ09a1UW3s3C3y7tr1Ykr4DGan5tryx JanIqa1jvF4xC3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvYb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwV C2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487McIj6xIIjxv2 0xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7 xvr2IY64vIr41l7480Y4vEI4kI2Ix0rVAqx4xJMxk0xIA0c2IEe2xFo4CEbIxvr21lc2xS Y4AK67AK6r4fMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I 8CrVAFwI0_JrI_JrWlx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUXVWU AwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x 0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AK xVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07 bOmhwUUUUU= X-CM-SenderInfo: 5wdqw5prxox03j6o00pqjv00gofq/ Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gdb-patches@sourceware.org, "Maciej W. Rozycki" Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Hi, Lancelo On 03/16/2022 04:42 PM, Lancelot SIX wrote: > On Wed, Mar 16, 2022 at 12:48:26PM +0800, Youling Tang wrote: >> $ objdump -d outputs/gdb.base/varargs/varargs >> 00000001200012e8 : >> ... >> 1200013b8: c7c10000 lwc1 $f1,0(s8) >> 1200013bc: c7c00004 lwc1 $f0,4(s8) >> 1200013c0: 46000886 mov.s $f2,$f1 >> 1200013c4: 46000046 mov.s $f1,$f0 >> 1200013c8: 46001006 mov.s $f0,$f2 >> 1200013cc: 46000886 mov.s $f2,$f1 >> 1200013d0: 03c0e825 move sp,s8 >> 1200013d4: dfbe0038 ld s8,56(sp) >> 1200013d8: 67bd0080 daddiu sp,sp,128 >> 1200013dc: 03e00008 jr ra >> 1200013e0: 00000000 nop >> >> From the above disassembly, we can see that when the return value of the >> function is a complex type and len <= 2 * MIPS64_REGSIZE, the return value >> will be passed through $f0 and $f2, so fix the corresponding processing >> in mips_n32n64_return_value(). >> >> $ make check RUNTESTFLAGS='GDB=../gdb gdb.base/varargs.exp --outdir=test' >> >> Before applying the patch: >> FAIL: gdb.base/varargs.exp: print find_max_float_real(4, fc1, fc2, fc3, fc4) >> FAIL: gdb.base/varargs.exp: print find_max_double_real(4, dc1, dc2, dc3, dc4) >> >> # of expected passes 9 >> # of unexpected failures 2 >> >> After applying the patch: >> # of expected passes 11 >> >> Signed-off-by: Youling Tang >> --- >> gdb/mips-tdep.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c >> index 7e37578..cddb8f8 100644 >> --- a/gdb/mips-tdep.c >> +++ b/gdb/mips-tdep.c >> @@ -5224,9 +5224,10 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function, >> >> if (TYPE_LENGTH (type) > 2 * MIPS64_REGSIZE) >> return RETURN_VALUE_STRUCT_CONVENTION; >> - else if (type->code () == TYPE_CODE_FLT >> + else if ((type->code () == TYPE_CODE_FLT >> && TYPE_LENGTH (type) == 16 >> && tdep->mips_fpu_type != MIPS_FPU_NONE) > Hi, > > Just minor note, those 2 lines above should be indented 2 more space I > think (so the && operator continues to vertically align with "type->code > ()"). > >> + || (type->code () == TYPE_CODE_COMPLEX)) > I do not think the extra set of parens are requires (but they do no harm > either). Ok, I will modify this code style in the next version. Thanks, Youling. > For the rest, it seems reasonable to me but I’ll let MIPS / global > maintainers comment. > > Best, > Lancelot. >> { >> /* A 128-bit floating-point value fills both $f0 and $f2. The >> two registers are used in the same as memory order, so the >> -- >> 2.1.0 >>