[Lldb-commits] [lldb] [lldb] Ask the reporter what happened in a bug report (PR #213173)

via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 30 16:54:25 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

<details>
<summary>Changes</summary>

A diagnostics bundle records the state of the debugger, never what the user was doing or what they expected instead, so reports arrive with a generic title and no description of the problem. Pre-fill the report with the questions only the person filing it can answer, and print a checklist when the bundle is written so an incomplete report doesn't get shared as-is.

rdar://183356348

---
Full diff: https://github.com/llvm/llvm-project/pull/213173.diff


6 Files Affected:

- (modified) lldb/include/lldb/Core/BugReporter.h (+9) 
- (modified) lldb/source/Commands/CommandObjectDiagnostics.cpp (+3) 
- (added) lldb/source/Core/BugReporter.cpp (+22) 
- (modified) lldb/source/Core/CMakeLists.txt (+1) 
- (modified) lldb/source/Plugins/BugReporter/GitHub/GitHubReporter.cpp (+9-4) 
- (modified) lldb/test/Shell/Diagnostics/TestReport.test (+3) 


``````````diff
diff --git a/lldb/include/lldb/Core/BugReporter.h b/lldb/include/lldb/Core/BugReporter.h
index 6a0b3c936008e..dbba754289514 100644
--- a/lldb/include/lldb/Core/BugReporter.h
+++ b/lldb/include/lldb/Core/BugReporter.h
@@ -12,6 +12,8 @@
 #include "lldb/Core/Diagnostics.h"
 #include "lldb/Core/PluginInterface.h"
 
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 
 namespace lldb_private {
@@ -24,6 +26,13 @@ class BugReporter : public PluginInterface {
   virtual llvm::Error File(const Diagnostics::Report &report) = 0;
 };
 
+/// The parts of a report only the person filing it can supply. Shared so every
+/// reporter asks for the same thing.
+/// @{
+llvm::StringRef GetBugReportTitlePlaceholder();
+llvm::ArrayRef<llvm::StringRef> GetBugReportQuestions();
+/// @}
+
 } // namespace lldb_private
 
 #endif // LLDB_CORE_BUGREPORTER_H
diff --git a/lldb/source/Commands/CommandObjectDiagnostics.cpp b/lldb/source/Commands/CommandObjectDiagnostics.cpp
index a23670519428a..c654f2ccaaaaa 100644
--- a/lldb/source/Commands/CommandObjectDiagnostics.cpp
+++ b/lldb/source/Commands/CommandObjectDiagnostics.cpp
@@ -199,6 +199,9 @@ class CommandObjectDiagnosticsReport : public CommandObjectParsed {
       for (const std::string &file : report->attachments.files)
         out << "  [ ] " << file << "\n";
     }
+    out << "Complete the report before sharing it:\n";
+    out << "  [ ] Replace the placeholder title with a descriptive one\n";
+    out << "  [ ] Answer the questions\n";
     result.AppendWarning("the report may contain file paths, command history "
                          "and program data. Review it before attaching it to a "
                          "public issue");
diff --git a/lldb/source/Core/BugReporter.cpp b/lldb/source/Core/BugReporter.cpp
new file mode 100644
index 0000000000000..17318d2433094
--- /dev/null
+++ b/lldb/source/Core/BugReporter.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Core/BugReporter.h"
+
+llvm::StringRef lldb_private::GetBugReportTitlePlaceholder() {
+  return "[lldb] <replace this with a descriptive title>";
+}
+
+llvm::ArrayRef<llvm::StringRef> lldb_private::GetBugReportQuestions() {
+  static constexpr llvm::StringRef g_questions[] = {
+      "What were you doing?",
+      "What did you expect to happen?",
+      "What happened instead?",
+  };
+  return g_questions;
+}
diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt
index dd25c3cc86e6d..53a17ef8d4565 100644
--- a/lldb/source/Core/CMakeLists.txt
+++ b/lldb/source/Core/CMakeLists.txt
@@ -26,6 +26,7 @@ add_lldb_library(lldbCore NO_PLUGIN_DEPENDENCIES
   AddressRangeListImpl.cpp
   AddressResolver.cpp
   AddressResolverFileLine.cpp
+  BugReporter.cpp
   Communication.cpp
   DataFileCache.cpp
   Debugger.cpp
diff --git a/lldb/source/Plugins/BugReporter/GitHub/GitHubReporter.cpp b/lldb/source/Plugins/BugReporter/GitHub/GitHubReporter.cpp
index edecd69cd8fd3..8173e8de521f1 100644
--- a/lldb/source/Plugins/BugReporter/GitHub/GitHubReporter.cpp
+++ b/lldb/source/Plugins/BugReporter/GitHub/GitHubReporter.cpp
@@ -39,6 +39,11 @@ std::unique_ptr<BugReporter> GitHubReporter::CreateInstance() {
 llvm::Error GitHubReporter::File(const Diagnostics::Report &report) {
   std::string body;
   llvm::raw_string_ostream os(body);
+  // Lead with the questions: an oversized body is truncated from the end.
+  os << "### Please answer these questions\n\n";
+  for (llvm::StringRef question : GetBugReportQuestions())
+    os << "- " << question << "\n";
+  os << "\n\n";
   os << "### LLDB version\n" << report.version << "\n\n";
   os << "### Host\n" << report.os << "\n\n";
   if (!report.invocation.empty())
@@ -57,10 +62,10 @@ llvm::Error GitHubReporter::File(const Diagnostics::Report &report) {
     body += "\n\n...(truncated, see the attached diagnostics directory)";
   }
 
-  std::string url = llvm::formatv("https://github.com/llvm/llvm-project/issues/"
-                                  "new?title={0}&body={1}&labels=lldb",
-                                  Host::URLEncode("[lldb] Bug report"),
-                                  Host::URLEncode(body));
+  std::string url = llvm::formatv(
+      "https://github.com/llvm/llvm-project/issues/"
+      "new?title={0}&body={1}&labels=lldb",
+      Host::URLEncode(GetBugReportTitlePlaceholder()), Host::URLEncode(body));
 
   return Host::OpenURL(url);
 }
diff --git a/lldb/test/Shell/Diagnostics/TestReport.test b/lldb/test/Shell/Diagnostics/TestReport.test
index ed5611b50c9a1..8554b08109c6e 100644
--- a/lldb/test/Shell/Diagnostics/TestReport.test
+++ b/lldb/test/Shell/Diagnostics/TestReport.test
@@ -7,6 +7,9 @@
 # CHECK: Attach the following files to the issue:
 # CHECK-DAG: [ ] statistics.json
 # CHECK-DAG: [ ] commands.txt
+# CHECK: Complete the report before sharing it:
+# CHECK: [ ] Replace the placeholder title with a descriptive one
+# CHECK: [ ] Answer the questions
 # CHECK: warning: the report may contain
 
 # Scalars (version, OS, invocation) ride in the report, not as redundant files.

``````````

</details>


https://github.com/llvm/llvm-project/pull/213173


More information about the lldb-commits mailing list