[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)
Ebuka Ezike via lldb-commits
lldb-commits at lists.llvm.org
Thu Apr 24 03:20:55 PDT 2025
================
@@ -0,0 +1,195 @@
+"""
+Test lldb-dap stack trace when some of the source paths are missing
+"""
+
+from lldbsuite.test.decorators import skipIfWindows
+from lldbsuite.test.lldbtest import line_number
+import lldbdap_testcase
+from contextlib import contextmanager
+import os
+
+
+OTHER_C_SOURCE_CODE = """
+int fibonacci(int n) {
+ if (n < 0) return -1;
+ if (n == 0) return 0;
+ if (n == 1) return 1;
+ int a = 0, b = 1, c;
+ for (int i = 2; i <= n; ++i) {
+ c = a + b;
+ a = b;
+ b = c;
+ }
+
+ return b; // Break here
+}
+"""
+
+
+ at contextmanager
+def delete_file_on_exit(path):
+ try:
+ yield path
+ finally:
+ if os.path.exists(path):
+ os.remove(path)
+
+
+class TestDAP_stackTraceMissingSourcePath(lldbdap_testcase.DAPTestCaseBase):
+ def build_and_run_until_breakpoint(self, stop_disassembly_display: str):
+ """
+ Build the program and run until the breakpoint is hit, and return the stack frames.
+ """
+ other_source_file = "other.c"
+ with delete_file_on_exit(other_source_file):
+ with open(other_source_file, "w") as f:
+ f.write(OTHER_C_SOURCE_CODE)
+
+ breakpoint_line = line_number(other_source_file, "// Break here")
+
+ program = self.getBuildArtifact("a.out")
+ init_commands = [
+ f"settings set stop-disassembly-display {stop_disassembly_display}"
+ ]
+ self.build_and_launch(program, initCommands=init_commands)
+
+ breakpoint_ids = self.set_source_breakpoints(
+ other_source_file, [breakpoint_line]
+ )
+ self.assertEqual(
+ len(breakpoint_ids), 1, "expect correct number of breakpoints"
+ )
+
+ self.continue_to_breakpoints(breakpoint_ids)
+
+ frames = self.get_stackFrames()
+ self.assertLessEqual(2, len(frames), "expect at least 2 frames")
+
+ self.assertIn(
+ "path",
+ frames[0]["source"],
+ "Expect source path to always be in frame (other.c)",
+ )
+ self.assertIn(
+ "path",
+ frames[1]["source"],
+ "Expect source path in always be in frame (main.c)",
+ )
+
+ return frames
+
+ @skipIfWindows
+ def test_stopDisassemblyDispay_noSource(self):
----------------
da-viper wrote:
```suggestion
def test_stopDisassemblyDisplay_noSource(self):
```
https://github.com/llvm/llvm-project/pull/136494
More information about the lldb-commits
mailing list