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

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

>From 6c9edc0907f8d7f7cb07fc6424eb05dd14c61abc Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <[email protected]>
Date: Thu, 30 Jul 2026 16:52:44 -0700
Subject: [PATCH] [lldb] Ask the reporter what happened in a bug report

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
---
 lldb/include/lldb/Core/BugReporter.h          |  9 ++++++++
 .../Commands/CommandObjectDiagnostics.cpp     |  3 +++
 lldb/source/Core/BugReporter.cpp              | 22 +++++++++++++++++++
 lldb/source/Core/CMakeLists.txt               |  1 +
 .../BugReporter/GitHub/GitHubReporter.cpp     | 13 +++++++----
 lldb/test/Shell/Diagnostics/TestReport.test   |  3 +++
 6 files changed, 47 insertions(+), 4 deletions(-)
 create mode 100644 lldb/source/Core/BugReporter.cpp

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.

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to