[Lldb-commits] [lldb] [lldb] Fix trace load hang (PR #187768)
Tom Hewitt via lldb-commits
lldb-commits at lists.llvm.org
Tue Mar 24 08:22:02 PDT 2026
https://github.com/tom-hewitt updated https://github.com/llvm/llvm-project/pull/187768
>From 1485fdda9bf95fc77e3550d32b33661418306c33 Mon Sep 17 00:00:00 2001
From: Tom Hewitt <47860067+tom-hewitt at users.noreply.github.com>
Date: Fri, 20 Mar 2026 19:00:14 +0000
Subject: [PATCH] [lldb] Fix trace load hang
This fix reintroduces the `SetPrivateState` call so a postmortem trace process will "stop" after being loaded, matching the logic used in `Process::LoadCore()`.
---
lldb/source/Target/ProcessTrace.cpp | 4 +++
lldb/unittests/Process/ProcessTraceTest.cpp | 27 ++++++++++++++++++++-
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Target/ProcessTrace.cpp b/lldb/source/Target/ProcessTrace.cpp
index 8b7d194aa0767..e2dcd7231b71d 100644
--- a/lldb/source/Target/ProcessTrace.cpp
+++ b/lldb/source/Target/ProcessTrace.cpp
@@ -72,6 +72,10 @@ void ProcessTrace::DidAttach(ArchSpec &process_arch) {
return;
}
+ // Pretend we stopped so we can show all of the threads
+ // in the trace and explore the final state.
+ SetPrivateState(lldb::eStateStopped);
+
EventSP event_sp;
WaitForProcessToStop(std::nullopt, &event_sp, true, listener_sp);
diff --git a/lldb/unittests/Process/ProcessTraceTest.cpp b/lldb/unittests/Process/ProcessTraceTest.cpp
index 0bf7ddcbbda21..811298f7b44b8 100644
--- a/lldb/unittests/Process/ProcessTraceTest.cpp
+++ b/lldb/unittests/Process/ProcessTraceTest.cpp
@@ -1,4 +1,4 @@
-//===-- ProcessEventDataTest.cpp ------------------------------------------===//
+//===-- ProcessTraceTest.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -61,3 +61,28 @@ TEST_F(ProcessTraceTest, ConstructorWithNullptrCoreFile) {
ASSERT_NE(process_sp, nullptr);
}
+
+// Test that a trace process stops after attaching.
+TEST_F(ProcessTraceTest, DidAttach) {
+ ArchSpec arch("i386-pc-linux");
+
+ Platform::SetHostPlatform(PlatformLinux::CreateInstance(true, &arch));
+ ASSERT_NE(Platform::GetHostPlatform(), nullptr);
+
+ DebuggerSP debugger_sp = Debugger::CreateInstance();
+ ASSERT_TRUE(debugger_sp);
+
+ TargetSP target_sp = CreateTarget(debugger_sp, arch);
+ ASSERT_TRUE(target_sp);
+
+ ProcessSP process_sp = target_sp->CreateProcess(
+ /*listener*/ nullptr, "trace",
+ /*crash_file*/ nullptr,
+ /*can_connect*/ false);
+
+ ASSERT_NE(process_sp, nullptr);
+
+ process_sp->DidAttach(arch);
+
+ ASSERT_EQ(process_sp->GetState(), lldb::eStateStopped);
+}
More information about the lldb-commits
mailing list