[Lldb-commits] [lldb] [lldb][telemetry] Implement LLDB Telemetry (part 1) (PR #119716)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Mon Feb 10 14:31:41 PST 2025
================
@@ -0,0 +1,74 @@
+//===-- Telemetry.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_TELEMETRY_H
+#define LLDB_CORE_TELEMETRY_H
+
+#include "lldb/Core/StructuredDataImpl.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-forward.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Telemetry/Telemetry.h"
+#include <chrono>
+#include <ctime>
+#include <memory>
+#include <optional>
+#include <string>
+#include <unordered_map>
+
+namespace lldb_private {
+namespace telemetry {
+
+struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
+ static const llvm::telemetry::KindType BaseInfo = 0b11000;
+};
+
+/// Defines a convenient type for timestamp of various events.
+using SteadyTimePoint = std::chrono::time_point<std::chrono::steady_clock,
+ std::chrono::nanoseconds>;
+struct LLDBBaseTelemetryInfo : public llvm::telemetry::TelemetryInfo {
+ /// Start time of an event
+ SteadyTimePoint start_time;
+ /// End time of an event - may be empty if not meaningful.
+ std::optional<SteadyTimePoint> end_time;
+ // TBD: could add some memory stats here too?
+
+ Debugger *debugger;
+
+ // For dyn_cast, isa, etc operations.
+ llvm::telemetry::KindType getKind() const override {
+ return LLDBEntryKind::BaseInfo;
+ }
+
+ static bool classof(const llvm::telemetry::TelemetryInfo *t) {
+ // Subclasses of this is also acceptable.
+ return (t->getKind() & LLDBEntryKind::BaseInfo) == LLDBEntryKind::BaseInfo;
+ }
+
+ void serialize(llvm::telemetry::Serializer &serializer) const override;
+};
+
+/// The base Telemetry manager instance in LLDB
----------------
JDevlieghere wrote:
Nit: missing period.
https://github.com/llvm/llvm-project/pull/119716
More information about the lldb-commits
mailing list