[Lldb-commits] [lldb] Define Telemetry plugin for LLDB. (PR #126588)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Feb 13 07:29:21 PST 2025


================
@@ -0,0 +1,74 @@
+//===-- TelemetryTest.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 "llvm/Config/llvm-config.h"
+
+#ifdef LLVM_BUILD_TELEMETRY
+
+#include "lldb/Core/PluginInterface.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Telemetry.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Telemetry/Telemetry.h"
+#include "gtest/gtest.h"
+
+#include <memory>
+
+namespace lldb_private {
+
+struct FakeTelemetryInfo : public llvm::telemetry::TelemetryInfo {
+  std::string msg;
+};
+
+class FakePlugin : public telemetry::TelemetryManager {
+public:
+  FakePlugin()
+      : telemetry::TelemetryManager(
+            std::make_unique<llvm::telemetry::Config>(true)) {}
+
+  // TelemetryManager interface
+  llvm::Error dispatch(llvm::telemetry::TelemetryInfo *entry) override {
+    if (auto *fake_entry = llvm::dyn_cast<FakeTelemetryInfo>(entry)) {
+      fake_entry->msg = "In FakePlugin";
+    }
----------------
labath wrote:

```suggestion
    if (auto *fake_entry = llvm::dyn_cast<FakeTelemetryInfo>(entry))
      fake_entry->msg = "In FakePlugin";
```

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


More information about the lldb-commits mailing list