diff --git a/lldb/test/class_types/TestClassTypes.py b/lldb/test/class_types/TestClassTypes.py index 7dc5bb1e5b2c..4172a5b98e94 100644 --- a/lldb/test/class_types/TestClassTypes.py +++ b/lldb/test/class_types/TestClassTypes.py @@ -46,14 +46,21 @@ class ClassTypesTestCase(TestBase): self.buildDwarf() self.class_types_expr_parser() + def setUp(self): + super(ClassTypesTestCase, self).setUp() + # Find the line number to break for main.cpp. + self.line = line_number('main.cpp', '// Set break point at this line.') + def class_types(self): """Test 'frame variable this' when stopped on a class constructor.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break on the ctor function of class C. - self.expect("breakpoint set -f main.cpp -l 93", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = 93") + self.expect("breakpoint set -f main.cpp -l %d" % self.line, + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.cpp', line = %d" % + self.line) self.runCmd("run", RUN_SUCCEEDED) @@ -96,13 +103,13 @@ class ClassTypesTestCase(TestBase): bpfilespec = lldb.SBFileSpec("main.cpp") - breakpoint = target.BreakpointCreateByLocation(bpfilespec, 93) + breakpoint = target.BreakpointCreateByLocation(bpfilespec, self.line) self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) # Verify the breakpoint just created. self.expect(repr(breakpoint), BREAKPOINT_CREATED, exe=False, substrs = ['main.cpp', - '93']) + str(self.line)]) # Now launch the process, and do not stop at entry point. rc = lldb.SBError() @@ -127,7 +134,7 @@ class ClassTypesTestCase(TestBase): # should be 93. self.expect("%s:%d" % (lldbutil.GetFilenames(thread)[0], lldbutil.GetLineNumbers(thread)[0]), - "Break correctly at main.cpp:93", exe=False, + "Break correctly at main.cpp:%d" % self.line, exe=False, startstr = "main.cpp:") ### clang compiled code reported main.cpp:94? ### startstr = "main.cpp:93") diff --git a/lldb/test/class_types/TestClassTypesDisassembly.py b/lldb/test/class_types/TestClassTypesDisassembly.py index b2a207a6bb68..779ecf7928d3 100644 --- a/lldb/test/class_types/TestClassTypesDisassembly.py +++ b/lldb/test/class_types/TestClassTypesDisassembly.py @@ -33,14 +33,21 @@ class IterateFrameAndDisassembleTestCase(TestBase): self.buildDwarf() self.disassemble_call_stack_api() + def setUp(self): + super(IterateFrameAndDisassembleTestCase, self).setUp() + # Find the line number to break for main.cpp. + self.line = line_number('main.cpp', '// Set break point at this line.') + def breakOnCtor(self): """Setup/run the program so it stops on C's constructor.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break on the ctor function of class C. - self.expect("breakpoint set -f main.cpp -l 93", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.cpp', line = 93") + self.expect("breakpoint set -f main.cpp -l %d" % self.line, + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.cpp', line = %d" % + self.line) self.runCmd("run", RUN_SUCCEEDED) diff --git a/lldb/test/class_types/main.cpp b/lldb/test/class_types/main.cpp index 1766ef0ba2bc..251e66c3c9f7 100644 --- a/lldb/test/class_types/main.cpp +++ b/lldb/test/class_types/main.cpp @@ -90,7 +90,7 @@ public: B(ai, bi), m_c_int(ci) { - printf("Within C::ctor() m_c_int=%d\n", m_c_int); + printf("Within C::ctor() m_c_int=%d\n", m_c_int); // Set break point at this line. } //virtual