[llvm-commits] [PATCH] Add support for OutputDebugString to raw_ostream and add support for virtualized out/err streams

Erik Olofsson Erik.Olofsson at hansoft.se
Wed Mar 2 12:37:40 PST 2011


> From: Dan Gohman [mailto:gohman at apple.com]
> Hmm. It's not even possible to view the output of a classic
> "hello world"?

Exactly so. It is inexplicable that they haven't managed to implement this feature and I did some additional searching around the net and everyone is saying to use OutputDebugString.

> Would it be possible to achieve what you want by extending dbgs()?
> If not, how should code decide between using dbgs() and debugouts()?

Maybe, but it seems inappropriate as I want this to be a command line option and in that case I would have to change the behavior of dbgs globally when this command line option is specified. It would however be beneficial to be able to tell dbgs to output to debugouts instead of stderr.

Maybe it would be more appropriate to hide debugouts in the cpp file so it's not public and only use debugstreams() from the clang code.

I also want this code to work in release builds.

> What's the purpose of the raw_output_streams class? Are you expecting
> to migrate code that uses errs() and outs() to using it? If so,
> that's quite invasive. If not, what's the purpose?

Most functions that I needed to override already takes an raw_ostream. Some functions however needs both errs and outs. I first implemented this by letting these functions take both errs and outs as arguments, but that resulted in asserts because there is check in place that prevents the application from calling outs() if you are for example outputting the results to stdout. That is why I need to virtualize calling outs() so you can replace it without actually calling the outs() function until it's actually needed.

See the attached patch for how I'm expecting to implement this in clang. FYI I will split this patch into refactoring and implementing the new feature before submitting it again to clang-commits.

Regards,
Erik

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: clang-visual-studio-debuggability.patch.txt
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110302/65d6c189/attachment.txt>


More information about the llvm-commits mailing list