From 9a652a84b141901b6eb17a5948b0741e0febd141 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 26 Mar 2018 15:17:58 +0000 Subject: 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. llvm-svn: 328504 --- .../disassembly/TestDisassembleBreakpoint.py | 51 +++++++++------------- .../test/functionalities/disassembly/main.cpp | 4 +- 2 files changed, 22 insertions(+), 33 deletions(-) (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/disassembly') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py b/lldb/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py index 2e0d4fda369..52f9daf6bd4 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/disassembly/TestDisassembleBreakpoint.py @@ -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) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp index 93925829ec8..c68e3f1b321 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/functionalities/disassembly/main.cpp @@ -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); -- cgit v1.2.3