From ac0108ed8c596d7618a563b9b027a5980de3e5e1 Mon Sep 17 00:00:00 2001 From: Xusheng Date: Tue, 11 Apr 2023 17:51:32 +0800 Subject: [PATCH] Fix LLDB not updating the target status on time when debugging an ELF without dynamic loader --- core/adapters/lldbadapter.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/adapters/lldbadapter.cpp b/core/adapters/lldbadapter.cpp index 7283886..553d28d 100644 --- a/core/adapters/lldbadapter.cpp +++ b/core/adapters/lldbadapter.cpp @@ -999,7 +999,10 @@ DebugStopReason LldbAdapter::StopReason() { StateType state = m_process.GetState(); if (state == lldb::eStateExited) + { + LogWarn("target exited"); return DebugStopReason::ProcessExited; + } if (state == lldb::eStateStopped) { @@ -1387,7 +1390,12 @@ void LldbAdapter::EventListener() FixActiveThread(); DebuggerEvent dbgevt; dbgevt.type = AdapterStoppedEventType; - dbgevt.data.targetStoppedData.reason = StopReason(); + // LLDB sometimes fails to update the process status when it is already sending eStateStopped event. + // When we restart the process, the target will appear to have exited + auto reason = StopReason(); + if (reason == ProcessExited) + reason = UnknownReason; + dbgevt.data.targetStoppedData.reason = reason; PostDebuggerEvent(dbgevt); break; }