https://github.com/Teemperor created 
https://github.com/llvm/llvm-project/pull/204072

System includes slow down test compilation and create unnecessary dependencies 
on system header code.

This patch removes system headers from tests that do not test their 
functionality. For the most part, this just removes the dummy 'printf' we had 
in many tests.

>From ef004d74b824b3486137520e5c1e0ca73f309dba Mon Sep 17 00:00:00 2001
From: Raphael Isemann <[email protected]>
Date: Wed, 10 Jun 2026 16:21:37 +0100
Subject: [PATCH] [lldb] Remove several system header includes from tests

System includes slow down test compilation and create unnecessary
dependencies on system header code.

This patch removes system headers from tests that do not test their
functionality. For the most part, this just removes the dummy 'printf'
we had in many tests.
---
 lldb/test/API/api/listeners/main.c            |  3 ---
 .../commands/expression/ir-interpreter/main.c |  5 +----
 .../commands/expression/radar_9673664/main.c  |  4 +---
 .../commands/expression/top-level/dummy.cpp   |  4 +---
 .../commands/expression/weak_symbols/main.c   | 20 ++++++++++---------
 lldb/test/API/functionalities/asan/main.c     |  3 +--
 .../functionalities/memory-region/main.cpp    |  3 ---
 .../functionalities/object-file/bin/hello.c   |  3 ---
 .../functionalities/object-file/bin/hello.cpp |  3 ---
 .../process_save_core_minidump/main.cpp       |  5 +----
 .../step-vrs-interrupt/main.cpp               |  2 --
 .../thread/create_after_attach/main.cpp       |  2 --
 .../functionalities/tsan/thread_leak/main.c   |  2 --
 .../c/const_variables/TestConstVariables.py   |  1 -
 lldb/test/API/lang/c/const_variables/main.c   |  2 --
 .../test/API/macosx/profile_vrs_detach/main.c |  2 --
 lldb/test/API/python_api/breakpoint/main.c    |  3 ---
 .../python_api/process/address-masks/main.c   |  4 +---
 .../python_api/unified_section_list/main.cpp  |  3 ---
 lldb/test/API/tools/lldb-dap/cancel/main.c    |  3 ---
 .../tools/lldb-dap/eventStatistic/main.cpp    |  2 --
 .../API/tools/lldb-dap/locations/main.cpp     |  4 ++--
 lldb/test/API/tools/lldb-dap/restart/main.c   |  5 +----
 .../test/API/tools/lldb-dap/send-event/main.c |  5 +----
 .../lldb-dap/stackTrace/subtleFrames/main.cpp |  5 ++---
 .../API/tools/lldb-dap/startDebugging/main.c  |  5 +----
 .../tools/lldb-dap/terminated-event/main.cpp  |  3 +--
 lldb/test/API/tools/lldb-dap/unknown/main.c   |  3 ---
 28 files changed, 25 insertions(+), 84 deletions(-)

diff --git a/lldb/test/API/api/listeners/main.c 
b/lldb/test/API/api/listeners/main.c
index f930e51191582..df67b9156b427 100644
--- a/lldb/test/API/api/listeners/main.c
+++ b/lldb/test/API/api/listeners/main.c
@@ -1,7 +1,4 @@
-#include <stdio.h>
-
 int
 main()
 {
-    printf ("Hello there.\n");
 }
diff --git a/lldb/test/API/commands/expression/ir-interpreter/main.c 
b/lldb/test/API/commands/expression/ir-interpreter/main.c
index 31204b21d972a..fcf46a18b76f3 100644
--- a/lldb/test/API/commands/expression/ir-interpreter/main.c
+++ b/lldb/test/API/commands/expression/ir-interpreter/main.c
@@ -1,7 +1,4 @@
-#include <stdio.h>
-
 int main()
 {
-    printf("This is a dummy\n"); // Set breakpoint here   
-    return 0;
+    return 0; // Set breakpoint here
 }
