-
Notifications
You must be signed in to change notification settings - Fork 13.3k
include telemetry session-id in diagnostic msg when enabled #135924
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
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-lldb Author: Vy Nguyen (oontvoo) ChangesIf LLDB crashes, it often helpful to know what the user was doing up to the point of the crash. Reporting the session-id helps us looking up the relevant logs. (Given Telemetry is disabled upstream, this change should mostly be a no-op change) Full diff: https://github.com/llvm/llvm-project/pull/135924.diff 4 Files Affected:
diff --git a/lldb/include/lldb/Core/Telemetry.h b/lldb/include/lldb/Core/Telemetry.h
index fa01e2e4af90f..f21efe0a9c533 100644
--- a/lldb/include/lldb/Core/Telemetry.h
+++ b/lldb/include/lldb/Core/Telemetry.h
@@ -219,6 +219,8 @@ class TelemetryManager : public llvm::telemetry::Manager {
virtual llvm::StringRef GetInstanceName() const = 0;
+ llvm::StringRef GetSessionId() const;
+
static TelemetryManager *GetInstance();
protected:
diff --git a/lldb/source/Core/Telemetry.cpp b/lldb/source/Core/Telemetry.cpp
index 8db29889e0846..8497c4f866c18 100644
--- a/lldb/source/Core/Telemetry.cpp
+++ b/lldb/source/Core/Telemetry.cpp
@@ -112,6 +112,8 @@ llvm::Error TelemetryManager::preDispatch(TelemetryInfo *entry) {
return llvm::Error::success();
}
+llvm::StringRef TelemetryManager::GetSessionid() const { return m_id; }
+
class NoOpTelemetryManager : public TelemetryManager {
public:
llvm::Error preDispatch(llvm::telemetry::TelemetryInfo *entry) override {
diff --git a/lldb/source/Utility/Diagnostics.cpp b/lldb/source/Utility/Diagnostics.cpp
index b2a08165dd6ca..9c9e24bc9659f 100644
--- a/lldb/source/Utility/Diagnostics.cpp
+++ b/lldb/source/Utility/Diagnostics.cpp
@@ -70,6 +70,9 @@ bool Diagnostics::Dump(raw_ostream &stream) {
bool Diagnostics::Dump(raw_ostream &stream, const FileSpec &dir) {
stream << "LLDB diagnostics will be written to " << dir.GetPath() << "\n";
stream << "Please include the directory content when filing a bug report\n";
+ TelemetryManager *manager = TelemetryManager::GetInstance();
+ if (manager->GetConfig()->EnableTelemetry)
+ stream << "Telemetry-SessionId: " << manager->GetSessionid() << "\n";
if (Error error = Create(dir)) {
stream << toString(std::move(error)) << '\n';
diff --git a/lldb/source/Utility/LLDBAssert.cpp b/lldb/source/Utility/LLDBAssert.cpp
index 611ad43cd071b..dc1e4d53031cc 100644
--- a/lldb/source/Utility/LLDBAssert.cpp
+++ b/lldb/source/Utility/LLDBAssert.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Core/Telemetry.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/Signals.h"
@@ -51,11 +52,14 @@ void _lldb_assert(bool expression, const char *expr_text, const char *func,
std::string buffer;
llvm::raw_string_ostream backtrace(buffer);
llvm::sys::PrintStackTrace(backtrace);
-
+ std::string extra_detail;
+ TelemetryManager *manager = TelemetryManager::GetInstance();
+ if (manager->GetConfig()->EnableTelemetry)
+ extra_detail = ". Telemetry-SessionId:" + manager->GetSessionId();
(*g_lldb_assert_callback.load())(
llvm::formatv(
- "Assertion failed: ({0}), function {1}, file {2}, line {3}",
- expr_text, func, file, line)
+ "Assertion failed: ({0}), function {1}, file {2}, line {3}{4}",
+ expr_text, func, file, line, extra_detail)
.str(),
buffer,
"Please file a bug report against lldb and include the backtrace, the "
|
@@ -7,6 +7,7 @@ | |||
//===----------------------------------------------------------------------===// | |||
|
|||
#include "lldb/Utility/LLDBAssert.h" | |||
#include "lldb/Core/Telemetry.h" |
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.
Utility cannot depend on Core. If you want something like this, I guess you can put it somewhere under Debugger::AssertCallback
If LLDB crashes, it's often helpful to know what the user was doing up to the point of the crash. Reporting the session-id helps us look up the relevant logs.
(Given Telemetry is disabled upstream, this change should mostly be a no-op change)
P.S: One option I'd considered was making this a vendor-specific code but since the diagnostic reporting code is pretty simple at the moment, I'm not sure it'd be worth turning it into a complex plugin system.