================
@@ -56,13 +60,83 @@ struct LLDBBaseTelemetryInfo : public 
llvm::telemetry::TelemetryInfo {
   void serialize(llvm::telemetry::Serializer &serializer) const override;
 };
 
+/// Describes the exit status of a debugger.
+struct ExitDescription {
+  int exit_code;
+  std::string description;
+};
+
+struct DebuggerTelemetryInfo : public LLDBBaseTelemetryInfo {
+  std::string username;
+  std::string lldb_git_sha;
+  std::string lldb_path;
+  std::string cwd;
+  std::optional<ExitDescription> exit_desc;
+
+  DebuggerTelemetryInfo() = default;
+
+  // Provide a copy ctor because we may need to make a copy before
+  // sanitizing the data.
+  // (The sanitization might differ between different Destination classes).
----------------
labath wrote:

That makes sense to me, but it doesn't explain why we need to spell out the 
copying by hand. It's very easy to forget to update it (and it looks like even 
this implementation does not copy entries from the base class).

I thought this had something to do with this being being a polymorphic class 
(which usually have their copy constructors deleted -- for a reason), but 
AFAICT, all of the bases actually have their copy constructors (implicitly) 
defined. The possibility of object slicing is another complaint I have about 
this design (and I'm surprised it doesn't trigger any static analysis warnings).

In order to prevent object slicing, and avoid spelling out copy operations, how 
about we do something like [this](https://godbolt.org/z/GT591beeY). Basically, 
divide the two classes in the hierarchy into two kinds:
- abstract classes: these cannot be instantiated, so there's no danger of 
slicing. They still have a copy constructor, but they cannot be copied on their 
own.
- concrete final classes: these can be copied (using the default copy 
constructor implementation). However, they cannot be inherited from, which 
means they cannot slice anything.

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