diff options
Diffstat (limited to 'lldb/packages/Python')
7 files changed, 111 insertions, 12 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py index 5e3810992d17..c2c46b94454a 100644 --- a/lldb/packages/Python/lldbsuite/test/configuration.py +++ b/lldb/packages/Python/lldbsuite/test/configuration.py @@ -64,6 +64,9 @@ filecheck = None # Path to the yaml2obj tool. Not optional. yaml2obj = None +# Path to the yaml2macho-core tool. Not optional. +yaml2macho_core = None + # The arch might dictate some specific CFLAGS to be passed to the toolchain to build # the inferior programs. The global variable cflags_extras provides a hook to do # just that. @@ -174,3 +177,11 @@ def get_yaml2obj_path(): """ if yaml2obj and os.path.lexists(yaml2obj): return yaml2obj + + +def get_yaml2macho_core_path(): + """ + Get the path to the yaml2macho-core tool. + """ + if yaml2macho_core and os.path.lexists(yaml2macho_core): + return yaml2macho_core diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py index bd10bcc3d6ce..16a58cfc10b9 100644 --- a/lldb/packages/Python/lldbsuite/test/decorators.py +++ b/lldb/packages/Python/lldbsuite/test/decorators.py @@ -1,4 +1,8 @@ # System modules + +# allow the use of the `list[str]` type hint in Python 3.8 +from __future__ import annotations + from functools import wraps from packaging import version import ctypes diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 47a3c2ed2fc9..2966ac04227c 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -280,6 +280,9 @@ def parseOptionsAndInitTestdirs(): configuration.llvm_tools_dir = args.llvm_tools_dir configuration.filecheck = shutil.which("FileCheck", path=args.llvm_tools_dir) configuration.yaml2obj = shutil.which("yaml2obj", path=args.llvm_tools_dir) + configuration.yaml2macho_core = shutil.which( + "yaml2macho-core", path=args.llvm_tools_dir + ) if not configuration.get_filecheck_path(): logging.warning("No valid FileCheck executable; some tests may fail...") diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 0fc85fcc4d2d..b7077f8d8cc5 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1702,6 +1702,29 @@ class Base(unittest.TestCase): command += ["--max-size=%d" % max_size] self.runBuildCommand(command) + def yaml2macho_core(self, yaml_path, obj_path, uuids=None): + """ + Create a Mach-O corefile at the given path from a yaml file. + + Throws subprocess.CalledProcessError if the object could not be created. + """ + yaml2macho_core_bin = configuration.get_yaml2macho_core_path() + if not yaml2macho_core_bin: + self.assertTrue(False, "No valid yaml2macho-core executable specified") + if uuids != None: + command = [ + yaml2macho_core_bin, + "-i", + yaml_path, + "-o", + obj_path, + "-u", + uuids, + ] + else: + command = [yaml2macho_core_bin, "-i", yaml_path, "-o", obj_path] + self.runBuildCommand(command) + def cleanup(self, dictionary=None): """Platform specific way to do cleanup after build.""" module = builder_module() @@ -2264,7 +2287,9 @@ class TestBase(Base, metaclass=LLDBTestCaseFactory): given list of completions""" interp = self.dbg.GetCommandInterpreter() match_strings = lldb.SBStringList() - interp.HandleCompletion(command, len(command), 0, max_completions, match_strings) + interp.HandleCompletion( + command, len(command), 0, max_completions, match_strings + ) # match_strings is a 1-indexed list, so we have to slice... self.assertCountEqual( completions, list(match_strings)[1:], "List of returned completion is wrong" diff --git a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h index 491acb52be87..a1aa7e1a69f3 100644 --- a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h +++ b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h @@ -8,7 +8,9 @@ // 0 -> Post-c88580c layout // 1 -> Post-27c83382d83dc layout // 2 -> Post-769c42f4a552a layout -// 3 -> padding-less no_unique_address-based layout (introduced in 27c83382d83dc) +// 3 -> Post-f5e687d7bf49c layout +// 4 -> padding-less no_unique_address-based layout (introduced in +// 27c83382d83dc) namespace std { namespace __lldb { @@ -42,7 +44,7 @@ template <class _ToPad> class __compressed_pair_padding { ? 0 : sizeof(_ToPad) - __datasizeof_v<_ToPad>]; }; -#elif COMPRESSED_PAIR_REV > 1 && COMPRESSED_PAIR_REV < 3 +#elif COMPRESSED_PAIR_REV > 1 && COMPRESSED_PAIR_REV < 4 template <class _ToPad> inline const bool __is_reference_or_unpadded_object = (std::is_empty<_ToPad>::value && !__lldb_is_final<_ToPad>::value) || @@ -125,6 +127,27 @@ public: _LLDB_NO_UNIQUE_ADDRESS T3 Initializer3; \ _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T3> __padding3_; #elif COMPRESSED_PAIR_REV == 3 +#define _LLDB_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \ + struct { \ + [[__gnu__::__aligned__( \ + alignof(T2))]] _LLDB_NO_UNIQUE_ADDRESS T1 Initializer1; \ + _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T1> __padding1_; \ + _LLDB_NO_UNIQUE_ADDRESS T2 Initializer2; \ + _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T2> __padding2_; \ + } + +#define _LLDB_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, \ + Initializer3) \ + struct { \ + [[using __gnu__: __aligned__(alignof(T2)), \ + __aligned__(alignof(T3))]] _LLDB_NO_UNIQUE_ADDRESS T1 Initializer1; \ + _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T1> __padding1_; \ + _LLDB_NO_UNIQUE_ADDRESS T2 Initializer2; \ + _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T2> __padding2_; \ + _LLDB_NO_UNIQUE_ADDRESS T3 Initializer3; \ + _LLDB_NO_UNIQUE_ADDRESS __compressed_pair_padding<T3> __padding3_; \ + } +#elif COMPRESSED_PAIR_REV == 4 #define _LLDB_COMPRESSED_PAIR(T1, Name1, T2, Name2) \ _LLDB_NO_UNIQUE_ADDRESS T1 Name1; \ _LLDB_NO_UNIQUE_ADDRESS T2 Name2 diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py index 0608ac3fd83b..51debcf477a9 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py @@ -1490,12 +1490,17 @@ class DebugAdapterServer(DebugCommunication): init_commands: list[str] = [], log_file: Optional[TextIO] = None, env: Optional[dict[str, str]] = None, + additional_args: list[str] = [], ): self.process = None self.connection = None if executable is not None: process, connection = DebugAdapterServer.launch( - executable=executable, connection=connection, env=env, log_file=log_file + executable=executable, + connection=connection, + env=env, + log_file=log_file, + additional_args=additional_args, ) self.process = process self.connection = connection @@ -1528,6 +1533,8 @@ class DebugAdapterServer(DebugCommunication): env: Optional[dict[str, str]] = None, log_file: Optional[TextIO] = None, connection: Optional[str] = None, + connection_timeout: Optional[int] = None, + additional_args: list[str] = [], ) -> tuple[subprocess.Popen, Optional[str]]: adapter_env = os.environ.copy() if env is not None: @@ -1537,10 +1544,17 @@ class DebugAdapterServer(DebugCommunication): adapter_env["LLDBDAP_LOG"] = log_file args = [executable] + # Add additional arguments first (like --no-lldbinit) + args.extend(additional_args) + if connection is not None: args.append("--connection") args.append(connection) + if connection_timeout is not None: + args.append("--connection-timeout") + args.append(str(connection_timeout)) + process = subprocess.Popen( args, stdin=subprocess.PIPE, diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py index c23b2e73fb45..fffd4c23d6fc 100644 --- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py @@ -21,6 +21,7 @@ class DAPTestCaseBase(TestBase): self, lldbDAPEnv: Optional[dict[str, str]] = None, connection: Optional[str] = None, + additional_args: Optional[list[str]] = None, ): """Create the Visual Studio Code debug adapter""" self.assertTrue( @@ -33,15 +34,17 @@ class DAPTestCaseBase(TestBase): init_commands=self.setUpCommands(), log_file=log_file_path, env=lldbDAPEnv, + additional_args=additional_args or [], ) def build_and_create_debug_adapter( self, lldbDAPEnv: Optional[dict[str, str]] = None, dictionary: Optional[dict] = None, + additional_args: Optional[list[str]] = None, ): self.build(dictionary=dictionary) - self.create_debug_adapter(lldbDAPEnv) + self.create_debug_adapter(lldbDAPEnv, additional_args=additional_args) def build_and_create_debug_adapter_for_attach(self): """Variant of build_and_create_debug_adapter that builds a uniquely @@ -450,6 +453,25 @@ class DAPTestCaseBase(TestBase): return disassembled_instructions, disassembled_instructions[memoryReference] + def _build_error_message(self, base_message, response): + """Build a detailed error message from a DAP response. + Extracts error information from various possible locations in the response structure. + """ + error_msg = base_message + if response: + if "message" in response: + error_msg += " (%s)" % response["message"] + elif "body" in response and "error" in response["body"]: + if "format" in response["body"]["error"]: + error_msg += " (%s)" % response["body"]["error"]["format"] + else: + error_msg += " (error in body)" + else: + error_msg += " (no error details available)" + else: + error_msg += " (no response)" + return error_msg + def attach( self, *, @@ -477,9 +499,8 @@ class DAPTestCaseBase(TestBase): if expectFailure: return response if not (response and response["success"]): - self.assertTrue( - response["success"], "attach failed (%s)" % (response["message"]) - ) + error_msg = self._build_error_message("attach failed", response) + self.assertTrue(response and response["success"], error_msg) def launch( self, @@ -508,10 +529,8 @@ class DAPTestCaseBase(TestBase): if expectFailure: return response if not (response and response["success"]): - self.assertTrue( - response["success"], - "launch failed (%s)" % (response["body"]["error"]["format"]), - ) + error_msg = self._build_error_message("launch failed", response) + self.assertTrue(response and response["success"], error_msg) def build_and_launch( self, |
