From patchwork Tue Oct 17 09:08:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 23634 Received: (qmail 85015 invoked by alias); 17 Oct 2017 09:08:54 -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 85001 invoked by uid 89); 17 Oct 2017 09:08:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=H*x:2.5, H*UA:2.5, adhere X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Oct 2017 09:08:50 +0000 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9H98UYD144306 for ; Tue, 17 Oct 2017 05:08:49 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dnesmrm5e-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 17 Oct 2017 05:08:48 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Oct 2017 10:08:46 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 17 Oct 2017 10:08:44 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9H98hHB25821228; Tue, 17 Oct 2017 09:08:43 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 73CF8A404D; Tue, 17 Oct 2017 10:04:09 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 57345A4040; Tue, 17 Oct 2017 10:04:09 +0100 (BST) Received: from oc3748833570.ibm.com (unknown [9.167.243.191]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 17 Oct 2017 10:04:09 +0100 (BST) Received: by oc3748833570.ibm.com (Postfix, from userid 1000) id 390EBD807C2; Tue, 17 Oct 2017 11:08:43 +0200 (CEST) Subject: Re: [RFC v2][3/3] Target FP printing: Use floatformat_to_string in tdep code To: macro@imgtec.com (Maciej W. Rozycki) Date: Tue, 17 Oct 2017 11:08:43 +0200 (CEST) From: "Ulrich Weigand" Cc: gdb-patches@sourceware.org In-Reply-To: from "Maciej W. Rozycki" at Oct 11, 2017 07:23:15 PM MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17101709-0012-0000-0000-000005828EDF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17101709-0013-0000-0000-000018FCDF72 Message-Id: <20171017090843.390EBD807C2@oc3748833570.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-17_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710170129 Maciej W. Rozycki wrote: > > A few tdep files use target-specific printing routines to output values in > > the floating-point registers. To get rid of host floating-point code, > > this patch changes them to use floatformat_to_string instead. > > > > No functional change intended, the resulting output should look the same. > > I have now quickly checked it with a single target only and unfortunately > the layout still has changed, e.g. in gdb.base/callfuncs.exp it used to > be: > > [...] > f0: 0xd2f1a9fc flt: -5.18969491e+11 dbl: -0.001 > f1: 0xbf50624d flt: -0.813999951 > f2: 0x00000000 flt: 0 dbl: 0 > f3: 0x00000000 flt: 0 > f4: 0xffffffff flt: -nan dbl: -nan > f5: 0xffffffff flt: -nan > f6: 0xffffffff flt: -nan dbl: -nan > f7: 0xffffffff flt: -nan > [...] > > while now it is: > > [...] > f0: 0xd2f1a9fc flt: -5.18969491e+11 dbl: -0.001 > f1: 0xbf50624d flt: -0.813999951 > f2: 0x00000000 flt: 0 dbl: 0 > f3: 0x00000000 flt: 0 > f4: 0xffffffff flt: -nan(0x7fffff) dbl: -nan(0xfffffffffffff) > f5: 0xffffffff flt: -nan(0x7fffff) > f6: 0xffffffff flt: -nan(0x7fffff) dbl: -nan(0xfffffffffffff) > f7: 0xffffffff flt: -nan(0x7fffff) > [...] > > so it looks to me that the NaN formatter gets the character count wrong. I see. I guess we shouldn't use the special output strings at all when using formatted printing, but rely on the underlying printer to handle all cases. (This actually matches today's behavior of printf_command, which my patches inadvertently changed.) Can you verify using this additional patch on top of the series? Thanks again, Ulrich Index: binutils-gdb/gdb/doublest.c =================================================================== --- binutils-gdb.orig/gdb/doublest.c +++ binutils-gdb/gdb/doublest.c @@ -794,22 +794,27 @@ std::string floatformat_to_string (const struct floatformat *fmt, const gdb_byte *in, const char *format) { - /* Detect invalid representations. */ - if (!floatformat_is_valid (fmt, in)) - return ""; - - /* Handle NaN and Inf. */ - enum float_kind kind = floatformat_classify (fmt, in); - if (kind == float_nan) - { - const char *sign = floatformat_is_negative (fmt, in)? "-" : ""; - const char *mantissa = floatformat_mantissa (fmt, in); - return string_printf ("%snan(0x%s)", sign, mantissa); - } - else if (kind == float_infinite) + /* Unless we need to adhere to a specific format, provide special + output for certain cases. */ + if (format == nullptr) { - const char *sign = floatformat_is_negative (fmt, in)? "-" : ""; - return string_printf ("%sinf", sign); + /* Detect invalid representations. */ + if (!floatformat_is_valid (fmt, in)) + return ""; + + /* Handle NaN and Inf. */ + enum float_kind kind = floatformat_classify (fmt, in); + if (kind == float_nan) + { + const char *sign = floatformat_is_negative (fmt, in)? "-" : ""; + const char *mantissa = floatformat_mantissa (fmt, in); + return string_printf ("%snan(0x%s)", sign, mantissa); + } + else if (kind == float_infinite) + { + const char *sign = floatformat_is_negative (fmt, in)? "-" : ""; + return string_printf ("%sinf", sign); + } } /* Determine the format string to use on the host side. */