[lldb/test] Don't use preexec_fn for launching inferiors
authorPavel Labath <pavel@labath.sk>
Fri, 1 Jul 2022 12:32:50 +0000 (14:32 +0200)
committerPavel Labath <pavel@labath.sk>
Fri, 1 Jul 2022 12:36:01 +0000 (14:36 +0200)
commitb15b1421bc9a11b318b65b489e5fd58dd917db1f
tree7956491226784f96588468855b83ae4c9d24dac5
parentfabe915705472e2c06ed1aa9a90620462594e82f
[lldb/test] Don't use preexec_fn for launching inferiors

As the documentation states, using this is not safe in multithreaded
programs, and I have traced it to a rare deadlock in some of the tests.

The reason this was introduced was to be able to attach to a program
from the very first instruction, where our usual mechanism of
synchronization -- waiting for a file to appear -- does not work.

However, this is only needed for a single test
(TestGdbRemoteAttachWait) so instead of doing this everywhere, I create
a bespoke solution for that single test. The solution basically
consists of outsourcing the preexec_fn code to a separate (and
single-threaded) shim process, which enables attaching and then executes
the real program.

This pattern could be generalized in case we needed to use it for other
tests, but I suspect that we will not be having many tests like this.

This effectively reverts commit
a997a1d7fbe229433fb458bb0035b32424ecf3bd.
lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/tools/lldb-server/attach-wait/Makefile [new file with mode: 0644]
lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py [moved from lldb/test/API/tools/lldb-server/TestGdbRemoteAttachWait.py with 80% similarity]
lldb/test/API/tools/lldb-server/attach-wait/main.cpp [new file with mode: 0644]
lldb/test/API/tools/lldb-server/attach-wait/shim.cpp [new file with mode: 0644]