[Lldb-commits] [PATCH] D11066: Introduce a MainLoop class and switch llgs to use it

Adrian McCarthy amccarth at google.com
Thu Jul 9 16:54:37 PDT 2015


amccarth added a comment.

Assuming I've understood correctly ...

I don't think any approach will completely eliminate the need for a separate thread on Windows to run the debug loop (at least, not without an inefficient hack like polling for events).

On Windows, debug events are special--they don't work like other types of asynchronous events, so you can't just wait for them like you might wait for an asynchronous i/o or for some handle to become signaled.  Nor is there a hybrid wait function (like MsgWaitForMultipleObjects that lets you wait for a either a windows message or a handle to become signaled).  As far as I know, there's just WaitForDebugEvent, which only waits for debug events (and imposes some restrictions on other things that can be done in that thread).  You could poll by waiting with a 0 timeout, but that would be an inefficient hack, so that's a non-starter.

But that doesn't rule out this MainLoop abstraction.  A simple debug loop in a separate thread could translate raw Windows debugging events into events that could be detected by MainLoop.  So if MainLoop helps on other platforms, the Windows implementation could be made to work with this model, probably without a significant difference in performance or code complexity.


================
Comment at: include/lldb/Host/posix/MainLoopPosix.h:23
@@ +22,3 @@
+// using select(), and when they become readable, the specified callback will be invoked.
+// Montitoring for writability is not supported, but can be easily added if needed. Additionally,
+// this class supports invoking a callback when the process recieves a given signal.
----------------
s/Montitoring/Monitoring/

================
Comment at: include/lldb/Host/posix/MainLoopPosix.h:24
@@ +23,3 @@
+// Montitoring for writability is not supported, but can be easily added if needed. Additionally,
+// this class supports invoking a callback when the process recieves a given signal.
+//
----------------
s/recieves/receives/

================
Comment at: include/lldb/Host/posix/MainLoopPosix.h:81
@@ +80,3 @@
+    // signal handler. However, since the callback is not invoked synchronously, you cannot use
+    // this mechanism to handle SIGSEGV and the like.
+    SignalHandleUP
----------------
What sorts of signals might this mechanism be used for?

Be aware that Windows defines fewer signals than POSIX.

================
Comment at: include/lldb/Host/windows/MainLoopWindows.h:21
@@ +20,3 @@
+
+class MainLoopWindows
+{
----------------
Is there a particular reason you didn't defined a common interface in a base class that both MainLoopWindows and MainLoopPosix would derive from?  Is it concern over the performance of virtual function calls?  Or are you expecting different platforms to provide significantly different public interfaces?


http://reviews.llvm.org/D11066







More information about the lldb-commits mailing list