[lldb][testsuite] Create a SBDebugger instance for each test
authorTatyana Krasnukha <tatyana@synopsys.com>
Thu, 5 Mar 2020 07:12:54 +0000 (10:12 +0300)
committerTatyana Krasnukha <tatyana@synopsys.com>
Thu, 5 Mar 2020 07:12:54 +0000 (10:12 +0300)
Some tests set settings and don't clean them up, this leads to side effects in other tests.
The patch removes a global debugger instance with a per-test debugger to avoid such effects.

From what I see, lldb.DBG was needed to determine the platform before a test is run,
lldb.selected_platform is used for this purpose now. Though, this required adding a new function
to the SBPlatform interface.

Differential Revision: https://reviews.llvm.org/D74903

28 files changed:
lldb/bindings/interface/SBPlatform.i
lldb/include/lldb/API/SBPlatform.h
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/API/SBPlatform.cpp
lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py
lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py
lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py
lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
lldb/test/API/functionalities/thread/backtrace_all/TestBacktraceAll.py
lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
lldb/test/API/macosx/load-kext/TestLoadKext.py
lldb/test/API/python_api/file_handle/TestFileHandle.py
lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py

index 9baa2eb..1f52edb 100644 (file)
@@ -115,6 +115,8 @@ public:
 
     ~SBPlatform();
 
+    static SBPlatform GetHostPlatform();
+
     bool
     IsValid () const;
 
index 58dafc2..7fac182 100644 (file)
@@ -97,6 +97,8 @@ public:
 
   ~SBPlatform();
 
+  static SBPlatform GetHostPlatform();
+
   explicit operator bool() const;
 
   bool IsValid() const;
index ec17cb7..b0d2db7 100644 (file)
@@ -172,7 +172,7 @@ def _decorateTest(mode,
         skip_for_debug_info = _match_decorator_property(
             debug_info, self.getDebugInfo())
         skip_for_triple = _match_decorator_property(
-            triple, lldb.DBG.GetSelectedPlatform().GetTriple())
+            triple, lldb.selected_platform.GetTriple())
         skip_for_remote = _match_decorator_property(
             remote, lldb.remote_platform is not None)
 
index 5dddc99..991e29d 100644 (file)
@@ -774,16 +774,6 @@ def visit(prefix, dir, names):
             raise
 
 
-def setSetting(setting, value):
-    import lldb
-    ci = lldb.DBG.GetCommandInterpreter()
-    res = lldb.SBCommandReturnObject()
-    cmd = 'setting set %s %s'%(setting, value)
-    print(cmd)
-    ci.HandleCommand(cmd, res, False)
-    if not res.Succeeded():
-        raise Exception('failed to run "%s"'%cmd)
-
 # ======================================== #
 #                                          #
 # Execution of the test driver starts here #
@@ -809,6 +799,8 @@ def checkDsymForUUIDIsNotOn():
 
 
 def exitTestSuite(exitCode=None):
+    # lldb.py does SBDebugger.Initialize().
+    # Call SBDebugger.Terminate() on exit.
     import lldb
     lldb.SBDebugger.Terminate()
     if exitCode:
@@ -931,7 +923,7 @@ def checkWatchpointSupport():
 def checkDebugInfoSupport():
     import lldb
 
-    platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
+    platform = lldb.selected_platform.GetTriple().split('-')[2]
     compiler = configuration.compiler
     skipped = []
     for cat in test_categories.debug_info_categories:
@@ -961,17 +953,13 @@ def run_suite():
 
     setupSysPath()
 
-
-    # For the time being, let's bracket the test runner within the
-    # lldb.SBDebugger.Initialize()/Terminate() pair.
     import lldb
+    # Use host platform by default.
+    lldb.selected_platform = lldb.SBPlatform.GetHostPlatform()
 
     # Now we can also import lldbutil
     from lldbsuite.test import lldbutil
 
-    # Create a singleton SBDebugger in the lldb namespace.
-    lldb.DBG = lldb.SBDebugger.Create()
-
     if configuration.lldb_platform_name:
         print("Setting up remote platform '%s'" %
               (configuration.lldb_platform_name))
@@ -1020,7 +1008,7 @@ def run_suite():
         if not lldb.remote_platform.SetWorkingDirectory(
                 configuration.lldb_platform_working_dir):
             raise Exception("failed to set working directory '%s'" % configuration.lldb_platform_working_dir)
-        lldb.DBG.SetSelectedPlatform(lldb.remote_platform)
+        lldb.selected_platform = lldb.remote_platform
     else:
         lldb.remote_platform = None
         configuration.lldb_platform_working_dir = None
@@ -1031,7 +1019,7 @@ def run_suite():
     build_dir = configuration.test_build_dir
     lldbutil.mkdir_p(build_dir)
 
-    target_platform = lldb.DBG.GetSelectedPlatform().GetTriple().split('-')[2]
+    target_platform = lldb.selected_platform.GetTriple().split('-')[2]
 
     checkLibcxxSupport()
     checkLibstdcxxSupport()
@@ -1059,10 +1047,6 @@ def run_suite():
     # Now that we have loaded all the test cases, run the whole test suite.
     #
 
-    # Set any user-overridden settings.
-    for key, value in configuration.settings:
-        setSetting(key, value)
-
     # Install the control-c handler.
     unittest2.signals.installHandler()
 
index 02946f0..32c9c20 100644 (file)
@@ -57,7 +57,7 @@ def _run_adb_command(cmd, device_id):
 
 def target_is_android():
     if not hasattr(target_is_android, 'result'):
-        triple = lldb.DBG.GetSelectedPlatform().GetTriple()
+        triple = lldb.selected_platform.GetTriple()
         match = re.match(".*-.*-.*-android", triple)
         target_is_android.result = match is not None
     return target_is_android.result
@@ -129,7 +129,7 @@ def getDarwinOSTriples():
 
 def getPlatform():
     """Returns the target platform which the tests are running on."""
