[Lldb-commits] [lldb] Define TelemetryVendor plugin. (PR #126588)

via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 10 11:48:00 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Vy Nguyen (oontvoo)

<details>
<summary>Changes</summary>

Details:

Upstream in LLDB, we will have a default TelemetryVendor plugin will provide a default Config and NULL TelemetryManager. Downstream vendors can extend this to provide a vendor-specific Config along with a functional TelemetryManager instance.

---
Full diff: https://github.com/llvm/llvm-project/pull/126588.diff


2 Files Affected:

- (added) lldb/include/lldb/Core/TelemetryVendor.h (+39) 
- (added) lldb/source/Core/TelemetryVendor.cpp (+43) 


``````````diff
diff --git a/lldb/include/lldb/Core/TelemetryVendor.h b/lldb/include/lldb/Core/TelemetryVendor.h
new file mode 100644
index 000000000000000..a2ab3b69fde4225
--- /dev/null
+++ b/lldb/include/lldb/Core/TelemetryVendor.h
@@ -0,0 +1,39 @@
+//===-- TelemetryVendor.h -------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_CORE_TELEMETRYVENDOR_H
+#define LLDB_CORE_TELEMETRYVENDOR_H
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/Telemetry/Telemetry.h"
+
+#include <memory>
+
+namespace lldb_private {
+
+class TelemetryVendor : public PluginInterface {
+public:
+  TelemetryVendor() = default;
+
+  llvm::StringRef GetPluginName() override;
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static std::unique_ptr<llvm::telemetry::Config> GetTelemetryConfig();
+  static void
+  SetTelemetryConfig(std::unique_ptr<llvm::telemetry::Config> config);
+
+  static lldb::TelemetryManagerSP GetTelemetryManager();
+  static void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp);
+};
+
+} // namespace lldb_private
+#endif // LLDB_CORE_TELEMETRYVENDOR_H
diff --git a/lldb/source/Core/TelemetryVendor.cpp b/lldb/source/Core/TelemetryVendor.cpp
new file mode 100644
index 000000000000000..520a01b9b1c7a3e
--- /dev/null
+++ b/lldb/source/Core/TelemetryVendor.cpp
@@ -0,0 +1,43 @@
+//===-- TelemetryVendor.cpp -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Core/TelemetryVendor.h"
+
+namespace lldb_private {
+
+llvm::StringRef TelemetryVendor::GetPluginName() {
+  return "UpstreamTelemetryVendor";
+}
+
+void TelemetryVendor::Initialize() {
+  // The default (upstream) impl will have telemetry disabled by default.
+  SetTelemetryConfig(
+      std::make_unique<llvm::telemetry::Config>(/*enable_telemetry*/ false));
+  SetTelemetryManager(nullptr);
+}
+
+static std::unique_ptr<llvm::telemetry::Config> current_config;
+std::unique_ptr<llvm::telemetry::Config> TelemetryVendor::GetTelemetryConfig() {
+  return current_config;
+}
+
+void TelemetryVendor::SetTelemetryConfig(
+    std::unique_ptr<llvm::telemetry::Config> config) {
+  current_config = std::move(config);
+}
+
+lldb::TelemetryManagerSP TelemetryVendor::GetTelemetryManager() {
+  static TelemteryManagerSP g_telemetry_manager_sp;
+  return g_telemetry_manager_sp;
+}
+
+void SetTelemetryManager(const lldb::TelemetryManagerSP &manager_sp) {
+  GetTelemetryManager() = manager_sp;
+}
+
+} // namespace lldb_private

``````````

</details>


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


More information about the lldb-commits mailing list