From patchwork Fri Nov 3 13:45:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 24071 Received: (qmail 82739 invoked by alias); 3 Nov 2017 13:45:57 -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 82724 invoked by uid 89); 3 Nov 2017 13:45:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=huh 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; Fri, 03 Nov 2017 13:45:55 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vA3Djgr7098945 for ; Fri, 3 Nov 2017 09:45:53 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2e0rcsmhrm-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 03 Nov 2017 09:45:53 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 3 Nov 2017 13:45:52 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 3 Nov 2017 13:45:50 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vA3DjnvD27853036; Fri, 3 Nov 2017 13:45:49 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5E6C7AE051; Fri, 3 Nov 2017 13:39:32 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A3F8AE053; Fri, 3 Nov 2017 13:39:32 +0000 (GMT) Received: from oc3748833570.ibm.com (unknown [9.164.154.25]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 3 Nov 2017 13:39:32 +0000 (GMT) Received: by oc3748833570.ibm.com (Postfix, from userid 1000) id 26512D804DA; Fri, 3 Nov 2017 14:45:49 +0100 (CET) Subject: Re: [pushed] Re: [RFC][08/19] Target FP: Use target format throughout expression parsing To: qiyaoltc@gmail.com (Yao Qi) Date: Fri, 3 Nov 2017 14:45:49 +0100 (CET) From: "Ulrich Weigand" Cc: simark@simark.ca (Simon Marchi), brobecker@adacore.com (Joel Brobecker), gdb-patches@sourceware.org In-Reply-To: <20171103123319.GA318@1170ee0b50d5> from "Yao Qi" at Nov 03, 2017 12:33:19 PM MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17110313-0008-0000-0000-000004A732F6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17110313-0009-0000-0000-00001E39C009 Message-Id: <20171103134549.26512D804DA@oc3748833570.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-03_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1711030166 Yao Qi wrote: > On 17-10-25 15:35:24, Ulrich Weigand wrote: > > > On 2017-10-09 02:12 PM, Joel Brobecker wrote: > > > > One C++ thing I did notice but forgot to report... > > > > > > > >> +floatformat_from_string (const struct floatformat *fmt, gdb_byte *out, > > > >> + std::string in) > > > > > > > > Again, to be double-checked, but I think you want to pass the argument > > > > by reference in this case. Otherwise, you may end up having an overhead > > > > with might not be necessary due to the creation of a copy of the string > > > > being passed as argument here. > > > > > > > > > > Indeed, it's good practice to pass constant strings (or other objects) as > > > const references (const std::string &in). > > > > I've now pushed this patch (using the const reference as suggested). > > > > Hi Ulrich, > this patch causes a regression on arm target, > > PASS -> FAIL: gdb.base/bitops.exp: print value of 0.0 || 0 > > https://sourceware.org/ml/gdb-testers/2017-q4/msg03040.html > Do you have any clues? Huh. It looks like this exposed a bug in convert_doublest_to_floatformat that was already present: in the very specific case of converting a value of zero into the floatformats_ieee_double_littlebyte_bigword format, the output buffer was simply left uninitialized. Existing callers didn't notice since they had zeroed out the input buffer anyway ... I was able to reproduce it without an ARM system: (gdb) set architecture arm The target architecture is assumed to be arm (gdb) set debug expression 1 (gdb) print 0.0 Dump of expression @ 0x3ae6e10, before conversion to prefix form: Language c, 4 elements, 16 bytes each. Index Opcode Hex Value String Value 0 OP_FLOAT 39 '............... 1 61822288 PU.............. 2 BINOP_ADD 1 .........Q...... 3 OP_FLOAT 39 '............... Dump of expression @ 0x3ae6e10, after conversion to prefix form: Expression: `2.1219957909652723e-314' Language c, 4 elements, 16 bytes each. 0 OP_FLOAT Type @0x3af5550 (double), value 2.1219957909652723e-314 $1 = 2.1219957909652723e-314 Can you test whether the following patch fixes the problem on a real ARM system? Thanks, Ulrich diff --git a/gdb/doublest.c b/gdb/doublest.c index fe9fc23..ef98dde 100644 --- a/gdb/doublest.c +++ b/gdb/doublest.c @@ -387,7 +387,7 @@ convert_doublest_to_floatformat (const struct floatformat *fmt, } if (dfrom == 0) - return; /* Result is zero */ + goto finalize_byteorder; /* Result is zero */ if (dfrom != dfrom) /* Result is NaN */ { /* From is NaN */