[Lldb-commits] [lldb] r349397 - Remove sleep() synchronisation from teststcase and
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 18 08:07:10 PST 2018
> On Dec 18, 2018, at 12:11 AM, Pavel Labath <pavel at labath.sk> wrote:
> Not that I want to defend the use of sleep, but my expectation is that this will the test even more flaky.
> The only thing that test does after attaching is verifying the process backtrace to check that it contains the "main" function. If the test doesn't sleep, it increases the likelyhood that you will attach before it even enters the main function. This may be particularly true on linux, where the process needs to invoke a special api (PR_SET_TRACER) before we can attach to it, and so the even the attach will fail if it's done too early.
> One of the patterns for synchronization we have in other tests is to have the inferior create a file when it reaches the "safe to attach" point. The test then waits for this file to appear (lldbutil.wait_for_file_on_target) before proceeding. This still uses sleep() under the hood, but only because we don't have/don't want to implement a wait_for_file blocking api. In the end it still provides a more predictable state of the process we attach to.
That is an excellent idea. My first thought was to use piped IO to communicate that the process has launched but then immediately realized that this doesn't work on a remote platform. I'll try the file method!
More information about the lldb-commits