]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoins/TestConsecutiveBreakpoints.py
Vendor import of lldb release_38 branch r260756:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / breakpoint / consecutive_breakpoins / TestConsecutiveBreakpoints.py
1 """
2 Test continue from a breakpoint when there is a breakpoint on the next instruction also.
3 """
4
5 from __future__ import print_function
6
7
8
9 import unittest2
10 import lldb
11 import lldbsuite.test.lldbutil as lldbutil
12 from lldbsuite.test.lldbtest import *
13
14 class ConsecutiveBreakpoitsTestCase(TestBase):
15
16     mydir = TestBase.compute_mydir(__file__)
17
18     @expectedFailureAll("llvm.org/pr23478", oslist = not_in(["macosx"]))
19     def test (self):
20         self.build ()
21         self.consecutive_breakpoints_tests()
22         
23     def consecutive_breakpoints_tests(self):
24         exe = os.path.join (os.getcwd(), "a.out")
25
26         # Create a target by the debugger.
27         target = self.dbg.CreateTarget(exe)
28         self.assertTrue(target, VALID_TARGET)
29
30         breakpoint = target.BreakpointCreateBySourceRegex("Set breakpoint here", lldb.SBFileSpec("main.cpp"))
31         self.assertTrue(breakpoint and
32                         breakpoint.GetNumLocations() == 1,
33                         VALID_BREAKPOINT)
34
35         # Now launch the process, and do not stop at entry point.
36         process = target.LaunchSimple (None, None, self.get_process_working_directory())
37         self.assertTrue(process, PROCESS_IS_VALID)
38
39         # We should be stopped at the first breakpoint
40         thread = process.GetThreadAtIndex(0)
41         self.assertEqual(thread.GetStopReason(), lldb.eStopReasonBreakpoint)
42
43         # Set breakpoint to the next instruction
44         frame = thread.GetFrameAtIndex(0)
45         
46         address = frame.GetPCAddress()
47         instructions = target.ReadInstructions(address, 2)
48         self.assertTrue(len(instructions) == 2)
49         address = instructions[1].GetAddress()
50         
51         target.BreakpointCreateByAddress(address.GetLoadAddress(target))
52         process.Continue()
53
54         # We should be stopped at the second breakpoint
55         thread = process.GetThreadAtIndex(0)
56         self.assertEqual(thread.GetStopReason(), lldb.eStopReasonBreakpoint)
57
58         # Run the process until termination
59         process.Continue()