[LLVMdev] DEBUG macro for log message postponing

Frank Winter fwinter at jlab.org
Tue Jun 23 07:28:34 PDT 2015


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?

Many thanks,
Frank




More information about the llvm-dev mailing list