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