[Lldb-commits] [lldb] a31130f - [lldb][testsuite] Create a SBDebugger instance for each test
Tatyana Krasnukha via lldb-commits
lldb-commits at lists.llvm.org
Wed Mar 4 23:15:46 PST 2020
Author: Tatyana Krasnukha
Date: 2020-03-05T10:12:54+03:00
New Revision: a31130f6fcf27518b31a8ac1f5971a42fc24837e
URL: https://github.com/llvm/llvm-project/commit/a31130f6fcf27518b31a8ac1f5971a42fc24837e
DIFF: https://github.com/llvm/llvm-project/commit/a31130f6fcf27518b31a8ac1f5971a42fc24837e.diff
LOG: [lldb][testsuite] Create a SBDebugger instance for each test
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
Added:
Modified:
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
Removed:
################################################################################
diff --git a/lldb/bindings/interface/SBPlatform.i b/lldb/bindings/interface/SBPlatform.i
index 9baa2eb970c6..1f52edb0232c 100644
--- a/lldb/bindings/interface/SBPlatform.i
+++ b/lldb/bindings/interface/SBPlatform.i
@@ -115,6 +115,8 @@ public:
~SBPlatform();
+ static SBPlatform GetHostPlatform();
+
bool
IsValid () const;
diff --git a/lldb/include/lldb/API/SBPlatform.h b/lldb/include/lldb/API/SBPlatform.h
index 58dafc235c64..7fac182a0dd1 100644
--- a/lldb/include/lldb/API/SBPlatform.h
+++ b/lldb/include/lldb/API/SBPlatform.h
@@ -97,6 +97,8 @@ class LLDB_API SBPlatform {
~SBPlatform();
+ static SBPlatform GetHostPlatform();
+
explicit operator bool() const;
bool IsValid() const;
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index ec17cb7c2569..b0d2db7655ff 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -172,7 +172,7 @@ def fn(self):
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)
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index 5dddc996eda5..991e29d7e6b0 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -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()
diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 02946f0398b4..32c9c20d6eea 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -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 ''
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index b20c29dafc6a..866daada3b9e 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -703,6 +703,11 @@ def setUpCommands(cls):
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 @@ def setUp(self):
# 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 @@ def tearDown(self):
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 @@ def tearDown(self):
# 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
diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp
index b17509c01501..7aa0b54d0005 100644
--- a/lldb/source/API/SBPlatform.cpp
+++ b/lldb/source/API/SBPlatform.cpp
@@ -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();
diff --git a/lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py b/lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
index 0169cd494f54..874a90853c2a 100644
--- a/lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
+++ b/lldb/test/API/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
@@ -13,14 +13,6 @@
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 @@ def test_target_auto_install_main_executable(self):
# 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 @@ def del_debugger(new_debugger=new_debugger):
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 @@ def del_debugger(new_debugger=new_debugger):
(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 @@ def del_debugger(new_debugger=new_debugger):
(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 @@ def del_debugger(new_debugger=new_debugger):
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(),
diff --git a/lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py b/lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
index ff087159f613..068f563a010d 100644
--- a/lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
+++ b/lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py
@@ -79,9 +79,3 @@ def function(self, function, target):
i += 1
else:
i += 1
-
-if __name__ == '__main__':
- import atexit
- lldb.SBDebugger.Initialize()
- atexit.register(lambda: lldb.SBDebugger.Terminate())
- unittest2.main()
diff --git a/lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py b/lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
index ea94fd3ec1f3..4c8aa368790c 100644
--- a/lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
+++ b/lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
@@ -87,7 +87,6 @@ def test_step_instruction(self):
@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
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
index 9de0279bbfad..ae66bc278ed6 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
@@ -11,14 +11,6 @@ class gPacketResponder(MockGDBServerResponder):
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")
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
index f70c854ed6d4..59a11d45737c 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteLoad.py
@@ -6,14 +6,6 @@
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")
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestWasm.py b/lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
index 7a2346c21a07..8d0f2c89b73b 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestWasm.py
@@ -86,14 +86,6 @@ def readMemory(self, addr, length):
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):
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py b/lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
index b7f19a16bf39..73bd292463f0 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestWriteMemory.py
@@ -6,15 +6,6 @@
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):
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py b/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
index 44028e561ec3..6bfdd8c5ec23 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
@@ -10,14 +10,6 @@ class Responder(MockGDBServerResponder):
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")
diff --git a/lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py b/lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py
index e81d4076574d..b688bd4ce0c7 100644
--- a/lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py
+++ b/lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py
@@ -37,16 +37,14 @@ def test_load_plugin(self):
# 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 @@ def test_load_plugin(self):
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():
diff --git a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
index c2746bf1a80d..5a1eab3f9018 100644
--- a/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
+++ b/lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
@@ -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):
diff --git a/lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py b/lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py
index ca863d250481..6e16ce307846 100644
--- a/lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py
+++ b/lldb/test/API/functionalities/postmortem/elf-core/gcore/TestGCore.py
@@ -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
diff --git a/lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py b/lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
index 4be7ebe3122e..6e34c914ae28 100644
--- a/lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
+++ b/lldb/test/API/functionalities/postmortem/elf-core/thread_crash/TestLinuxCoreThreads.py
@@ -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
diff --git a/lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py b/lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py
index 7680b55e60d3..eaf8ab576c8b 100644
--- a/lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py
+++ b/lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py
@@ -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
diff --git a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
index 62b6c80e0b3d..f209261f0500 100644
--- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -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)
diff --git a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
index ca0ad5f67b21..c57aa98d934c 100644
--- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
+++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
@@ -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)
diff --git a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
index 067b04d997d0..f967a57e4ea7 100644
--- a/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
+++ b/lldb/test/API/functionalities/postmortem/netbsd-core/TestNetBSDCore.py
@@ -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)
diff --git a/lldb/test/API/functionalities/thread/backtrace_all/TestBacktraceAll.py b/lldb/test/API/functionalities/thread/backtrace_all/TestBacktraceAll.py
index 870b6b223c8d..372244a4c8ca 100644
--- a/lldb/test/API/functionalities/thread/backtrace_all/TestBacktraceAll.py
+++ b/lldb/test/API/functionalities/thread/backtrace_all/TestBacktraceAll.py
@@ -57,9 +57,3 @@ def test(self):
# Run to completion
self.runCmd("continue")
-
-if __name__ == '__main__':
- import atexit
- lldb.SBDebugger.Initialize()
- atexit.register(lambda: lldb.SBDebugger.Terminate())
- unittest2.main()
diff --git a/lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py b/lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
index cce485bd5a5a..552fdef4a471 100644
--- a/lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
+++ b/lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
@@ -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")
diff --git a/lldb/test/API/macosx/load-kext/TestLoadKext.py b/lldb/test/API/macosx/load-kext/TestLoadKext.py
index ec35ce854d83..d2e9a7ce658b 100644
--- a/lldb/test/API/macosx/load-kext/TestLoadKext.py
+++ b/lldb/test/API/macosx/load-kext/TestLoadKext.py
@@ -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."""
diff --git a/lldb/test/API/python_api/file_handle/TestFileHandle.py b/lldb/test/API/python_api/file_handle/TestFileHandle.py
index 53ca64932d64..996077cff4b4 100644
--- a/lldb/test/API/python_api/file_handle/TestFileHandle.py
+++ b/lldb/test/API/python_api/file_handle/TestFileHandle.py
@@ -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
diff erent
- # 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 @@ def handleCmd(self, cmd, check=True, collect_result=True):
@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 @@ def test_legacy_file_out_script(self):
@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 @@ def test_legacy_file_err_with_get(self):
@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 @@ def test_sbfile_read(self):
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 @@ def test_fileno_out(self):
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 @@ def test_fileno_help(self):
@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 @@ def test_immediate(self):
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 @@ def test_immediate_string(self):
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 @@ def test_immediate_sbfile_string(self):
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 @@ def test_fileno_inout(self):
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 @@ def test_inout(self):
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 @@ def test_inout(self):
@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 @@ def test_binary_inout(self):
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 @@ def test_string_inout(self):
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 @@ def test_fileno_error(self):
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 @@ def test_replace_stdout(self):
@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 @@ def test_sbfile_write_string(self):
@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 @@ def test_string_out(self):
@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 @@ def test_sbfile_read_bytes(self):
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 @@ def test_sbfile_out(self):
@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 @@ def test_file_out(self):
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 @@ def test_sbfile_error(self):
@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 @@ def test_exceptions(self):
@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 @@ def test_fileno_flush(self):
@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 @@ def test_close(self):
@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 @@ def test_stdout(self):
@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 @@ def i(sbf):
@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)
diff --git a/lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py b/lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
index ff708310ca93..a9847c66ca12 100644
--- a/lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
+++ b/lldb/test/API/tools/lldb-server/platform-process-connect/TestPlatformProcessConnect.py
@@ -10,14 +10,6 @@
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 @@ def test_platform_process_connect(self):
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 @@ def del_debugger(new_debugger=new_debugger):
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)
More information about the lldb-commits
mailing list