From f7d5e593d38a83bcd9ccaff6fbc1cdbca623fdb2 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 23 Mar 2026 14:45:05 -0500 Subject: [PATCH] [lldb] Check for arm64e debugserver in skipUnlessArm64eSupported (#188082) Explicitly check whether we are building debugserver for arm64e. To debug an arm64e binary, debugserver itself needs to be an arm64e process. This PR eliminates the possibility of configuring LLDB with Right now, it's possible to configure CMake with `LLDB_ENABLE_ARM64E_DEBUGSERVER=Off` and the decorator wouldn't account for that. --- lldb/packages/Python/lldbsuite/test/configuration.py | 3 +++ lldb/packages/Python/lldbsuite/test/decorators.py | 4 ++++ lldb/packages/Python/lldbsuite/test/dotest.py | 3 +++ lldb/packages/Python/lldbsuite/test/dotest_args.py | 6 ++++++ lldb/test/API/lit.cfg.py | 3 +++ lldb/test/API/lit.site.cfg.py.in | 1 + lldb/test/CMakeLists.txt | 7 ++++++- lldb/utils/lldb-dotest/CMakeLists.txt | 6 ++++++ lldb/utils/lldb-dotest/lldb-dotest.in | 3 +++ 9 files changed, 35 insertions(+), 1 deletion(-) diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py index 002d775594ff..dde1a5e52be4 100644 --- a/lldb/packages/Python/lldbsuite/test/configuration.py +++ b/lldb/packages/Python/lldbsuite/test/configuration.py @@ -150,6 +150,9 @@ enabled_plugins = [] # Whether MTE (Memory Tagging Extension) is enabled. mte_enabled = False +# Whether debugserver is built with arm64e support. +arm64e_debugserver = False + # the build type of lldb # Typical values include Debug, Release, RelWithDebInfo and MinSizeRel cmake_build_type = None diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index cb3aa1d6af11..bb698ab89939 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -1331,6 +1331,10 @@ def skipUnlessArm64eSupported(func): if not _compiler_supports(compiler_path, "-arch arm64e"): return "Compiler cannot target arm64e" + # Need debugserver built with arm64e support. + if not configuration.arm64e_debugserver: + return "debugserver not built with arm64e support" + return None return skipTestIfFn(can_build_and_run_arm64e)(func) diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 2bfef9c83aed..9b84375ba8e1 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -472,6 +472,9 @@ def parseOptionsAndInitTestdirs(): if args.enable_mte: configuration.mte_enabled = True + if args.arm64e_debugserver: + configuration.arm64e_debugserver = True + # Gather all the dirs passed on the command line. if len(args.args) > 0: configuration.testdirs = [ diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py b/lldb/packages/Python/lldbsuite/test/dotest_args.py index 8f4b623c4b1c..4c0a67203755 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest_args.py +++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py @@ -285,6 +285,12 @@ def create_parser(): action="store_true", help="Indicate that the test suite is running with MTE (Memory Tagging Extension) enabled.", ) + group.add_argument( + "--arm64e-debugserver", + dest="arm64e_debugserver", + action="store_true", + help="Indicate that debugserver is built with arm64e support.", + ) # Configuration options group = parser.add_argument_group("Remote platform options") diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py index a48cb8c5a9b4..c567e83f3d7f 100644 --- a/lldb/test/API/lit.cfg.py +++ b/lldb/test/API/lit.cfg.py @@ -303,6 +303,9 @@ if is_configured("enabled_plugins"): if getattr(config, "lldb_enable_mte", False): dotest_cmd += ["--enable-mte"] +if getattr(config, "lldb_enable_arm64e_debugserver", False): + dotest_cmd += ["--arm64e-debugserver"] + # `dotest` args come from three different sources: # 1. Derived by CMake based on its configs (LLDB_TEST_COMMON_ARGS), which end # up in `dotest_common_args_str`. diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in index 0f7630c1e6e4..f01e0d73441a 100644 --- a/lldb/test/API/lit.site.cfg.py.in +++ b/lldb/test/API/lit.site.cfg.py.in @@ -44,6 +44,7 @@ config.libcxx_include_dir = "@LIBCXX_GENERATED_INCLUDE_DIR@" config.libcxx_include_target_dir = "@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@" config.lldb_launcher = "@LLDB_LAUNCHER@" config.lldb_enable_mte = @LLDB_ENABLE_MTE@ +config.lldb_enable_arm64e_debugserver = @LLDB_USE_ARM64E_DEBUGSERVER@ # 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/CMakeLists.txt b/lldb/test/CMakeLists.txt index 1edfed8c6642..b117d24195f9 100644 --- a/lldb/test/CMakeLists.txt +++ b/lldb/test/CMakeLists.txt @@ -250,6 +250,10 @@ if (CMAKE_SIZEOF_VOID_P EQUAL 8) set(LLDB_IS_64_BITS 1) endif() +if (LLDB_ENABLE_ARM64E_DEBUGSERVER OR LLDB_USE_SYSTEM_DEBUGSERVER) + set(LLDB_USE_ARM64E_DEBUGSERVER ON) +endif() + set(LLDB_TEST_SHELL_DISABLE_REMOTE OFF CACHE BOOL "Disable remote Shell tests execution") # These values are not canonicalized within LLVM. @@ -267,7 +271,8 @@ llvm_canonicalize_cmake_booleans( LLDB_TOOL_LLDB_SERVER_BUILD LLDB_USE_SYSTEM_DEBUGSERVER LLDB_IS_64_BITS - LLDB_BUILD_LLDBRPC) + LLDB_BUILD_LLDBRPC + LLDB_USE_ARM64E_DEBUGSERVER) # Configure the individual test suites. add_subdirectory(API) diff --git a/lldb/utils/lldb-dotest/CMakeLists.txt b/lldb/utils/lldb-dotest/CMakeLists.txt index 50d0afadf25e..23f1fc23c783 100644 --- a/lldb/utils/lldb-dotest/CMakeLists.txt +++ b/lldb/utils/lldb-dotest/CMakeLists.txt @@ -11,9 +11,14 @@ if(TARGET darwin-mte-launcher) set(LLDB_LAUNCHER ${LLVM_RUNTIME_OUTPUT_INTDIR}/darwin-mte-launcher${CMAKE_EXECUTABLE_SUFFIX}) endif() +if (LLDB_ENABLE_ARM64E_DEBUGSERVER OR LLDB_USE_SYSTEM_DEBUGSERVER) + set(LLDB_USE_ARM64E_DEBUGSERVER ON) +endif() + llvm_canonicalize_cmake_booleans( LLDB_BUILD_INTEL_PT LLDB_HAS_LIBCXX + LLDB_USE_ARM64E_DEBUGSERVER ) if ("libcxx" IN_LIST LLVM_ENABLE_RUNTIMES) @@ -50,6 +55,7 @@ set(vars LIBCXX_GENERATED_INCLUDE_DIR LIBCXX_GENERATED_INCLUDE_TARGET_DIR LLDB_LAUNCHER + LLDB_USE_ARM64E_DEBUGSERVER ) llvm_canonicalize_cmake_booleans(LLDB_HAS_LIBCXX) diff --git a/lldb/utils/lldb-dotest/lldb-dotest.in b/lldb/utils/lldb-dotest/lldb-dotest.in index 6657b6f74dd0..6465b1ddd547 100755 --- a/lldb/utils/lldb-dotest/lldb-dotest.in +++ b/lldb/utils/lldb-dotest/lldb-dotest.in @@ -23,6 +23,7 @@ libcxx_libs_dir = "@LIBCXX_LIBRARY_DIR@" libcxx_include_dir = "@LIBCXX_GENERATED_INCLUDE_DIR@" libcxx_include_target_dir = "@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@" cmake_build_type = "@CMAKE_BUILD_TYPE@" +lldb_enable_arm64e_debugserver = @LLDB_USE_ARM64E_DEBUGSERVER@ if __name__ == '__main__': wrapper_args = sys.argv[1:] @@ -53,6 +54,8 @@ if __name__ == '__main__': cmd.extend(['--framework', lldb_framework_dir]) if lldb_build_intel_pt == "1": cmd.extend(['--enable-plugin', 'intel-pt']) + if lldb_enable_arm64e_debugserver: + cmd.extend(['--arm64e-debugserver']) cmd.extend(['--lldb-obj-root', lldb_obj_root]) cmd.extend(['--cmake-build-type', cmake_build_type]) cmd.extend(wrapper_args)