Skip to content

Commit e31e539

Browse files
committed
[debugserver] Remove unnecessary sleep in MachProcess::AttachForDebug
Remove the unnecessary sleep in MachProcess::AttachForDebug. The preceding comment makes it seem like it's necessary for synchronization, though I don't believe that's the case (see below), and even if it were, sleeping is not a reliable way to achieve that. The reason I don't believe it's necessary is because after we return, we synchronize with the exception thread on a state change. The latter will call and update the process state, which is exactly what we synchronize on. I was able to verify that this is the first time we change the process state: i.e., `GetState` doesn't return a different value before and after the sleep. On top of that, there are 3 more places where we call ptrace attach (`PosixSpawnChildForPTraceDebugging`, `SBLaunchForDebug`, and `BoardServiceLaunchForDebug`) where we don't sleep. rdar://163952037
1 parent bd9030e commit e31e539

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,12 +2853,6 @@ static uint64_t bits(uint64_t value, uint32_t msbit, uint32_t lsbit) {
28532853

28542854
if (err.Success()) {
28552855
m_flags |= eMachProcessFlagsAttached;
2856-
// Sleep a bit to let the exception get received and set our process
2857-
// status
2858-
// to stopped.
2859-
::usleep(250000);
2860-
DNBLog("[LaunchAttach] (%d) Done napping after ptrace(PT_ATTACHEXC)'ing",
2861-
getpid());
28622856
DNBLogThreadedIf(LOG_PROCESS, "successfully attached to pid %d", pid);
28632857
return m_pid;
28642858
} else {

0 commit comments

Comments
 (0)