Fix order of inferiors in "thread apply all"

Message ID m3twe2mihn.fsf@oc1027705133.ibm.com
State New, archived
Headers

Commit Message

Andreas Arnez Aug. 30, 2016, 2:36 p.m. UTC
  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(-)
  

Comments

Pedro Alves Aug. 30, 2016, 2:44 p.m. UTC | #1
On 08/30/2016 03:36 PM, Andreas Arnez wrote:
> This inserts missing parentheses in the calculation of the comparison
> result between two different inferior numbers.  The problem was found by
> Philipp Rudo.

Whoops.

> 
> gdb/ChangeLog:
> 
> 	* thread.c (tp_array_compar): Insert missing parentheses.
> 
> gdb/testsuite/ChangeLog:
> 
> 	* gdb.multi/tids.exp: Test "thread apply all".

OK.

Thanks,
Pedro Alves
  
Andreas Arnez Aug. 30, 2016, 3:08 p.m. UTC | #2
On Tue, Aug 30 2016, Pedro Alves wrote:

> On 08/30/2016 03:36 PM, Andreas Arnez wrote:
>> This inserts missing parentheses in the calculation of the comparison
>> result between two different inferior numbers.  The problem was found by
>> Philipp Rudo.
>
> Whoops.
>
>> 
>> gdb/ChangeLog:
>> 
>> 	* thread.c (tp_array_compar): Insert missing parentheses.
>> 
>> gdb/testsuite/ChangeLog:
>> 
>> 	* gdb.multi/tids.exp: Test "thread apply all".
>
> OK.

Thanks, pushed.

--
Andreas
  

Patch

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));
     }