Skip to content

Commit 7dbcdd5

Browse files
committed
Revert "[LLDB][Telemetry]Define TargetInfo for collecting data about a target (#127834)"
This reverts commit 04e39ce due to test breakage.
1 parent 415dd38 commit 7dbcdd5

File tree

5 files changed

+9
-134
lines changed

5 files changed

+9
-134
lines changed

lldb/include/lldb/Core/Telemetry.h

Lines changed: 6 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@
2323
#include <atomic>
2424
#include <chrono>
2525
#include <ctime>
26-
#include <functional>
2726
#include <memory>
2827
#include <optional>
2928
#include <string>
30-
#include <type_traits>
31-
#include <utility>
3229

3330
namespace lldb_private {
3431
namespace telemetry {
@@ -49,18 +46,12 @@ struct LLDBConfig : public ::llvm::telemetry::Config {
4946
// Specifically:
5047
// - Length: 8 bits
5148
// - First two bits (MSB) must be 11 - the common prefix
52-
// - Last two bits (LSB) are reserved for grand-children of LLDBTelemetryInfo
5349
// If any of the subclass has descendents, those descendents
54-
// must have their LLDBEntryKind in the similar form (ie., share common prefix
55-
// and differ by the last two bits)
50+
// must have their LLDBEntryKind in the similar form (ie., share common prefix)
5651
struct LLDBEntryKind : public ::llvm::telemetry::EntryKind {
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
52+
static const llvm::telemetry::KindType BaseInfo = 0b11000000;
53+
static const llvm::telemetry::KindType CommandInfo = 0b11010000;
54+
static const llvm::telemetry::KindType DebuggerInfo = 0b11000100;
6455
};
6556

6657
/// Defines a convenient type for timestamp of various events.
@@ -98,7 +89,7 @@ struct CommandInfo : public LLDBBaseTelemetryInfo {
9889
/// session. Necessary because we'd send off an entry right before a command's
9990
/// execution and another right after. This is to avoid losing telemetry if
10091
/// the command does not execute successfully.
101-
uint64_t command_id = 0;
92+
uint64_t command_id;
10293
/// The command name(eg., "breakpoint set")
10394
std::string command_name;
10495
/// These two fields are not collected by default due to PII risks.
@@ -125,7 +116,7 @@ struct CommandInfo : public LLDBBaseTelemetryInfo {
125116

126117
void serialize(llvm::telemetry::Serializer &serializer) const override;
127118

128-
static uint64_t GetNextID();
119+
static uint64_t GetNextId();
129120

130121
private:
131122
// We assign each command (in the same session) a unique id so that their
@@ -155,59 +146,6 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo {
155146
void serialize(llvm::telemetry::Serializer &serializer) const override;
156147
};
157148

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-
211149
/// The base Telemetry manager instance in LLDB.
212150
/// This class declares additional instrumentation points
213151
/// applicable to LLDB.

lldb/source/Core/Telemetry.cpp

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,36 +76,15 @@ void CommandInfo::serialize(Serializer &serializer) const {
7676
serializer.write("error_data", error_data.value());
7777
}
7878

79-
std::atomic<uint64_t> CommandInfo::g_command_id_seed = 1;
80-
uint64_t CommandInfo::GetNextID() { return g_command_id_seed.fetch_add(1); }
81-
8279
void DebuggerInfo::serialize(Serializer &serializer) const {
8380
LLDBBaseTelemetryInfo::serialize(serializer);
8481

8582
serializer.write("lldb_version", lldb_version);
8683
serializer.write("is_exit_entry", is_exit_entry);
8784
}
8885

89-
void ExecutableModuleInfo::serialize(Serializer &serializer) const {
90-
LLDBBaseTelemetryInfo::serialize(serializer);
91-
92-
serializer.write("uuid", uuid.GetAsString());
93-
serializer.write("pid", pid);
94-
serializer.write("triple", triple);
95-
serializer.write("is_start_entry", is_start_entry);
96-
}
97-
98-
void ProcessExitInfo::serialize(Serializer &serializer) const {
99-
LLDBBaseTelemetryInfo::serialize(serializer);
100-
101-
serializer.write("module_uuid", module_uuid.GetAsString());
102-
serializer.write("pid", pid);
103-
serializer.write("is_start_entry", is_start_entry);
104-
if (exit_desc.has_value()) {
105-
serializer.write("exit_code", exit_desc->exit_code);
106-
serializer.write("exit_desc", exit_desc->description);
107-
}
108-
}
86+
std::atomic<uint64_t> CommandInfo::g_command_id_seed = 0;
87+
uint64_t CommandInfo::GetNextId() { return g_command_id_seed.fetch_add(1); }
10988

11089
TelemetryManager::TelemetryManager(std::unique_ptr<LLDBConfig> config)
11190
: m_config(std::move(config)), m_id(MakeUUID()) {}

lldb/source/Interpreter/CommandInterpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1891,7 +1891,7 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
18911891
telemetry::TelemetryManager::GetInstance()
18921892
->GetConfig()
18931893
->detailed_command_telemetry;
1894-
const int command_id = telemetry::CommandInfo::GetNextID();
1894+
const int command_id = telemetry::CommandInfo::GetNextId();
18951895

18961896
std::string command_string(command_line);
18971897
std::string original_command_string(command_string);

lldb/source/Target/Process.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "lldb/Core/ModuleSpec.h"
2323
#include "lldb/Core/PluginManager.h"
2424
#include "lldb/Core/Progress.h"
25-
#include "lldb/Core/Telemetry.h"
2625
#include "lldb/Expression/DiagnosticManager.h"
2726
#include "lldb/Expression/DynamicCheckerFunctions.h"
2827
#include "lldb/Expression/UserExpression.h"
@@ -1067,26 +1066,6 @@ const char *Process::GetExitDescription() {
10671066
bool Process::SetExitStatus(int status, llvm::StringRef exit_string) {
10681067
// Use a mutex to protect setting the exit status.
10691068
std::lock_guard<std::mutex> guard(m_exit_status_mutex);
1070-
telemetry::ScopedDispatcher<telemetry::ProcessExitInfo> helper;
1071-
1072-
// Find the executable-module's UUID, if available.
1073-
Target &target = GetTarget();
1074-
helper.SetDebugger(&(target.GetDebugger()));
1075-
UUID module_uuid;
1076-
if (ModuleSP mod = target.GetExecutableModule())
1077-
module_uuid = mod->GetUUID();
1078-
1079-
helper.DispatchNow([&](telemetry::ProcessExitInfo *info) {
1080-
info->module_uuid = module_uuid;
1081-
info->pid = m_pid;
1082-
info->is_start_entry = true;
1083-
info->exit_desc = {status, exit_string.str()};
1084-
});
1085-
1086-
helper.DispatchOnExit([&](telemetry::ProcessExitInfo *info) {
1087-
info->module_uuid = module_uuid;
1088-
info->pid = m_pid;
1089-
});
10901069

10911070
Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
10921071
LLDB_LOG(log, "(plugin = {0} status = {1} ({1:x8}), description=\"{2}\")",

lldb/source/Target/Target.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "lldb/Core/Section.h"
2525
#include "lldb/Core/SourceManager.h"
2626
#include "lldb/Core/StructuredDataImpl.h"
27-
#include "lldb/Core/Telemetry.h"
2827
#include "lldb/DataFormatters/FormatterSection.h"
2928
#include "lldb/Expression/DiagnosticManager.h"
3029
#include "lldb/Expression/ExpressionVariable.h"
@@ -1560,30 +1559,10 @@ void Target::DidExec() {
15601559

15611560
void Target::SetExecutableModule(ModuleSP &executable_sp,
15621561
LoadDependentFiles load_dependent_files) {
1563-
telemetry::ScopedDispatcher<telemetry::ExecutableModuleInfo> helper(
1564-
&m_debugger);
15651562
Log *log = GetLog(LLDBLog::Target);
15661563
ClearModules(false);
15671564

15681565
if (executable_sp) {
1569-
lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
1570-
if (ProcessSP proc = GetProcessSP())
1571-
pid = proc->GetID();
1572-
1573-
helper.DispatchNow([&](telemetry::ExecutableModuleInfo *info) {
1574-
info->exec_mod = executable_sp;
1575-
info->uuid = executable_sp->GetUUID();
1576-
info->pid = pid;
1577-
info->triple = executable_sp->GetArchitecture().GetTriple().getTriple();
1578-
info->is_start_entry = true;
1579-
});
1580-
1581-
helper.DispatchOnExit([&](telemetry::ExecutableModuleInfo *info) {
1582-
info->exec_mod = executable_sp;
1583-
info->uuid = executable_sp->GetUUID();
1584-
info->pid = pid;
1585-
});
1586-
15871566
ElapsedTime elapsed(m_stats.GetCreateTime());
15881567
LLDB_SCOPED_TIMERF("Target::SetExecutableModule (executable = '%s')",
15891568
executable_sp->GetFileSpec().GetPath().c_str());

0 commit comments

Comments
 (0)