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 @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr19310') 22 @expectedFailureNetBSD 23 @skipIfWindows # llvm.org/pr24778, llvm.org/pr21753 24 @skipIfReproducer # FIXME: Unexpected packet during (active) replay 25 def test_attach_continue_interrupt_detach(self): 26 """Test attach/continue/interrupt/detach""" 27 self.build() 28 self.process_attach_continue_interrupt_detach() 29 30 def process_attach_continue_interrupt_detach(self): 31 """Test attach/continue/interrupt/detach""" 32 33 exe = self.getBuildArtifact(exe_name) 34 35 popen = self.spawnSubprocess(exe) 36 37 self.runCmd("process attach -p " + str(popen.pid)) 38 39 self.setAsync(True) 40 listener = self.dbg.GetListener() 41 process = self.dbg.GetSelectedTarget().GetProcess() 42 43 self.runCmd("c") 44 lldbutil.expect_state_changes( 45 self, listener, process, [ 46 lldb.eStateRunning]) 47 48 self.runCmd("process interrupt") 49 lldbutil.expect_state_changes( 50 self, listener, process, [ 51 lldb.eStateStopped]) 52 53 # be sure to continue/interrupt/continue (r204504) 54 self.runCmd("c") 55 lldbutil.expect_state_changes( 56 self, listener, process, [ 57 lldb.eStateRunning]) 58 59 self.runCmd("process interrupt") 60 lldbutil.expect_state_changes( 61 self, listener, process, [ 62 lldb.eStateStopped]) 63 64 # Second interrupt should have no effect. 65 self.expect( 66 "process interrupt", 67 patterns=["Process is not running"], 68 error=True) 69 70 # check that this breakpoint is auto-cleared on detach (r204752) 71 self.runCmd("br set -f main.cpp -l %u" % 72 (line_number('main.cpp', '// Set breakpoint here'))) 73 74 self.runCmd("c") 75 lldbutil.expect_state_changes( 76 self, listener, process, [ 77 lldb.eStateRunning, lldb.eStateStopped]) 78 self.expect('br list', 'Breakpoint not hit', 79 substrs=['hit count = 1']) 80 81 # Make sure the breakpoint is not hit again. 82 self.expect("expr debugger_flag = false", substrs=[" = false"]) 83 84 self.runCmd("c") 85 lldbutil.expect_state_changes( 86 self, listener, process, [ 87 lldb.eStateRunning]) 88 89 # make sure to detach while in running state (r204759) 90 self.runCmd("detach") 91 lldbutil.expect_state_changes( 92 self, listener, process, [ 93 lldb.eStateDetached]) 94