diff --git a/lldb/test/API/commands/expression/radar_9673664/main.c 
b/lldb/test/API/commands/expression/radar_9673664/main.c
index f29faf0af1fff..11fbb32bdc4be 100644
--- a/lldb/test/API/commands/expression/radar_9673664/main.c
+++ b/lldb/test/API/commands/expression/radar_9673664/main.c
@@ -1,8 +1,6 @@
-#include <stdio.h>
-
 int main (int argc, char const *argv[])
 {
-    printf("Hello, world.\n"); // Set breakpoint here.
+    return 0; // Set breakpoint here.
     
     return 0;
 }
diff --git a/lldb/test/API/commands/expression/top-level/dummy.cpp 
b/lldb/test/API/commands/expression/top-level/dummy.cpp
index fa49bd4bda7e3..ca27c31e06158 100644
--- a/lldb/test/API/commands/expression/top-level/dummy.cpp
+++ b/lldb/test/API/commands/expression/top-level/dummy.cpp
@@ -1,5 +1,3 @@
-#include <stdio.h>
-
 // These are needed to make sure that the linker does not strip the parts of 
the
 // C++ abi library that are necessary to execute the expressions in the
 // debugger. It would be great if we did not need to do this, but the fact that
@@ -10,6 +8,6 @@ struct DummyB : public virtual DummyA {};
 
 int main() {
   DummyB b;
-  printf("This is a dummy\n"); // Set breakpoint here
+  (void)b; // Set breakpoint here
   return 0;
 }
diff --git a/lldb/test/API/commands/expression/weak_symbols/main.c 
b/lldb/test/API/commands/expression/weak_symbols/main.c
index 5ea257bae5b9c..0689c31bef756 100644
--- a/lldb/test/API/commands/expression/weak_symbols/main.c
+++ b/lldb/test/API/commands/expression/weak_symbols/main.c
@@ -1,18 +1,20 @@
 #include "dylib.h"
-#include <stdio.h>
+
+int sink;
+void *sinkPtr;
 
 int
 doSomething()
 {
   // Set a breakpoint here.
-  if (&absent_weak_int != NULL)
-    printf("In absent_weak_int: %d\n", absent_weak_int);
-  if (absent_weak_function != NULL)
-    printf("In absent_weak_func: %p\n", absent_weak_function);
-  if (&present_weak_int != NULL)
-    printf("In present_weak_int: %d\n", present_weak_int);
-  if (present_weak_function != NULL)
-    printf("In present_weak_func: %p\n", present_weak_function);
+  if (&absent_weak_int != 0)
+    sink = absent_weak_int;
+  if (absent_weak_function != 0)
+    sinkPtr = absent_weak_function;
+  if (&present_weak_int != 0)
+    sink = present_weak_int;
+  if (present_weak_function != 0)
+    sinkPtr = present_weak_function;
 
 }
 
diff --git a/lldb/test/API/functionalities/asan/main.c 
b/lldb/test/API/functionalities/asan/main.c
index 85e7c5ec64edb..32a61aaf671b1 100644
--- a/lldb/test/API/functionalities/asan/main.c
+++ b/lldb/test/API/functionalities/asan/main.c
@@ -1,4 +1,3 @@
-#include <stdio.h>
 #include <stdlib.h>
 
 char *pointer;
@@ -18,7 +17,7 @@ int main (int argc, char const *argv[])
     f1();
     f2();
 
-    printf("Hello world!\n"); // break line
+    int bp = 0; // break line
 
     pointer[0] = 'A'; // BOOM line
 
diff --git a/lldb/test/API/functionalities/memory-region/main.cpp 
b/lldb/test/API/functionalities/memory-region/main.cpp
index 116c10a6c3eab..14478f0c75094 100644
--- a/lldb/test/API/functionalities/memory-region/main.cpp
+++ b/lldb/test/API/functionalities/memory-region/main.cpp
@@ -1,6 +1,3 @@
-#include <iostream>
-
 int main (int argc, char const **argv) {
-  std::cout << "Program with sections" << std::endl;
   return 0; // Run here before printing memory regions
 }
diff --git a/lldb/test/API/functionalities/object-file/bin/hello.c 
b/lldb/test/API/functionalities/object-file/bin/hello.c
index 8c804005afe3e..d6d52c9cbe506 100644
--- a/lldb/test/API/functionalities/object-file/bin/hello.c
+++ b/lldb/test/API/functionalities/object-file/bin/hello.c
@@ -1,8 +1,5 @@
-#include <stdio.h>
-
 int main(int argc, char **argv)
 {
-       printf("Hello, world\n");
        return 0;
 }
 
