[LLVMdev] Old DOUT
dag at cray.com
Fri Dec 11 09:03:03 PST 2009
On Thursday 10 December 2009 17:53, Chris Lattner wrote:
> > So I would write the above as:
> > DEBUG(dbgs() << foo);
> > Does that sound reasonable?
> If you're asking if a new dbgs() might be useful, "yes if specified well".
> If you're asking if you can convert everything to using it, "no".
I'm not sure what you mean here. It's not ok to convert code under DEBUG() or
#ifndef NDEBUG to use dbgs()? Then what's the point of providing it?
My intent is to have dbgs() == errs() when debug mode is disabled.
> > There are some tricky cases where dump routines are used either to
> > print error messages or to print debug information. In those cases
> > I may have to parameterize the dump routine with the stream.
> What do you mean?
For example, SDNode::dump() is used to both print out debug information
and to do dumps in error context (cannot select, etc.).
One option is to make the signature SDNode::dump(raw_ostream &) or create
a new overload.
Another option is to have SDNode::dump() use dbgs() and when debugging is
off, dbgs() == errs(). Of course, when debugging is on, error dumps will
go to the debug stream, which actually isn't the worst thing in the world,
especially if you have a huge source input and are using the (new)
circular-buffering raw_ostream to capture the last N bytes of stream output.
More information about the llvm-dev