[Lldb-commits] [lldb] [lldb][lldb-dap] Implement jump to cursor (PR #130503)

Adrian Vogelsgesang via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 13 07:01:36 PDT 2025


================
@@ -0,0 +1,138 @@
+"""
+Test lldb-dap gotoTarget request
+"""
+
+from typing import Dict, Any
+from unittest import SkipTest
+
+from lldbsuite.test.lldbtest import line_number
+import lldbdap_testcase
+import os
+
+
+class TestDAP_gotoTargets(lldbdap_testcase.DAPTestCaseBase):
+    def verify_variable(
+        self, actual_dict: Dict[str, Any], expected_dict: Dict[str, Any]
+    ):
+        for key, value in expected_dict.items():
+            actual_value = actual_dict[key]
+            self.assertEqual(
+                actual_value,
+                value,
+                f"values does not match for key: `{key}` expected_value: `{value}`, actual_value: `{actual_value}`",
+            )
+
+    def test_default(self):
+        """
+        Tests the jump to cursor of a simple program. No arguments,
+        environment, or anything else is specified.
+        This does not run any statement between the current breakpoint
+        and the jump line location.
+        """
+        program = self.getBuildArtifact("a.out")
+        self.build_and_launch(program)
+
+        source_file = "main.c"
+        self.source_path = os.path.join(os.getcwd(), source_file)
+        self.set_source_breakpoints(
+            source_file, [line_number(source_file, "// breakpoint 1")]
+        )
+        self.continue_to_next_stop()
+
+        first_var_1_object = self.dap_server.get_local_variable("var_1")
+        self.assertEqual(first_var_1_object["value"], "10")
+
+        goto_line = line_number(source_file, "// goto 1")
+        goto_column = 1
+        response = self.dap_server.request_gotoTargets(
+            source_file, self.source_path, goto_line, goto_column
+        )
+
+        self.assertEqual(
+            response["success"], True, "expects success when request for targets"
----------------
vogelsgesang wrote:

```suggestion
            response["success"], True, "request for gotoTargets should be successful"
```

https://github.com/llvm/llvm-project/pull/130503


More information about the lldb-commits mailing list