Occasionally, with test-case gdb.multi/remote-with-running-inferior.exp I run
into:
...
(gdb) continue^M
Continuing.^M
^M
Thread 1.1 "remote-with-run" hit Breakpoint 1.1, main () at \
remote-with-running-inferior.c:31^M
31 for (int i = 0; i < 30; ++i)^M
(gdb) PASS: $exp: target_non_stop=auto: non_stop=off: \
continue to breakpoint: continue to breakpoint in breakpt
bt 1^M
(gdb) FAIL: $exp: target_non_stop=auto: non_stop=off: \
check inferior 1 is in breakpt
...
The problem is a race between:
- inferior 1 reaching main, and
- gdb setting a breakpoint on main.
If the breakpoint on main is set before inferior 1 reaches main, the
breakpoint triggers for inferior 1, which the test-case doesn't expect.
Fix this by setting the breakpoint on main only for inferior 2.
Tested on x86_64-linux.
PR testsuite/33621
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33621
# Allow inferior 2 to reach main. The confirms that inferior 2 can be
# set running again.
- gdb_breakpoint main
+ gdb_test "break main inferior 2" \
+ "Breakpoint $::decimal at .*"
gdb_continue_to_breakpoint "breakpoint in main"
gdb_test "bt 1" \
"#0\\s+main \\(\\) at\[^\r\n\]+" \