[Lldb-commits] [lldb] Add lldb version into initialize response lldb-dap (PR #98703)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Jul 12 17:37:00 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: None (jeffreytan81)
<details>
<summary>Changes</summary>
Frequently, while troubleshooting user's debugging issues in VScode, we would like to know its version so that we can confirm if certain patch/feature is in or not.
This PR adds version string into `initialize` response so that telemetry can track it.
---
Full diff: https://github.com/llvm/llvm-project/pull/98703.diff
2 Files Affected:
- (modified) lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py (+30)
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+2)
``````````diff
diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
index b1b3d05ed4548..66d6d04cde882 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
@@ -475,3 +475,33 @@ def test_terminate_commands(self):
pattern=terminateCommands[0],
)
self.verify_commands("terminateCommands", output, terminateCommands)
+
+ @skipIfWindows
+ def test_version(self):
+ """
+ Tests that "initialize" response contains the "version" string the same
+ as the one returned by "version" command.
+ """
+ program = self.getBuildArtifact("a.out")
+ self.build_and_launch(program)
+
+ source = "main.c"
+ breakpoint_line = line_number(source, "// breakpoint 1")
+ lines = [breakpoint_line]
+ # Set breakpoint in the thread function so we can step the threads
+ breakpoint_ids = self.set_source_breakpoints(source, lines)
+ self.continue_to_breakpoints(breakpoint_ids)
+
+ version_eval_response = self.dap_server.request_evaluate(
+ "`version", context="repl"
+ )
+ version_eval_output = version_eval_response["body"]["result"]
+
+ # The first line is the prompt line like "(lldb) version", so we skip it.
+ version_eval_output_without_prompt_line = version_eval_output.splitlines()[1:]
+ version_string = self.dap_server.get_initialize_value("version")
+ self.assertEqual(
+ version_eval_output_without_prompt_line,
+ version_string.splitlines(),
+ "version string does not match",
+ )
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index b74474b9d383c..020e08bfb75d0 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -1710,6 +1710,8 @@ void request_initialize(const llvm::json::Object &request) {
body.try_emplace("supportsLogPoints", true);
// The debug adapter supports data watchpoints.
body.try_emplace("supportsDataBreakpoints", true);
+ // Putting version string. Note: this is not part of DAP spec.
+ body.try_emplace("version", g_dap.debugger.GetVersionString());
response.try_emplace("body", std::move(body));
g_dap.SendJSON(llvm::json::Value(std::move(response)));
``````````
</details>
https://github.com/llvm/llvm-project/pull/98703
More information about the lldb-commits
mailing list