[Reproducer] Disconnect when the replay server is out of packets.
authorJonas Devlieghere <jonas@devlieghere.com>
Mon, 9 Sep 2019 22:05:48 +0000 (22:05 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Mon, 9 Sep 2019 22:05:48 +0000 (22:05 +0000)
This is a fix for the issue described in r371144.

> On more than one occasion I've found this test got stuck during replay
> while waiting for a packet from debugserver when the debugger was in
> the process of being destroyed.

When the replay server is out of packets we should just disconnect so
the debugger doesn't have to do any cleanup that it wouldn't do during
capture.

llvm-svn: 371459

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp

index 417f573..39304a6 100644 (file)
@@ -9,6 +9,7 @@
 #include <errno.h>
 
 #include "lldb/Host/Config.h"
+#include "llvm/ADT/ScopeExit.h"
 
 #include "GDBRemoteCommunicationReplayServer.h"
 #include "ProcessGDBRemoteLog.h"
@@ -256,11 +257,10 @@ void GDBRemoteCommunicationReplayServer::ReceivePacket(
 thread_result_t GDBRemoteCommunicationReplayServer::AsyncThread(void *arg) {
   GDBRemoteCommunicationReplayServer *server =
       (GDBRemoteCommunicationReplayServer *)arg;
-
+  auto D = make_scope_exit([&]() { server->Disconnect(); });
   EventSP event_sp;
   bool done = false;
-
-  while (true) {
+  while (!done) {
     if (server->m_async_listener_sp->GetEvent(event_sp, llvm::None)) {
       const uint32_t event_type = event_sp->GetType();
       if (event_sp->BroadcasterIs(&server->m_async_broadcaster)) {