[lldb-dev] LLDB Process Attach Failed When Waiting

Ryan Lovelett via lldb-dev lldb-dev at lists.llvm.org
Wed Jun 6 19:07:40 PDT 2018


> Sleep is used to make the system sleep the current thread a little bit 
> between polling for processes by name. If the sleep isn't there, we will 
> light up a CPU with really quick polling for the processes by name, so 
> we should use usleep() which take a sleep amount in microseconds to not 
> peg the CPU at 100% while waiting.

Are there any objections to using std::this_thread::sleep_for? The headers seem to already be included and other tools inside the project seem to make use of it.

Another "issue" I've encountered is related to Ubuntu's ptrace protection [1]. If ptrace is blocked for non-child processes then you get an error. In lldb you'd see "error: attach failed: lost connection" but in the logs of the lldb-server you'd see "GDBRemoteCommunicationServerLLGS::Handle_vAttachWait failed to attach to process named langserver-swift: Operation not permitted". Of note is the "Operation not permitted".

While I'm still not sure how to check for the presence of the ptrace protection (so that a more detailed error can be provided). I think displaying "operation not permitted" is more indicative of the underlying error than "lost connection". So here's the question: is there a way that I could go about surfacing that error back to main lldb?

[1] https://wiki.ubuntu.com/SecurityTeam/Roadmap/KernelHardening#ptrace_Protection


More information about the lldb-dev mailing list