[Lldb-commits] [lldb] [LLDB][Telemetry]Define DebuggerTelemetryInfo and related methods (PR #127696)
Vy Nguyen via lldb-commits
lldb-commits at lists.llvm.org
Thu Feb 20 06:05:16 PST 2025
================
@@ -761,12 +767,29 @@ void Debugger::InstanceInitialize() {
DebuggerSP Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
void *baton) {
+#ifdef LLVM_BUILD_TELEMETRY
+ lldb_private::telemetry::SteadyTimePoint start_time =
+ std::chrono::steady_clock::now();
+#endif
DebuggerSP debugger_sp(new Debugger(log_callback, baton));
if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
std::lock_guard<std::recursive_mutex> guard(*g_debugger_list_mutex_ptr);
g_debugger_list_ptr->push_back(debugger_sp);
}
debugger_sp->InstanceInitialize();
+
+#ifdef LLVM_BUILD_TELEMETRY
+ if (auto *telemetry_manager = telemetry::TelemetryManager::getInstance()) {
+ if (telemetry_manager->getConfig()->EnableTelemetry) {
+ lldb_private::telemetry::DebuggerTelemetryInfo entry;
+ entry.start_time = start_time;
+ entry.end_time = std::chrono::steady_clock::now();
+ entry.debugger = debugger_sp.get();
+ telemetry_manager->atDebuggerStartup(&entry);
+ }
+ }
+#endif
----------------
oontvoo wrote:
> be sufficient? (if we put that in a header, we should also have a decent chance of the compiler dead-stripping all the code which depends on this)
It could be a bit more complicated because the callers/users have to reference the structs/classes defined in the telemetry library. (The library itself is not actually 100% abstract classes. All of the TelemetryInfo* are concretely defined upstream.)
So I would argue for reverting the current if-def approach.
Specifically,
- Rename BUILD_LLVM_TELEMETRY => ENABLE_LLVM_TELEMETRY (which is set to TRUE by default)
- In the base Config class:
````
struct Config {
public:
const bool EnableTelemetry;
// Telemetry can only be enabled at runtime if both the build-flag and the runtime condition is TRUE
Config(bool Enable) : EnableTelemetry(Enable && ENABLE_TELEMETRY) {}
}
```
```
https://github.com/llvm/llvm-project/pull/127696
More information about the lldb-commits
mailing list