[lldb] Add diagnostics

Around this time last year, I said on the mailing list [1] that I wanted
to to transform the reproducers into something that resembles a
sysdiagnose on Apple platforms: a collection of files containing a
variety of information to help diagnose bugs or troubleshoot issues.

This patch adds that framework. Based on lessons learned from the
reproducers, I've intentionally tried to keep it small and simple.
Different parts of LLDB can register callbacks (this is necessary for
layering purposes) that will get called when the diagnostics should be
generated.

[1] https://lists.llvm.org/pipermail/lldb-dev/2021-September/017045.html

Differential revision: https://reviews.llvm.org/D134991
This commit is contained in:
Jonas Devlieghere
2022-10-28 14:26:11 -07:00
parent 1f8ac37e2d
commit 84ea6b6f78
8 changed files with 153 additions and 0 deletions

View File

@@ -51,6 +51,7 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/TargetList.h"
#include "lldb/Utility/Args.h"
#include "lldb/Utility/Diagnostics.h"
#include "lldb/Utility/State.h"
#include "lldb/Version/Version.h"
@@ -218,6 +219,16 @@ void SBDebugger::PrintStackTraceOnError() {
llvm::sys::PrintStackTraceOnErrorSignal(executable);
}
static void DumpDiagnostics(void *cookie) {
Diagnostics::Instance().Dump(llvm::errs());
}
void SBDebugger::PrintDiagnosticsOnError() {
LLDB_INSTRUMENT();
llvm::sys::AddSignalHandler(&DumpDiagnostics, nullptr);
}
void SBDebugger::Terminate() {
LLDB_INSTRUMENT();