[LLVMdev] [PATCH] Circular Buffered Debug Stream
Chris Lattner
clattner at apple.com
Fri Dec 18 17:24:02 PST 2009
On Dec 18, 2009, at 11:53 AM, David Greene wrote:
> On Friday 18 December 2009 12:28, Chris Lattner wrote:
>
>> This is looking a lot better, here are some more comments:
>>> + /// current_pos - Return the current position within the
>>> stream,
>>> + /// not counting the bytes currently in the buffer.
>>> + virtual uint64_t current_pos() {
>>
>> I didn't notice this earlier, but is there any reason for
>> current_pos to be
>> non-const in raw_ostream?
>
> Probably not. I'm going to let someone else fix that, though.
Alright, I'll do it.
>> How about just asserting that BufferSize is not zero? This stream
>> won't
>> work well and doesn't make sense with a buffer of zero.
>
> Sure it does. In fact it's crucial for making dbgs() work like
> errs() in
> the default case.
Ah, I forgot the usage model.
>> Is this to debug the implementation of the stream? Should this go
>> into the
>> tree?
>
> No, this is what gets dumped at program termination. Remember, this
> stream
> buffers everything you send it, effectively dropping everything
> except the
> last N characters, when N == BufferSize. Then at program
> termination it
> dumps the buffer.
Aha, ok. So the usage model is that it normally is unbuffered and
pass through like errs(), but you can pass a flag that causes all the -
debug output to be circular buffered?
> logs() might be a better name than dbgs() for this. What do you
> think?
If it writes out to stderr, I think dbgs() is a better name, logs()
implies that it writes to a log file (at least to me).
-Chris
More information about the llvm-dev
mailing list