================
@@ -761,7 +765,14 @@ void Debugger::InstanceInitialize() {
 
 DebuggerSP Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
                                     void *baton) {
+  lldb_private::telemetry::ScopedDispatcher<
+      lldb_private::telemetry::DebuggerInfo>
+      helper([](lldb_private::telemetry::DebuggerInfo *entry) {
+        entry->lldb_version = lldb_private::GetVersion();
+      });
   DebuggerSP debugger_sp(new Debugger(log_callback, baton));
+  helper.SetDebugger(debugger_sp.get());
----------------
labath wrote:

This is definitely better, but lambdas tend to add some boilerplate of their 
own. They may be useful in some cases (if you need to set some field at the 
very end) but I think that in many cases (this one included) we could just set 
the field directly, so I want to float this idea: I think this would be shorter 
if we had the dispatcher object expose the telemetry entry it is managing 
directly:
```suggestion
  telemetry::ScopedDispatcher<telemetry::DebuggerInfo> helper;
  DebuggerSP debugger_sp(new Debugger(log_callback, baton));
  if (telemetry::DebuggerInfo *info = helper.GetEntry()) {// returns NULL if 
telemetry is disabled
    info->debugger = debugger_sp.get();
    info->lldb_version = lldb_private::GetVersion();
  }
```

(and if we do need a callback, I don't see a reason why this couldn't coexist 
with that)

Any thoughts @JDevlieghere ?

https://github.com/llvm/llvm-project/pull/127696
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to