[Lldb-commits] [lldb] [lldb][test] check if CoreDumping is supported at runtime (PR #161385)

Ebuka Ezike via lldb-commits lldb-commits at lists.llvm.org
Tue Sep 30 07:41:31 PDT 2025


https://github.com/da-viper created https://github.com/llvm/llvm-project/pull/161385

#160333 reimplementation but at runtime instead because of broken CI. 

>From bbc894aab1a2c58611b84025362422f5aa0821ac Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Tue, 30 Sep 2025 14:22:55 +0100
Subject: [PATCH 1/2] Revert "[lldb][test] check if CoreDumping info is
 supported (#160333)"

This reverts commit 02d8fb5789f64ed9cff3f42b005105a51c6c7550.
---
 lldb/unittests/Host/posix/HostTest.cpp | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/lldb/unittests/Host/posix/HostTest.cpp b/lldb/unittests/Host/posix/HostTest.cpp
index dc75b288ba76a..082edccf4e774 100644
--- a/lldb/unittests/Host/posix/HostTest.cpp
+++ b/lldb/unittests/Host/posix/HostTest.cpp
@@ -15,10 +15,6 @@
 #include <cerrno>
 #include <sys/resource.h>
 
-#ifdef __linux__
-#include <linux/version.h>
-#endif // __linux__
-
 using namespace lldb_private;
 
 namespace {
@@ -120,12 +116,7 @@ TEST_F(HostTest, GetProcessInfoSetsPriority) {
   ASSERT_TRUE(Info.IsZombie().has_value());
   ASSERT_FALSE(Info.IsZombie().value());
 
-  // CoreDumping was added in kernel version 4.15.
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
   ASSERT_TRUE(Info.IsCoreDumping().has_value());
   ASSERT_FALSE(Info.IsCoreDumping().value());
-#else
-  ASSERT_FALSE(Info.IsCoreDumping().has_value());
-#endif
 }
 #endif

>From 7d3221629ec8da1e96363a2aa3783584f56cbaa4 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Tue, 30 Sep 2025 15:37:20 +0100
Subject: [PATCH 2/2] [lldb][test] check if CoreDumping is supported at runtime

---
 lldb/unittests/Host/posix/HostTest.cpp | 40 ++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/lldb/unittests/Host/posix/HostTest.cpp b/lldb/unittests/Host/posix/HostTest.cpp
index 082edccf4e774..d4f6d10ec5d3d 100644
--- a/lldb/unittests/Host/posix/HostTest.cpp
+++ b/lldb/unittests/Host/posix/HostTest.cpp
@@ -15,6 +15,12 @@
 #include <cerrno>
 #include <sys/resource.h>
 
+#ifdef __linux__
+#include <linux/version.h>
+#include <sstream>
+#include <sys/utsname.h>
+#endif // __linux__
+
 using namespace lldb_private;
 
 namespace {
@@ -94,6 +100,28 @@ TEST_F(HostTest, GetProcessInfo) {
 
 // Only linux currently sets these.
 #ifdef __linux__
+
+int KernelVersion(int major, int minor, int patch) {
+  return KERNEL_VERSION(major, minor, patch);
+}
+
+std::optional<int> GetLinuxVersion() {
+  struct utsname buffer;
+
+  if (uname(&buffer) != 0)
+    return std::nullopt;
+
+  std::stringstream release(buffer.release);
+  int major = 0;
+  int minor = 0;
+  int patch = 0;
+  release >> major;
+  release >> minor;
+  release >> patch;
+
+  return KernelVersion(major, minor, patch);
+}
+
 TEST_F(HostTest, GetProcessInfoSetsPriority) {
   ProcessInstanceInfo Info;
   struct rlimit rlim;
@@ -116,7 +144,15 @@ TEST_F(HostTest, GetProcessInfoSetsPriority) {
   ASSERT_TRUE(Info.IsZombie().has_value());
   ASSERT_FALSE(Info.IsZombie().value());
 
-  ASSERT_TRUE(Info.IsCoreDumping().has_value());
-  ASSERT_FALSE(Info.IsCoreDumping().value());
+  std::optional<int> opt_linux_version = GetLinuxVersion();
+  if (opt_linux_version.has_value()) {
+
+    if (opt_linux_version.value() >= KernelVersion(4, 15, 0)) {
+      ASSERT_TRUE(Info.IsCoreDumping().has_value());
+      ASSERT_FALSE(Info.IsCoreDumping().value());
+    } else {
+      ASSERT_FALSE(Info.IsCoreDumping().has_value());
+    }
+  }
 }
 #endif



More information about the lldb-commits mailing list