ftmemsim-valgrind/gdbserver_tests/nlcontrolc.stdinB.gdb
Philippe Waroquiers c79180a3af Fix nlcontrolc.vgtest hanging on newer glibc and/or arm64
This test verifies that GDB can interrupt a process with all threads
blocked in a long select syscall.
The test used to terminate by having GDB modifying the select argument.
However, modifying the select argument works only for specific arch
and/or specific versions of glibc.
The test then blocks on other architectures/glibc versions.

The previous version of the test was:
  * first launching sleepers so as to have all threads blocked in long select
  * interrupting these threads
  * changing the select time arg so that the threads burn cpu
  * and then change variables to have the program exit.

The new version does:
  * first launches sleepers so that all threads are burning cpu.
  * interrupting these threads
  * change the local variables of sleepers so that the threads will
    block in a long select syscall
  * interrupt these threads
  * kill the program.

With this new version, we still check the behaviour of gdb+vgdbserver
for both burning and sleep threads, but without having the termination
depending on modifying select syscall argument.

Tested on debian amd64 and on ubuntu arm64 (to check the test does not hang
on an arm64 platform).
2021-03-07 22:35:58 +01:00

52 lines
1.6 KiB
Plaintext

# connect gdb to Valgrind gdbserver:
target remote | ./vgdb --wait=60 --vgdb-prefix=./vgdb-prefix-nlcontrolc
echo vgdb launched process attached\n
monitor v.set vgdb-error 999999
#
#
# simulate control-c in a few seconds
shell ./simulate_control_c --vgdb-prefix=./vgdb-prefix-nlcontrolc 1 grep main nlcontrolc.stderr.out
#
continue
#
# Threads are burning cpu now
# We would like to fully test info threads here, but which thread are Runnable
# or Yielding is unpredictable. With a recent enough gdb, check the nr of
# threads by state using pipe commands and grep/wc.
init-if-undefined $_gdb_major = 0
init-if-undefined $_gdb_minor = 0
if $_gdb_major >= 9
| info threads | grep VgTs_Runnable | wc -l
| info threads | grep VgTs_Yielding | wc -l
else
echo 1\n
echo 3\n
end
# We change the variables so that all the threads are blocked in a syscall
p burn = 0
p sleepms = 1000000
#
#
shell ./simulate_control_c --vgdb-prefix=./vgdb-prefix-nlcontrolc 1 grep changed nlcontrolc.stdoutB.out
#
echo changed burning parameters to sleeping parameters\n
continue
# Here, all tasks should be blocked in a loooonnnng select, all in WaitSys
info threads
# We reset the sleepms to 0. The threads should still be blocked in the syscall
p sleepms = 0
shell ./simulate_control_c --vgdb-prefix=./vgdb-prefix-nlcontrolc 1 grep reset nlcontrolc.stdoutB.out
#
echo reset to sleeping parameters\n
continue
# threads should still be blocked in a loooonnnng select, all in WaitSys
info threads
if $_gdb_major >= 9
| info threads | grep VgTs_WaitSys | wc -l
else
echo 4\n
end
# Make the process die.
kill
quit