aboutsummaryrefslogtreecommitdiff
path: root/gdb/linux-nat.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2022-02-23 11:17:26 +0000
committerPedro Alves <pedro@palves.net>2022-03-10 11:35:53 +0000
commitcdff184f42743670a499bbac6b69c2d504760a78 (patch)
treed2d56f132073c26baca3980541b27361297a38a2 /gdb/linux-nat.c
parente48359eaa8c4c79a40a21726c9fa823241793b1e (diff)
downloadbinutils-cdff184f42743670a499bbac6b69c2d504760a78.zip
binutils-cdff184f42743670a499bbac6b69c2d504760a78.tar.gz
binutils-cdff184f42743670a499bbac6b69c2d504760a78.tar.bz2
Fix gdb.threads/clone-new-thread-event.exp race
If we make GDB report the process EXIT event for the leader thread, instead of whatever is the last thread in the LWP list, as will be done in a latter patch of this series, then gdb.threads/current-lwp-dead.exp starts failing: (gdb) FAIL: gdb.threads/clone-new-thread-event.exp: catch SIGUSR1 (the program exited) This is a testcase race -- the main thread does not wait for the spawned clone "thread" to finish before exiting, so the main program may exit before the second thread is scheduled and reports its SIGUSR1. With the change to make GDB report the EXIT for the leader, the race is 100% reproducible by adding a sleep(), like so: --- c/gdb/testsuite/gdb.threads/clone-new-thread-event.c +++ w/gdb/testsuite/gdb.threads/clone-new-thread-event.c @@ -51,6 +51,7 @@ local_gettid (void) static int fn (void *unused) { + sleep (1); tkill (local_gettid (), SIGUSR1); return 0; } Resulting in: Breakpoint 1, main (argc=1, argv=0x7fffffffd418) at gdb.threads/clone-new-thread-event.c:65 65 stack = malloc (STACK_SIZE); (gdb) continue Continuing. [New LWP 3715562] [Inferior 1 (process 3715555) exited normally] (gdb) FAIL: gdb.threads/clone-new-thread-event.exp: catch SIGUSR1 (the program exited) That inferior exit reported is actually correct. The main thread has indeed exited, and that's the thread that has the right exit code to report to the user, as that's the exit code that is reported to the program's parent. In this case, GDB managed to collect the exit code for the leader thread before reaping the other thread, because in reality, the testcase isn't creating standard threads, it is using raw clone, and the new clones are put in their own thread group. Fix it by making the main thread wait for the child to exit. Also, run the program to completion for completeness. Change-Id: I315cd3dc2b9e860395dcab9658341ea868d7a6bf
Diffstat (limited to 'gdb/linux-nat.c')
0 files changed, 0 insertions, 0 deletions