[Lldb-commits] [lldb] [llvm] [lldb] Skip tests that are incompatible with MTE (PR #186043)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 11 23:38:29 PDT 2026


https://github.com/JDevlieghere created https://github.com/llvm/llvm-project/pull/186043

Skip tests that are incompatible with MTE. 

Depends on:
- https://github.com/llvm/llvm-project/pull/185780

>From 102b7b0c18043b7e25d6887b4f45fda4843bd4e6 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Wed, 11 Mar 2026 23:32:41 -0700
Subject: [PATCH 1/3] [lldb] Update TestObjcOptimized.py for MTE

Use process.FixAddress to strip the top byte when running under MTE.
---
 .../lang/objc/objc-optimized/TestObjcOptimized.py   | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/lang/objc/objc-optimized/TestObjcOptimized.py b/lldb/test/API/lang/objc/objc-optimized/TestObjcOptimized.py
index 1d74047a49bd1..387a3e11e0c0f 100644
--- a/lldb/test/API/lang/objc/objc-optimized/TestObjcOptimized.py
+++ b/lldb/test/API/lang/objc/objc-optimized/TestObjcOptimized.py
@@ -6,7 +6,6 @@
 optimized it into a register.
 """
 
-
 import lldb
 import re
 
@@ -57,10 +56,20 @@ def test_break(self):
         if mo:
             desired_pointer = mo.group(0)
 
+        # Use FixAddress to strip top-byte metadata (PtrAuth tags, MTE tags).
+        process = self.dbg.GetSelectedTarget().GetProcess()
+        desired_addr = process.FixAddress(int(desired_pointer, 16))
+
         self.expect(
             "expression (self)",
-            substrs=[("(%s *) $1 = " % self.myclass), desired_pointer],
+            substrs=["(%s *) $1 = " % self.myclass],
         )
+        interp.HandleCommand("expression (self)", result)
+        expr_output = result.GetOutput()
+        mo = re.search("0x[0-9a-f]+", expr_output)
+        self.assertTrue(mo, "Expected a pointer in expression output")
+        expr_addr = process.FixAddress(int(mo.group(0), 16))
+        self.assertEqual(desired_addr, expr_addr)
 
         self.expect(
             "expression self->non_member",

>From aed1ce19cb5cc6d02c32fa3e9daee020990a46fa Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Tue, 10 Mar 2026 17:07:34 -0700
Subject: [PATCH 2/3] [lldb] Run tests under MTE on capable HW

---
 lldb/cmake/modules/LLDBConfig.cmake | 21 +++++++++++++++++++++
 lldb/test/API/lit.site.cfg.py.in    |  1 +
 lldb/test/API/lldbtest.py           |  4 ++++
 lldb/test/CMakeLists.txt            |  5 +++++
 lldb/test/Shell/helper/toolchain.py |  4 ++++
 lldb/test/Shell/lit.site.cfg.py.in  |  1 +
 lldb/tools/CMakeLists.txt           |  4 +++-
 llvm/utils/lit/lit/llvm/subst.py    |  4 ++++
 8 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake
index 42af86b57cfcc..291f189c2bee8 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -163,6 +163,27 @@ if (LLDB_ENABLE_LIBEDIT)
   set(CMAKE_EXTRA_INCLUDE_FILES)
 endif()
 
+if (APPLE)
+  set(default_enable_mte OFF)
+
+  execute_process(
+      COMMAND sysctl -n hw.optional.arm.FEAT_MTE4
+      OUTPUT_VARIABLE SYSCTL_OUTPUT
+      ERROR_QUIET
+      RESULT_VARIABLE SYSCTL_RESULT
+      OUTPUT_STRIP_TRAILING_WHITESPACE
+  )
+  if(SYSCTL_RESULT EQUAL 0)
+    set(default_enable_mte ON)
+  endif()
+
+  option(LLDB_ENABLE_MTE "Run the LLDB test suite with MTE enabled." ${default_enable_mte})
+
+  if (LLDB_ENABLE_MTE)
+    message(STATUS "Running the LLDB test suite with MTE")
+  endif()
+endif()
+
 if (LLDB_ENABLE_PYTHON)
   if(CMAKE_SYSTEM_NAME MATCHES "Windows")
     set(default_embed_python_home ON)
diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in
index c4e4352fe7915..6cc4542bca75e 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -42,6 +42,7 @@ config.has_libcxx = @LLDB_HAS_LIBCXX@
 config.libcxx_libs_dir = "@LIBCXX_LIBRARY_DIR@"
 config.libcxx_include_dir = "@LIBCXX_GENERATED_INCLUDE_DIR@"
 config.libcxx_include_target_dir = "@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@"
+config.lldb_launcher = "@LLDB_LAUNCHER@"
 # The API tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-api")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-api")
diff --git a/lldb/test/API/lldbtest.py b/lldb/test/API/lldbtest.py
index acd018236e440..9762c47205647 100644
--- a/lldb/test/API/lldbtest.py
+++ b/lldb/test/API/lldbtest.py
@@ -55,6 +55,10 @@ def execute(self, test, litConfig):
         # python exe as the first parameter of the command.
         cmd = [executable] + self.dotest_cmd + [testPath, "-p", testFile]
 
+        launcher = getattr(test.config, "lldb_launcher", None)
+        if launcher:
+            cmd = [launcher] + cmd
+
         if isLuaTest:
             cmd.extend(["--env", "LUA_EXECUTABLE=%s" % test.config.lua_executable])
             cmd.extend(["--env", "LLDB_LUA_CPATH=%s" % test.config.lldb_lua_cpath])
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 513d1ec493ee1..d7d745a512002 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -132,6 +132,11 @@ if(TARGET lldb-framework)
   add_lldb_test_dependency(lldb-framework)
 endif()
 
+if(TARGET darwin-mte-launcher)
+  add_lldb_test_dependency(darwin-mte-launcher)
+  set(LLDB_LAUNCHER ${LLVM_RUNTIME_OUTPUT_INTDIR}/darwin-mte-launcher${CMAKE_EXECUTABLE_SUFFIX})
+endif()
+
 if (LLDB_CAN_USE_LLDB_RPC_SERVER)
   add_lldb_test_dependency(lldb-rpc-generate-sources)
 endif()
diff --git a/lldb/test/Shell/helper/toolchain.py b/lldb/test/Shell/helper/toolchain.py
index 66664561a249d..df20a4ae7af5e 100644
--- a/lldb/test/Shell/helper/toolchain.py
+++ b/lldb/test/Shell/helper/toolchain.py
@@ -118,24 +118,28 @@ def use_lldb_substitutions(config):
         build_script_args.append("--sysroot={0}".format(config.cmake_sysroot))
 
     lldb_init = _get_lldb_init_path(config)
+    launcher = getattr(config, "lldb_launcher", None)
 
     primary_tools = [
         ToolSubst(
             "%lldb",
             command=FindTool("lldb"),
             extra_args=get_lldb_args(config),
+            launcher=launcher,
             unresolved="fatal",
         ),
         ToolSubst(
             "%lldb-init",
             command=FindTool("lldb"),
             extra_args=["-S", lldb_init],
+            launcher=launcher,
             unresolved="fatal",
         ),
         ToolSubst(
             "%lldb-noinit",
             command=FindTool("lldb"),
             extra_args=["--no-lldbinit"],
+            launcher=launcher,
             unresolved="fatal",
         ),
         ToolSubst(
diff --git a/lldb/test/Shell/lit.site.cfg.py.in b/lldb/test/Shell/lit.site.cfg.py.in
index 47beac002a19c..b260b2fce90b7 100644
--- a/lldb/test/Shell/lit.site.cfg.py.in
+++ b/lldb/test/Shell/lit.site.cfg.py.in
@@ -35,6 +35,7 @@ config.lldb_system_debugserver = @LLDB_USE_SYSTEM_DEBUGSERVER@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.lldb_has_lldbrpc = @LLDB_BUILD_LLDBRPC@
 config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
+config.lldb_launcher = "@LLDB_LAUNCHER@"
 # The shell tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-shell")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-shell")
diff --git a/lldb/tools/CMakeLists.txt b/lldb/tools/CMakeLists.txt
index eaa74f1953b3c..4e6600e3d2eec 100644
--- a/lldb/tools/CMakeLists.txt
+++ b/lldb/tools/CMakeLists.txt
@@ -20,7 +20,9 @@ endif()
 
 if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
   add_lldb_tool_subdirectory(darwin-debug)
-  add_lldb_tool_subdirectory(darwin-mte-launcher)
+  if (LLDB_ENABLE_MTE)
+    add_lldb_tool_subdirectory(darwin-mte-launcher)
+  endif()
   if(NOT LLDB_USE_SYSTEM_DEBUGSERVER)
     add_lldb_tool_subdirectory(debugserver)
   endif()
diff --git a/llvm/utils/lit/lit/llvm/subst.py b/llvm/utils/lit/lit/llvm/subst.py
index 09ab3555a6b44..39a6a75e4c79b 100644
--- a/llvm/utils/lit/lit/llvm/subst.py
+++ b/llvm/utils/lit/lit/llvm/subst.py
@@ -44,6 +44,7 @@ def __init__(
         verbatim=False,
         unresolved="warn",
         extra_args=None,
+        launcher=None,
     ):
         """Construct a ToolSubst.
 
@@ -79,6 +80,7 @@ def __init__(
         """
         self.unresolved = unresolved
         self.extra_args = extra_args
+        self.launcher = launcher
         self.key = key
         self.command = command if command is not None else FindTool(key)
         self.was_resolved = False
@@ -120,6 +122,8 @@ def resolve(self, config, search_dirs):
         if command_str:
             if self.extra_args:
                 command_str = " ".join([command_str] + self.extra_args)
+            if self.launcher:
+                command_str = self.launcher + " " + command_str
         else:
             if self.unresolved == "warn":
                 # Warn, but still provide a substitution.

>From 48925cb03eb28d108ed558d6ca525345814297de Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Wed, 11 Mar 2026 23:33:13 -0700
Subject: [PATCH 3/3] [lldb] Skip tests that are incompatible with MTE

---
 lldb/cmake/modules/LLDBConfig.cmake                   |  2 ++
 lldb/packages/Python/lldbsuite/test/decorators.py     | 11 +++++++++++
 lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py |  1 +
 .../cpp/global_operators/TestCppGlobalOperators.py    |  1 +
 lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py   |  1 +
 lldb/test/API/lua_api/TestLuaAPI.py                   |  1 +
 lldb/test/API/macosx/mte/TestDarwinMTE.py             | 11 ++++++++++-
 .../API/tools/lldb-server/TestAppleSimulatorOSType.py |  1 +
 .../test/API/tools/lldb-server/TestGdbRemoteAttach.py |  1 +
 .../API/tools/lldb-server/TestGdbRemoteProcessInfo.py |  1 +
 .../tools/lldb-server/TestGdbRemoteRegisterState.py   |  1 +
 .../lldb-server/TestGdbRemoteThreadsInStopReply.py    |  1 +
 .../tools/lldb-server/TestGdbRemote_qMemoryRegion.py  |  1 +
 lldb/test/API/tools/lldb-server/TestLldbGdbServer.py  |  1 +
 .../attach-wait/TestGdbRemoteAttachWait.py            |  1 +
 lldb/test/CMakeLists.txt                              |  1 +
 lldb/test/Shell/Heap/heap-cstr.test                   |  2 ++
 lldb/test/Shell/lit.cfg.py                            |  3 +++
 lldb/test/Shell/lit.site.cfg.py.in                    |  1 +
 .../tools/darwin-mte-launcher/darwin-mte-launcher.cpp |  1 +
 20 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake
index 291f189c2bee8..aeabb34256e78 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -182,6 +182,8 @@ if (APPLE)
   if (LLDB_ENABLE_MTE)
     message(STATUS "Running the LLDB test suite with MTE")
   endif()
+else()
+  set(LLDB_ENABLE_MTE OFF)
 endif()
 
 if (LLDB_ENABLE_PYTHON)
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index 6a516e2e4addc..3f677f06d4c11 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1129,6 +1129,17 @@ def is_running_under_asan():
     return None
 
 
+def is_running_under_mte():
+    if "LLDB_MTE_ENABLED" in os.environ:
+        return "MTE unsupported"
+    return None
+
+
+def skipIfMTE(func):
+    """Skip this test when running with MTE (Memory Tagging Extension) enabled."""
+    return skipTestIfFn(is_running_under_mte)(func)
+
+
 def skipUnlessAddressSanitizer(func):
     """Decorate the item to skip test unless Clang -fsanitize=thread is supported."""
 
diff --git a/lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py b/lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py
index 95d81bf8a9992..e638718e5e95e 100644
--- a/lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py
+++ b/lldb/test/API/functionalities/ptr_refs/TestPtrRefs.py
@@ -11,6 +11,7 @@
 
 class TestPtrRefs(TestBase):
     @skipIfAsan  # The output looks different under ASAN.
+    @skipIfMTE  # Heap scanning reads tagged memory with untagged pointers.
     @skipUnlessDarwin
     def test_ptr_refs(self):
         """Test format string functionality."""
diff --git a/lldb/test/API/lang/cpp/global_operators/TestCppGlobalOperators.py b/lldb/test/API/lang/cpp/global_operators/TestCppGlobalOperators.py
index 358ab5bb7e0ee..b659f4aec2a44 100644
--- a/lldb/test/API/lang/cpp/global_operators/TestCppGlobalOperators.py
+++ b/lldb/test/API/lang/cpp/global_operators/TestCppGlobalOperators.py
@@ -85,6 +85,7 @@ def do_new_test(self, frame, expr, expected_value_name):
         self.assertTrue(got_type.IsPointerType())
         self.assertEqual(got_type.GetPointeeType().GetName(), "Struct")
 
+    @skipIfMTE  # Expression evaluation of overridden operator new fails under MTE.
     def test_operator_new(self):
         frame = self.prepare_executable_and_get_frame()
 
diff --git a/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py b/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py
index 9d8b52ae85420..acecf1981dcf4 100644
--- a/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py
+++ b/lldb/test/API/lang/objc/ptr_refs/TestPtrRefsObjC.py
@@ -11,6 +11,7 @@
 
 class TestPtrRefsObjC(TestBase):
     @skipIfAsan  # The output looks different under ASAN.
+    @skipIfMTE  # Heap scanning reads tagged memory with untagged pointers.
     def test_ptr_refs(self):
         """Test the ptr_refs tool on Darwin with Objective-C"""
         self.build()
diff --git a/lldb/test/API/lua_api/TestLuaAPI.py b/lldb/test/API/lua_api/TestLuaAPI.py
index e78ed9de72375..1fb64e7fc20d0 100644
--- a/lldb/test/API/lua_api/TestLuaAPI.py
+++ b/lldb/test/API/lua_api/TestLuaAPI.py
@@ -157,6 +157,7 @@ def get_tests(self):
                     tests.append(filename)
         return tests
 
+    @skipIfMTE  # Lua is not MTE-aware.
     def test_lua_api(self):
         if "LUA_EXECUTABLE" not in os.environ or not os.path.exists(
             os.environ["LUA_EXECUTABLE"]
diff --git a/lldb/test/API/macosx/mte/TestDarwinMTE.py b/lldb/test/API/macosx/mte/TestDarwinMTE.py
index a70b4b4aed26b..8975d77f9dd4f 100644
--- a/lldb/test/API/macosx/mte/TestDarwinMTE.py
+++ b/lldb/test/API/macosx/mte/TestDarwinMTE.py
@@ -1,5 +1,6 @@
 """Test MTE Memory Tagging on Apple platforms"""
 
+import os
 import lldb
 import re
 from lldbsuite.test.decorators import *
@@ -18,7 +19,15 @@ def test_process_launch_memory_tagging(self):
         self.build(make_targets=["binary-plain"])
         self.createTestTarget(self.getBuildArtifact(exe_name))
 
-        self.expect("process launch", substrs=["exited with status = 0"])
+        if "LLDB_MTE_ENABLED" in os.environ:
+            # When running under the MTE launcher, MTE is inherited by child
+            # processes, so even without --memory-tagging the UAF is caught.
+            self.expect(
+                "process launch",
+                substrs=["stopped", "stop reason = EXC_ARM_MTE_TAG_FAULT"],
+            )
+        else:
+            self.expect("process launch", substrs=["exited with status = 0"])
 
         self.expect(
             "process launch --memory-tagging",
diff --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index 865e6fb7d6c01..3dc11a3ff74f2 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -9,6 +9,7 @@
 import re
 
 
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class TestAppleSimulatorOSType(gdbremote_testcase.GdbRemoteTestCaseBase):
     SHARED_BUILD_TESTCASE = False
 
diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
index 5aa790b1c97e5..7059302048396 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteAttach.py
@@ -5,6 +5,7 @@
 from lldbsuite.test import lldbutil
 
 
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class TestGdbRemoteAttach(gdbremote_testcase.GdbRemoteTestCaseBase):
     def test_attach_with_vAttach(self):
         self.build()
diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
index 398264a70a417..c780be62d517c 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteProcessInfo.py
@@ -5,6 +5,7 @@
 from lldbsuite.test import lldbutil
 
 
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class TestGdbRemoteProcessInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
     def test_qProcessInfo_returns_running_process(self):
         self.build()
diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
index 39aa473322a9f..8ffe8a6aba6c8 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteRegisterState.py
@@ -4,6 +4,7 @@
 from lldbsuite.test import lldbutil
 
 
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class TestGdbRemoteRegisterState(gdbremote_testcase.GdbRemoteTestCaseBase):
     """Test QSaveRegisterState/QRestoreRegisterState support."""
 
diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py b/lldb/test/API/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
index 17fc8c1a0f08c..fb563faf98efc 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
@@ -7,6 +7,7 @@
 from lldbsuite.test import lldbutil
 
 
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class TestGdbRemoteThreadsInStopReply(gdbremote_testcase.GdbRemoteTestCaseBase):
     ENABLE_THREADS_IN_STOP_REPLY_ENTRIES = [
         "read packet: $QListThreadsInStopReply#21",
diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemote_qMemoryRegion.py b/lldb/test/API/tools/lldb-server/TestGdbRemote_qMemoryRegion.py
index 1a5df1a250184..5119ddaf8365f 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemote_qMemoryRegion.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemote_qMemoryRegion.py
@@ -4,6 +4,7 @@
 from lldbsuite.test.lldbdwarf import *
 
 
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class TestGdbRemote_qMemoryRegion(gdbremote_testcase.GdbRemoteTestCaseBase):
     def test_qMemoryRegionInfo_is_supported(self):
         self.build()
diff --git a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
index f1c0519ae56d8..717c4da171eeb 100644
--- a/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
+++ b/lldb/test/API/tools/lldb-server/TestLldbGdbServer.py
@@ -25,6 +25,7 @@
 # On Linux systems with Yama ptrace_scope = 1 there is a race condition when the
 # debugee enables tracing. See https://github.com/llvm/llvm-project/issues/161510.
 @skipIfLinux
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class LldbGdbServerTestCase(
     gdbremote_testcase.GdbRemoteTestCaseBase, DwarfOpcodeParser
 ):
diff --git a/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py b/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py
index 84aab9c969aa4..bbbfa733db2da 100644
--- a/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py
+++ b/lldb/test/API/tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py
@@ -8,6 +8,7 @@
 from lldbsuite.test import lldbutil
 
 
+ at skipIfMTE  # MTE security transition shims restrict socket operations.
 class TestGdbRemoteAttachWait(gdbremote_testcase.GdbRemoteTestCaseBase):
     def _set_up_inferior(self):
         self._exe_to_attach = "%s_%d" % (self.testMethodName, os.getpid())
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index d7d745a512002..1edfed8c66427 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -255,6 +255,7 @@ set(LLDB_TEST_SHELL_DISABLE_REMOTE OFF CACHE BOOL "Disable remote Shell tests ex
 # These values are not canonicalized within LLVM.
 llvm_canonicalize_cmake_booleans(
   LLDB_BUILD_INTEL_PT
+  LLDB_ENABLE_MTE
   LLDB_ENABLE_PYTHON
   LLDB_ENABLE_LUA
   LLDB_ENABLE_LZMA
diff --git a/lldb/test/Shell/Heap/heap-cstr.test b/lldb/test/Shell/Heap/heap-cstr.test
index cabf6d6a25aab..a559a978f6b2f 100644
--- a/lldb/test/Shell/Heap/heap-cstr.test
+++ b/lldb/test/Shell/Heap/heap-cstr.test
@@ -1,5 +1,7 @@
 # REQUIRES: system-darwin
 # REQUIRES: python
+# Heap scanning reads tagged memory with untagged pointers.
+# UNSUPPORTED: lldb-mte
 # RUN: %clang_host %p/Inputs/cstr.c -g -o %t
 # RUN: %lldb -b -s %s -f %t | FileCheck %s
 
diff --git a/lldb/test/Shell/lit.cfg.py b/lldb/test/Shell/lit.cfg.py
index cdc0cfe51f7c6..8d28f2d5201b3 100644
--- a/lldb/test/Shell/lit.cfg.py
+++ b/lldb/test/Shell/lit.cfg.py
@@ -144,6 +144,9 @@ def calculate_arch_features(arch_string):
 if config.lldb_enable_python:
     config.available_features.add("python")
 
+if getattr(config, "lldb_enable_mte", False):
+    config.available_features.add("lldb-mte")
+
 if config.lldb_enable_lua:
     config.available_features.add("lua")
 
diff --git a/lldb/test/Shell/lit.site.cfg.py.in b/lldb/test/Shell/lit.site.cfg.py.in
index b260b2fce90b7..546df37775361 100644
--- a/lldb/test/Shell/lit.site.cfg.py.in
+++ b/lldb/test/Shell/lit.site.cfg.py.in
@@ -36,6 +36,7 @@ config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.lldb_has_lldbrpc = @LLDB_BUILD_LLDBRPC@
 config.have_dia_sdk = @LLVM_ENABLE_DIA_SDK@
 config.lldb_launcher = "@LLDB_LAUNCHER@"
+config.lldb_enable_mte = @LLDB_ENABLE_MTE@
 # The shell tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-shell")
 config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-shell")
diff --git a/lldb/tools/darwin-mte-launcher/darwin-mte-launcher.cpp b/lldb/tools/darwin-mte-launcher/darwin-mte-launcher.cpp
index 8f55e09f5c60b..1cc9cb5364b75 100644
--- a/lldb/tools/darwin-mte-launcher/darwin-mte-launcher.cpp
+++ b/lldb/tools/darwin-mte-launcher/darwin-mte-launcher.cpp
@@ -52,6 +52,7 @@ int main(int argc, const char *argv[], const char *envp[]) {
   for (const char **e = envp; *e; ++e)
     new_envp.push_back(*e);
   new_envp.push_back("PYTHONMALLOC=malloc");
+  new_envp.push_back("LLDB_MTE_ENABLED=1");
   new_envp.push_back(nullptr);
 
   pid_t pid;



More information about the lldb-commits mailing list