From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26240 invoked by alias); 20 Apr 2004 18:03:53 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 26233 invoked from network); 20 Apr 2004 18:03:50 -0000 Received: from unknown (HELO dublin.act-europe.fr) (212.157.227.154) by sources.redhat.com with SMTP; 20 Apr 2004 18:03:50 -0000 Received: from localhost (province.act-europe.fr [10.10.0.214]) by filtered-dublin.act-europe.fr (Postfix) with ESMTP id 1C195229E80 for ; Tue, 20 Apr 2004 20:03:49 +0200 (MET DST) Received: from dublin.act-europe.fr ([10.10.0.154]) by localhost (province.act-europe.fr [10.10.0.214]) (amavisd-new, port 10024) with ESMTP id 79185-05 for ; Tue, 20 Apr 2004 20:03:49 +0200 (CEST) Received: from berne.act-europe.fr (berne.act-europe.fr [10.10.0.165]) by dublin.act-europe.fr (Postfix) with ESMTP id E57F9229E39 for ; Tue, 20 Apr 2004 20:03:48 +0200 (MET DST) Received: by berne.act-europe.fr (Postfix, from userid 560) id 8F846592B; Tue, 20 Apr 2004 14:03:48 -0400 (EDT) Date: Tue, 20 Apr 2004 18:03:00 -0000 From: Jerome Guitton To: gdb-patches@sources.redhat.com Subject: [RFA] powerpc - extract a float return value Message-ID: <20040420180348.GA23715@act-europe.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="LZvS9be/3tNcYl/X" Content-Disposition: inline User-Agent: Mutt/1.4i X-Virus-Scanned: by amavisd-new at act-europe.fr X-SW-Source: 2004-04/txt/msg00468.txt.bz2 --LZvS9be/3tNcYl/X Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 607 Hello GDB folks, The way GDB extracts float return values in rs6000-tdep.c (rs6000_extract_return_value) seems dubious to me: [...] memcpy (&dd, ®buf[DEPRECATED_REGISTER_BYTE (FP0_REGNUM + 1)], 8); ff = (float) dd; memcpy (valbuf, &ff, sizeof (float)); [...] The cast will not work properly if the target and the host have not a similar float representation. I propose to fix that by a call to convert_typed_floating. See patch in attachment. I have not yet tested it against the testsuite, I will do that tomorrow. In the meantime, if you have comments I would be happy to address them! -- Jerome --LZvS9be/3tNcYl/X Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="diff.2" Content-length: 1301 2004-04-20 Jerome Guitton * rs6000-tdep.c (rs6000_extract_return_value): When extracting a float, use convert_typed_floating to get the appropriate format. Index: rs6000-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/rs6000-tdep.c,v retrieving revision 1.191 diff -u -p -r1.191 rs6000-tdep.c --- rs6000-tdep.c 1 Apr 2004 21:00:59 -0000 1.191 +++ rs6000-tdep.c 20 Apr 2004 17:45:24 -0000 @@ -1251,8 +1251,6 @@ rs6000_extract_return_value (struct type if (TYPE_CODE (valtype) == TYPE_CODE_FLT) { - double dd; - float ff; /* floats and doubles are returned in fpr1. fpr's have a size of 8 bytes. We need to truncate the return value into float size (4 byte) if necessary. */ @@ -1263,9 +1261,11 @@ rs6000_extract_return_value (struct type TYPE_LENGTH (valtype)); else { /* float */ - memcpy (&dd, ®buf[DEPRECATED_REGISTER_BYTE (FP0_REGNUM + 1)], 8); - ff = (float) dd; - memcpy (valbuf, &ff, sizeof (float)); + convert_typed_floating (®buf[DEPRECATED_REGISTER_BYTE + (FP0_REGNUM + 1)], + builtin_type_double, + valbuf, + valtype); } } else if (TYPE_CODE (valtype) == TYPE_CODE_ARRAY --LZvS9be/3tNcYl/X--