23
23
#include < atomic>
24
24
#include < chrono>
25
25
#include < ctime>
26
+ #include < functional>
26
27
#include < memory>
27
28
#include < optional>
28
29
#include < string>
30
+ #include < type_traits>
31
+ #include < utility>
29
32
30
33
namespace lldb_private {
31
34
namespace telemetry {
@@ -46,12 +49,18 @@ struct LLDBConfig : public ::llvm::telemetry::Config {
46
49
// Specifically:
47
50
// - Length: 8 bits
48
51
// - First two bits (MSB) must be 11 - the common prefix
52
+ // - Last two bits (LSB) are reserved for grand-children of LLDBTelemetryInfo
49
53
// 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)
51
56
struct 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
55
64
};
56
65
57
66
// / Defines a convenient type for timestamp of various events.
@@ -89,7 +98,7 @@ struct CommandInfo : public LLDBBaseTelemetryInfo {
89
98
// / session. Necessary because we'd send off an entry right before a command's
90
99
// / execution and another right after. This is to avoid losing telemetry if
91
100
// / the command does not execute successfully.
92
- uint64_t command_id;
101
+ uint64_t command_id = 0 ;
93
102
// / The command name(eg., "breakpoint set")
94
103
std::string command_name;
95
104
// / These two fields are not collected by default due to PII risks.
@@ -116,7 +125,7 @@ struct CommandInfo : public LLDBBaseTelemetryInfo {
116
125
117
126
void serialize (llvm::telemetry::Serializer &serializer) const override ;
118
127
119
- static uint64_t GetNextId ();
128
+ static uint64_t GetNextID ();
120
129
121
130
private:
122
131
// We assign each command (in the same session) a unique id so that their
@@ -146,6 +155,59 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo {
146
155
void serialize (llvm::telemetry::Serializer &serializer) const override ;
147
156
};
148
157
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
+
149
211
// / The base Telemetry manager instance in LLDB.
150
212
// / This class declares additional instrumentation points
151
213
// / applicable to LLDB.
0 commit comments