[Lldb-commits] [lldb] [LLDB][ELF CORE] Only display a stop reason when there is a valid signo (PR #172781)
Jacob Lalonde via lldb-commits
lldb-commits at lists.llvm.org
Wed Jan 7 15:00:46 PST 2026
https://github.com/Jlalond updated https://github.com/llvm/llvm-project/pull/172781
>From b5dbd41ab383ad9b74c17d450ef50a2f21a0a135 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Tue, 16 Dec 2025 11:27:58 -0800
Subject: [PATCH 1/2] 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());
+}
>From a6b3e7c30388ceaa1070fece0aaf2149eedc2066 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde <jalalonde at fb.com>
Date: Wed, 7 Jan 2026 14:59:47 -0800
Subject: [PATCH 2/2] Also check for the siginfo_t bytes are empty before
failing out to handle cases where the NT_SIGINFO data is not handled by the
target platform
---
lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
index 61f6ab0e45593..0141931957f45 100644
--- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -282,7 +282,7 @@ bool ThreadElfCore::CalculateStopInfo() {
// 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)
+ if (m_signo == 0 && !m_siginfo_bytes.empty())
return false;
SetStopInfo(StopInfo::CreateStopReasonWithSignal(*this, m_signo));
More information about the lldb-commits
mailing list