llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Vy Nguyen (oontvoo)

<details>
<summary>Changes</summary>

If 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:

- (modified) lldb/include/lldb/Core/Telemetry.h (+2) 
- (modified) lldb/source/Core/Telemetry.cpp (+2) 
- (modified) lldb/source/Utility/Diagnostics.cpp (+3) 
- (modified) lldb/source/Utility/LLDBAssert.cpp (+7-3) 


``````````diff
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 "

``````````

</details>


https://github.com/llvm/llvm-project/pull/135924
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to