Skip to content

Commit db9ac92

Browse files
jeffreytan81jeffreytan81
andauthored
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 <[email protected]>
1 parent 864478c commit db9ac92

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,3 +475,34 @@ def test_terminate_commands(self):
475475
pattern=terminateCommands[0],
476476
)
477477
self.verify_commands("terminateCommands", output, terminateCommands)
478+
479+
@skipIfWindows
480+
def test_version(self):
481+
"""
482+
Tests that "initialize" response contains the "version" string the same
483+
as the one returned by "version" command.
484+
"""
485+
program = self.getBuildArtifact("a.out")
486+
self.build_and_launch(program)
487+
488+
source = "main.c"
489+
breakpoint_line = line_number(source, "// breakpoint 1")
490+
lines = [breakpoint_line]
491+
# Set breakpoint in the thread function so we can step the threads
492+
breakpoint_ids = self.set_source_breakpoints(source, lines)
493+
self.continue_to_breakpoints(breakpoint_ids)
494+
495+
version_eval_response = self.dap_server.request_evaluate(
496+
"`version", context="repl"
497+
)
498+
version_eval_output = version_eval_response["body"]["result"]
499+
500+
# The first line is the prompt line like "(lldb) version", so we skip it.
501+
version_eval_output_without_prompt_line = version_eval_output.splitlines()[1:]
502+
lldb_json = self.dap_server.get_initialize_value("__lldb")
503+
version_string = lldb_json["version"]
504+
self.assertEqual(
505+
version_eval_output_without_prompt_line,
506+
version_string.splitlines(),
507+
"version string does not match",
508+
)

lldb/tools/lldb-dap/lldb-dap.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,11 @@ void request_initialize(const llvm::json::Object &request) {
17191719
// The debug adapter supports data watchpoints.
17201720
body.try_emplace("supportsDataBreakpoints", true);
17211721

1722+
// Put in non-DAP specification lldb specific information.
1723+
llvm::json::Object lldb_json;
1724+
lldb_json.try_emplace("version", g_dap.debugger.GetVersionString());
1725+
body.try_emplace("__lldb", std::move(lldb_json));
1726+
17221727
response.try_emplace("body", std::move(body));
17231728
g_dap.SendJSON(llvm::json::Value(std::move(response)));
17241729
}

0 commit comments

Comments
 (0)