diff --git a/lldb/test/API/functionalities/object-file/bin/hello.cpp 
b/lldb/test/API/functionalities/object-file/bin/hello.cpp
index 8c804005afe3e..d6d52c9cbe506 100644
--- a/lldb/test/API/functionalities/object-file/bin/hello.cpp
+++ b/lldb/test/API/functionalities/object-file/bin/hello.cpp
@@ -1,8 +1,5 @@
-#include <stdio.h>
-
 int main(int argc, char **argv)
 {
-       printf("Hello, world\n");
        return 0;
 }
 
diff --git a/lldb/test/API/functionalities/process_save_core_minidump/main.cpp 
b/lldb/test/API/functionalities/process_save_core_minidump/main.cpp
index 15daa68e9a648..2abd712ae7195 100644
--- a/lldb/test/API/functionalities/process_save_core_minidump/main.cpp
+++ b/lldb/test/API/functionalities/process_save_core_minidump/main.cpp
@@ -1,5 +1,4 @@
 #include <cassert>
-#include <iostream>
 #include <thread>
 thread_local size_t lf = 42;
 
@@ -20,10 +19,8 @@ size_t h() {
 int main() {
   std::thread t1(f);
 
-  size_t x = h();
+  h();
 
   t1.join();
-
-  std::cout << "X is " << x << "\n";
   return 0;
 }
diff --git a/lldb/test/API/functionalities/step-vrs-interrupt/main.cpp 
b/lldb/test/API/functionalities/step-vrs-interrupt/main.cpp
index 2c818921ee5f1..15f4e0475a2b9 100644
--- a/lldb/test/API/functionalities/step-vrs-interrupt/main.cpp
+++ b/lldb/test/API/functionalities/step-vrs-interrupt/main.cpp
@@ -1,9 +1,7 @@
-#include <stdio.h>
 #include <chrono>
 #include <thread>
 
 void call_me() {
-  printf("I was called");
   std::this_thread::sleep_for(std::chrono::seconds(3));
 }
 
diff --git a/lldb/test/API/functionalities/thread/create_after_attach/main.cpp 
b/lldb/test/API/functionalities/thread/create_after_attach/main.cpp
index d99fb05f08315..caf53fd82dc0b 100644
--- a/lldb/test/API/functionalities/thread/create_after_attach/main.cpp
+++ b/lldb/test/API/functionalities/thread/create_after_attach/main.cpp
@@ -1,6 +1,5 @@
 #include "attach.h"
 #include <chrono>
-#include <cstdio>
 #include <thread>
 
 using std::chrono::microseconds;
@@ -58,5 +57,4 @@ int main(int argc, char const *argv[])
     thread_1.join();
     thread_2.join();
 
-    printf("Exiting now\n");
 }
diff --git a/lldb/test/API/functionalities/tsan/thread_leak/main.c 
b/lldb/test/API/functionalities/tsan/thread_leak/main.c
index c773bec3f1c50..f8ba2851a527b 100644
--- a/lldb/test/API/functionalities/tsan/thread_leak/main.c
+++ b/lldb/test/API/functionalities/tsan/thread_leak/main.c
@@ -1,9 +1,7 @@
 #include <pthread.h>
-#include <stdio.h>
 #include <stdlib.h>
 
 void *f1(void *p) {
-    printf("hello\n");
     return NULL;
 }
 
diff --git a/lldb/test/API/lang/c/const_variables/TestConstVariables.py 
b/lldb/test/API/lang/c/const_variables/TestConstVariables.py
index 0b75f88682acf..70d0825cf7330 100644
--- a/lldb/test/API/lang/c/const_variables/TestConstVariables.py
+++ b/lldb/test/API/lang/c/const_variables/TestConstVariables.py
@@ -35,7 +35,6 @@ def test_and_run_command(self):
         # The breakpoint should have a hit count of 1.
         lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
 
