|
| 1 | +""" |
| 2 | +Test lldb-dap stack trace containing x86 assembly |
| 3 | +""" |
| 4 | + |
| 5 | +import lldbdap_testcase |
| 6 | +from lldbsuite.test.decorators import skipUnlessArch, skipUnlessPlatform |
| 7 | +from lldbsuite.test.lldbtest import line_number |
| 8 | + |
| 9 | + |
| 10 | +class TestDAP_stacktrace_x86(lldbdap_testcase.DAPTestCaseBase): |
| 11 | + @skipUnlessArch("x86_64") |
| 12 | + @skipUnlessPlatform(["linux"]) |
| 13 | + def test_stacktrace_x86(self): |
| 14 | + """ |
| 15 | + Tests that lldb-dap steps through correctly and the source lines are correct in x86 assembly. |
| 16 | + """ |
| 17 | + program = self.getBuildArtifact("a.out") |
| 18 | + self.build_and_launch( |
| 19 | + program, |
| 20 | + initCommands=[ |
| 21 | + "settings set target.process.thread.step-in-avoid-nodebug false" |
| 22 | + ], |
| 23 | + ) |
| 24 | + |
| 25 | + source = "main.c" |
| 26 | + breakpoint_ids = self.set_source_breakpoints( |
| 27 | + source, |
| 28 | + [line_number(source, "// Break here")], |
| 29 | + ) |
| 30 | + self.continue_to_breakpoints(breakpoint_ids) |
| 31 | + self.stepIn() |
| 32 | + |
| 33 | + frame = self.get_stackFrames()[0] |
| 34 | + self.assertEqual( |
| 35 | + frame["name"], |
| 36 | + "no_branch_func", |
| 37 | + "verify we are in the no_branch_func function", |
| 38 | + ) |
| 39 | + |
| 40 | + self.assertEqual(frame["line"], 1, "verify we are at the start of the function") |
| 41 | + minimum_assembly_lines = ( |
| 42 | + line_number(source, "Assembly end") |
| 43 | + - line_number(source, "Assembly start") |
| 44 | + + 1 |
| 45 | + ) |
| 46 | + self.assertLessEqual( |
| 47 | + 10, |
| 48 | + minimum_assembly_lines, |
| 49 | + "verify we have a reasonable number of assembly lines", |
| 50 | + ) |
| 51 | + |
| 52 | + for i in range(2, minimum_assembly_lines): |
| 53 | + self.stepIn() |
| 54 | + frame = self.get_stackFrames()[0] |
| 55 | + self.assertEqual( |
| 56 | + frame["name"], |
| 57 | + "no_branch_func", |
| 58 | + "verify we are still in the no_branch_func function", |
| 59 | + ) |
| 60 | + self.assertEqual( |
| 61 | + frame["line"], |
| 62 | + i, |
| 63 | + f"step in should advance a single line in the function to {i}", |
| 64 | + ) |
0 commit comments