1""" 2Test that commands do not try and hold on to stale CommandInterpreters in a multiple debuggers scenario 3""" 4 5from __future__ import print_function 6 7 8import lldb 9from lldbsuite.test.decorators import * 10from lldbsuite.test.lldbtest import * 11from lldbsuite.test import lldbutil 12 13 14class MultipleDebuggersCommandsTestCase(TestBase): 15 16 @no_debug_info_test 17 def test_multipledebuggers_commands(self): 18 """Test that commands do not try and hold on to stale CommandInterpreters in a multiple debuggers scenario""" 19 source_init_files = False 20 magic_text = "The following commands may relate to 'env'" 21 22 debugger_1 = lldb.SBDebugger.Create(source_init_files) 23 interpreter_1 = debugger_1.GetCommandInterpreter() 24 25 retobj = lldb.SBCommandReturnObject() 26 interpreter_1.HandleCommand("apropos env", retobj) 27 self.assertTrue( 28 magic_text in str(retobj), 29 "[interpreter_1]: the output does not contain the correct words") 30 31 if self.TraceOn(): 32 print(str(retobj)) 33 34 lldb.SBDebugger.Destroy(debugger_1) 35 36 # now do this again with a different debugger - we shouldn't crash 37 38 debugger_2 = lldb.SBDebugger.Create(source_init_files) 39 interpreter_2 = debugger_2.GetCommandInterpreter() 40 41 retobj = lldb.SBCommandReturnObject() 42 interpreter_2.HandleCommand("apropos env", retobj) 43 self.assertTrue( 44 magic_text in str(retobj), 45 "[interpreter_2]: the output does not contain the correct words") 46 47 if self.TraceOn(): 48 print(str(retobj)) 49 50 lldb.SBDebugger.Destroy(debugger_2) 51