https://github.com/Jlalond created https://github.com/llvm/llvm-project/pull/172781
This patch fixes where ELF cores will report all threads as `STOP REASON 0`. This was/is a large personal annoyance of mine; added a test to verify a default elf core process/thread has no valid stop reason. >From b5dbd41ab383ad9b74c17d450ef50a2f21a0a135 Mon Sep 17 00:00:00 2001 From: Jacob Lalonde <[email protected]> Date: Tue, 16 Dec 2025 11:27:58 -0800 Subject: [PATCH] Have ThreadELFCore not emit a stop reason for signo == 0 --- .../Plugins/Process/elf-core/ThreadElfCore.cpp | 9 +++++++++ .../Process/elf-core/ThreadElfCoreTest.cpp | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp index 7015c3c65cc7d..61f6ab0e45593 100644 --- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp @@ -276,6 +276,15 @@ bool ThreadElfCore::CalculateStopInfo() { } } + // The above code references the siginfo_t bytes from the NT_SIGINFO note. + // This is not the only way to get a signo in an ELF core, and so + // ThreadELFCore has a m_signo variable for these cases, which is populated + // with a non-zero value when there is no NT_SIGINFO note. However if this is + // 0, it's the default value and we have no valid signal and should not report + // a stop info. + if (m_signo == 0) + return false; + SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, m_signo)); return true; } diff --git a/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp b/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp index 288729b447060..68919945198d4 100644 --- a/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp +++ b/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp @@ -181,3 +181,20 @@ TEST_F(ElfCoreTest, PopulatePrStatusTest) { ASSERT_EQ(prstatus_opt->pr_pgrp, static_cast<uint32_t>(getpgrp())); ASSERT_EQ(prstatus_opt->pr_sid, static_cast<uint32_t>(getsid(gettid()))); } + +TEST_F(ElfCoreTest, NoStopReasonWhenNoPrStatus) { + ArchSpec arch{HostInfo::GetTargetTriple()}; + lldb::DebuggerSP debugger_sp = Debugger::CreateInstance(); + ASSERT_TRUE(debugger_sp); + + lldb::TargetSP target_sp = CreateTarget(debugger_sp, arch); + ASSERT_TRUE(target_sp); + + lldb::ListenerSP listener_sp(Listener::MakeListener("dummy")); + lldb::ProcessSP process_sp = + std::make_shared<DummyProcess>(target_sp, listener_sp); + ASSERT_TRUE(process_sp); + lldb::ThreadSP thread_sp = CreateThread(process_sp); + ASSERT_TRUE(thread_sp); + ASSERT_FALSE(thread_sp->ThreadStoppedForAReason()); +} _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
