1 from __future__ import print_function
6 from lldbsuite.test.lldbtest import *
7 import lldbsuite.test.lldbutil as lldbutil
10 class TestMoveNearest(TestBase):
12 mydir = TestBase.compute_mydir(__file__)
13 NO_DEBUG_INFO_TESTCASE = True
16 # Call super's setUp().
18 # Find the line number to break inside main().
19 self.line1 = line_number('foo.h', '// !BR1')
20 self.line2 = line_number('foo.h', '// !BR2')
21 self.line_between = line_number('main.cpp', "// BR_Between")
22 print("BR_Between found at", self.line_between)
23 self.line_main = line_number('main.cpp', '// !BR_main')
26 """Test target.move-to-nearest logic"""
29 target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
30 self.assertTrue(target, VALID_TARGET)
32 lldbutil.run_break_set_by_symbol(self, 'main', sym_exact=True)
33 environment = self.registerSharedLibrariesWithTarget(target, ["foo"])
34 process = target.LaunchSimple(None, environment, self.get_process_working_directory())
35 self.assertEquals(process.GetState(), lldb.eStateStopped)
37 # Regardless of the -m value the breakpoint should have exactly one
38 # location on the foo functions
39 self.runCmd("settings set target.move-to-nearest-code true")
40 lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line1,
41 loc_exact=True, extra_options="-m 1")
42 lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line2,
43 loc_exact=True, extra_options="-m 1")
45 self.runCmd("settings set target.move-to-nearest-code false")
46 lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line1,
47 loc_exact=True, extra_options="-m 0")
48 lldbutil.run_break_set_by_file_and_line(self, 'foo.h', self.line2,
49 loc_exact=True, extra_options="-m 0")
52 # Make sure we set a breakpoint in main with -m 1 for various lines in
53 # the function declaration
55 lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
56 self.line_main-1, extra_options="-m 1")
58 lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
59 self.line_main, extra_options="-m 1")
61 lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
62 self.line_main+1, extra_options="-m 1")
64 lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
65 self.line_main+2, extra_options="-m 1")
67 # Make sure we don't put move the breakpoint if it is set between two functions:
68 lldbutil.run_break_set_by_file_and_line(self, 'main.cpp',
69 self.line_between, extra_options="-m 1", num_expected_locations=0)