[gdb/testsuite] Fix gdb.threads/schedlock.exp for gcc 4.8.5
authorTom de Vries <tdevries@suse.de>
Mon, 20 Feb 2023 10:16:02 +0000 (11:16 +0100)
committerTom de Vries <tdevries@suse.de>
Mon, 20 Feb 2023 10:16:02 +0000 (11:16 +0100)
commit13d4a4bd5a7a686d8d5473a4c93b7798de97f745
treec3cb0e628f8052cb4bdf3066cc5bc682bf034b87
parentc50e4ced39b19ae49748634356c8c37e18427129
[gdb/testsuite] Fix gdb.threads/schedlock.exp for gcc 4.8.5

Since commit 9af467b8240 ("[gdb/testsuite] Fix gdb.threads/schedlock.exp on
fast cpu"), the test-case fails for gcc 4.8.5.

The problem is that for gcc 4.8.5, the commit turned a two-line loop:
...
(gdb) next
78          while (*myp > 0)
(gdb) next
81              MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
(gdb) next
78          while (*myp > 0)
...
into a three-line loop:
...
(gdb) next
83              MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
(gdb) next
84              cnt++;
(gdb) next
85            }
(gdb) next
83              MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
(gdb)
...
and the test-case doesn't expect this.

Fix this by reverting back to the original loop shape as much as possible by:
- removing the cnt++ line
- replacing "while (1)" with "while (one)", where one is a volatile variable
  set to 1.

Tested on x86_64-linux, using compilers:
- gcc 4.8.5, 7.5.0, 12.2.1
- clang 4.0.1, 13.0.1
gdb/testsuite/gdb.threads/schedlock.c