summaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2022-02-25 14:47:27 +0100
committerPavel Labath <pavel@labath.sk>2022-03-09 16:11:16 +0100
commitffb9429b6f3c29ab4687b96fd85374924c98ad16 (patch)
treed4b72bab146d56e95b7a32253f9ad5663bfaee85 /lldb/test/API/python_api/debugger/TestDebuggerAPI.py
parent0f622bd281bda627cb988024bb1d86768d411e01 (diff)
[lldb] Remove the global platform list
This patch moves the platform creation and selection logic into the per-debugger platform lists. I've tried to keep functional changes to a minimum -- the main (only) observable difference in this change is that APIs, which select a platform by name (e.g., Debugger::SetCurrentPlatform) will not automatically pick up a platform associated with another debugger (or no debugger at all). I've also added several tests for this functionality -- one of the pleasant consequences of the debugger isolation is that it is now possible to test the platform selection and creation logic. This is a product of the discussion at <https://discourse.llvm.org/t/multiple-platforms-with-the-same-name/59594>. Differential Revision: https://reviews.llvm.org/D120810
Diffstat (limited to 'lldb/test/API/python_api/debugger/TestDebuggerAPI.py')
-rw-r--r--lldb/test/API/python_api/debugger/TestDebuggerAPI.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/lldb/test/API/python_api/debugger/TestDebuggerAPI.py b/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
index 0a19945af109..f0ba1d1e20aa 100644
--- a/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
+++ b/lldb/test/API/python_api/debugger/TestDebuggerAPI.py
@@ -92,3 +92,55 @@ class DebuggerAPITestCase(TestBase):
# Test the local property again, is it set to new_cache_line_size?
self.assertEqual(get_cache_line_size(), new_cache_line_size)
+
+ def test_CreateTarget_platform(self):
+ exe = self.getBuildArtifact("a.out")
+ self.yaml2obj("elf.yaml", exe)
+ error = lldb.SBError()
+ target1 = self.dbg.CreateTarget(exe, None, "remote-linux",
+ False, error)
+ self.assertSuccess(error)
+ platform1 = target1.GetPlatform()
+ platform1.SetWorkingDirectory("/foo/bar")
+
+ # Reuse a platform if it matches the currently selected one...
+ target2 = self.dbg.CreateTarget(exe, None, "remote-linux",
+ False, error)
+ self.assertSuccess(error)
+ platform2 = target2.GetPlatform()
+ self.assertEqual(platform2.GetWorkingDirectory(), "/foo/bar")
+
+ # ... but create a new one if it doesn't.
+ self.dbg.SetSelectedPlatform(lldb.SBPlatform("remote-windows"))
+ target3 = self.dbg.CreateTarget(exe, None, "remote-linux",
+ False, error)
+ self.assertSuccess(error)
+ platform3 = target3.GetPlatform()
+ self.assertIsNone(platform3.GetWorkingDirectory())
+
+ def test_CreateTarget_arch(self):
+ exe = self.getBuildArtifact("a.out")
+ if lldbplatformutil.getHostPlatform() == 'linux':
+ self.yaml2obj("macho.yaml", exe)
+ arch = "x86_64-apple-macosx"
+ else:
+ self.yaml2obj("elf.yaml", exe)
+ arch = "x86_64-pc-linux"
+
+ fbsd = lldb.SBPlatform("remote-freebsd")
+ self.dbg.SetSelectedPlatform(fbsd)
+
+ error = lldb.SBError()
+ target1 = self.dbg.CreateTarget(exe, arch, None, False, error)
+ self.assertSuccess(error)
+ platform1 = target1.GetPlatform()
+ self.assertEqual(platform1.GetName(), "remote-macosx")
+ platform1.SetWorkingDirectory("/foo/bar")
+
+ # Reuse a platform even if it is not currently selected.
+ self.dbg.SetSelectedPlatform(fbsd)
+ target2 = self.dbg.CreateTarget(exe, arch, None, False, error)
+ self.assertSuccess(error)
+ platform2 = target2.GetPlatform()
+ self.assertEqual(platform2.GetName(), "remote-macosx")
+ self.assertEqual(platform2.GetWorkingDirectory(), "/foo/bar")