]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdbserver/linux-low.cc
Bail out of "attach" if a thread cannot be traced
authorTom Tromey <tromey@adacore.com>
Fri, 8 Sep 2023 14:25:15 +0000 (08:25 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 1 Dec 2023 17:36:00 +0000 (10:36 -0700)
commitc6f7f9c80c3b92c6d877214d38aaef141adc5b93
tree243638f58de9fe248d6193ffffa913a0ab25ae38
parent596cd22cb10519f9baad6295fed13443d1ef86f9
Bail out of "attach" if a thread cannot be traced

On Linux, threads are treated much like separate processes by the
kernel.  In particular, it's possible to ptrace just a single thread.
If gdb tries to attach to a multi-threaded inferior, where a non-main
thread is already being traced (e.g., by strace), then gdb will get
into an infinite loop attempting to attach.

This patch fixes this problem by having the attach fail if ptrace
fails to attach to any thread of the inferior.
gdb/linux-nat.c
gdb/testsuite/gdb.base/traced-thread.c [new file with mode: 0644]
gdb/testsuite/gdb.base/traced-thread.exp [new file with mode: 0644]
gdbserver/linux-low.cc