-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[LLDB][Telemetry]Define TargetInfo for collecting data about a target #127834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 26 commits
0d6a36d
19c6181
f152b3b
4f8555a
a5bd22e
bb22874
f49c3e2
3bd8897
d3cb8d8
267345a
32d949b
5c6c83c
39c39cc
1fdf120
1ed73e7
92e06fa
aab5002
31c63e0
20c8f59
9954083
55aa4ee
c8ca5b8
4783b57
ae73ebe
0a2505a
4d3d26e
b1b7a50
f7be9c9
41f0696
5e99cc7
a709ac3
220554a
1ecbe48
1231bc2
5757b41
a936e2e
142097a
d297813
885675e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -23,9 +23,12 @@ | |||||
| #include <atomic> | ||||||
| #include <chrono> | ||||||
| #include <ctime> | ||||||
| #include <functional> | ||||||
| #include <memory> | ||||||
| #include <optional> | ||||||
| #include <string> | ||||||
| #include <type_traits> | ||||||
| #include <utility> | ||||||
|
|
||||||
| namespace lldb_private { | ||||||
| namespace telemetry { | ||||||
|
|
@@ -46,12 +49,18 @@ struct LLDBConfig : public ::llvm::telemetry::Config { | |||||
| // Specifically: | ||||||
| // - Length: 8 bits | ||||||
| // - First two bits (MSB) must be 11 - the common prefix | ||||||
| // - Last two bits (LSB) are reserved for grand-children of LLDBTelemetryInfo | ||||||
| // If any of the subclass has descendents, those descendents | ||||||
| // must have their LLDBEntryKind in the similar form (ie., share common prefix) | ||||||
| // must have their LLDBEntryKind in the similar form (ie., share common prefix | ||||||
| // and differ by the last two bits) | ||||||
| struct LLDBEntryKind : public ::llvm::telemetry::EntryKind { | ||||||
| static const llvm::telemetry::KindType BaseInfo = 0b11000000; | ||||||
| static const llvm::telemetry::KindType CommandInfo = 0b11010000; | ||||||
| static const llvm::telemetry::KindType DebuggerInfo = 0b11000100; | ||||||
| // clang-format off | ||||||
| static const llvm::telemetry::KindType BaseInfo = 0b11000000; | ||||||
| static const llvm::telemetry::KindType CommandInfo = 0b11010000; | ||||||
| static const llvm::telemetry::KindType DebuggerInfo = 0b11001000; | ||||||
| static const llvm::telemetry::KindType ExecModuleInfo = 0b11000100; | ||||||
| static const llvm::telemetry::KindType ProcessExitInfo = 0b11001100; | ||||||
| // clang-format on | ||||||
| }; | ||||||
|
|
||||||
| /// Defines a convenient type for timestamp of various events. | ||||||
|
|
@@ -146,6 +155,58 @@ struct DebuggerInfo : public LLDBBaseTelemetryInfo { | |||||
| void serialize(llvm::telemetry::Serializer &serializer) const override; | ||||||
| }; | ||||||
|
|
||||||
| struct ExecModuleInfo : public LLDBBaseTelemetryInfo { | ||||||
|
||||||
| struct ExecModuleInfo : public LLDBBaseTelemetryInfo { | |
| struct ExecutableModuleInfo : public LLDBBaseTelemetryInfo { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's drop the exec_ prefix as this is relatively obvious from the class it belongs to and we don't consistently prefix all the members.
| lldb::ModuleSP exec_mod; | |
| lldb::ModuleSP exec_mod; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// If true, this entry was emitted at the beginning of an event (eg., before | |
| /// If true, this entry was emitted at the beginning of an event (e.g. before |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Subclasses of this is also acceptable | |
| // Subclasses of this is also acceptable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contrary to my other comments I think we can keep the exit_ prefix here as "exit code" is a fairly well understood term.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| UUID exec_uuid; | |
| UUID uuid; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Subclasses of this is also acceptable | |
| // Subclasses of this is also acceptable. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |||||
| #include "lldb/lldb-forward.h" | ||||||
| #include "llvm/ADT/StringRef.h" | ||||||
| #include "llvm/Support/Error.h" | ||||||
| #include "llvm/Support/Path.h" | ||||||
| #include "llvm/Support/RandomNumberGenerator.h" | ||||||
| #include "llvm/Telemetry/Telemetry.h" | ||||||
| #include <chrono> | ||||||
|
|
@@ -76,15 +77,36 @@ void CommandInfo::serialize(Serializer &serializer) const { | |||||
| serializer.write("error_data", error_data.value()); | ||||||
| } | ||||||
|
|
||||||
| std::atomic<uint64_t> CommandInfo::g_command_id_seed = 0; | ||||||
| uint64_t CommandInfo::GetNextId() { return g_command_id_seed.fetch_add(1); } | ||||||
|
||||||
| uint64_t CommandInfo::GetNextId() { return g_command_id_seed.fetch_add(1); } | |
| uint64_t CommandInfo::GetNextID() { return g_command_id_seed.fetch_add(1); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| #include "lldb/Core/ModuleSpec.h" | ||
| #include "lldb/Core/PluginManager.h" | ||
| #include "lldb/Core/Progress.h" | ||
| #include "lldb/Core/Telemetry.h" | ||
| #include "lldb/Expression/DiagnosticManager.h" | ||
| #include "lldb/Expression/DynamicCheckerFunctions.h" | ||
| #include "lldb/Expression/UserExpression.h" | ||
|
|
@@ -1064,6 +1065,29 @@ const char *Process::GetExitDescription() { | |
| bool Process::SetExitStatus(int status, llvm::StringRef exit_string) { | ||
| // Use a mutex to protect setting the exit status. | ||
| std::lock_guard<std::mutex> guard(m_exit_status_mutex); | ||
| telemetry::ScopedDispatcher<telemetry::ProcessExitInfo> helper; | ||
|
|
||
| // Find the executable-module's UUID, if available. | ||
| UUID exec_uuid; | ||
| // Check if there is (still) a valid target and get the debugger and exec_uuid | ||
| // from it. | ||
| TargetSP target_sp(Debugger::FindTargetWithProcessID(m_pid)); | ||
| if (target_sp) { | ||
oontvoo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| helper.SetDebugger(&(target_sp->GetDebugger())); | ||
| exec_uuid = target_sp->GetExecModuleUUID(); | ||
|
||
| } | ||
|
|
||
| helper.DispatchNow([&](telemetry::ProcessExitInfo *info) { | ||
| info->exec_uuid = exec_uuid; | ||
| info->pid = m_pid; | ||
| info->is_start_entry = true; | ||
| info->exit_desc = {status, exit_string.str()}; | ||
| }); | ||
|
|
||
| helper.DispatchOnExit([&](telemetry::ProcessExitInfo *info) { | ||
| info->exec_uuid = exec_uuid; | ||
| info->pid = m_pid; | ||
| }); | ||
|
|
||
| Log *log(GetLog(LLDBLog::State | LLDBLog::Process)); | ||
| LLDB_LOG(log, "(plugin = {0} status = {1} ({1:x8}), description=\"{2}\")", | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |||||||||||||
| #include "lldb/Core/Section.h" | ||||||||||||||
| #include "lldb/Core/SourceManager.h" | ||||||||||||||
| #include "lldb/Core/StructuredDataImpl.h" | ||||||||||||||
| #include "lldb/Core/Telemetry.h" | ||||||||||||||
| #include "lldb/DataFormatters/FormatterSection.h" | ||||||||||||||
| #include "lldb/Expression/DiagnosticManager.h" | ||||||||||||||
| #include "lldb/Expression/ExpressionVariable.h" | ||||||||||||||
|
|
@@ -1559,10 +1560,29 @@ void Target::DidExec() { | |||||||||||||
|
|
||||||||||||||
| void Target::SetExecutableModule(ModuleSP &executable_sp, | ||||||||||||||
| LoadDependentFiles load_dependent_files) { | ||||||||||||||
| telemetry::ScopedDispatcher<telemetry::ExecModuleInfo> helper(&m_debugger); | ||||||||||||||
| Log *log = GetLog(LLDBLog::Target); | ||||||||||||||
| ClearModules(false); | ||||||||||||||
|
|
||||||||||||||
| if (executable_sp) { | ||||||||||||||
| m_current_exec_mod_uuid = executable_sp->GetUUID(); | ||||||||||||||
| lldb::pid_t pid; | ||||||||||||||
| if (ProcessSP proc = GetProcessSP()) | ||||||||||||||
| pid = proc->GetID(); | ||||||||||||||
|
||||||||||||||
| lldb::pid_t pid; | |
| if (ProcessSP proc = GetProcessSP()) | |
| pid = proc->GetID(); | |
| lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; | |
| if (ProcessSP proc = GetProcessSP()) | |
| pid = proc->GetID(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to say I'm liking this bitfield system less and less every time I see it.