1""" 2Test process attach/resume. 3""" 4 5 6 7import lldb 8from lldbsuite.test.decorators import * 9from lldbsuite.test.lldbtest import * 10from lldbsuite.test import lldbutil 11 12exe_name = "AttachResume" # Must match Makefile 13 14 15class AttachResumeTestCase(TestBase): 16 17 mydir = TestBase.compute_mydir(__file__) 18 NO_DEBUG_INFO_TESTCASE = True 19 20 @skipIfRemote 21 @expectedFailureNetBSD 22 @skipIfWindows # llvm.org/pr24778, llvm.org/pr21753 23 def test_attach_continue_interrupt_detach(self): 24 """Test attach/continue/interrupt/detach""" 25 self.build() 26 self.process_attach_continue_interrupt_detach() 27 28 def process_attach_continue_interrupt_detach(self): 29 """Test attach/continue/interrupt/detach""" 30 31 exe = self.getBuildArtifact(exe_name) 32 33 popen = self.spawnSubprocess(exe) 34 35 self.runCmd("process attach -p " + str(popen.pid)) 36 37 self.setAsync(True) 38 listener = self.dbg.GetListener() 39 process = self.dbg.GetSelectedTarget().GetProcess() 40 41 self.runCmd("c") 42 lldbutil.expect_state_changes( 43 self, listener, process, [ 44 lldb.eStateRunning]) 45 46 self.runCmd("process interrupt") 47 lldbutil.expect_state_changes( 48 self, listener, process, [ 49 lldb.eStateStopped]) 50 51 # be sure to continue/interrupt/continue (r204504) 52 self.runCmd("c") 53 lldbutil.expect_state_changes( 54 self, listener, process, [ 55 lldb.eStateRunning]) 56 57 self.runCmd("process interrupt") 58 lldbutil.expect_state_changes( 59 self, listener, process, [ 60 lldb.eStateStopped]) 61 62 # Second interrupt should have no effect. 63 self.expect( 64 "process interrupt", 65 patterns=["Process is not running"], 66 error=True) 67 68 # check that this breakpoint is auto-cleared on detach (r204752) 69 self.runCmd("br set -f main.cpp -l %u" % 70 (line_number('main.cpp', '// Set breakpoint here'))) 71 72 self.runCmd("c") 73 lldbutil.expect_state_changes( 74 self, listener, process, [ 75 lldb.eStateRunning, lldb.eStateStopped]) 76 self.expect('br list', 'Breakpoint not hit', 77 substrs=['hit count = 1']) 78 79 # Make sure the breakpoint is not hit again. 80 self.expect("expr debugger_flag = false", substrs=[" = false"]) 81 82 self.runCmd("c") 83 lldbutil.expect_state_changes( 84 self, listener, process, [ 85 lldb.eStateRunning]) 86 87 # make sure to detach while in running state (r204759) 88 self.runCmd("detach") 89 lldbutil.expect_state_changes( 90 self, listener, process, [ 91 lldb.eStateDetached]) 92