-        self.runCmd("next")
         self.runCmd("next")
 
         # Try frame variable.
diff --git a/lldb/test/API/lang/c/const_variables/main.c 
b/lldb/test/API/lang/c/const_variables/main.c
index 50a924e01d948..d135f14da0ffc 100644
--- a/lldb/test/API/lang/c/const_variables/main.c
+++ b/lldb/test/API/lang/c/const_variables/main.c
@@ -1,5 +1,4 @@
 #include <stdint.h>
-#include <stdio.h>
 
 extern int foo();
 extern int bar();
@@ -15,7 +14,6 @@ int main()
 
   if (bar())
   {
-    printf("COMPILER PLEASE STOP HERE\n");
     index = 256;
   }
 
diff --git a/lldb/test/API/macosx/profile_vrs_detach/main.c 
b/lldb/test/API/macosx/profile_vrs_detach/main.c
index 939308414edcf..21762b6208ad1 100644
--- a/lldb/test/API/macosx/profile_vrs_detach/main.c
+++ b/lldb/test/API/macosx/profile_vrs_detach/main.c
@@ -1,4 +1,3 @@
-#include <stdio.h>
 #include <unistd.h>
 
 int
@@ -6,7 +5,6 @@ main()
 {
   while (1) {
     sleep(1); // Set a breakpoint here
-    printf("I slept\n");
   }
   return 0;
 }
diff --git a/lldb/test/API/python_api/breakpoint/main.c 
b/lldb/test/API/python_api/breakpoint/main.c
index 2677594e622ef..b5265eddbdaba 100644
--- a/lldb/test/API/python_api/breakpoint/main.c
+++ b/lldb/test/API/python_api/breakpoint/main.c
@@ -1,9 +1,6 @@
-#include <stdio.h>
-
 void
 AFunction()
 {
-  printf ("I am a function.\n");
 }
 
 int
diff --git a/lldb/test/API/python_api/process/address-masks/main.c 
b/lldb/test/API/python_api/process/address-masks/main.c
index f21a10a16d5a7..24693f1a8db98 100644
--- a/lldb/test/API/python_api/process/address-masks/main.c
+++ b/lldb/test/API/python_api/process/address-masks/main.c
@@ -1,5 +1,3 @@
-#include <stdio.h>
-
 int main(int argc, char const *argv[]) {
-  puts("Hello address masking world"); // break here
+  return 0; // break here
 }
diff --git a/lldb/test/API/python_api/unified_section_list/main.cpp 
b/lldb/test/API/python_api/unified_section_list/main.cpp
index 45fd52eeeb303..e69de29bb2d1d 100644
--- a/lldb/test/API/python_api/unified_section_list/main.cpp
+++ b/lldb/test/API/python_api/unified_section_list/main.cpp
@@ -1,3 +0,0 @@
-#include <stdio.h>
-
-int main() { printf("Hello World\n"); }
diff --git a/lldb/test/API/tools/lldb-dap/cancel/main.c 
b/lldb/test/API/tools/lldb-dap/cancel/main.c
index ecc0d99ec8db7..3e4e63d6b0dea 100644
--- a/lldb/test/API/tools/lldb-dap/cancel/main.c
+++ b/lldb/test/API/tools/lldb-dap/cancel/main.c
@@ -1,6 +1,3 @@
-#include <stdio.h>
-
 int main(int argc, char const *argv[]) {
-  printf("Hello world!\n");
   return 0;
 }
diff --git a/lldb/test/API/tools/lldb-dap/eventStatistic/main.cpp 
b/lldb/test/API/tools/lldb-dap/eventStatistic/main.cpp
index 86044f561d257..9b345aab0e99b 100644
--- a/lldb/test/API/tools/lldb-dap/eventStatistic/main.cpp
+++ b/lldb/test/API/tools/lldb-dap/eventStatistic/main.cpp
@@ -1,8 +1,6 @@
 #include "foo.h"
-#include <iostream>
 
 int main(int argc, char const *argv[]) {
-  std::cout << "Hello World!" << std::endl;
   foo();
   return 0;
 }
