From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19865 invoked by alias); 24 Jul 2012 16:37:54 -0000 Received: (qmail 19750 invoked by uid 22791); 24 Jul 2012 16:37:52 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,TW_EG X-Spam-Check-By: sourceware.org Received: from mail-out.m-online.net (HELO mail-out.m-online.net) (212.18.0.9) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 24 Jul 2012 16:37:38 +0000 Received: from frontend1.mail.m-online.net (unknown [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3WhQGT1Rjlz4KK9P for ; Tue, 24 Jul 2012 18:37:37 +0200 (CEST) X-Auth-Info: 9x1BDlgIAFhsWOfugzuGyAABz6YN3NaqhpPz+ZxoBek= Received: from igel.home (ppp-88-217-117-46.dynamic.mnet-online.de [88.217.117.46]) by mail.mnet-online.de (Postfix) with ESMTPA id 3WhQGT146Qzbbg2 for ; Tue, 24 Jul 2012 18:37:37 +0200 (CEST) Received: by igel.home (Postfix, from userid 501) id F330CCA2A2; Tue, 24 Jul 2012 18:37:35 +0200 (CEST) From: Andreas Schwab To: gdb-patches@sourceware.org Subject: [PATCH] Handle complex return values like structure types X-Yow: When you said ``HEAVILY FORESTED'' it reminded me of an overdue CLEANING BILL.. Don't you SEE? O'Grogan SWALLOWED a VALUABLE COIN COLLECTION and HAD to murder the ONLY MAN who KNEW!! Date: Tue, 24 Jul 2012 16:37:00 -0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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-07/txt/msg00495.txt.bz2 Complex types are basically just structures with two fields, and they are handled like this wrt the return method. Tested on m68k-linux and committed. Andreas. * m68k-tdep.c (m68k_reg_struct_return_p): Accept complex types. (m68k_return_value): Handle complex types like structures. (m68k_svr4_return_value): Likewise. --- gdb/m68k-tdep.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index b1e2cd4..b507c37 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -377,8 +377,8 @@ m68k_svr4_store_return_value (struct type *type, struct regcache *regcache, m68k_store_return_value (type, regcache, valbuf); } -/* Return non-zero if TYPE, which is assumed to be a structure or - union type, should be returned in registers for architecture +/* Return non-zero if TYPE, which is assumed to be a structure, union or + complex type, should be returned in registers for architecture GDBARCH. */ static int @@ -388,7 +388,8 @@ m68k_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type) enum type_code code = TYPE_CODE (type); int len = TYPE_LENGTH (type); - gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION); + gdb_assert (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION + || code == TYPE_CODE_COMPLEX); if (tdep->struct_return == pcc_struct_return) return 0; @@ -410,7 +411,8 @@ m68k_return_value (struct gdbarch *gdbarch, struct value *function, enum type_code code = TYPE_CODE (type); /* GCC returns a `long double' in memory too. */ - if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION) + if (((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION + || code == TYPE_CODE_COMPLEX) && !m68k_reg_struct_return_p (gdbarch, type)) || (code == TYPE_CODE_FLT && TYPE_LENGTH (type) == 12)) { @@ -444,7 +446,8 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function, { enum type_code code = TYPE_CODE (type); - if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION) + if ((code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION + || code == TYPE_CODE_COMPLEX) && !m68k_reg_struct_return_p (gdbarch, type)) { /* The System V ABI says that: -- 1.7.11.3 -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."