From 2cff3dec1171188ce04ab1a4373cc1885ab97be1 Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Fri, 19 Feb 2021 00:36:05 +0000 Subject: [lldb/bindings] Add Python ScriptedProcess base class to lldb module In order to facilitate the writting of Scripted Processes, this patch introduces a `ScriptedProcess` python base class in the lldb module. The base class holds the python interface with all the - abstract - methods that need to be implemented by the inherited class but also some methods that can be overwritten. This patch also provides an example of a Scripted Process with the `MyScriptedProcess` class. rdar://65508855 Differential Revision: https://reviews.llvm.org/D95712 Signed-off-by: Med Ismail Bennani --- .../scripted_process/TestScriptedProcess.py | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py (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 new file mode 100644 index 000000000000..a5da07027aaf --- /dev/null +++ b/lldb/test/API/functionalities/scripted_process/TestScriptedProcess.py @@ -0,0 +1,45 @@ +""" +Test python scripted process in lldb +""" + +import os + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil +from lldbsuite.test import lldbtest + + +class PlatformProcessCrashInfoTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + def setUp(self): + TestBase.setUp(self) + self.source = "main.c" + + def tearDown(self): + TestBase.tearDown(self) + + def test_python_plugin_package(self): + """Test that the lldb python module has a `plugins.scripted_process` + package.""" + self.expect('script import lldb.plugins', + substrs=["ModuleNotFoundError"], matching=False) + + self.expect('script dir(lldb.plugins)', + substrs=["scripted_process"]) + + self.expect('script import lldb.plugins.scripted_process', + substrs=["ModuleNotFoundError"], matching=False) + + self.expect('script dir(lldb.plugins.scripted_process)', + substrs=["ScriptedProcess"]) + + self.expect('script from lldb.plugins.scripted_process import ScriptedProcess', + substrs=["ImportError"], matching=False) + + self.expect('script dir(ScriptedProcess)', + substrs=["launch"]) + -- cgit v1.2.3