9f184fb0ff4ef2c2c76616d676c081ccd6a08d63
[platform/upstream/llvm.git] /
1 """
2 Test that inlined breakpoints (breakpoint set on a file/line included from
3 another source file) works correctly.
4 """
5
6 from __future__ import print_function
7
8
9 import lldb
10 from lldbsuite.test.lldbtest import *
11 import lldbsuite.test.lldbutil as lldbutil
12
13
14 class InlinedBreakpointsTestCase(TestBase):
15     """Bug fixed: rdar://problem/8464339"""
16
17     mydir = TestBase.compute_mydir(__file__)
18
19     def test_with_run_command(self):
20         """Test 'b basic_types.cpp:176' does break (where int.cpp includes basic_type.cpp)."""
21         self.build()
22         self.inlined_breakpoints()
23
24     def setUp(self):
25         # Call super's setUp().
26         TestBase.setUp(self)
27         # Find the line number to break inside basic_type.cpp.
28         self.line = line_number(
29             'basic_type.cpp',
30             '// Set break point at this line.')
31
32     def inlined_breakpoints(self):
33         """Test 'b basic_types.cpp:176' does break (where int.cpp includes basic_type.cpp)."""
34         exe = self.getBuildArtifact("a.out")
35         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
36
37         # With the inline-breakpoint-strategy, our file+line breakpoint should
38         # not resolve to a location.
39         self.runCmd('settings set target.inline-breakpoint-strategy headers')
40
41         # Set a breakpoint and fail because it is in an inlined source
42         # implemenation file
43         lldbutil.run_break_set_by_file_and_line(
44             self, "basic_type.cpp", self.line, num_expected_locations=0)
45
46         # Now enable breakpoints in implementation files and see the breakpoint
47         # set succeed
48         self.runCmd('settings set target.inline-breakpoint-strategy always')
49         # And add hooks to restore the settings during tearDown().
50         self.addTearDownHook(lambda: self.runCmd(
51             "settings set target.inline-breakpoint-strategy always"))
52
53         lldbutil.run_break_set_by_file_and_line(
54             self,
55             "basic_type.cpp",
56             self.line,
57             num_expected_locations=1,
58             loc_exact=True)
59
60         self.runCmd("run", RUN_SUCCEEDED)
61
62         # The stop reason of the thread should be breakpoint.
63         # And it should break at basic_type.cpp:176.
64         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
65                     substrs=['stopped',
66                              'stop reason = breakpoint',
67                              'basic_type.cpp:%d' % self.line])