From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id F0AA93858C51 for ; Wed, 16 Mar 2022 04:48:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F0AA93858C51 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 bogon.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9AxuswabDFilwkKAA--.7241S2; Wed, 16 Mar 2022 12:48:26 +0800 (CST) From: Youling Tang To: gdb-patches@sourceware.org, "Maciej W. Rozycki" Subject: [PATCH] gdb: mips: Fix the handling of complex type of function return value Date: Wed, 16 Mar 2022 12:48:26 +0800 Message-Id: <1647406106-25723-1-git-send-email-tangyouling@loongson.cn> X-Mailer: git-send-email 2.1.0 X-CM-TRANSID: AQAAf9AxuswabDFilwkKAA--.7241S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr15tr4xtF1ktF43XF4rAFb_yoW8CFW3p3 yayr1xuFWrXw1xAF4xKw4rXr4fCw47JryDGr4S9rWj9a17W34fC3y2qr4Ykr4DGws8tr17 Gwnxta1jvF4fA3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkYb7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I 8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI 64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r106r15McIj6I8E87Iv67AKxVWUJVW8Jw Am72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lc2xSY4AK67AK6r45MxAIw28I cxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2 IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUXVWUAwCIc40Y0x0EwIxGrwCI 42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42 IY6xAIw20EY4v20xvaj40_Zr0_Wr1UMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2 jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU5pa0JUUUUU== X-CM-SenderInfo: 5wdqw5prxox03j6o00pqjv00gofq/ X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Wed, 16 Mar 2022 04:48:31 -0000 $ 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) + || (type->code () == TYPE_CODE_COMPLEX)) { /* 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