[Lldb-commits] [lldb] db9ac92 - Add lldb version into initialize response lldb-dap (#98703)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 15 17:03:53 PDT 2024
Author: jeffreytan81
Date: 2024-07-15T20:03:50-04:00
New Revision: db9ac92501509ce02ed188bb20a5211a9f29d5d3
URL: https://github.com/llvm/llvm-project/commit/db9ac92501509ce02ed188bb20a5211a9f29d5d3
DIFF: https://github.com/llvm/llvm-project/commit/db9ac92501509ce02ed188bb20a5211a9f29d5d3.diff
LOG: Add lldb version into initialize response lldb-dap (#98703)
Frequently, while troubleshooting user's debugging issues in VScode, we
would like to know lldb 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.
---------
Co-authored-by: jeffreytan81 <jeffreytan at fb.com>
Added:
Modified:
lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
lldb/tools/lldb-dap/lldb-dap.cpp
Removed:
################################################################################
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..dd47a2db8709b 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,34 @@ 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:]
+ lldb_json = self.dap_server.get_initialize_value("__lldb")
+ version_string = lldb_json["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 b50d40acb51a2..ea84f31aec3a6 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -1719,6 +1719,11 @@ void request_initialize(const llvm::json::Object &request) {
// The debug adapter supports data watchpoints.
body.try_emplace("supportsDataBreakpoints", true);
+ // Put in non-DAP specification lldb specific information.
+ llvm::json::Object lldb_json;
+ lldb_json.try_emplace("version", g_dap.debugger.GetVersionString());
+ body.try_emplace("__lldb", std::move(lldb_json));
+
response.try_emplace("body", std::move(body));
g_dap.SendJSON(llvm::json::Value(std::move(response)));
}
More information about the lldb-commits
mailing list