On Thursday 10 December 2009 16:30, Anton Korobeynikov wrote:> Hello, David > > > What replaced the old DOUT? > > DEBUG(errs() << foo); > > The reason is quite simple - DOUT in release mode was just /dev/null, > but the functions sending data to it were still called.errs() is no good. I would want to keep errs() printing things out immediately. I need something else that buffers until program termination. So I would write the above as: DEBUG(dbgs() << foo); Does that sound reasonable? 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. -Dave
On Dec 10, 2009, at 1:46 PM, David Greene wrote:> On Thursday 10 December 2009 16:30, Anton Korobeynikov wrote: >> Hello, David >> >>> What replaced the old DOUT? >> >> DEBUG(errs() << foo); >> >> The reason is quite simple - DOUT in release mode was just /dev/null, >> but the functions sending data to it were still called. > > errs() is no good. I would want to keep errs() printing things out > immediately. I need something else that buffers until program termination. > > 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".> 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? -Chris
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. -Dave