From caea440a11e47bf86b0e43feb28a9287e4fbe3f8 Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Wed, 1 Dec 2021 18:56:29 -0800 Subject: [lldb/plugins] Add arm64(e) support to ScriptedProcess This patch adds support for arm64(e) targets to ScriptedProcess, by providing the `DynamicRegisterInfo` to the base `lldb.ScriptedThread` class. This allows create and debugging ScriptedProcess on Apple Silicon hardware as well as Apple mobile devices. It also replace the C++ asserts on `ScriptedThread::GetDynamicRegisterInfo` by some error logging, re-enables `TestScriptedProcess` for arm64 Darwin platforms and adds a new invalid Scripted Thread test. rdar://85892451 Differential Revision: https://reviews.llvm.org/D114923 Signed-off-by: Med Ismail Bennani --- .../scripted_process/TestScriptedProcess.py | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py') diff --git a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py index 9df72cdda190..87ea860f436d 100644 --- a/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py +++ b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py @@ -41,6 +41,38 @@ class ScriptedProcesTestCase(TestBase): self.expect('script dir(ScriptedProcess)', substrs=["launch"]) + def test_invalid_scripted_register_context(self): + """Test that we can launch an lldb scripted process with an invalid + Scripted Thread, with invalid register context.""" + self.build() + target = self.dbg.CreateTarget(self.getBuildArtifact("a.out")) + self.assertTrue(target, VALID_TARGET) + + os.environ['SKIP_SCRIPTED_PROCESS_LAUNCH'] = '1' + def cleanup(): + del os.environ["SKIP_SCRIPTED_PROCESS_LAUNCH"] + self.addTearDownHook(cleanup) + + scripted_process_example_relpath = 'invalid_scripted_process.py' + self.runCmd("command script import " + os.path.join(self.getSourceDir(), + scripted_process_example_relpath)) + + launch_info = lldb.SBLaunchInfo(None) + launch_info.SetProcessPluginName("ScriptedProcess") + launch_info.SetScriptedProcessClassName("invalid_scripted_process.InvalidScriptedProcess") + error = lldb.SBError() + with tempfile.NamedTemporaryFile() as log_file: + self.runCmd("log enable lldb thread -f " + log_file.name) + process = target.Launch(launch_info, error) + + self.assertTrue(error.Success(), error.GetCString()) + self.assertTrue(process, PROCESS_IS_VALID) + self.assertEqual(process.GetProcessID(), 666) + self.assertEqual(process.GetNumThreads(), 0) + + self.assertIn("Failed to get scripted thread registers data.".encode(), + log_file.read()) + @skipIf(archs=no_match(['x86_64'])) def test_scripted_process_and_scripted_thread(self): """Test that we can launch an lldb scripted process using the SBAPI, @@ -103,7 +135,6 @@ class ScriptedProcesTestCase(TestBase): @skipUnlessDarwin @skipIfOutOfTreeDebugserver - @skipIf(archs=no_match(['x86_64'])) @skipIfAsan # rdar://85954489 def test_launch_scripted_process_stack_frames(self): """Test that we can launch an lldb scripted process from the command -- cgit v1.2.3