From patchwork Thu Sep 15 11:52:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 15660 Received: (qmail 29982 invoked by alias); 15 Sep 2016 11:54:09 -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 29969 invoked by uid 89); 15 Sep 2016 11:54:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.2 spammy=Hx-languages-length:1405, rudo X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 15 Sep 2016 11:54:07 +0000 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id u8FBr8pn127251 for ; Thu, 15 Sep 2016 07:54:06 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 25fr7xrxta-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 15 Sep 2016 07:54:05 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Sep 2016 12:54:03 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 15 Sep 2016 12:54:01 +0100 X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: arnez@linux.vnet.ibm.com X-IBM-RcptTo: gdb-patches@sourceware.org Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 315501B0804B for ; Thu, 15 Sep 2016 12:55:50 +0100 (BST) Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u8FBs1TE18350370 for ; Thu, 15 Sep 2016 11:54:01 GMT Received: from d06av03.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u8FBs0uq024633 for ; Thu, 15 Sep 2016 05:54:00 -0600 Received: from oc1027705133.ibm.com (dyn-9-152-212-159.boeblingen.de.ibm.com [9.152.212.159]) by d06av03.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u8FBrJf9022548 for ; Thu, 15 Sep 2016 05:54:00 -0600 From: Andreas Arnez To: gdb-patches@sourceware.org Subject: [PATCH] Fix order of inferiors in "thread apply all" Date: Thu, 15 Sep 2016 13:52:32 +0200 In-Reply-To: <1473940399-2891-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1473940399-2891-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16091511-0008-0000-0000-000002C5A572 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16091511-0009-0000-0000-000019D85ABF Message-Id: <1473940399-2891-2-git-send-email-arnez@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-09-15_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609020000 definitions=main-1609150161 X-IsSubscribed: yes This inserts missing parentheses in the calculation of the comparison result between two different inferior numbers. The problem was found by Philipp Rudo. gdb/ChangeLog: * thread.c (tp_array_compar): Insert missing parentheses. gdb/testsuite/ChangeLog: * gdb.multi/tids.exp: Test "thread apply all". --- gdb/testsuite/gdb.multi/tids.exp | 6 ++++++ gdb/thread.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.multi/tids.exp b/gdb/testsuite/gdb.multi/tids.exp index 5d8701e..12ce98a 100644 --- a/gdb/testsuite/gdb.multi/tids.exp +++ b/gdb/testsuite/gdb.multi/tids.exp @@ -224,6 +224,12 @@ with_test_prefix "two inferiors" { thr_apply_info_thr "1.1-2 2.2-3" \ "1.1 1.2 2.2 2.3" + # All threads. + thread_apply "all" \ + "2.3 2.2 2.1 1.3 1.2 1.1" + thread_apply "all -ascending" \ + "1.1 1.2 1.3 2.1 2.2 2.3" + # Now test using GDB convenience variables. gdb_test "p \$inf = 1" " = 1" diff --git a/gdb/thread.c b/gdb/thread.c index ab98777..a66a2b5 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -1725,7 +1725,7 @@ tp_array_compar (const void *ap_voidp, const void *bp_voidp) if (a->inf->num != b->inf->num) { - return ((a->inf->num > b->inf->num) - (a->inf->num < b->inf->num) + return (((a->inf->num > b->inf->num) - (a->inf->num < b->inf->num)) * (tp_array_compar_ascending ? +1 : -1)); }