diff options
author | David Spickett <david.spickett@linaro.org> | 2023-08-03 09:01:54 +0000 |
---|---|---|
committer | David Spickett <david.spickett@linaro.org> | 2023-08-03 15:09:12 +0000 |
commit | 165f45a877742a74988d63f36aee635c8e0a47da (patch) | |
tree | 3a2971dbcd4e5a2db16145921ac2f6f461ab28e0 /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | bdeb35bda4381d3b416a92d797713b4b5a6a6c97 (diff) | |
download | llvm-165f45a877742a74988d63f36aee635c8e0a47da.zip llvm-165f45a877742a74988d63f36aee635c8e0a47da.tar.gz llvm-165f45a877742a74988d63f36aee635c8e0a47da.tar.bz2 |
[lldb][lldb-vscode] Pretty print JSON to log files
This makes anlysing test failures much more easy.
For SendJSON this is simple, just use llvm::format instead.
For GetNextObject/ReadJSON it's a bit more tricky.
* Print the "Content-Length:" line in ReadJSON, but not the json.
* Back in GetNextObject, if the JSON doesn't parse, it'll be
printed as a normal string along with an error message.
* If we didn't error before, we have a JSON value so we pretty print it.
* Finally, if it isn't an object we'll log an error for that,
not including the JSON.
Before:
```
<--
Content-Length: 81
{"command":"disconnect","request_seq":5,"seq":0,"success":true,"type":"response"}
```
After:
```
<--
Content-Length: 81
{
"command": "disconnect",
"request_seq": 5,
"seq": 0,
"success": true,
"type": "response"
}
```
There appear to be some responses that include strings that are themselves JSON,
and this won't pretty print those but I think it's still worth doing.
Reviewed By: wallace
Differential Revision: https://reviews.llvm.org/D156979
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions