On 6/23/15 8:28 AM, Frank Winter wrote:> A pass first collects some log data in form of strings and at some later
> point decides depending on program state whether to print it to dbgs()
> or not. In other words the debug stream would be totally flooded if
> every string was printed. I was thinking of guarding a std::stringstream
> object with the DEBUG macro. Something like
>
> DEBUG(std::stringstream ss);
> DEBUG(ss << "Conditional logging data" << I <<
"\n");
>
> ... at some later stage ...
>
> DEBUG( if (log_me) dbgs() << ss.str());
>
> However, LLVM doesn't like the above construct. In LLVM, how can one
> postpone some debugging logs for later printing?
What you're asking for is usually written as:
#ifndef NDEBUG
std::stringstream ss
#endif
DEBUG(ss << "Conditional logging data" << I <<
"\n");
DEBUG( if (log_me) dbgs() << ss.str());
Jon
>
> Many thanks,
> Frank
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
--
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded