Skip to content

Commit 9954083

Browse files
committed
reconcile with main
1 parent 92e06fa commit 9954083

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

lldb/include/lldb/Core/Telemetry.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ struct LLDBBaseTelemetryInfo : public llvm::telemetry::TelemetryInfo {
8989
void serialize(llvm::telemetry::Serializer &serializer) const override;
9090
};
9191

92-
9392
/// Describes an exit status.
9493
struct ExitDescription {
9594
int exit_code;
@@ -101,6 +100,8 @@ struct TargetInfo : public LLDBBaseTelemetryInfo {
101100

102101
/// The same as the executable-module's UUID.
103102
UUID target_uuid;
103+
/// PID of the process owned by this target.
104+
lldb::pid_t pid;
104105
std::string arch_name;
105106

106107
/// If true, this entry was emitted at the beginning of an event (eg., before
@@ -123,7 +124,7 @@ struct TargetInfo : public LLDBBaseTelemetryInfo {
123124
}
124125
void serialize(llvm::telemetry::Serializer &serializer) const override;
125126
};
126-
127+
127128
struct CommandInfo : public LLDBBaseTelemetryInfo {
128129
/// If the command is/can be associated with a target entry this field
129130
/// contains that target's UUID. <EMPTY> otherwise.

lldb/source/Core/Telemetry.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ void CommandInfo::serialize(Serializer &serializer) const {
7777
serializer.write("error_data", error_data.value());
7878
}
7979

80-
8180
std::atomic<uint64_t> CommandInfo::g_command_id_seed = 0;
8281
uint64_t CommandInfo::GetNextId() { return g_command_id_seed.fetch_add(1); }
8382

@@ -136,7 +135,6 @@ class NoOpTelemetryManager : public TelemetryManager {
136135
static std::unique_ptr<NoOpTelemetryManager> g_ins =
137136
std::make_unique<NoOpTelemetryManager>();
138137
return g_ins.get();
139-
140138
}
141139
};
142140

lldb/source/Target/Process.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,18 +1065,24 @@ const char *Process::GetExitDescription() {
10651065
bool Process::SetExitStatus(int status, llvm::StringRef exit_string) {
10661066
// Use a mutex to protect setting the exit status.
10671067
std::lock_guard<std::mutex> guard(m_exit_status_mutex);
1068-
Debugger *debugger = &(GetTarget().GetDebugger());
1069-
telemetry::ScopedDispatcher<telemetry::TargetInfo> helper(debugger);
1070-
// Save the Module UUID since the Module might be gone by end of scope.
1071-
UUID target_uuid = GetTarget().GetExecutableModule()->GetUUID();
1068+
telemetry::ScopedDispatcher<telemetry::TargetInfo> helper;
10721069

1070+
// Check if there is (still) a valid target and get the debugger from it.
1071+
TargetSP target_sp(Debugger::FindTargetWithProcessID(m_pid));
1072+
if (target_sp)
1073+
helper.SetDebugger(&(target_sp->GetDebugger()));
1074+
1075+
// TODO: Find the executable-module's UUID somehow. (Maybe save the UUID in
1076+
// Target?) We might not have a valid executable-mod anymore.
10731077
helper.DispatchNow([&](telemetry::TargetInfo *info) {
1074-
info->target_uuid = target_uuid;
1078+
// info->target_uuid = target_uuid;
1079+
info->pid = m_pid;
10751080
info->is_start_entry = true;
10761081
});
10771082

10781083
helper.DispatchOnExit([&](telemetry::TargetInfo *info) {
1079-
info->target_uuid = target_uuid;
1084+
// info->target_uuid = target_uuid;
1085+
info->pid = m_pid;
10801086
info->exit_desc = {status, exit_string.str()};
10811087
});
10821088

lldb/source/Target/Target.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,16 +1565,21 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
15651565
ClearModules(false);
15661566

15671567
if (executable_sp) {
1568+
lldb::pid_t pid;
1569+
if (ProcessSP proc = GetProcessSP())
1570+
pid = proc->GetID();
15681571
helper.DispatchNow([&](telemetry::TargetInfo *info) {
15691572
info->exec_mod = executable_sp;
15701573
info->target_uuid = executable_sp->GetUUID();
1574+
info->pid = pid;
15711575
info->arch_name = executable_sp->GetArchitecture().GetArchitectureName();
15721576
info->is_start_entry = true;
15731577
});
15741578

15751579
helper.DispatchOnExit([&](telemetry::TargetInfo *info) {
15761580
info->exec_mod = executable_sp;
15771581
info->target_uuid = executable_sp->GetUUID();
1582+
info->pid = pid;
15781583
});
15791584

15801585
ElapsedTime elapsed(m_stats.GetCreateTime());

0 commit comments

Comments
 (0)