[Lldb-commits] [lldb] [llvm] [lldb] Add a GitHub bug reporter (PR #206607)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 29 16:51:34 PDT 2026
https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/206607
>From 0dd1b3f474ba2744acd5759699120f9f517a1514 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Mon, 29 Jun 2026 15:24:20 -0700
Subject: [PATCH 1/4] [lldb] Add a GitHub bug reporter
Add a BugReporter plugin that files a diagnostics bundle as an
llvm/llvm-project GitHub issue. File() renders a short Markdown body
from the Diagnostics::Report (version, host, invocation, and a pointer
to the bundle directory to attach), truncates it under a GET-safe URL
length on a UTF-8 character boundary, and opens a pre-filled issues/new
page with Host::OpenURL.
It is gated by LLDB_ENABLE_GITHUB_BUG_REPORTER (default on) and registers
ahead of the no-op fallback, so it is the default destination for
"diagnostics report" while a downstream tree can still register its own
reporter ahead of it.
---
.../Commands/CommandObjectDiagnostics.cpp | 5 +-
.../source/Plugins/BugReporter/CMakeLists.txt | 7 ++
.../BugReporter/GitHub/BugReporterGitHub.cpp | 66 +++++++++++++++++++
.../BugReporter/GitHub/BugReporterGitHub.h | 33 ++++++++++
.../Plugins/BugReporter/GitHub/CMakeLists.txt | 9 +++
lldb/test/Shell/Diagnostics/TestReport.test | 2 +-
llvm/docs/ReleaseNotes.md | 2 +
7 files changed, 121 insertions(+), 3 deletions(-)
create mode 100644 lldb/source/Plugins/BugReporter/GitHub/BugReporterGitHub.cpp
create mode 100644 lldb/source/Plugins/BugReporter/GitHub/BugReporterGitHub.h
create mode 100644 lldb/source/Plugins/BugReporter/GitHub/CMakeLists.txt
diff --git a/lldb/source/Commands/CommandObjectDiagnostics.cpp b/lldb/source/Commands/CommandObjectDiagnostics.cpp
index c8e50ac7c0b2a..4b02f3b337224 100644
--- a/lldb/source/Commands/CommandObjectDiagnostics.cpp
+++ b/lldb/source/Commands/CommandObjectDiagnostics.cpp
@@ -194,8 +194,9 @@ class CommandObjectDiagnosticsReport : public CommandObjectParsed {
Stream &out = result.GetOutputStream();
out << "Bug report written to " << directory->GetPath() << "\n";
- out << "WARNING: the report may contain file paths, command history and "
- "program data. Review it before attaching it to a public issue.\n";
+ result.AppendWarning("the report may contain file paths, command history "
+ "and program data. Review it before attaching it to a "
+ "public issue");
if (m_options.no_open) {
result.SetStatus(eReturnStatusSuccessFinishResult);
diff --git a/lldb/source/Plugins/BugReporter/CMakeLists.txt b/lldb/source/Plugins/BugReporter/CMakeLists.txt
index 784d87338c625..2e3133a03621e 100644
--- a/lldb/source/Plugins/BugReporter/CMakeLists.txt
+++ b/lldb/source/Plugins/BugReporter/CMakeLists.txt
@@ -1,5 +1,12 @@
set_property(DIRECTORY PROPERTY LLDB_PLUGIN_KIND BugReporter)
+option(LLDB_ENABLE_GITHUB_BUG_REPORTER
+ "Build the GitHub bug reporter so 'diagnostics report' can file a GitHub issue."
+ ON)
+
# Reporters are tried in subdirectory order, so keep None (the fallback) last.
# Downstream adds its own reporter subdirectory ahead of these.
+if(LLDB_ENABLE_GITHUB_BUG_REPORTER)
+ add_subdirectory(GitHub)
+endif()
add_subdirectory(None)
diff --git a/lldb/source/Plugins/BugReporter/GitHub/BugReporterGitHub.cpp b/lldb/source/Plugins/BugReporter/GitHub/BugReporterGitHub.cpp
new file mode 100644
index 0000000000000..c0f7b188e6831
--- /dev/null
+++ b/lldb/source/Plugins/BugReporter/GitHub/BugReporterGitHub.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 "Plugins/BugReporter/GitHub/BugReporterGitHub.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Host/Host.h"
+
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace lldb_private;
+
+LLDB_PLUGIN_DEFINE(BugReporterGitHub)
+
+// A GitHub "new issue" URL is fetched with GET, so its length is bounded (the
+// server rejects very long URLs). Keep the pre-filled body well under that so
+// the rest of the URL always fits. The full payload lives in the bundle.
+static constexpr size_t g_max_body_size = 6000;
+
+void BugReporterGitHub::Initialize() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ "File a bug as a GitHub issue.",
+ &BugReporterGitHub::CreateInstance);
+}
+
+void BugReporterGitHub::Terminate() {
+ PluginManager::UnregisterPlugin(&BugReporterGitHub::CreateInstance);
+}
+
+std::unique_ptr<BugReporter> BugReporterGitHub::CreateInstance() {
+ return std::make_unique<BugReporterGitHub>();
+}
+
+llvm::Error BugReporterGitHub::File(const Diagnostics::Report &report) {
+ std::string body;
+ llvm::raw_string_ostream os(body);
+ os << "### LLDB version\n" << report.version << "\n\n";
+ os << "### Host\n" << report.os << "\n\n";
+ if (!report.invocation.empty())
+ os << "### Invocation\n`" << report.invocation << "`\n\n";
+ os << "### Diagnostics\n"
+ << "Full diagnostics were written to:\n`" << report.attachments.directory
+ << "`\nPlease attach the contents of that directory to this issue.\n";
+
+ if (body.size() > g_max_body_size) {
+ // Back up off any UTF-8 continuation bytes so truncation lands on a
+ // character boundary rather than splitting a multi-byte sequence.
+ size_t cut = g_max_body_size;
+ while (cut > 0 && (static_cast<unsigned char>(body[cut]) & 0xC0) == 0x80)
+ --cut;
+ body.resize(cut);
+ 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));
+
+ return Host::OpenURL(url);
+}
diff --git a/lldb/source/Plugins/BugReporter/GitHub/BugReporterGitHub.h b/lldb/source/Plugins/BugReporter/GitHub/BugReporterGitHub.h
new file mode 100644
index 0000000000000..45bcdca59d7d7
--- /dev/null
+++ b/lldb/source/Plugins/BugReporter/GitHub/BugReporterGitHub.h
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SOURCE_PLUGINS_BUGREPORTER_GITHUB_BUGREPORTERGITHUB_H
+#define LLDB_SOURCE_PLUGINS_BUGREPORTER_GITHUB_BUGREPORTERGITHUB_H
+
+#include "lldb/Core/BugReporter.h"
+
+namespace lldb_private {
+
+/// Opens a pre-filled github.com/llvm/llvm-project "new issue" page. The body
+/// carries a short summary and points at the on-disk bundle to attach, since
+/// large artifacts cannot travel in the URL.
+class BugReporterGitHub : public BugReporter {
+public:
+ static void Initialize();
+ static void Terminate();
+ static llvm::StringRef GetPluginNameStatic() { return "github"; }
+ static std::unique_ptr<BugReporter> CreateInstance();
+
+ llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
+
+ llvm::Error File(const Diagnostics::Report &report) override;
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_SOURCE_PLUGINS_BUGREPORTER_GITHUB_BUGREPORTERGITHUB_H
diff --git a/lldb/source/Plugins/BugReporter/GitHub/CMakeLists.txt b/lldb/source/Plugins/BugReporter/GitHub/CMakeLists.txt
new file mode 100644
index 0000000000000..5c51252567888
--- /dev/null
+++ b/lldb/source/Plugins/BugReporter/GitHub/CMakeLists.txt
@@ -0,0 +1,9 @@
+add_lldb_library(lldbPluginBugReporterGitHub PLUGIN
+ BugReporterGitHub.cpp
+
+ LINK_COMPONENTS
+ Support
+ LINK_LIBS
+ lldbCore
+ lldbHost
+ )
diff --git a/lldb/test/Shell/Diagnostics/TestReport.test b/lldb/test/Shell/Diagnostics/TestReport.test
index d9606e52a7755..5cfb86e76df68 100644
--- a/lldb/test/Shell/Diagnostics/TestReport.test
+++ b/lldb/test/Shell/Diagnostics/TestReport.test
@@ -4,7 +4,7 @@
# RUN: rm -rf %t.report
# RUN: %lldb --no-lldbinit -b -o 'diagnostics report --no-open -d %t.report' 2>&1 | FileCheck %s
# CHECK: Bug report written to
-# CHECK: WARNING: the report may contain
+# CHECK: warning: the report may contain
# Scalars (version, OS, invocation) ride in the report, not as redundant files.
# RUN: test -f %t.report/statistics.json
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index d1448eb469614..942d9ad6d0adf 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -386,6 +386,8 @@ Makes programs 10x faster by doing Special New Thing.
show `platform.plugin.qemu-user` as one of the results.
* Reading global and static variables on WebAssembly targets now works correctly. Previously their
values could not be read because data sections were mapped to the wrong address space.
+* A new `diagnostics report` command (aliased `bugreport`) assembles a diagnostics bundle and files
+ a pre-filled GitHub issue, pointing at the bundle to attach.
#### Deprecated APIs
>From 890e588669cd0d3a7c6f55f9a88600fc773dea8a Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Mon, 29 Jun 2026 16:41:10 -0700
Subject: [PATCH 2/4] Address Alex' feedback
---
llvm/docs/ReleaseNotes.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 942d9ad6d0adf..2c33fde26b3c7 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -387,7 +387,8 @@ Makes programs 10x faster by doing Special New Thing.
* Reading global and static variables on WebAssembly targets now works correctly. Previously their
values could not be read because data sections were mapped to the wrong address space.
* A new `diagnostics report` command (aliased `bugreport`) assembles a diagnostics bundle and files
- a pre-filled GitHub issue, pointing at the bundle to attach.
+ a pre-filled GitHub issue, pointing at the bundle to attach. The GitHub reporter is built by
+ default and can be disabled with the `LLDB_ENABLE_GITHUB_BUG_REPORTER=OFF` CMake option.
#### Deprecated APIs
>From 705c00ac58f9f94b501c7e511f0e2b9544bb9b4f Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Mon, 29 Jun 2026 16:45:40 -0700
Subject: [PATCH 3/4] Show a checklist of the files expected to be attached
---
lldb/source/Commands/CommandObjectDiagnostics.cpp | 5 +++++
lldb/test/Shell/Diagnostics/TestReport.test | 3 +++
2 files changed, 8 insertions(+)
diff --git a/lldb/source/Commands/CommandObjectDiagnostics.cpp b/lldb/source/Commands/CommandObjectDiagnostics.cpp
index 4b02f3b337224..a23670519428a 100644
--- a/lldb/source/Commands/CommandObjectDiagnostics.cpp
+++ b/lldb/source/Commands/CommandObjectDiagnostics.cpp
@@ -194,6 +194,11 @@ class CommandObjectDiagnosticsReport : public CommandObjectParsed {
Stream &out = result.GetOutputStream();
out << "Bug report written to " << directory->GetPath() << "\n";
+ if (!report->attachments.files.empty()) {
+ out << "Attach the following files to the issue:\n";
+ for (const std::string &file : report->attachments.files)
+ out << " [ ] " << file << "\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/test/Shell/Diagnostics/TestReport.test b/lldb/test/Shell/Diagnostics/TestReport.test
index 5cfb86e76df68..ed5611b50c9a1 100644
--- a/lldb/test/Shell/Diagnostics/TestReport.test
+++ b/lldb/test/Shell/Diagnostics/TestReport.test
@@ -4,6 +4,9 @@
# RUN: rm -rf %t.report
# RUN: %lldb --no-lldbinit -b -o 'diagnostics report --no-open -d %t.report' 2>&1 | FileCheck %s
# CHECK: Bug report written to
+# CHECK: Attach the following files to the issue:
+# CHECK-DAG: [ ] statistics.json
+# CHECK-DAG: [ ] commands.txt
# CHECK: warning: the report may contain
# Scalars (version, OS, invocation) ride in the report, not as redundant files.
>From 84489fa25f046f6cbf90027054ce8d374ea18625 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Mon, 29 Jun 2026 16:51:16 -0700
Subject: [PATCH 4/4] Rename plugin BugReporterGitHub -> GitHubReporter
---
.../Plugins/BugReporter/GitHub/CMakeLists.txt | 4 ++--
...ugReporterGitHub.cpp => GitHubReporter.cpp} | 18 +++++++++---------
.../{BugReporterGitHub.h => GitHubReporter.h} | 8 ++++----
3 files changed, 15 insertions(+), 15 deletions(-)
rename lldb/source/Plugins/BugReporter/GitHub/{BugReporterGitHub.cpp => GitHubReporter.cpp} (80%)
rename lldb/source/Plugins/BugReporter/GitHub/{BugReporterGitHub.h => GitHubReporter.h} (79%)
diff --git a/lldb/source/Plugins/BugReporter/GitHub/CMakeLists.txt b/lldb/source/Plugins/BugReporter/GitHub/CMakeLists.txt
index 5c51252567888..4964bc568e113 100644
--- a/lldb/source/Plugins/BugReporter/GitHub/CMakeLists.txt
+++ b/lldb/source/Plugins/BugReporter/GitHub/CMakeLists.txt
@@ -1,5 +1,5 @@
-add_lldb_library(lldbPluginBugReporterGitHub PLUGIN
- BugReporterGitHub.cpp
+add_lldb_library(lldbPluginGitHubReporter PLUGIN
+ GitHubReporter.cpp
LINK_COMPONENTS
Support
diff --git a/lldb/source/Plugins/BugReporter/GitHub/BugReporterGitHub.cpp b/lldb/source/Plugins/BugReporter/GitHub/GitHubReporter.cpp
similarity index 80%
rename from lldb/source/Plugins/BugReporter/GitHub/BugReporterGitHub.cpp
rename to lldb/source/Plugins/BugReporter/GitHub/GitHubReporter.cpp
index c0f7b188e6831..edecd69cd8fd3 100644
--- a/lldb/source/Plugins/BugReporter/GitHub/BugReporterGitHub.cpp
+++ b/lldb/source/Plugins/BugReporter/GitHub/GitHubReporter.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "Plugins/BugReporter/GitHub/BugReporterGitHub.h"
+#include "Plugins/BugReporter/GitHub/GitHubReporter.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Host/Host.h"
@@ -15,28 +15,28 @@
using namespace lldb_private;
-LLDB_PLUGIN_DEFINE(BugReporterGitHub)
+LLDB_PLUGIN_DEFINE(GitHubReporter)
// A GitHub "new issue" URL is fetched with GET, so its length is bounded (the
// server rejects very long URLs). Keep the pre-filled body well under that so
// the rest of the URL always fits. The full payload lives in the bundle.
static constexpr size_t g_max_body_size = 6000;
-void BugReporterGitHub::Initialize() {
+void GitHubReporter::Initialize() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
"File a bug as a GitHub issue.",
- &BugReporterGitHub::CreateInstance);
+ &GitHubReporter::CreateInstance);
}
-void BugReporterGitHub::Terminate() {
- PluginManager::UnregisterPlugin(&BugReporterGitHub::CreateInstance);
+void GitHubReporter::Terminate() {
+ PluginManager::UnregisterPlugin(&GitHubReporter::CreateInstance);
}
-std::unique_ptr<BugReporter> BugReporterGitHub::CreateInstance() {
- return std::make_unique<BugReporterGitHub>();
+std::unique_ptr<BugReporter> GitHubReporter::CreateInstance() {
+ return std::make_unique<GitHubReporter>();
}
-llvm::Error BugReporterGitHub::File(const Diagnostics::Report &report) {
+llvm::Error GitHubReporter::File(const Diagnostics::Report &report) {
std::string body;
llvm::raw_string_ostream os(body);
os << "### LLDB version\n" << report.version << "\n\n";
diff --git a/lldb/source/Plugins/BugReporter/GitHub/BugReporterGitHub.h b/lldb/source/Plugins/BugReporter/GitHub/GitHubReporter.h
similarity index 79%
rename from lldb/source/Plugins/BugReporter/GitHub/BugReporterGitHub.h
rename to lldb/source/Plugins/BugReporter/GitHub/GitHubReporter.h
index 45bcdca59d7d7..af177cb50f76b 100644
--- a/lldb/source/Plugins/BugReporter/GitHub/BugReporterGitHub.h
+++ b/lldb/source/Plugins/BugReporter/GitHub/GitHubReporter.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_SOURCE_PLUGINS_BUGREPORTER_GITHUB_BUGREPORTERGITHUB_H
-#define LLDB_SOURCE_PLUGINS_BUGREPORTER_GITHUB_BUGREPORTERGITHUB_H
+#ifndef LLDB_SOURCE_PLUGINS_BUGREPORTER_GITHUB_GITHUBREPORTER_H
+#define LLDB_SOURCE_PLUGINS_BUGREPORTER_GITHUB_GITHUBREPORTER_H
#include "lldb/Core/BugReporter.h"
@@ -16,7 +16,7 @@ namespace lldb_private {
/// Opens a pre-filled github.com/llvm/llvm-project "new issue" page. The body
/// carries a short summary and points at the on-disk bundle to attach, since
/// large artifacts cannot travel in the URL.
-class BugReporterGitHub : public BugReporter {
+class GitHubReporter : public BugReporter {
public:
static void Initialize();
static void Terminate();
@@ -30,4 +30,4 @@ class BugReporterGitHub : public BugReporter {
} // namespace lldb_private
-#endif // LLDB_SOURCE_PLUGINS_BUGREPORTER_GITHUB_BUGREPORTERGITHUB_H
+#endif // LLDB_SOURCE_PLUGINS_BUGREPORTER_GITHUB_GITHUBREPORTER_H
More information about the lldb-commits
mailing list