Displaying 7 results from an estimated 7 matches for "dbgstream".
Did you mean:
bistream
2009 Dec 19
0
[LLVMdev] [PATCH] Implement dbgs()
...> +raw_ostream &llvm::dbgs() {
> + static circular_raw_ostream strm(errs(), DebugBufferSize);
> +
> + static bool initialized = false;
> + if (!initialized) {
> + initialized = true;
This isn't thread safe. A way to fix this is to do something like:
static struct dbgstream {
circular_raw_ostream strm;
dbgstream() : strm(errs(), DebugBufferSize) {
your one time init stuff here.
}
} thestrm;
return thestrm.strm;
Please commit with the appropriate fixes when we settle on the stream
design.
-Chris
2009 Dec 19
3
[LLVMdev] [PATCH] Implement dbgs()
...> + static circular_raw_ostream strm(errs(), DebugBufferSize);
> > +
> > + static bool initialized = false;
> > + if (!initialized) {
> > + initialized = true;
>
> This isn't thread safe. A way to fix this is to do something like:
>
> static struct dbgstream {
> circular_raw_ostream strm;
>
> dbgstream() : strm(errs(), DebugBufferSize) {
> your one time init stuff here.
> }
> } thestrm;
>
> return thestrm.strm;
Ok.
> Please commit with the appropriate fixes when we settle on the stream
> design.
All right....
2009 Dec 18
2
[LLVMdev] [PATCH] Implement dbgs()
Here's the patch to provide dbgs(). By default it works just like errs().
When -debug-buffer-size=N (N > 0) is set, it buffers output sent to it and
dumps it at program termination via a signal handler.
Please review. Thanks!
-Dave
Index: include/llvm/Support/Debug.h
===================================================================
---
2009 Dec 21
2
[LLVMdev] [PATCH] Implement dbgs()
...nd line, or if none was specified on the command
line
// with the -debug-only=X option.
@@ -66,9 +91,29 @@
CurrentDebugType = Type;
}
+/// 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(), DebugBufferSize) {
+ sys::AddSignalHandler(&debug_user_sig_handler, 0);
+ // TODO: Add a handler for SIGUSER1-type signals so the user can
+ // force a debug dump.
+ }
+ } thestrm;
+
+ return thestrm.strm;
+...
2009 Dec 19
0
[LLVMdev] [PATCH] Implement dbgs()
On Dec 18, 2009, at 6:36 PM, David Greene wrote:
>>> +// Signal handlers - dump debug output on termination.
>>> +static void debug_user_sig_handler(void *Cookie)
>>> +{
>>> + llvm::circular_raw_ostream *logout =
>>> + dynamic_cast<llvm::circular_raw_ostream *>(&llvm::dbgs());
>>
>> Please do not use dynamic_cast, we're
2009 Dec 21
0
[LLVMdev] [PATCH] Implement dbgs()
On 2009-12-21 18:06, David Greene wrote:
> On Saturday 19 December 2009 00:16, Chris Lattner wrote:
>
>
>>> Or I think I can just assume (Yikes!) that if the signal handler is
>>> invoked it will really be a circular_raw_ostream since the handler
>>> should (!) only be set up in debug mode.
>>>
>>> That scares me a bit, though.
>>>
2009 Dec 21
2
[LLVMdev] [PATCH] Implement dbgs()
...ntDebugType = Type;
}
+/// DisableDebugBuffering - Turn off signal handler installation.
+///
+bool llvm::DisableDebugBuffering = false;
+
+/// 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(),
+ (DisableDebugBuffering || !DebugFlag) ? 0 : DebugBufferSize) {
+ if (!DisableDebugBuffering && DebugFlag && DebugBufferSize != 0)
+ // TODO: Add a handler for SIGUSER1-type signals...