diff --git a/lldb/test/API/tools/lldb-dap/locations/main.cpp 
b/lldb/test/API/tools/lldb-dap/locations/main.cpp
index 0df5491b959d5..1739fe4f00c96 100644
--- a/lldb/test/API/tools/lldb-dap/locations/main.cpp
+++ b/lldb/test/API/tools/lldb-dap/locations/main.cpp
@@ -1,6 +1,6 @@
-#include <cstdio>
+int g = 0;
 
-void greet() { printf("Hello"); }
+void greet() { g++; }
 
 struct Test {
   void foo() {}
diff --git a/lldb/test/API/tools/lldb-dap/restart/main.c 
b/lldb/test/API/tools/lldb-dap/restart/main.c
index b02928a694c9a..1659ab9f18a5a 100644
--- a/lldb/test/API/tools/lldb-dap/restart/main.c
+++ b/lldb/test/API/tools/lldb-dap/restart/main.c
@@ -1,9 +1,6 @@
-#include <stdio.h>
-
 int main(int argc, char const *argv[], char const *envp[]) {
   int i = 0;
-  printf("Do something\n"); // breakpoint A
-  printf("Do something else\n");
+  (void)i; // breakpoint A
   i = 1234;
   return 0; // breakpoint B
 }
diff --git a/lldb/test/API/tools/lldb-dap/send-event/main.c 
b/lldb/test/API/tools/lldb-dap/send-event/main.c
index 27bc22b94794b..62bcb78696b08 100644
--- a/lldb/test/API/tools/lldb-dap/send-event/main.c
+++ b/lldb/test/API/tools/lldb-dap/send-event/main.c
@@ -1,6 +1,3 @@
-#include <stdio.h>
-
 int main(int argc, char const *argv[]) {
-  printf("example\n"); // breakpoint 1
-  return 0;
+  return 0; // breakpoint 1
 }
diff --git a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/main.cpp 
b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/main.cpp
index 71944528441e3..6d10d1b80f06e 100644
--- a/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/main.cpp
+++ b/lldb/test/API/tools/lldb-dap/stackTrace/subtleFrames/main.cpp
@@ -1,9 +1,8 @@
 #include <functional>
-#include <iostream>
 
+int g = 0;
 void greet() {
-  // BREAK HERE
-  std::cout << "Hello\n";
+  g++; // BREAK HERE
 }
 
 int main() {
diff --git a/lldb/test/API/tools/lldb-dap/startDebugging/main.c 
b/lldb/test/API/tools/lldb-dap/startDebugging/main.c
index 27bc22b94794b..62bcb78696b08 100644
--- a/lldb/test/API/tools/lldb-dap/startDebugging/main.c
+++ b/lldb/test/API/tools/lldb-dap/startDebugging/main.c
@@ -1,6 +1,3 @@
-#include <stdio.h>
-
 int main(int argc, char const *argv[]) {
-  printf("example\n"); // breakpoint 1
-  return 0;
+  return 0; // breakpoint 1
 }
diff --git a/lldb/test/API/tools/lldb-dap/terminated-event/main.cpp 
b/lldb/test/API/tools/lldb-dap/terminated-event/main.cpp
index 50dd77c0a9c1d..63f0ff675e782 100644
--- a/lldb/test/API/tools/lldb-dap/terminated-event/main.cpp
+++ b/lldb/test/API/tools/lldb-dap/terminated-event/main.cpp
@@ -1,8 +1,7 @@
 #include "foo.h"
-#include <iostream>
 
 int main(int argc, char const *argv[]) {
-  std::cout << "Hello World!" << std::endl; // main breakpoint 1
+  int bp = 0; // main breakpoint 1
   foo();
   return 0;
 }
diff --git a/lldb/test/API/tools/lldb-dap/unknown/main.c 
b/lldb/test/API/tools/lldb-dap/unknown/main.c
index 092333773d0b6..4cce7f667ff72 100644
--- a/lldb/test/API/tools/lldb-dap/unknown/main.c
+++ b/lldb/test/API/tools/lldb-dap/unknown/main.c
@@ -1,6 +1,3 @@
-#include <stdio.h>
-
 int main() {
-  printf("Hello, World!\n");
   return 0;
 }

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to