2323#include < atomic>
2424#include < chrono>
2525#include < ctime>
26+ #include < functional>
2627#include < memory>
2728#include < optional>
2829#include < string>
30+ #include < type_traits>
31+ #include < utility>
2932
3033namespace lldb_private {
3134namespace telemetry {
@@ -46,12 +49,18 @@ struct LLDBConfig : public ::llvm::telemetry::Config {
4649// Specifically:
4750// - Length: 8 bits
4851// - First two bits (MSB) must be 11 - the common prefix
52+ // - Last two bits (LSB) are reserved for grand-children of LLDBTelemetryInfo
4953// If any of the subclass has descendents, those descendents
50- // must have their LLDBEntryKind in the similar form (ie., share common prefix)
54+ // must have their LLDBEntryKind in the similar form (ie., share common prefix
55+ // and differ by the last two bits)
5156struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
52- static const llvm::telemetry::KindType BaseInfo = 0b11000000 ;
53- static const llvm::telemetry::KindType CommandInfo = 0b11010000 ;
54- static const llvm::telemetry::KindType DebuggerInfo = 0b11000100 ;
57+ // clang-format off
58+ static const llvm::telemetry::KindType BaseInfo = 0b11000000 ;
59+ static const llvm::telemetry::KindType CommandInfo = 0b11010000 ;
60+ static const llvm::telemetry::KindType DebuggerInfo = 0b11001000 ;
61+ static const llvm::telemetry::KindType ExecModuleInfo = 0b11000100 ;
62+ static const llvm::telemetry::KindType ProcessExitInfo = 0b11001100 ;
63+ // clang-format on
5564};
5665
5766// / Defines a convenient type for timestamp of various events.
@@ -89,7 +98,7 @@ struct CommandInfo : public LLDBBaseTelemetryInfo {
8998 // / session. Necessary because we'd send off an entry right before a command's
9099 // / execution and another right after. This is to avoid losing telemetry if
91100 // / the command does not execute successfully.
92- uint64_t command_id;
101+ uint64_t command_id = 0 ;
93102 // / The command name(eg., "breakpoint set")
94103 std::string command_name;
95104 // / These two fields are not collected by default due to PII risks.
@@ -116,7 +125,7 @@ struct CommandInfo : public LLDBBaseTelemetryInfo {
116125
117126 void serialize (llvm::telemetry::Serializer &serializer) const override ;
118127
119- static uint64_t GetNextId ();
128+ static uint64_t GetNextID ();
120129
121130private:
122131 // We assign each command (in the same session) a unique id so that their
@@ -146,6 +155,59 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo {
146155 void serialize (llvm::telemetry::Serializer &serializer) const override ;
147156};
148157
158+ struct ExecutableModuleInfo : public LLDBBaseTelemetryInfo {
159+ lldb::ModuleSP exec_mod;
160+ // / The same as the executable-module's UUID.
161+ UUID uuid;
162+ // / PID of the process owned by this target.
163+ lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
164+ // / The triple of this executable module.
165+ std::string triple;
166+
167+ // / If true, this entry was emitted at the beginning of an event (eg., before
168+ // / the executable is set). Otherwise, it was emitted at the end of an
169+ // / event (eg., after the module and any dependency were loaded.)
170+ bool is_start_entry = false ;
171+
172+ ExecutableModuleInfo () = default ;
173+
174+ llvm::telemetry::KindType getKind () const override {
175+ return LLDBEntryKind::ExecModuleInfo;
176+ }
177+
178+ static bool classof (const TelemetryInfo *T) {
179+ // Subclasses of this is also acceptable
180+ return (T->getKind () & LLDBEntryKind::ExecModuleInfo) ==
181+ LLDBEntryKind::ExecModuleInfo;
182+ }
183+ void serialize (llvm::telemetry::Serializer &serializer) const override ;
184+ };
185+
186+ // / Describes an exit status.
187+ struct ExitDescription {
188+ int exit_code;
189+ std::string description;
190+ };
191+
192+ struct ProcessExitInfo : public LLDBBaseTelemetryInfo {
193+ // The executable-module's UUID.
194+ UUID module_uuid;
195+ lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
196+ bool is_start_entry = false ;
197+ std::optional<ExitDescription> exit_desc;
198+
199+ llvm::telemetry::KindType getKind () const override {
200+ return LLDBEntryKind::ProcessExitInfo;
201+ }
202+
203+ static bool classof (const TelemetryInfo *T) {
204+ // Subclasses of this is also acceptable
205+ return (T->getKind () & LLDBEntryKind::ProcessExitInfo) ==
206+ LLDBEntryKind::ProcessExitInfo;
207+ }
208+ void serialize (llvm::telemetry::Serializer &serializer) const override ;
209+ };
210+
149211// / The base Telemetry manager instance in LLDB.
150212// / This class declares additional instrumentation points
151213// / applicable to LLDB.
0 commit comments