]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/attach_resume/TestAttachResume.py
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / attach_resume / TestAttachResume.py
1 """
2 Test process attach/resume.
3 """
4
5 from __future__ import print_function
6
7
8
9 import os, time
10 import lldb
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
14
15 exe_name = "AttachResume"  # Must match Makefile
16
17 class AttachResumeTestCase(TestBase):
18
19     mydir = TestBase.compute_mydir(__file__)
20
21     @skipIfRemote
22     @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr19310')
23     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
24     def test_attach_continue_interrupt_detach(self):
25         """Test attach/continue/interrupt/detach"""
26         self.build()
27         self.process_attach_continue_interrupt_detach()
28
29     def process_attach_continue_interrupt_detach(self):
30         """Test attach/continue/interrupt/detach"""
31
32         exe = os.path.join(os.getcwd(), exe_name)
33
34         popen = self.spawnSubprocess(exe)
35         self.addTearDownHook(self.cleanupSubprocesses)
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(self, listener, process, [lldb.eStateRunning])
45
46         self.runCmd("process interrupt")
47         lldbutil.expect_state_changes(self, listener, process, [lldb.eStateStopped])
48
49         # be sure to continue/interrupt/continue (r204504)
50         self.runCmd("c")
51         lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning])
52
53         self.runCmd("process interrupt")
54         lldbutil.expect_state_changes(self, listener, process, [lldb.eStateStopped])
55
56         # Second interrupt should have no effect.
57         self.expect("process interrupt", patterns=["Process is not running"], error=True)
58
59         # check that this breakpoint is auto-cleared on detach (r204752)
60         self.runCmd("br set -f main.cpp -l %u" % (line_number('main.cpp', '// Set breakpoint here')))
61
62         self.runCmd("c")
63         lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning, lldb.eStateStopped])
64         self.expect('br list', 'Breakpoint not hit',
65             substrs = ['hit count = 1'])
66
67         # Make sure the breakpoint is not hit again.
68         self.expect("expr debugger_flag = false", substrs=[" = false"]);
69
70         self.runCmd("c")
71         lldbutil.expect_state_changes(self, listener, process, [lldb.eStateRunning])
72
73         # make sure to detach while in running state (r204759)
74         self.runCmd("detach")
75         lldbutil.expect_state_changes(self, listener, process, [lldb.eStateDetached])