[Lldb-commits] [lldb] [NFCI][lldb][test] Enable GNU POSIX extensions where necessary (PR #166768)

via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 6 05:12:21 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Raul Tambre (tambry)

<details>
<summary>Changes</summary>

Otherwise these tests are reliant on the compiler defaulting to having the extensions on. Rest of LLVM's codebase doesn't seem to make such assumptions.

Tested by building with `-std=c2y` in Clang's C frotend's config file.

---
Full diff: https://github.com/llvm/llvm-project/pull/166768.diff


7 Files Affected:

- (modified) lldb/test/API/commands/expression/call-restarts/lotta-signals.c (+6-2) 
- (modified) lldb/test/API/driver/quit_speed/main.c (+4) 
- (modified) lldb/test/API/functionalities/process_group/main.c (+4) 
- (modified) lldb/test/API/lang/c/tls_globals/a.c (+4) 
- (modified) lldb/test/API/lang/c/tls_globals/main.c (+4-1) 
- (modified) lldb/test/Shell/Commands/Inputs/sigchld.c (+4) 
- (modified) lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test (+2-2) 


``````````diff
diff --git a/lldb/test/API/commands/expression/call-restarts/lotta-signals.c b/lldb/test/API/commands/expression/call-restarts/lotta-signals.c
index f5c15b41e2de3..149ceb787f707 100644
--- a/lldb/test/API/commands/expression/call-restarts/lotta-signals.c
+++ b/lldb/test/API/commands/expression/call-restarts/lotta-signals.c
@@ -1,3 +1,7 @@
+#if defined(__linux__)
+#define _DEFAULT_SOURCE /* for kill(), usleep() and GNU's signal() */
+#endif
+
 #include <unistd.h>
 #include <stdio.h>
 #include <signal.h>
@@ -46,12 +50,12 @@ call_me_nosig (int some_value)
   return some_value;
 }
 
-int 
+int
 main ()
 {
   int ret_val;
   signal (SIGCHLD, sigchld_handler);
-  
+
   ret_val = call_me (2);  // Stop here in main.
 
   ret_val = call_me_nosig (10);
diff --git a/lldb/test/API/driver/quit_speed/main.c b/lldb/test/API/driver/quit_speed/main.c
index 3d6d45ce5e806..95e4de911ccfa 100644
--- a/lldb/test/API/driver/quit_speed/main.c
+++ b/lldb/test/API/driver/quit_speed/main.c
@@ -1,3 +1,7 @@
+#if defined(__linux__)
+#define _XOPEN_SOURCE 500 /* for usleep() */
+#endif
+
 #include <unistd.h>
 
 int main (int argc, char **argv) {
diff --git a/lldb/test/API/functionalities/process_group/main.c b/lldb/test/API/functionalities/process_group/main.c
index b4d5abc58169c..75c2b41351c3e 100644
--- a/lldb/test/API/functionalities/process_group/main.c
+++ b/lldb/test/API/functionalities/process_group/main.c
@@ -1,3 +1,7 @@
+#if defined(__linux__)
+#define _XOPEN_SOURCE 500 /* for getpgid() */
+#endif
+
 #include "attach.h"
 #include <stdio.h>
 #include <sys/wait.h>
diff --git a/lldb/test/API/lang/c/tls_globals/a.c b/lldb/test/API/lang/c/tls_globals/a.c
index f63108d8cceb1..16bfeaeca0a78 100644
--- a/lldb/test/API/lang/c/tls_globals/a.c
+++ b/lldb/test/API/lang/c/tls_globals/a.c
@@ -1,3 +1,7 @@
+#if defined(__linux__)
+#define _XOPEN_SOURCE 500 /* for usleep() */
+#endif
+
 #include <unistd.h>
 
 __thread int var_shared = 33;
diff --git a/lldb/test/API/lang/c/tls_globals/main.c b/lldb/test/API/lang/c/tls_globals/main.c
index fac760b350ab2..e6a6d3c868462 100644
--- a/lldb/test/API/lang/c/tls_globals/main.c
+++ b/lldb/test/API/lang/c/tls_globals/main.c
@@ -1,4 +1,7 @@
-#include <stdio.h>
+#if defined(__linux__)
+#define _XOPEN_SOURCE 500 /* for usleep() */
+#endif
+
 #include <pthread.h>
 #include <unistd.h>
 
diff --git a/lldb/test/Shell/Commands/Inputs/sigchld.c b/lldb/test/Shell/Commands/Inputs/sigchld.c
index ba8c5ef45365b..0121e70c1bdd0 100644
--- a/lldb/test/Shell/Commands/Inputs/sigchld.c
+++ b/lldb/test/Shell/Commands/Inputs/sigchld.c
@@ -1,3 +1,7 @@
+#if defined(__linux__)
+#define _XOPEN_SOURCE 500 /* for CLD_EXITED */
+#endif
+
 #include <assert.h>
 #include <signal.h>
 #include <stdio.h>
diff --git a/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test b/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
index fa4a93e5904aa..9987efedd8020 100644
--- a/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
+++ b/lldb/test/Shell/Commands/command-list-reach-beginning-of-file.test
@@ -4,7 +4,7 @@
 # RUN: %lldb %t.out -b -s %s 2>&1 | FileCheck %s
 
 list
-# CHECK: note: No source available 
+# CHECK: note: No source available
 
 b main
 # CHECK: Breakpoint 1:
@@ -18,7 +18,7 @@ list
 list -
 # CHECK: int main()
 
-list -10
+list -13
 # CHECK: #include <assert.h>
 
 list -

``````````

</details>


https://github.com/llvm/llvm-project/pull/166768


More information about the lldb-commits mailing list