This is an archive of the discontinued LLVM Phabricator instance.

When darwin-debug exec's inferior suspended, make debugserver know that suspend count is higher than normal
ClosedPublic

Authored by jasonmolenda on Jan 17 2020, 3:35 PM.

Details

Summary

darwin-debug is used to launch a binary while setting the current working directory/env vars/architecture, exec'ing it stopped so lldb can attach to it. This is used on macOS to launch a binary in a new Terminal window via AppleScript. If lldb attaches to the inferior, stopped on the first instruction, all is good. But if lldb attaches before the inferior is running, it will attach to darwin-debug, see the Exec mach exception when the inferior is run, but instead of the normal suspend count of 1 at this point, because darwin-debug asked it to be launch suspended, the suspend count will be 2. debugserver needs to double-resume the inferior to make it run.

This patch adds a specially named segment to darwin-debug so that it can be detected unambiguously by debugserver.

In debugserver, if we attach to a process with the specially named segment, set a flag that will be checked the next time we received an Exec mach exception. When that Exec comes in, set a flag that will be checked the next time we go to resume the inferior to indicate that we need to resume it twice to allow it to run.

Diff Detail

Event Timeline

jasonmolenda created this revision.Jan 17 2020, 3:35 PM

We do have people that don't create debugserver and just use the installed one to avoid code signing. Will there be any issue with people using older debugservers?

This revision was not accepted when it landed; it landed in state Needs Review.Jan 21 2020, 3:00 PM
This revision was automatically updated to reflect the committed changes.