[lldb/Target] Fix event handling during process launch

This patch fixes process event handling when the events are broadcasted
at launch. To do so, the patch introduces a new listener to fetch events
by hand off the event queue and then resending them ensure the event ordering.

Differental Revision: https://reviews.llvm.org/D105698

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
This commit is contained in:
Med Ismail Bennani 2021-07-12 12:32:07 +01:00
parent 88024a724c
commit 8266b7ea7d
1 changed files with 6 additions and 0 deletions

View File

@ -10,6 +10,7 @@
#include <memory>
#include <mutex>
#include "llvm/ADT/ScopeExit.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/Threading.h"
@ -2473,6 +2474,11 @@ Status Process::Launch(ProcessLaunchInfo &launch_info) {
if (error.Fail())
return error;
// Listen and queue events that are broadcasted during the process launch.
ListenerSP listener_sp(Listener::MakeListener("LaunchEventHijack"));
HijackProcessEvents(listener_sp);
auto on_exit = llvm::make_scope_exit([this]() { RestoreProcessEvents(); });
if (PrivateStateThreadIsValid())
PausePrivateStateThread();