[Lldb-commits] [lldb] [lldb][test] StepUntil disable test for unsupported linkers. (PR #157474)

via lldb-commits lldb-commits at lists.llvm.org
Mon Sep 8 07:30:58 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)

<details>
<summary>Changes</summary>

`INSERT BEFORE` keyword is not supported in current versions gold and mold linkers. Since we cannot confirm accurately what linker and version is available on the system and when it will be supported. We test it with a sample program using the script keywords.

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


2 Files Affected:

- (modified) lldb/test/API/functionalities/thread/step_until/TestStepUntil.py (+40) 
- (modified) lldb/test/API/functionalities/thread/step_until/TestStepUntilAPI.py (+43) 


``````````diff
diff --git a/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py b/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py
index 965da02ed0f98..90f207b5d4660 100644
--- a/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py
+++ b/lldb/test/API/functionalities/thread/step_until/TestStepUntil.py
@@ -1,11 +1,50 @@
 """Test stepping over vrs. hitting breakpoints & subsequent stepping in various forms."""
 
+from typing import Optional
 
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
+import tempfile
+
+
+def linker_script_syntax_unsupported() -> Optional[str]:
+    """Current versions of mold and gold linker does not support some syntax of
+    linker scripts, this maybe supported in future versions. check if it compiles,
+    if not it is not supported.
+    """
+    with tempfile.TemporaryDirectory() as tmpdir:
+        output_path = os.path.join(tmpdir, "linker_support.out")
+        linker_script_path = os.path.join(tmpdir, "test.ld")
+
+        with open(linker_script_path, "w") as linker_script:
+            linker_script.write(
+                "SECTIONS {.text.ordered : { *(.text.ordered) *(.text.foo) } } INSERT BEFORE .text;"
+            )
+
+        compiler_cmd = subprocess.Popen(
+            [
+                lldbplatformutil.getCompiler(),
+                f"-o {output_path}",
+                "-ffunction-sections",
+                f"-Wl,--script={linker_script_path}",
+                "-xc",
+                "-",
+            ],
+            shell=True,
+            universal_newlines=True,
+            stdin=subprocess.PIPE,
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE,
+        )
+        _, comp_err = compiler_cmd.communicate(
+            "int foo() { return 1; } int main() { return 0; }"
+        )
 
+        if len(comp_err) != 0:
+            return str(tmpdir) + " " + comp_err
+        return None
 
 class StepUntilTestCase(TestBase):
     def setUp(self):
@@ -112,6 +151,7 @@ def test_bad_line(self):
     @no_debug_info_test
     @skipIf(oslist=lldbplatformutil.getDarwinOSTriples() + ["windows"])
     @skipIf(archs=no_match(["x86_64", "aarch64"]))
+    @skipTestIfFn(linker_script_syntax_unsupported)
     def test_bad_line_discontinuous(self):
         """Test that we get an error if attempting to step outside the current
         function -- and the function is discontinuous"""
diff --git a/lldb/test/API/functionalities/thread/step_until/TestStepUntilAPI.py b/lldb/test/API/functionalities/thread/step_until/TestStepUntilAPI.py
index 59e028acf014c..44e764c43cd20 100644
--- a/lldb/test/API/functionalities/thread/step_until/TestStepUntilAPI.py
+++ b/lldb/test/API/functionalities/thread/step_until/TestStepUntilAPI.py
@@ -1,8 +1,48 @@
+from typing import Optional
+
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
+import tempfile
+
+
+def linker_script_syntax_unsupported() -> Optional[str]:
+    """Current versions of mold and gold linker does not support some syntax of
+    linker scripts, this maybe supported in future versions. check if it compiles,
+    if not it is not supported.
+    """
+    with tempfile.TemporaryDirectory() as tmpdir:
+        output_path = os.path.join(tmpdir, "linker_support.out")
+        linker_script_path = os.path.join(tmpdir, "test.ld")
+
+        with open(linker_script_path, "w") as linker_script:
+            linker_script.write(
+                "SECTIONS {.text.ordered : { *(.text.ordered) *(.text.foo) } } INSERT BEFORE .text;"
+            )
+
+        compiler_cmd = subprocess.Popen(
+            [
+                lldbplatformutil.getCompiler(),
+                f"-o {output_path}",
+                "-ffunction-sections",
+                f"-Wl,--script={linker_script_path}",
+                "-xc",
+                "-",
+            ],
+            shell=True,
+            universal_newlines=True,
+            stdin=subprocess.PIPE,
+            stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE,
+        )
+        _, comp_err = compiler_cmd.communicate(
+            "int foo() { return 1; } int main() { return 0; }"
+        )
 
+        if len(comp_err) != 0:
+            return comp_err
+        return None
 
 class TestStepUntilAPI(TestBase):
     NO_DEBUG_INFO_TESTCASE = True
@@ -74,6 +114,7 @@ def test_hitting(self):
 
     @skipIf(oslist=lldbplatformutil.getDarwinOSTriples() + ["windows"])
     @skipIf(archs=no_match(["x86_64", "aarch64"]))
+    @skipTestIfFn(linker_script_syntax_unsupported)
     def test_hitting_discontinuous(self):
         """Test SBThread.StepOverUntil - targeting a line and hitting it -- with
         discontinuous functions"""
@@ -93,6 +134,7 @@ def test_missing(self):
 
     @skipIf(oslist=lldbplatformutil.getDarwinOSTriples() + ["windows"])
     @skipIf(archs=no_match(["x86_64", "aarch64"]))
+    @skipTestIfFn(linker_script_syntax_unsupported)
     def test_missing_discontinuous(self):
         """Test SBThread.StepOverUntil - targeting a line and missing it by
         stepping out to call site -- with discontinuous functions"""
@@ -120,6 +162,7 @@ def test_bad_line(self):
 
     @skipIf(oslist=lldbplatformutil.getDarwinOSTriples() + ["windows"])
     @skipIf(archs=no_match(["x86_64", "aarch64"]))
+    @skipTestIfFn(linker_script_syntax_unsupported)
     def test_bad_line_discontinuous(self):
         """Test that we get an error if attempting to step outside the current
         function -- and the function is discontinuous"""

``````````

</details>


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


More information about the lldb-commits mailing list