jasonmolenda created this revision. jasonmolenda added a reviewer: davide. jasonmolenda added a project: LLDB. Herald added subscribers: llvm-commits, JDevlieghere.
I hit this while trying to debug lldb-server. When lldb-server is waiting for connections, it will be in MainLoop::RunImpl::Poll(), in the kevent() call. On darwin systems, attaching to the process (or interrupting it to add a breakpoint or detach) will interrupt the system call it is sitting in. We will get back an error return value (-1) and errno will be set to EINTR. Currently we flag this as an error and lldb-server exits with error: IO object is not valid. which makes it a bit difficult to debug. This section of code is only used on the *BSD systems and Darwin (it's #ifdef'ed HAVE_SYS_EVENT_H). I tested it on Darwin and on Linux (before noticing that linux doesn't have sys/event.h) but don't have access to a *BSD system. I don't expect any problems handling the interrupted kevent() call on those systems as I'm doing here. Repository: rLLD LLVM Linker https://reviews.llvm.org/D42206 Files: source/Host/common/MainLoop.cpp Index: source/Host/common/MainLoop.cpp =================================================================== --- source/Host/common/MainLoop.cpp +++ source/Host/common/MainLoop.cpp @@ -105,8 +105,11 @@ for (auto &fd : loop.m_read_fds) EV_SET(&in_events[i++], fd.first, EVFILT_READ, EV_ADD, 0, 0, 0); - num_events = kevent(loop.m_kqueue, in_events.data(), in_events.size(), - out_events, llvm::array_lengthof(out_events), nullptr); + do { + errno = 0; + num_events = kevent(loop.m_kqueue, in_events.data(), in_events.size(), + out_events, llvm::array_lengthof(out_events), nullptr); + } while (num_events == -1 && errno == EINTR); if (num_events < 0) return Status("kevent() failed with error %d\n", num_events);
Index: source/Host/common/MainLoop.cpp =================================================================== --- source/Host/common/MainLoop.cpp +++ source/Host/common/MainLoop.cpp @@ -105,8 +105,11 @@ for (auto &fd : loop.m_read_fds) EV_SET(&in_events[i++], fd.first, EVFILT_READ, EV_ADD, 0, 0, 0); - num_events = kevent(loop.m_kqueue, in_events.data(), in_events.size(), - out_events, llvm::array_lengthof(out_events), nullptr); + do { + errno = 0; + num_events = kevent(loop.m_kqueue, in_events.data(), in_events.size(), + out_events, llvm::array_lengthof(out_events), nullptr); + } while (num_events == -1 && errno == EINTR); if (num_events < 0) return Status("kevent() failed with error %d\n", num_events);
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits