Author: labath Date: Mon Mar 26 08:17:58 2018 New Revision: 328504 URL: http://llvm.org/viewvc/llvm-project?rev=328504&view=rev Log: Fix TestDisassembleBreakpoint broken by r328488
The first issue was that the test was capturing the "before" disassembly before launching, and the "after" after. This is a problem because some of the disassembly will change after we know the load address (e.g. PCs in call instructions). I fix this by capturing both disassemblies with the process running. The second issue was that the refactor in r328488 accidentaly changed the meaning of the test, as it was no longer disassembling the function which contained the breakpoint. While inside, I also modernize the test to use lldbutil.run_to_source_breakpoint and prevent debug-info replication. Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py?rev=328504&r1=328503&r2=328504&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py Mon Mar 26 08:17:58 2018 @@ -16,40 +16,29 @@ from lldbsuite.test import lldbutil class DisassemblyTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True @expectedFailureAll( oslist=["windows"], bugnumber="function names print fully demangled instead of name-only") def test(self): self.build() - exe = self.getBuildArtifact("a.out") - self.expect("file " + exe, - patterns=["Current executable set to .*a.out.*"]) - - self.runCmd("dis -n main") - disassembly_before_break = self.res.GetOutput().splitlines() - - match_object = lldbutil.run_break_set_command(self, "br s -n sum") - lldbutil.check_breakpoint_result( - self, - match_object, - symbol_name='sum', - symbol_match_exact=False, - num_locations=1) - - self.expect("run", - patterns=["Process .* launched: "]) - - self.runCmd("dis -n main") - disassembly_after_break = self.res.GetOutput().splitlines() - - # make sure all assembly instructions are the same as the original - # instructions before inserting breakpoints. - self.assertEqual(len(disassembly_before_break), - len(disassembly_after_break)) - - for dis_inst_before, dis_inst_after in \ - zip(disassembly_before_break, disassembly_after_break): - inst_before = dis_inst_before.split(':')[-1] - inst_after = dis_inst_after.split(':')[-1] - self.assertEqual(inst_before, inst_after) + target, _, _, bkpt = lldbutil.run_to_source_breakpoint(self, + "Set a breakpoint here", lldb.SBFileSpec("main.cpp")) + self.runCmd("dis -f") + disassembly_with_break = self.res.GetOutput().splitlines() + + self.assertTrue(target.BreakpointDelete(bkpt.GetID())) + + self.runCmd("dis -f") + disassembly_without_break = self.res.GetOutput().splitlines() + + # Make sure all assembly instructions are the same as instructions + # with the breakpoint removed. + self.assertEqual(len(disassembly_with_break), + len(disassembly_without_break)) + for dis_inst_with, dis_inst_without in \ + zip(disassembly_with_break, disassembly_without_break): + inst_with = dis_inst_with.split(':')[-1] + inst_without = dis_inst_without.split(':')[-1] + self.assertEqual(inst_with, inst_without) Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp?rev=328504&r1=328503&r2=328504&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp Mon Mar 26 08:17:58 2018 @@ -10,7 +10,7 @@ int sum (int a, int b) { - int result = a + b; + int result = a + b; // Set a breakpoint here return result; } @@ -20,7 +20,7 @@ main(int argc, char const *argv[]) int array[3]; - array[0] = sum (1238, 78392); // Set a breakpoint here + array[0] = sum (1238, 78392); array[1] = sum (379265, 23674); array[2] = sum (872934, 234); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits