https://github.com/charles-zablit updated 
https://github.com/llvm/llvm-project/pull/213239

>From c9328894f9f598158357fee314aa89b06705f0eb Mon Sep 17 00:00:00 2001
From: Charles Zablit <[email protected]>
Date: Fri, 31 Jul 2026 12:31:33 +0200
Subject: [PATCH 1/3] [lldb][Windows] Dump thread stacks before lit's timeout
 kills a test

---
 lldb/packages/Python/lldbsuite/test/dotest.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 604fb98b1e2e5..3c966dceb96c7 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -504,6 +504,19 @@ def registerFaulthandler():
     if getattr(faulthandler, "register", None):
         faulthandler.register(signal.SIGTERM, chain=True)
 
+    if sys.platform != "win32":
+        return
+
+    # lit kills a hung test with TerminateProcess on Windows, so the SIGTERM
+    # handler above never runs and a timeout is reported with no indication of
+    # where it hung. Dump every thread's stack while the process is still 
alive.
+    try:
+        secs = float(os.environ.get("LLDB_TEST_STACK_DUMP_SECS", 300))
+    except ValueError:
+        secs = 300
+    if secs > 0:
+        faulthandler.dump_traceback_later(secs, exit=False)
+
 
 def setupSysPath():
     """

>From 79b4e4fa0e1a4506bdc17f4f5dc4ee7e7f9ab853 Mon Sep 17 00:00:00 2001
From: Charles Zablit <[email protected]>
Date: Mon, 3 Aug 2026 19:34:33 +0200
Subject: [PATCH 2/3] fixup! [lldb][Windows] Dump thread stacks before lit's
 timeout kills a test

---
 .../Python/lldbsuite/test/configuration.py    |  4 ++++
 lldb/packages/Python/lldbsuite/test/dotest.py | 19 ++++++++++++-------
 .../Python/lldbsuite/test/dotest_args.py      |  8 ++++++++
 lldb/test/API/lldbtest.py                     |  3 +++
 4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py 
b/lldb/packages/Python/lldbsuite/test/configuration.py
index 7f9616be9a482..af069adf9c69e 100644
--- a/lldb/packages/Python/lldbsuite/test/configuration.py
+++ b/lldb/packages/Python/lldbsuite/test/configuration.py
@@ -169,6 +169,10 @@
 # Typical values include Debug, Release, RelWithDebInfo and MinSizeRel
 cmake_build_type = None
 
+# The timeout (in seconds) lit is using to run this test, if any. 0 means no
+# timeout was configured.
+timeout = 0
+
 
 def shouldSkipBecauseOfCategories(test_categories):
     if use_categories:
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 3c966dceb96c7..840d7545a9b94 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -449,6 +449,8 @@ def parseOptionsAndInitTestdirs():
         configuration.lldb_platform_available_ports = 
args.lldb_platform_available_ports
     if platform_system == "Darwin" and args.apple_sdk:
         configuration.apple_sdk = args.apple_sdk
+    if args.timeout:
+        configuration.timeout = args.timeout
     if args.test_build_dir:
         configuration.test_build_dir = args.test_build_dir
     if args.lldb_module_cache_dir:
@@ -509,13 +511,16 @@ def registerFaulthandler():
 
     # lit kills a hung test with TerminateProcess on Windows, so the SIGTERM
     # handler above never runs and a timeout is reported with no indication of
-    # where it hung. Dump every thread's stack while the process is still 
alive.
-    try:
-        secs = float(os.environ.get("LLDB_TEST_STACK_DUMP_SECS", 300))
-    except ValueError:
-        secs = 300
-    if secs > 0:
-        faulthandler.dump_traceback_later(secs, exit=False)
+    # where it hung. Dump every thread's stack shortly before lit's own
+    # per-test timeout (--timeout, forwarded from lit's `maxIndividualTestTime`
+    # by lldbtest.py) would kill the process.
+    if configuration.timeout <= 0:
+        return
+
+    # Leave some headroom so the dump has time to reach lit's output before
+    # the process is terminated.
+    secs = max(1.0, configuration.timeout * 0.9)
+    faulthandler.dump_traceback_later(secs, exit=False)
 
 
 def setupSysPath():
diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py 
b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index 41070edf89022..516559fb6268d 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -248,6 +248,14 @@ def create_parser():
         ),
         help="The root build directory for the tests. It will be removed 
before running.",
     )
+    group.add_argument(
+        "--timeout",
+        dest="timeout",
+        metavar="Timeout in seconds",
+        type=float,
+        default=0,
+        help="The timeout lit is using to run this test, if any.",
+    )
     group.add_argument(
         "--lldb-module-cache-dir",
         dest="lldb_module_cache_dir",
diff --git a/lldb/test/API/lldbtest.py b/lldb/test/API/lldbtest.py
index 6dad5a412a5a5..502865feb5d15 100644
--- a/lldb/test/API/lldbtest.py
+++ b/lldb/test/API/lldbtest.py
@@ -55,6 +55,9 @@ def execute(self, test, litConfig):
         # python exe as the first parameter of the command.
         cmd = [executable] + self.dotest_cmd + [testPath, "-p", testFile]
 
+        if test.config.maxIndividualTestTime > 0:
+            cmd += ["--timeout", str(test.config.maxIndividualTestTime)]
+
         launcher = getattr(test.config, "lldb_launcher", None)
         if launcher:
             cmd = [launcher] + cmd

>From ada35e91ad5d12e601813d07c4734b0e33a51a28 Mon Sep 17 00:00:00 2001
From: Charles Zablit <[email protected]>
Date: Tue, 11 Aug 2026 12:21:34 +0200
Subject: [PATCH 3/3] fixup! [lldb][Windows] Dump thread stacks before lit's
 timeout kills a test

---
 lldb/packages/Python/lldbsuite/test/dotest.py | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 840d7545a9b94..4903eba2bbca6 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -509,16 +509,11 @@ def registerFaulthandler():
     if sys.platform != "win32":
         return
 
-    # lit kills a hung test with TerminateProcess on Windows, so the SIGTERM
-    # handler above never runs and a timeout is reported with no indication of
-    # where it hung. Dump every thread's stack shortly before lit's own
-    # per-test timeout (--timeout, forwarded from lit's `maxIndividualTestTime`
-    # by lldbtest.py) would kill the process.
+    # Dump every thread's stack shortly before lit's own per-test timeout would
+    # kill the process.
     if configuration.timeout <= 0:
         return
 
-    # Leave some headroom so the dump has time to reach lit's output before
-    # the process is terminated.
     secs = max(1.0, configuration.timeout * 0.9)
     faulthandler.dump_traceback_later(secs, exit=False)
 

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

Reply via email to