================ @@ -0,0 +1,619 @@ + +//===-- Telemetry.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/Telemetry.h" + +#include <stdbool.h> +#include <sys/auxv.h> + +#include <memory> + +#include <chrono> +#include <cstdlib> +#include <ctime> +#include <fstream> +#include <iostream> +#include <string> +#include <typeinfo> +#include <utility> +#include <vector> + +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBProcess.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/Module.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Statistics.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/UUID.h" +#include "lldb/Version/Version.h" +#include "lldb/lldb-enumerations.h" +#include "lldb/lldb-forward.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Twine.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/LineIterator.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/RandomNumberGenerator.h" +#include "llvm/Telemetry/Telemetry.h" + +#ifdef HAS_VENDOR_TELEMETRY_PLUGINS +// TODO: could make this path a build-variable rather than hard-coded +#include "lldb/Core/VendorTelemetryPlugin.h" + +// This must include definitions for these functions +extern void ApplyVendorSpecificConfigs( + llvm::telemetry::TelemetryConfig *config) /* __attribute__((weak))*/; +extern std::shared_ptr<llvm::telemetry::TelemetryInfo> SanitizeSensitiveFields( + const llvm::telemetry::TelemetryInfo *entry) /*__attribute__((weak))*/; +extern std::shared_ptr<lldb_private::LldbTelemeter> +CreateVendorSpecificTelemeter( + llvm::telemetry::TelemetryConfig *config) /*__attribute__((weak))*/; +#endif + +namespace lldb_private { + +static std::string GetDuration(const TelemetryEventStats &stats) { + if (stats.m_end.has_value()) + return std::to_string((stats.m_end.value() - stats.m_start).count()) + + "(nanosec)"; + return "<NONE>"; +} + +std::string DebuggerTelemetryInfo::ToString() const { + std::string duration_desc = + (exit_description.has_value() ? " lldb session duration: " + : " lldb startup duration: ") + + std::to_string((stats.m_end.value() - stats.m_start).count()) + + "(nanosec)\n"; ---------------- labath wrote:
```suggestion llvm::formatv(" lldb {0} duration: {1:ns}", exit_description?"session":"startup", stats.m_end.value() - stats.m_start); ``` https://github.com/llvm/llvm-project/pull/98528 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits