[llvm] Add option to log debugging to stdout (PR #91533)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu May 9 13:12:04 PDT 2024
================
@@ -161,31 +166,39 @@ static void debug_user_sig_handler(void *Cookie) {
/// dbgs - Return a circular-buffered debug stream.
raw_ostream &llvm::dbgs() {
- // Do one-time initialization in a thread-safe way.
- static struct dbgstream {
- circular_raw_ostream strm;
-
- dbgstream()
- : strm(errs(), "*** Debug Log Output ***\n",
- (!EnableDebugBuffering || !DebugFlag) ? 0 : *DebugBufferSize) {
- if (EnableDebugBuffering && DebugFlag && *DebugBufferSize != 0)
- // TODO: Add a handler for SIGUSER1-type signals so the user can
- // force a debug dump.
- sys::AddSignalHandler(&debug_user_sig_handler, nullptr);
- // Otherwise we've already set the debug stream buffer size to
- // zero, disabling buffering so it will output directly to errs().
- }
- } thestrm;
-
- return thestrm.strm;
+ if (LogDebugToStdOut) {
+ return outs();
+ } else {
----------------
dwblaikie wrote:
Generally LLVM omits {} on single-line if statements, and avoids else-after-return, so this would be:
```
if (LogDebugToStdOut)
return outs();
static struct dbgstream {
...
};
return thstrm.strm;
```
https://github.com/llvm/llvm-project/pull/91533
More information about the llvm-commits
mailing list