Skip to content

Commit 4b6a4bd

Browse files
committed
remove unused fields
1 parent 5aec284 commit 4b6a4bd

File tree

2 files changed

+41
-96
lines changed

2 files changed

+41
-96
lines changed

lldb/include/lldb/Core/Telemetry.h

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct LLDBBaseTelemetryInfo : public llvm::telemetry::TelemetryInfo {
4545
std::optional<SteadyTimePoint> end_time;
4646
// TBD: could add some memory stats here too?
4747

48+
uint64_t debugger_id = 0;
4849
Debugger *debugger;
4950

5051
// For dyn_cast, isa, etc operations.
@@ -70,10 +71,6 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo {
7071
std::string lldb_version;
7172
std::optional<ExitDescription> exit_desc;
7273

73-
std::string lldb_path;
74-
std::string cwd;
75-
std::string username;
76-
7774
DebuggerInfo() = default;
7875

7976
llvm::telemetry::KindType getKind() const override {
@@ -87,35 +84,6 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo {
8784
void serialize(llvm::telemetry::Serializer &serializer) const override;
8885
};
8986

90-
/// The "catch-all" entry to store a set of non-standard data, such as
91-
/// error-messages, etc.
92-
struct MiscTelemetryInfo : public LLDBBaseTelemetryInfo {
93-
/// If the event is/can be associated with a target entry,
94-
/// this field contains that target's UUID.
95-
/// <EMPTY> otherwise.
96-
std::string target_uuid;
97-
98-
/// Set of key-value pairs for any optional (or impl-specific) data
99-
llvm::StringMap<std::string> meta_data;
100-
101-
MiscTelemetryInfo() = default;
102-
103-
MiscTelemetryInfo(const MiscTelemetryInfo &other) {
104-
target_uuid = other.target_uuid;
105-
meta_data = other.meta_data;
106-
}
107-
108-
llvm::telemetry::KindType getKind() const override {
109-
return LLDBEntryKind::MiscInfo;
110-
}
111-
112-
static bool classof(const llvm::telemetry::TelemetryInfo *T) {
113-
return T->getKind() == LLDBEntryKind::MiscInfo;
114-
}
115-
116-
void serialize(llvm::telemetry::Serializer &serializer) const override;
117-
};
118-
11987
/// The base Telemetry manager instance in LLDB.
12088
/// This class declares additional instrumentation points
12189
/// applicable to LLDB.
@@ -141,10 +109,6 @@ class TelemetryManager : public llvm::telemetry::Manager {
141109
// Each instance of a TelemetryManager is assigned a unique ID.
142110
const std::string m_id;
143111

144-
// Map of debugger's ID to a unique session_id string.
145-
// All TelemetryInfo entries emitted for the same debugger instance
146-
// will get the same session_id.
147-
llvm::DenseMap<lldb::user_id_t, std::string> session_ids;
148112
static std::unique_ptr<TelemetryManager> g_instance;
149113
};
150114

lldb/source/Core/Telemetry.cpp

Lines changed: 40 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static uint64_t ToNanosec(const SteadyTimePoint Point) {
4343

4444
// Generate a unique string. This should be unique across different runs.
4545
// We build such string by combining three parts:
46-
// <16 random bytes>_<timestamp>_<hash of username>
46+
// <16 random bytes>_<timestamp>
4747
// This reduces the chances of getting the same UUID, even when the same
4848
// user runs the two copies of binary at the same time.
4949
static std::string MakeUUID() {
@@ -56,17 +56,9 @@ static std::string MakeUUID() {
5656
randomString = UUID(random_bytes).GetAsString();
5757
}
5858

59-
std::string username = "_";
60-
UserIDResolver &resolver = lldb_private::HostInfo::GetUserIDResolver();
61-
std::optional<llvm::StringRef> opt_username =
62-
resolver.GetUserName(lldb_private::HostInfo::GetUserID());
63-
if (opt_username)
64-
username = *opt_username;
65-
6659
return llvm::formatv(
67-
"{0}_{1}_{2}", randomString,
68-
std::chrono::steady_clock::now().time_since_epoch().count(),
69-
llvm::MD5Hash(username));
60+
"{0}_{1}", randomString,
61+
std::chrono::steady_clock::now().time_since_epoch().count());
7062
}
7163

7264
void LLDBBaseTelemetryInfo::serialize(Serializer &serializer) const {
@@ -90,74 +82,63 @@ void DebuggerInfo::serialize(Serializer &serializer) const {
9082
}
9183
}
9284

93-
void MiscTelemetryInfo::serialize(Serializer &serializer) const {
94-
LLDBBaseTelemetryInfo::serialize(serializer);
95-
serializer.write("target_uuid", target_uuid);
96-
serializer.beginObject("meta_data");
97-
for (const auto &kv : meta_data)
98-
serializer.write(kv.first, kv.second);
99-
serializer.endObject();
100-
}
101-
10285
TelemetryManager::TelemetryManager(std::unique_ptr<Config> config)
10386
: m_config(std::move(config)), m_id(MakeUUID) {}
10487

10588
llvm::Error TelemetryManager::preDispatch(TelemetryInfo *entry) {
106-
// Look up the session_id to assign to this entry or make one
107-
// if none had been computed for this debugger.
89+
// Assign the manager_id, and debugger_id, if available, to this entry.
10890
LLDBBaseTelemetryInfo *lldb_entry =
10991
llvm::dyn_cast<LLDBBaseTelemetryInfo>(entry);
110-
std::string session_id = m_id;
111-
if (Debugger *debugger = lldb_entry->debugger) {
112-
auto session_id_pos = session_ids.find(debugger->getID());
113-
if (session_id_pos != session_ids.end())
114-
session_id = session_id_pos->second;
115-
else
116-
session_id_pos->second = session_id =
117-
llvm::formatv("{0}_{1}", m_id, debugger->getID());
118-
}
119-
lldb_entry->SessionId = session_id;
92+
lldb_entry->SessionId = m_id;
93+
if (Debugger *debugger = lldb_entry->debugger)
94+
lldb_entry->debugger_id = debugger->GetID();
12095

12196
return llvm::Error::success();
12297
}
12398

12499
const Config *getConfig() { return m_config.get(); }
125100

126101
void TelemetryManager::AtDebuggerStartup(DebuggerInfo *entry) {
127-
if (auto er = dispatch(entry)) {
128-
LLDB_LOG(GetLog(LLDBLog::Object), "Failed to dispatch entry at startup");
102+
if (llvm::Error er = dispatch(entry)) {
103+
LLDB_LOG_ERROR(GetLog(LLDBLog::Object), std::move(er),
104+
"Failed to dispatch entry at debugger startup: {0}");
129105
}
130-
}
131106

132-
void TelemetryManager::AtDebuggerExit(DebuggerInfo *entry) {
133-
// There must be a reference to the debugger at this point.
134-
assert(entry->debugger != nullptr);
135-
136-
if (auto *selected_target =
137-
entry->debugger->GetSelectedExecutionContext().GetTargetPtr()) {
138-
if (!selected_target->IsDummyTarget()) {
139-
const lldb::ProcessSP proc = selected_target->GetProcessSP();
140-
if (proc == nullptr) {
141-
// no process has been launched yet.
142-
entry->exit_desc = {-1, "no process launched."};
143-
} else {
144-
entry->exit_desc = {proc->GetExitStatus(), ""};
145-
if (const char *description = proc->GetExitDescription())
146-
entry->exit_desc->description = std::string(description);
107+
void TelemetryManager::AtDebuggerExit(DebuggerInfo * entry) {
108+
// There must be a reference to the debugger at this point.
109+
assert(entry->debugger != nullptr);
110+
111+
if (auto *selected_target =
112+
entry->debugger->GetSelectedExecutionContext().GetTargetPtr()) {
113+
if (!selected_target->IsDummyTarget()) {
114+
const lldb::ProcessSP proc = selected_target->GetProcessSP();
115+
if (proc == nullptr) {
116+
// no process has been launched yet.
117+
entry->exit_desc = {-1, "no process launched."};
118+
} else {
119+
entry->exit_desc = {proc->GetExitStatus(), ""};
120+
if (const char *description = proc->GetExitDescription())
121+
entry->exit_desc->description = std::string(description);
122+
}
147123
}
148124
}
149-
}
150-
dispatch(entry);
151-
}
152125

153-
std::unique_ptr<TelemetryManager> TelemetryManager::g_instance = nullptr;
154-
TelemetryManager *TelemetryManager::getInstance() { return g_instance.get(); }
126+
if (llvm::Error er = dispatch(entry)) {
127+
LLDB_LOG_ERROR(GetLog(LLDBLog::Object), std::move(er),
128+
"Failed to dispatch entry at debugger exit: {0}");
129+
}
155130

156-
void TelemetryManager::setInstance(std::unique_ptr<TelemetryManager> manager) {
157-
g_instance = std::move(manager);
158-
}
131+
std::unique_ptr<TelemetryManager> TelemetryManager::g_instance = nullptr;
132+
TelemetryManager *TelemetryManager::getInstance() {
133+
return g_instance.get();
134+
}
135+
136+
void TelemetryManager::setInstance(
137+
std::unique_ptr<TelemetryManager> manager) {
138+
g_instance = std::move(manager);
139+
}
159140

160-
} // namespace telemetry
141+
} // namespace telemetry
161142
} // namespace lldb_private
162143

163144
#endif // LLVM_BUILD_TELEMETRY

0 commit comments

Comments
 (0)