-    triple = lldb.DBG.GetSelectedPlatform().GetTriple()
+    triple = lldb.selected_platform.GetTriple()
     if triple is None:
       # It might be an unconnected remote platform.
       return ''
index b20c29d..866daad 100644 (file)
@@ -703,6 +703,11 @@ class Base(unittest2.TestCase):
                 configuration.lldb_module_cache_dir),
             "settings set use-color false",
         ]
+
+        # Set any user-overridden settings.
+        for setting, value in configuration.settings:
+            commands.append('setting set %s %s'%(setting, value))
+
         # Make sure that a sanitizer LLDB's environment doesn't get passed on.
         if cls.platformContext and cls.platformContext.shlib_environment_var in os.environ:
             commands.append('settings set target.env-vars {}='.format(
@@ -803,11 +808,11 @@ class Base(unittest2.TestCase):
             # set environment variable names for finding shared libraries
             self.dylibPath = self.platformContext.shlib_environment_var
 
-        # Create the debugger instance if necessary.
-        try:
-            self.dbg = lldb.DBG
-        except AttributeError:
-            self.dbg = lldb.SBDebugger.Create()
+        # Create the debugger instance.
+        self.dbg = lldb.SBDebugger.Create()
+        # Copy selected platform from a global instance if it exists.
+        if lldb.selected_platform is not None:
+            self.dbg.SetSelectedPlatform(lldb.selected_platform)
 
         if not self.dbg:
             raise Exception('Invalid debugger instance')
@@ -1018,6 +1023,11 @@ class Base(unittest2.TestCase):
                 for dict in reversed(self.dicts):
                     self.cleanup(dictionary=dict)
 
+        # This must be the last statement, otherwise teardown hooks or other
+        # lines might depend on this still being active.
+        lldb.SBDebugger.Destroy(self.dbg)
+        del self.dbg
+
     # =========================================================
     # Various callbacks to allow introspection of test progress
     # =========================================================
@@ -1994,10 +2004,6 @@ class TestBase(Base):
         # Do this last, to make sure it's in reverse order from how we setup.
         Base.tearDown(self)
 
-        # This must be the last statement, otherwise teardown hooks or other
-        # lines might depend on this still being active.
-        del self.dbg
-
     def switch_to_thread_with_stop_reason(self, stop_reason):
         """
         Run the 'thread list' command, and select the thread with stop reason as
index b17509c..7aa0b54 100644 (file)
@@ -303,6 +303,12 @@ SBPlatform &SBPlatform::operator=(const SBPlatform &rhs) {
 
 SBPlatform::~SBPlatform() = default;
 
+SBPlatform SBPlatform::GetHostPlatform() {
+  SBPlatform host_platform;
+  host_platform.m_opaque_sp = Platform::GetHostPlatform();
+  return host_platform;
+}
+
 bool SBPlatform::IsValid() const {
   LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBPlatform, IsValid);
   return this->operator bool();
index 0169cd4..874a908 100644 (file)
@@ -13,14 +13,6 @@ from lldbsuite.test import lldbutil
 class TestAutoInstallMainExecutable(gdbremote_testcase.GdbRemoteTestCaseBase):
     mydir = TestBase.compute_mydir(__file__)
 
-    def setUp(self):
-        super(TestAutoInstallMainExecutable, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(TestAutoInstallMainExecutable, self).tearDown()
-
     @llgs_test
     @no_debug_info_test
     @skipIf(remote=False)
@@ -61,16 +53,11 @@ class TestAutoInstallMainExecutable(gdbremote_testcase.GdbRemoteTestCaseBase):
         # Wait for the new process gets ready.
         time.sleep(0.1)
 
-        new_debugger = lldb.SBDebugger.Create()
-        new_debugger.SetAsync(False)
-
-        def del_debugger(new_debugger=new_debugger):
-            del new_debugger
-        self.addTearDownHook(del_debugger)
+        self.dbg.SetAsync(False)
 
         new_platform = lldb.SBPlatform(lldb.remote_platform.GetName())
-        new_debugger.SetSelectedPlatform(new_platform)
-        new_interpreter = new_debugger.GetCommandInterpreter()
+        self.dbg.SetSelectedPlatform(new_platform)
+        interpreter = self.dbg.GetCommandInterpreter()
 
         connect_url = "%s://%s:%s" % (protocol, hostname, str(hostport+1))
 
@@ -79,7 +66,7 @@ class TestAutoInstallMainExecutable(gdbremote_testcase.GdbRemoteTestCaseBase):
         result = lldb.SBCommandReturnObject()
 
         # Test the default setting.
-        new_interpreter.HandleCommand("settings show target.auto-install-main-executable", result)
+        interpreter.HandleCommand("settings show target.auto-install-main-executable", result)
         self.assertTrue(
             result.Succeeded() and
             "target.auto-install-main-executable (boolean) = true" in result.GetOutput(),
@@ -87,16 +74,16 @@ class TestAutoInstallMainExecutable(gdbremote_testcase.GdbRemoteTestCaseBase):
             (result.GetOutput(), result.GetError()))
 
         # Disable the auto install.
-        new_interpreter.HandleCommand("settings set target.auto-install-main-executable false", result)
-        new_interpreter.HandleCommand("settings show target.auto-install-main-executable", result)
+        interpreter.HandleCommand("settings set target.auto-install-main-executable false", result)
+        interpreter.HandleCommand("settings show target.auto-install-main-executable", result)
         self.assertTrue(
             result.Succeeded() and
             "target.auto-install-main-executable (boolean) = false" in result.GetOutput(),
             "Default settings for target.auto-install-main-executable failed.: %s - %s" %
             (result.GetOutput(), result.GetError()))
 
-        new_interpreter.HandleCommand("platform select %s"%configuration.lldb_platform_name, result)
-        new_interpreter.HandleCommand(command, result)
+        interpreter.HandleCommand("platform select %s"%configuration.lldb_platform_name, result)
+        interpreter.HandleCommand(command, result)
 
         self.assertTrue(
             result.Succeeded(),
@@ -104,7 +91,7 @@ class TestAutoInstallMainExecutable(gdbremote_testcase.GdbRemoteTestCaseBase):
             (result.GetOutput(),result.GetError()))
 
         # Create the target with the original file.
-        new_interpreter.HandleCommand("target create --remote-file %s %s "%
+        interpreter.HandleCommand("target create --remote-file %s %s "%
                                         (os.path.join(working_dir,dest.GetFilename()), self.getBuildArtifact("a.out")),
                                       result)
         self.assertTrue(
@@ -128,7 +115,7 @@ class TestAutoInstallMainExecutable(gdbremote_testcase.GdbRemoteTestCaseBase):
         frame = thread.GetFrameAtIndex(0)
         self.assertEqual(frame.GetFunction().GetName(), "main")
 
-        new_interpreter.HandleCommand("target variable build", result)
+        interpreter.HandleCommand("target variable build", result)
         self.assertTrue(
             result.Succeeded() and
             '"device"' in result.GetOutput(),
index ff08715..068f563 100644 (file)
@@ -79,9 +79,3 @@ class AvoidBreakpointInDelaySlotAPITestCase(TestBase):
                 i += 1
             else:
                 i += 1
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
index ea94fd3..4c8aa36 100644 (file)
@@ -87,7 +87,6 @@ class StepOverBreakpointsTestCase(TestBase):
 
     @skipIf(bugnumber="llvm.org/pr31972", hostoslist=["windows"])
     def test_step_over(self):
-        #lldb.DBG.EnableLog("lldb", ["step","breakpoint"])
 
         self.thread.StepOver()
         # We should be stopped at the breakpoint_2 line with stop plan complete reason
index 9de0279..ae66bc2 100644 (file)
@@ -11,14 +11,6 @@ class TestGDBRemoteClient(GDBRemoteTestBase):
         def readRegisters(self):
             return '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
 
-    def setUp(self):
-        super(TestGDBRemoteClient, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(TestGDBRemoteClient, self).tearDown()
-
     def test_connect(self):
         """Test connecting to a remote gdb server"""
         target = self.createTarget("a.yaml")
index f70c854..59a11d4 100644 (file)
@@ -6,14 +6,6 @@ from gdbclientutils import *
 
 class TestGDBRemoteLoad(GDBRemoteTestBase):
 
-    def setUp(self):
-        super(TestGDBRemoteLoad, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(TestGDBRemoteLoad, self).tearDown()
-
     def test_module_load_address(self):
         """Test that setting the load address of a module uses virtual addresses"""
         target = self.createTarget("a.yaml")
index 7a2346c..8d0f2c8 100644 (file)
@@ -86,14 +86,6 @@ class MyResponder(MockGDBServerResponder):
 
 class TestWasm(GDBRemoteTestBase):
 
-    def setUp(self):
-        super(TestWasm, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(TestWasm, self).tearDown()
-
     @skipIfAsan
     @skipIfXmlSupportMissing
     def test_load_module_with_embedded_symbols_from_remote(self):
index b7f19a1..73bd292 100644 (file)
@@ -6,15 +6,6 @@ from gdbclientutils import *
 
 class TestWriteMemory(GDBRemoteTestBase):
 
-    def setUp(self):
-        super(TestWriteMemory, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(TestWriteMemory, self).tearDown()
-
-
     def test(self):
 
         class MyResponder(MockGDBServerResponder):
index 44028e5..6bfdd8c 100644 (file)
@@ -10,14 +10,6 @@ class TestqOffsets(GDBRemoteTestBase):
         def qOffsets(self):
             return 'Text=470000;Data=470000'
 
-    def setUp(self):
-        super(TestqOffsets, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(TestqOffsets, self).tearDown()
-
     def test(self):
         self.server.responder = TestqOffsets.Responder()
         target = self.createTarget("qOffsets.yaml")
index e81d407..b688bd4 100644 (file)
@@ -37,16 +37,14 @@ class PluginCommandTestCase(TestBase):
         # Invoke the library build rule.
         self.buildLibrary("plugin.cpp", plugin_name)
 
-        debugger = lldb.SBDebugger.Create()
-
         retobj = lldb.SBCommandReturnObject()
 
-        retval = debugger.GetCommandInterpreter().HandleCommand(
+        retval = self.dbg.GetCommandInterpreter().HandleCommand(
             "plugin load %s" % self.getBuildArtifact(plugin_lib_name), retobj)
 
         retobj.Clear()
 
-        retval = debugger.GetCommandInterpreter().HandleCommand(
+        retval = self.dbg.GetCommandInterpreter().HandleCommand(
             "plugin_loaded_command child abc def ghi", retobj)
 
         if self.TraceOn():
@@ -57,7 +55,7 @@ class PluginCommandTestCase(TestBase):
         retobj.Clear()
 
         # check that abbreviations work correctly in plugin commands.
-        retval = debugger.GetCommandInterpreter().HandleCommand(
+        retval = self.dbg.GetCommandInterpreter().HandleCommand(
             "plugin_loaded_ ch abc def ghi", retobj)
 
         if self.TraceOn():
index c2746bf..5a1eab3 100644 (file)
@@ -33,14 +33,6 @@ class LinuxCoreTestCase(TestBase):
     _mips_regions = 5
     _ppc64le_regions = 2
 
-    def setUp(self):
-        super(LinuxCoreTestCase, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(LinuxCoreTestCase, self).tearDown()
-
     @skipIf(triple='^mips')
     @skipIfLLVMTargetMissing("X86")
     def test_i386(self):
index ca863d2..6e16ce3 100644 (file)
@@ -14,13 +14,6 @@ class GCoreTestCase(TestBase):
     NO_DEBUG_INFO_TESTCASE = True
 
     mydir = TestBase.compute_mydir(__file__)
-    def setUp(self):
-        super(GCoreTestCase, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(GCoreTestCase, self).tearDown()
 
     _i386_pid = 5586
     _x86_64_pid = 5669
index 4be7ebe..6e34c91 100644 (file)
@@ -15,14 +15,6 @@ class LinuxCoreThreadsTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    def setUp(self):
-        super(LinuxCoreThreadsTestCase, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(LinuxCoreThreadsTestCase, self).tearDown()
-
     _i386_pid = 5193
     _x86_64_pid = 5222
 
index 7680b55..eaf8ab5 100644 (file)
@@ -15,14 +15,6 @@ class MachCoreTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    def setUp(self):
-        super(MachCoreTestCase, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(MachCoreTestCase, self).tearDown()
-
     # This was originally marked as expected failure on Windows, but it has
     # started timing out instead, so the expectedFailure attribute no longer
     # correctly tracks it: llvm.org/pr37371
index 62b6c80..f209261 100644 (file)
@@ -22,14 +22,6 @@ class MiniDumpNewTestCase(TestBase):
     _linux_x86_64_not_crashed_pid = 29939
     _linux_x86_64_not_crashed_pid_offset = 0xD967
 
-    def setUp(self):
-        super(MiniDumpNewTestCase, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(MiniDumpNewTestCase, self).tearDown()
-
     def process_from_yaml(self, yaml_file):
         minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + ".dmp")
         self.yaml2obj(yaml_file, minidump_path)
index ca0ad5f..c57aa98 100644 (file)
@@ -18,14 +18,6 @@ class MiniDumpUUIDTestCase(TestBase):
 
     NO_DEBUG_INFO_TESTCASE = True
 
-    def setUp(self):
-        super(MiniDumpUUIDTestCase, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(MiniDumpUUIDTestCase, self).tearDown()
-
     def verify_module(self, module, verify_path, verify_uuid):
         uuid = module.GetUUIDString()
         self.assertEqual(verify_path, module.GetFileSpec().fullpath)
index 067b04d..f967a57 100644 (file)
@@ -18,14 +18,6 @@ class NetBSDCoreCommonTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    def setUp(self):
-        super(NetBSDCoreCommonTestCase, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(NetBSDCoreCommonTestCase, self).tearDown()
-
     def check_memory_regions(self, process, region_count):
         region_list = process.GetMemoryRegions()
         self.assertEqual(region_list.GetSize(), region_count)
index 870b6b2..372244a 100644 (file)
@@ -57,9 +57,3 @@ class BacktraceAllTestCase(TestBase):
 
         # Run to completion
         self.runCmd("continue")
-
-if __name__ == '__main__':
-    import atexit
-    lldb.SBDebugger.Initialize()
-    atexit.register(lambda: lldb.SBDebugger.Terminate())
-    unittest2.main()
index cce485b..552fdef 100644 (file)
@@ -15,14 +15,6 @@ class TestNoreturnModuleEnd(TestBase):
     NO_DEBUG_INFO_TESTCASE = True
     mydir = TestBase.compute_mydir(__file__)
 
-    def setUp(self):
-        super(TestNoreturnModuleEnd, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(TestNoreturnModuleEnd, self).tearDown()
-
     def test(self):
         target = self.dbg.CreateTarget("test.out")
         process = target.LoadCore("test.core")
index ec35ce8..d2e9a7c 100644 (file)
@@ -15,11 +15,6 @@ class LoadKextTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    def setUp(self):
-        TestBase.setUp(self)
-        #super(LoadKextTestCase, self).setUp()
-        #self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
     def test_load_kext(self):
         """Test that lldb can load a kext binary."""
 
index 53ca649..996077c 100644 (file)
@@ -82,12 +82,7 @@ class FileHandleTestCase(lldbtest.TestBase):
     NO_DEBUG_INFO_TESTCASE = True
     mydir = lldbtest.Base.compute_mydir(__file__)
 
-    # The way this class interacts with the debugger is different
-    # than normal.   Most of these test cases will mess with the
-    # debugger I/O streams, so we want a fresh debugger for each
-    # test so those mutations don't interfere with each other.
-    #
-    # Also, the way normal tests evaluate debugger commands is
+    # The way normal tests evaluate debugger commands is
     # by using a SBCommandInterpreter directly, which captures
     # the output in a result object.   For many of tests tests
     # we want the debugger to write the  output directly to
@@ -98,30 +93,27 @@ class FileHandleTestCase(lldbtest.TestBase):
 
     def setUp(self):
         super(FileHandleTestCase, self).setUp()
-        self.debugger = lldb.SBDebugger.Create()
         self.out_filename = self.getBuildArtifact('output')
         self.in_filename = self.getBuildArtifact('input')
 
     def tearDown(self):
-        lldb.SBDebugger.Destroy(self.debugger)
         super(FileHandleTestCase, self).tearDown()
         for name in (self.out_filename, self.in_filename):
             if os.path.exists(name):
                 os.unlink(name)
 
-    # Similar to runCmd(), but this uses the per-test debugger, and it
-    # supports, letting the debugger just print the results instead
-    # of collecting them.
+    # Similar to runCmd(), but letting the debugger just print the results
+    # instead of collecting them.
     def handleCmd(self, cmd, check=True, collect_result=True):
         assert not check or collect_result
         ret = lldb.SBCommandReturnObject()
         if collect_result:
-            interpreter = self.debugger.GetCommandInterpreter()
+            interpreter = self.dbg.GetCommandInterpreter()
             interpreter.HandleCommand(cmd, ret)
         else:
-            self.debugger.HandleCommand(cmd)
-        self.debugger.GetOutputFile().Flush()
-        self.debugger.GetErrorFile().Flush()
+            self.dbg.HandleCommand(cmd)
+        self.dbg.GetOutputFile().Flush()
+        self.dbg.GetErrorFile().Flush()
         if collect_result and check:
             self.assertTrue(ret.Succeeded())
         return ret.GetOutput()
@@ -130,14 +122,13 @@ class FileHandleTestCase(lldbtest.TestBase):
     @add_test_categories(['pyapi'])
     def test_legacy_file_out_script(self):
         with open(self.out_filename, 'w') as f:
-            self.debugger.SetOutputFileHandle(f, False)
+            self.dbg.SetOutputFileHandle(f, False)
             # scripts print to output even if you capture the results
             # I'm not sure I love that behavior, but that's the way
             # it's been for a long time.  That's why this test works
             # even with collect_result=True.
             self.handleCmd('script 1+1')
-            self.debugger.GetOutputFileHandle().write('FOO\n')
-        lldb.SBDebugger.Destroy(self.debugger)
+            self.dbg.GetOutputFileHandle().write('FOO\n')
         with open(self.out_filename, 'r') as f:
             self.assertEqual(readStrippedLines(f), ['2', 'FOO'])
 
@@ -145,21 +136,19 @@ class FileHandleTestCase(lldbtest.TestBase):
     @add_test_categories(['pyapi'])
     def test_legacy_file_out(self):
         with open(self.out_filename, 'w') as f:
-            self.debugger.SetOutputFileHandle(f, False)
+            self.dbg.SetOutputFileHandle(f, False)
             self.handleCmd('p/x 3735928559', collect_result=False, check=False)
-        lldb.SBDebugger.Destroy(self.debugger)
         with open(self.out_filename, 'r') as f:
             self.assertIn('deadbeef', f.read())
 
     @add_test_categories(['pyapi'])
     def test_legacy_file_err_with_get(self):
         with open(self.out_filename, 'w') as f:
-            self.debugger.SetErrorFileHandle(f, False)
+            self.dbg.SetErrorFileHandle(f, False)
             self.handleCmd('lolwut', check=False, collect_result=False)
-            f2 = self.debugger.GetErrorFileHandle()
+            f2 = self.dbg.GetErrorFileHandle()
             f2.write('FOOBAR\n')
             f2.flush()
-        lldb.SBDebugger.Destroy(self.debugger)
         with open(self.out_filename, 'r') as f:
             errors = f.read()
             self.assertTrue(re.search(r'error:.*lolwut', errors))
@@ -169,18 +158,16 @@ class FileHandleTestCase(lldbtest.TestBase):
     @add_test_categories(['pyapi'])
     def test_legacy_file_err(self):
         with open(self.out_filename, 'w') as f:
-            self.debugger.SetErrorFileHandle(f, False)
+            self.dbg.SetErrorFileHandle(f, False)
             self.handleCmd('lol', check=False, collect_result=False)
-        lldb.SBDebugger.Destroy(self.debugger)
         with open(self.out_filename, 'r') as f:
             self.assertIn("is not a valid command", f.read())
 
 
     @add_test_categories(['pyapi'])
     def test_legacy_file_error(self):
-        debugger = self.debugger
         with open(self.out_filename, 'w') as f:
-            debugger.SetErrorFileHandle(f, False)
+            self.dbg.SetErrorFileHandle(f, False)
             self.handleCmd('lolwut', check=False, collect_result=False)
         with open(self.out_filename, 'r') as f:
             errors = f.read()
@@ -255,10 +242,10 @@ class FileHandleTestCase(lldbtest.TestBase):
     def test_fileno_out(self):
         with open(self.out_filename, 'w') as f:
             sbf = lldb.SBFile(f.fileno(), "w", False)
-            status = self.debugger.SetOutputFile(sbf)
+            status = self.dbg.SetOutputFile(sbf)
             self.assertTrue(status.Success())
             self.handleCmd('script 1+2')
-            self.debugger.GetOutputFile().Write(b'quux')
+            self.dbg.GetOutputFile().Write(b'quux')
 
         with open(self.out_filename, 'r') as f:
             self.assertEqual(readStrippedLines(f), ['3', 'quux'])
@@ -268,7 +255,7 @@ class FileHandleTestCase(lldbtest.TestBase):
     def test_fileno_help(self):
         with open(self.out_filename, 'w') as f:
             sbf = lldb.SBFile(f.fileno(), "w", False)
-            status = self.debugger.SetOutputFile(sbf)
+            status = self.dbg.SetOutputFile(sbf)
             self.assertTrue(status.Success())
             self.handleCmd("help help", collect_result=False, check=False)
         with open(self.out_filename, 'r') as f:
@@ -277,9 +264,8 @@ class FileHandleTestCase(lldbtest.TestBase):
 
     @add_test_categories(['pyapi'])
     def test_help(self):
-        debugger = self.debugger
         with open(self.out_filename, 'w') as f:
-            status = debugger.SetOutputFile(lldb.SBFile(f))
+            status = self.dbg.SetOutputFile(lldb.SBFile(f))
             self.assertTrue(status.Success())
             self.handleCmd("help help", check=False, collect_result=False)
         with open(self.out_filename, 'r') as f:
@@ -291,7 +277,7 @@ class FileHandleTestCase(lldbtest.TestBase):
         with open(self.out_filename, 'w') as f:
             ret = lldb.SBCommandReturnObject()
             ret.SetImmediateOutputFile(f)
-            interpreter = self.debugger.GetCommandInterpreter()
+            interpreter = self.dbg.GetCommandInterpreter()
             interpreter.HandleCommand("help help", ret)
             # make sure the file wasn't closed early.
             f.write("\nQUUX\n")
@@ -308,7 +294,7 @@ class FileHandleTestCase(lldbtest.TestBase):
         f = io.StringIO()
         ret = lldb.SBCommandReturnObject()
         ret.SetImmediateOutputFile(f)
-        interpreter = self.debugger.GetCommandInterpreter()
+        interpreter = self.dbg.GetCommandInterpreter()
         interpreter.HandleCommand("help help", ret)
         # make sure the file wasn't closed early.
         f.write("\nQUUX\n")
@@ -324,7 +310,7 @@ class FileHandleTestCase(lldbtest.TestBase):
         f = io.StringIO()
         ret = lldb.SBCommandReturnObject()
         ret.SetImmediateOutputFile(lldb.SBFile(f))
-        interpreter = self.debugger.GetCommandInterpreter()
+        interpreter = self.dbg.GetCommandInterpreter()
         interpreter.HandleCommand("help help", ret)
         output = f.getvalue()
         ret = None # call destructor and flush streams
@@ -341,16 +327,16 @@ class FileHandleTestCase(lldbtest.TestBase):
         with open(self.out_filename, 'w') as outf, open(self.in_filename, 'r') as inf:
 
             outsbf = lldb.SBFile(outf.fileno(), "w", False)
-            status = self.debugger.SetOutputFile(outsbf)
+            status = self.dbg.SetOutputFile(outsbf)
             self.assertTrue(status.Success())
 
             insbf = lldb.SBFile(inf.fileno(), "r", False)
-            status = self.debugger.SetInputFile(insbf)
+            status = self.dbg.SetInputFile(insbf)
             self.assertTrue(status.Success())
 
             opts = lldb.SBCommandInterpreterRunOptions()
-            self.debugger.RunCommandInterpreter(True, False, opts, 0, False, False)
-            self.debugger.GetOutputFile().Flush()
+            self.dbg.RunCommandInterpreter(True, False, opts, 0, False, False)
+            self.dbg.GetOutputFile().Flush()
 
         with open(self.out_filename, 'r') as f:
             self.assertTrue(re.search(r'Show a list of all debugger commands', f.read()))
@@ -362,13 +348,13 @@ class FileHandleTestCase(lldbtest.TestBase):
             f.write("help help\n")
         with  open(self.out_filename, 'w') as outf, \
               open(self.in_filename, 'r') as inf:
-            status = self.debugger.SetOutputFile(lldb.SBFile(outf))
+            status = self.dbg.SetOutputFile(lldb.SBFile(outf))
             self.assertTrue(status.Success())
-            status = self.debugger.SetInputFile(lldb.SBFile(inf))
+            status = self.dbg.SetInputFile(lldb.SBFile(inf))
             self.assertTrue(status.Success())
             opts = lldb.SBCommandInterpreterRunOptions()
-            self.debugger.RunCommandInterpreter(True, False, opts, 0, False, False)
-            self.debugger.GetOutputFile().Flush()
+            self.dbg.RunCommandInterpreter(True, False, opts, 0, False, False)
+            self.dbg.GetOutputFile().Flush()
         with open(self.out_filename, 'r') as f:
             output = f.read()
             self.assertIn('Show a list of all debugger commands', output)
@@ -376,18 +362,17 @@ class FileHandleTestCase(lldbtest.TestBase):
 
     @add_test_categories(['pyapi'])
     def test_binary_inout(self):
-        debugger = self.debugger
         with open(self.in_filename, 'w') as f:
             f.write("help help\n")
         with  open(self.out_filename, 'wb') as outf, \
               open(self.in_filename, 'rb') as inf:
-            status = debugger.SetOutputFile(lldb.SBFile(outf))
+            status = self.dbg.SetOutputFile(lldb.SBFile(outf))
             self.assertTrue(status.Success())
-            status = debugger.SetInputFile(lldb.SBFile(inf))
+            status = self.dbg.SetInputFile(lldb.SBFile(inf))
             self.assertTrue(status.Success())
             opts = lldb.SBCommandInterpreterRunOptions()
-            debugger.RunCommandInterpreter(True, False, opts, 0, False, False)
-            debugger.GetOutputFile().Flush()
+            self.dbg.RunCommandInterpreter(True, False, opts, 0, False, False)
+            self.dbg.GetOutputFile().Flush()
         with open(self.out_filename, 'r') as f:
             output = f.read()
             self.assertIn('Show a list of all debugger commands', output)
@@ -398,13 +383,13 @@ class FileHandleTestCase(lldbtest.TestBase):
     def test_string_inout(self):
         inf = io.StringIO("help help\np/x ~0\n")
         outf = io.StringIO()
-        status = self.debugger.SetOutputFile(lldb.SBFile(outf))
+        status = self.dbg.SetOutputFile(lldb.SBFile(outf))
         self.assertTrue(status.Success())
-        status = self.debugger.SetInputFile(lldb.SBFile(inf))
+        status = self.dbg.SetInputFile(lldb.SBFile(inf))
         self.assertTrue(status.Success())
         opts = lldb.SBCommandInterpreterRunOptions()
-        self.debugger.RunCommandInterpreter(True, False, opts, 0, False, False)
-        self.debugger.GetOutputFile().Flush()
+        self.dbg.RunCommandInterpreter(True, False, opts, 0, False, False)
+        self.dbg.GetOutputFile().Flush()
         output = outf.getvalue()
         self.assertIn('Show a list of all debugger commands', output)
         self.assertIn('0xfff', output)
@@ -415,13 +400,13 @@ class FileHandleTestCase(lldbtest.TestBase):
     def test_bytes_inout(self):
         inf = io.BytesIO(b"help help\nhelp b\n")
         outf = io.BytesIO()
-        status = self.debugger.SetOutputFile(lldb.SBFile(outf))
+        status = self.dbg.SetOutputFile(lldb.SBFile(outf))
         self.assertTrue(status.Success())
-        status = self.debugger.SetInputFile(lldb.SBFile(inf))
+        status = self.dbg.SetInputFile(lldb.SBFile(inf))
         self.assertTrue(status.Success())
         opts = lldb.SBCommandInterpreterRunOptions()
-        self.debugger.RunCommandInterpreter(True, False, opts, 0, False, False)
-        self.debugger.GetOutputFile().Flush()
+        self.dbg.RunCommandInterpreter(True, False, opts, 0, False, False)
+        self.dbg.GetOutputFile().Flush()
         output = outf.getvalue()
         self.assertIn(b'Show a list of all debugger commands', output)
         self.assertIn(b'Set a breakpoint', output)
@@ -432,12 +417,12 @@ class FileHandleTestCase(lldbtest.TestBase):
         with open(self.out_filename, 'w') as f:
 
             sbf = lldb.SBFile(f.fileno(), 'w', False)
-            status = self.debugger.SetErrorFile(sbf)
+            status = self.dbg.SetErrorFile(sbf)
             self.assertTrue(status.Success())
 
             self.handleCmd('lolwut', check=False, collect_result=False)
 
-            self.debugger.GetErrorFile().Write(b'\nzork\n')
+            self.dbg.GetErrorFile().Write(b'\nzork\n')
 
         with open(self.out_filename, 'r') as f:
             errors = f.read()
@@ -457,7 +442,6 @@ class FileHandleTestCase(lldbtest.TestBase):
 
     @add_test_categories(['pyapi'])
     def test_replace_stdout_with_nonfile(self):
-        debugger = self.debugger
         f = io.StringIO()
         with replace_stdout(f):
             class Nothing():
@@ -545,7 +529,7 @@ class FileHandleTestCase(lldbtest.TestBase):
     @skipIf(py_version=['<', (3,)])
     def test_string_out(self):
         f = io.StringIO()
-        status = self.debugger.SetOutputFile(f)
+        status = self.dbg.SetOutputFile(f)
         self.assertTrue(status.Success())
         self.handleCmd("script 'foobar'")
         self.assertEqual(f.getvalue().strip(), "'foobar'")
@@ -555,8 +539,7 @@ class FileHandleTestCase(lldbtest.TestBase):
     @skipIf(py_version=['<', (3,)])
     def test_string_error(self):
         f = io.StringIO()
-        debugger = self.debugger
-        status = debugger.SetErrorFile(f)
+        status = self.dbg.SetErrorFile(f)
         self.assertTrue(status.Success())
         self.handleCmd('lolwut', check=False, collect_result=False)
         errors = f.getvalue()
@@ -614,7 +597,7 @@ class FileHandleTestCase(lldbtest.TestBase):
     def test_sbfile_out(self):
         with open(self.out_filename, 'w') as f:
             sbf = lldb.SBFile(f)
-            status = self.debugger.SetOutputFile(sbf)
+            status = self.dbg.SetOutputFile(sbf)
             self.assertTrue(status.Success())
             self.handleCmd('script 2+2')
         with open(self.out_filename, 'r') as f:
@@ -625,7 +608,7 @@ class FileHandleTestCase(lldbtest.TestBase):
     @skipIf(py_version=['<', (3,)])
     def test_file_out(self):
         with open(self.out_filename, 'w') as f:
-            status = self.debugger.SetOutputFile(f)
+            status = self.dbg.SetOutputFile(f)
             self.assertTrue(status.Success())
             self.handleCmd('script 2+2')
         with open(self.out_filename, 'r') as f:
@@ -636,7 +619,7 @@ class FileHandleTestCase(lldbtest.TestBase):
     def test_sbfile_error(self):
         with open(self.out_filename, 'w') as f:
             sbf = lldb.SBFile(f)
-            status = self.debugger.SetErrorFile(sbf)
+            status = self.dbg.SetErrorFile(sbf)
             self.assertTrue(status.Success())
             self.handleCmd('lolwut', check=False, collect_result=False)
         with open(self.out_filename, 'r') as f:
@@ -647,7 +630,7 @@ class FileHandleTestCase(lldbtest.TestBase):
     @add_test_categories(['pyapi'])
     def test_file_error(self):
         with open(self.out_filename, 'w') as f:
-            status = self.debugger.SetErrorFile(f)
+            status = self.dbg.SetErrorFile(f)
             self.assertTrue(status.Success())
             self.handleCmd('lolwut', check=False, collect_result=False)
         with open(self.out_filename, 'r') as f:
@@ -677,9 +660,9 @@ class FileHandleTestCase(lldbtest.TestBase):
     @skipIf(py_version=['<', (3,)])
     def test_exceptions_logged(self):
         messages = list()
-        self.debugger.SetLoggingCallback(messages.append)
+        self.dbg.SetLoggingCallback(messages.append)
         self.handleCmd('log enable lldb script')
-        self.debugger.SetOutputFile(lldb.SBFile(BadIO()))
+        self.dbg.SetOutputFile(lldb.SBFile(BadIO()))
         self.handleCmd('script 1+1')
         self.assertTrue(any('OH NOE' in msg for msg in messages))
 
@@ -737,14 +720,13 @@ class FileHandleTestCase(lldbtest.TestBase):
 
     @add_test_categories(['pyapi'])
     def test_close(self):
-        debugger = self.debugger
         with open(self.out_filename, 'w') as f:
-            status = debugger.SetOutputFile(f)
+            status = self.dbg.SetOutputFile(f)
             self.assertTrue(status.Success())
             self.handleCmd("help help", check=False, collect_result=False)
             # make sure the file wasn't closed early.
             f.write("\nZAP\n")
-            lldb.SBDebugger.Destroy(debugger)
+            lldb.SBDebugger.Destroy(self.dbg)
             # check that output file was closed when debugger was destroyed.
             with self.assertRaises(ValueError):
                 f.write("\nQUUX\n")
@@ -758,7 +740,7 @@ class FileHandleTestCase(lldbtest.TestBase):
     @skipIf(py_version=['<', (3,)])
     def test_stdout(self):
         f = io.StringIO()
-        status = self.debugger.SetOutputFile(f)
+        status = self.dbg.SetOutputFile(f)
         self.assertTrue(status.Success())
         self.handleCmd(r"script sys.stdout.write('foobar\n')")
         self.assertEqual(f.getvalue().strip().split(), ["foobar", "7"])
@@ -767,7 +749,7 @@ class FileHandleTestCase(lldbtest.TestBase):
     @add_test_categories(['pyapi'])
     def test_stdout_file(self):
         with open(self.out_filename, 'w') as f:
-            status = self.debugger.SetOutputFile(f)
+            status = self.dbg.SetOutputFile(f)
             self.assertTrue(status.Success())
             self.handleCmd(r"script sys.stdout.write('foobar\n')")
         with open(self.out_filename, 'r') as f:
@@ -856,38 +838,38 @@ class FileHandleTestCase(lldbtest.TestBase):
 
     @add_test_categories(['pyapi'])
     def test_set_filehandle_none(self):
-        self.assertRaises(Exception, self.debugger.SetOutputFile, None)
-        self.assertRaises(Exception, self.debugger.SetOutputFile, "ham sandwich")
-        self.assertRaises(Exception, self.debugger.SetOutputFileHandle, "ham sandwich")
-        self.assertRaises(Exception, self.debugger.SetInputFile, None)
-        self.assertRaises(Exception, self.debugger.SetInputFile, "ham sandwich")
-        self.assertRaises(Exception, self.debugger.SetInputFileHandle, "ham sandwich")
-        self.assertRaises(Exception, self.debugger.SetErrorFile, None)
-        self.assertRaises(Exception, self.debugger.SetErrorFile, "ham sandwich")
-        self.assertRaises(Exception, self.debugger.SetErrorFileHandle, "ham sandwich")
+        self.assertRaises(Exception, self.dbg.SetOutputFile, None)
+        self.assertRaises(Exception, self.dbg.SetOutputFile, "ham sandwich")
+        self.assertRaises(Exception, self.dbg.SetOutputFileHandle, "ham sandwich")
+        self.assertRaises(Exception, self.dbg.SetInputFile, None)
+        self.assertRaises(Exception, self.dbg.SetInputFile, "ham sandwich")
+        self.assertRaises(Exception, self.dbg.SetInputFileHandle, "ham sandwich")
+        self.assertRaises(Exception, self.dbg.SetErrorFile, None)
+        self.assertRaises(Exception, self.dbg.SetErrorFile, "ham sandwich")
+        self.assertRaises(Exception, self.dbg.SetErrorFileHandle, "ham sandwich")
 
         with open(self.out_filename, 'w') as f:
-            status = self.debugger.SetOutputFile(f)
+            status = self.dbg.SetOutputFile(f)
             self.assertTrue(status.Success())
-            status = self.debugger.SetErrorFile(f)
+            status = self.dbg.SetErrorFile(f)
             self.assertTrue(status.Success())
-            self.debugger.SetOutputFileHandle(None, False)
-            self.debugger.SetErrorFileHandle(None, False)
-            sbf = self.debugger.GetOutputFile()
+            self.dbg.SetOutputFileHandle(None, False)
+            self.dbg.SetErrorFileHandle(None, False)
+            sbf = self.dbg.GetOutputFile()
             if sys.version_info.major >= 3:
                 # python 2 lacks PyFile_FromFd, so GetFile() will
                 # have to duplicate the file descriptor and make a FILE*
                 # in order to convert a NativeFile it back to a python
                 # file.
                 self.assertEqual(sbf.GetFile().fileno(), 1)
-            sbf = self.debugger.GetErrorFile()
+            sbf = self.dbg.GetErrorFile()
             if sys.version_info.major >= 3:
                 self.assertEqual(sbf.GetFile().fileno(), 2)
         with open(self.out_filename, 'r') as f:
-            status = self.debugger.SetInputFile(f)
+            status = self.dbg.SetInputFile(f)
             self.assertTrue(status.Success())
-            self.debugger.SetInputFileHandle(None, False)
-            sbf = self.debugger.GetInputFile()
+            self.dbg.SetInputFileHandle(None, False)
+            sbf = self.dbg.GetInputFile()
             if sys.version_info.major >= 3:
                 self.assertEqual(sbf.GetFile().fileno(), 0)
 
index ff70831..a9847c6 100644 (file)
@@ -10,14 +10,6 @@ from lldbsuite.test import lldbutil
 class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
     mydir = TestBase.compute_mydir(__file__)
 
-    def setUp(self):
-        super(TestPlatformProcessConnect, self).setUp()
-        self._initial_platform = lldb.DBG.GetSelectedPlatform()
-
-    def tearDown(self):
-        lldb.DBG.SetSelectedPlatform(self._initial_platform)
-        super(TestPlatformProcessConnect, self).tearDown()
-
     @llgs_test
     @no_debug_info_test
     @skipIf(remote=False)
@@ -66,16 +58,10 @@ class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
 
         socket_id = lldbutil.wait_for_file_on_target(self, port_file)
 
-        new_debugger = lldb.SBDebugger.Create()
-        new_debugger.SetAsync(False)
-
-        def del_debugger(new_debugger=new_debugger):
-            del new_debugger
-        self.addTearDownHook(del_debugger)
+        self.dbg.SetAsync(False)
 
         new_platform = lldb.SBPlatform(lldb.remote_platform.GetName())
-        new_debugger.SetSelectedPlatform(new_platform)
-        new_interpreter = new_debugger.GetCommandInterpreter()
+        self.dbg.SetSelectedPlatform(new_platform)
 
         if unix_protocol:
             connect_url = "%s://%s%s" % (protocol, hostname, socket_id)
@@ -84,13 +70,13 @@ class TestPlatformProcessConnect(gdbremote_testcase.GdbRemoteTestCaseBase):
 
         command = "platform connect %s" % (connect_url)
         result = lldb.SBCommandReturnObject()
-        new_interpreter.HandleCommand(command, result)
+        self.dbg.GetCommandInterpreter().HandleCommand(command, result)
         self.assertTrue(
             result.Succeeded(),
             "platform process connect failed: %s" %
             result.GetOutput())
 
-        target = new_debugger.GetSelectedTarget()
+        target = self.dbg.GetSelectedTarget()
         process = target.GetProcess()
         thread = process.GetThreadAtIndex(0)