[lldb] Collect a diagnostics bundle on the Diagnostics class (#206189)
Add Diagnostics::Collect, which gathers the state a triager needs into a
directory, best-effort (one failed section never sinks the rest): the
always-on log plus the debugger's file logs, statistics.json from
DebuggerStats, and a snapshot of the commands run first when triaging
(target list, image list, thread list, backtraces, image lookup, frame
variable).
It returns a Diagnostics::Report with the LLDB version, host, and how
LLDB was invoked, plus an Attachments holding the bundle directory and
the files written into it. Each file is recorded as it is written, so a
file that could not be created is simply absent from the list. The
report is expected to grow more fields over time.
`diagnostics dump` now calls Collect and prints the report as JSON to
the terminal instead of only reporting where the directory was written.
Here's what this all looks like:
```
(lldb) diagnostics dump
{
"attachments": {
"directory": "/var/folders/6b/3sb80ks56rz5vwlhsdvpsxmh0000gn/T/diagnostics-4b5e9f",
"files": [
"diagnostics.log",
"statistics.json",
"commands.txt"
]
},
"invocation": "./build/bin/count",
"os": "arm64-apple-macosx platform=host os=27.0 build=26A374",
"version": "lldb version 23.0.0git (git@github.com:llvm/llvm-project.git revision 85fa95f05bc5f0c6b4fd845141e522cd4b9589d7)\n clang revision 85fa95f05bc5f0c6b4fd845141e522cd4b9589d7\n llvm revision 85fa95f05bc5f0c6b4fd845141e522cd4b9589d7"
}
```
This is in preparation for a future PR which adds the ability to take
all this information and pre-fill a bug report with it.