[Lldb-commits] [PATCH] D42210: Re-enable logging on the child side of a fork() in lldb-server platform mode

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 17 15:55:47 PST 2018


jasonmolenda created this revision.
jasonmolenda added a reviewer: labath.
jasonmolenda added a project: LLDB.
Herald added a subscriber: llvm-commits.

When lldb-server is in platform mode and waiting for a connection, when it receives a connection it fork()'s and then runs an lldb-server/debugserver to respond to that connection.  The amount of things done between a fork() and an exec() should be very small, but if there is a bug in lldb-server and you're trying to use logging to debug it, the fact that logging does not happen in the child process makes it challenging to understand what is going on.

The fact that the logging re-enablement in the child will only happen when done by hand makes me more comfortable with this.

Pavel, do you think you're the best person to talk to about this?  I've tested this on darwin and on ubuntu and both exhibit the same behavior.  e.g.

terminal1% ./a.out

terminal2% bin/lldb-server platform --verbose --log-channels 'lldb all:gdb-remote all' --server --listen '*:11110' -m 11120 -M 11250

terminal3% lldb
(lldb) pla sel remote-linux
(lldb) pla connect connect://localhost:11110
(lldb) pla pro att -n a.out

without this patch, the only logging you'll see is lldb-server waiting for a connection, receiving a connection, and that's about it.


Repository:
  rL LLVM

https://reviews.llvm.org/D42210

Files:
  tools/lldb-server/lldb-platform.cpp


Index: tools/lldb-server/lldb-platform.cpp
===================================================================
--- tools/lldb-server/lldb-platform.cpp
+++ tools/lldb-server/lldb-platform.cpp
@@ -328,6 +328,10 @@
         // Parent will continue to listen for new connections.
         continue;
       } else {
+        // We lose the logging on the child side of the fork, re-enable it.  
+        if (!LLDBServerUtilities::SetupLogging(log_file, log_channels, 0))
+          return -1;
+
         // Child process will handle the connection and exit.
         g_server = 0;
         // Listening socket is owned by parent process.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42210.130305.patch
Type: text/x-patch
Size: 633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180117/ec56440c/attachment.bin>


More information about the lldb-commits mailing list