From e61491954f5e5aaa5469dc869a2301c1a41de28d Mon Sep 17 00:00:00 2001 From: Xusheng Date: Thu, 1 Dec 2022 17:31:10 +0800 Subject: [PATCH] Fix LLDB event listener --- core/adapters/lldbadapter.cpp | 37 ++++++++--------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/core/adapters/lldbadapter.cpp b/core/adapters/lldbadapter.cpp index f3c09750..09056dba 100644 --- a/core/adapters/lldbadapter.cpp +++ b/core/adapters/lldbadapter.cpp @@ -53,7 +53,11 @@ LldbAdapter::LldbAdapter(BinaryView* data) : DebugAdapter(data) } -LldbAdapter::~LldbAdapter() {} +LldbAdapter::~LldbAdapter() +{ + m_process.Destroy(); + SBDebugger::Destroy(m_debugger); +} LldbAdapterType::LldbAdapterType() : DebugAdapterType("LLDB") {} @@ -1213,25 +1217,12 @@ void LldbAdapter::FixActiveThread() void LldbAdapter::EventListener() { - SBEvent event; - SBListener listener = SBListener("listener"); - listener.StartListeningForEventClass(m_debugger, SBProcess::GetBroadcasterClassName(), - lldb::SBProcess::eBroadcastBitStateChanged | - lldb::SBProcess::eBroadcastBitSTDERR | - lldb::SBProcess::eBroadcastBitSTDOUT); - - listener.StartListeningForEventClass(m_debugger, SBTarget::GetBroadcasterClassName(), - lldb::SBTarget::eBroadcastBitBreakpointChanged | - lldb::SBTarget::eBroadcastBitModulesLoaded | - lldb::SBTarget::eBroadcastBitModulesUnloaded); - - listener.StartListeningForEventClass(m_debugger, SBCommandInterpreter::GetBroadcasterClass(), - lldb::SBCommandInterpreter::eBroadcastBitAsynchronousErrorData | - lldb::SBCommandInterpreter::eBroadcastBitAsynchronousOutputData); + auto listener = m_debugger.GetListener(); bool done = false; while (!done) { + SBEvent event; if (!listener.WaitForEvent(1, event)) continue; @@ -1410,19 +1401,7 @@ void LldbAdapter::EventListener() } } - listener.StopListeningForEventClass(m_debugger, SBProcess::GetBroadcasterClassName(), - lldb::SBProcess::eBroadcastBitStateChanged | - lldb::SBProcess::eBroadcastBitSTDERR | - lldb::SBProcess::eBroadcastBitSTDOUT); - - listener.StopListeningForEventClass(m_debugger, SBTarget::GetBroadcasterClassName(), - lldb::SBTarget::eBroadcastBitBreakpointChanged | - lldb::SBTarget::eBroadcastBitModulesLoaded | - lldb::SBTarget::eBroadcastBitModulesUnloaded); - - listener.StopListeningForEventClass(m_debugger, SBCommandInterpreter::GetBroadcasterClass(), - lldb::SBCommandInterpreter::eBroadcastBitAsynchronousErrorData | - lldb::SBCommandInterpreter::eBroadcastBitAsynchronousOutputData); + listener.Clear(); }