[Lldb-commits] [PATCH] D41069: NPL: Clean up handling of inferior exit

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 11 09:37:26 PST 2017


labath added a comment.

In https://reviews.llvm.org/D41069#951208, @clayborg wrote:

> Is the lldb_private::Process we have an exit status in the class itself. The first person to set the exit status wins and no one can set it twice. Doesn't look like what we are doing here. I am not able to tell what actually fixes things here?


The `Process` class is in the client. The problem I am fixing is in server code, which was sending the `Wxx` packet multiple times. The happened because on linux we get one ptrace stop before the process dies (in this state its memory still exists, so we could still inspect it, if we wanted to) and then another one after its death (this happens after zombification of the process), and we were sending the packet after both.



================
Comment at: source/Plugins/Process/Linux/NativeProcessLinux.cpp:439
-        // The main thread exited.  We're done monitoring.  Report to delegate.
-        SetExitStatus(status, true);
 
----------------
This is where the second packet got sent. Now it's the only place that sends death packets.


================
Comment at: source/Plugins/Process/Linux/NativeProcessLinux.cpp:681
-    if (is_main_thread)
-      SetExitStatus(WaitStatus::Decode(data), true);
 
----------------
This is what sent the first packet (it eventually trickles down into GDBRemoteCommunicationServerLLGS::HandleInferiorState_Exited, which is what does the sending). Deleting it fixes things.


https://reviews.llvm.org/D41069





More information about the lldb-commits mailing list