[Lldb-commits] [lldb] [LLDB][Telemetry] Collect telemetry from client when allowed. (PR #129728)

via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 18 07:29:05 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff d85a81b4e4cfc0fdc7c259d64f847e7bbeee56d2 4b134946c5f3aa315f5f4cb7cddfa571ff110a6d --extensions cpp,h -- lldb/include/lldb/API/SBDebugger.h lldb/include/lldb/Core/Debugger.h lldb/include/lldb/Core/Telemetry.h lldb/source/API/SBDebugger.cpp lldb/source/Core/Debugger.cpp lldb/source/Core/Telemetry.cpp lldb/tools/lldb-dap/DAP.cpp lldb/tools/lldb-dap/LLDBUtils.h lldb/unittests/Core/TelemetryTest.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/lldb/include/lldb/Core/Telemetry.h b/lldb/include/lldb/Core/Telemetry.h
index aadf15bd01..26eaba6538 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -36,15 +36,16 @@ struct LLDBConfig : public ::llvm::telemetry::Config {
   // the vendor while creating the Manager.
   const bool detailed_command_telemetry;
 
-    // If true, we will collect telemetry from LLDB's clients (eg., lldb-dap) via
+  // If true, we will collect telemetry from LLDB's clients (eg., lldb-dap) via
   // the SB interface. Must also be enabled by the vendor while creating the
   // manager.
   const bool enable_client_telemetry;
-  
-  explicit LLDBConfig(bool enable_telemetry, bool detailed_command_telemetry, bool enable_client_telemetry)
+
+  explicit LLDBConfig(bool enable_telemetry, bool detailed_command_telemetry,
+                      bool enable_client_telemetry)
       : ::llvm::telemetry::Config(enable_telemetry),
         detailed_command_telemetry(detailed_command_telemetry),
-        enable_client_telemetry(enable_client_telemetry){}
+        enable_client_telemetry(enable_client_telemetry) {}
 };
 
 // We expect each (direct) subclass of LLDBTelemetryInfo to
@@ -90,7 +91,7 @@ struct ClientInfo : public LLDBBaseTelemetryInfo {
   std::string request_name;
   std::optional<std::string> error_msg;
 };
-  
+
 struct CommandInfo : public LLDBBaseTelemetryInfo {
   /// If the command is/can be associated with a target entry this field
   /// contains that target's UUID. <EMPTY> otherwise.
diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp
index 51df8826e7..1a4d1bce95 100644
--- a/lldb/source/Core/Telemetry.cpp
+++ b/lldb/source/Core/Telemetry.cpp
@@ -148,7 +148,6 @@ void TelemetryManager::DispatchClientTelemetry(
                    "Failed to dispatch client telemetry");
 }
 
-
 class NoOpTelemetryManager : public TelemetryManager {
 public:
   llvm::Error preDispatch(llvm::telemetry::TelemetryInfo *entry) override {
@@ -164,11 +163,11 @@ public:
     return "NoOpTelemetryManager";
   }
 
-  DispatchClientTelemetry(
-    const lldb_private::StructuredDataImpl &entry, Debugger *debugger) override {
+  DispatchClientTelemetry(const lldb_private::StructuredDataImpl &entry,
+                          Debugger *debugger) override {
     // Does nothing.
   }
-  
+
   llvm::Error dispatch(llvm::telemetry::TelemetryInfo *entry) override {
     // Does nothing.
     return llvm::Error::success();
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 0e7a1a1d08..141edd8dbd 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -673,7 +673,7 @@ void DAP::SetTarget(const lldb::SBTarget target) {
 }
 
 bool DAP::HandleObject(const protocol::Message &M) {
- TelemetryDispatcher dispatcher;
+  TelemetryDispatcher dispatcher;
   if (const auto *req = std::get_if<protocol::Request>(&M)) {
     auto handler_pos = request_handlers.find(req->command);
     dispatcher.set("request_name", req->command);
@@ -682,7 +682,8 @@ bool DAP::HandleObject(const protocol::Message &M) {
       return true; // Success
     }
 
-    dispatcher.set("error", llvm::Twine("unhandled-command:" + req->command).str());
+    dispatcher.set("error",
+                   llvm::Twine("unhandled-command:" + req->command).str());
     DAP_LOG(log, "({0}) error: unhandled command '{1}'",
             transport.GetClientName(), req->command);
     return false; // Fail
diff --git a/lldb/unittests/Core/TelemetryTest.cpp b/lldb/unittests/Core/TelemetryTest.cpp
index 2c5e0a8c82..2d9c30b63c 100644
--- a/lldb/unittests/Core/TelemetryTest.cpp
+++ b/lldb/unittests/Core/TelemetryTest.cpp
@@ -53,7 +53,8 @@ class FakePlugin : public telemetry::TelemetryManager {
 public:
   FakePlugin()
       : telemetry::TelemetryManager(std::make_unique<telemetry::LLDBConfig>(
-            /*enable_telemetry=*/true, /*detailed_command_telemetry=*/true, /*enable_client_telemetry*/true)) {}
+            /*enable_telemetry=*/true, /*detailed_command_telemetry=*/true,
+            /*enable_client_telemetry*/ true)) {}
 
   // TelemetryManager interface
   llvm::Error preDispatch(llvm::telemetry::TelemetryInfo *entry) override {

``````````

</details>


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


More information about the lldb-commits mailing list